anaghanagesh commited on
Commit
f8981d4
·
verified ·
1 Parent(s): 6687bc1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -16,18 +16,20 @@ def drug_discovery(disease, symptoms):
16
  prompt = f"Recent treatments for {disease} with symptoms: {symptoms}."
17
  literature = bio_gpt(prompt, max_length=200)[0]['generated_text']
18
 
19
- # Generate SMILES using BioGPT
20
- molecule_prompt = f"Generate a valid drug-like SMILES string for treating {disease} with symptoms {symptoms}. Only return the SMILES."
21
- smiles_result = bio_gpt(molecule_prompt, max_length=50)[0]['generated_text']
22
- smiles_match = re.findall(r"(?<![A-Za-z0-9])[A-Za-z0-9@+\-\[\]\(\)=#$]{5,}(?![A-Za-z0-9])", smiles_result)
 
 
23
  smiles = None
24
- for match in smiles_match:
25
  mol_test = Chem.MolFromSmiles(match)
26
  if mol_test:
27
  smiles = match
28
  break
29
  if not smiles:
30
- smiles = "CC(C)CC" # fallback to isopentane
31
 
32
  # Generate RDKit molecule
33
  mol = Chem.MolFromSmiles(smiles)
@@ -124,4 +126,3 @@ iface = gr.Interface(
124
  )
125
 
126
  iface.launch(share=True)
127
-
 
16
  prompt = f"Recent treatments for {disease} with symptoms: {symptoms}."
17
  literature = bio_gpt(prompt, max_length=200)[0]['generated_text']
18
 
19
+ # Generate SMILES using BioGPT with stricter filtering
20
+ molecule_prompt = f"List 5 different valid drug-like SMILES strings that can treat {disease} with symptoms {symptoms}. Only list SMILES separated by spaces."
21
+ smiles_result = bio_gpt(molecule_prompt, max_length=100)[0]['generated_text']
22
+
23
+ # Extract and validate SMILES strings
24
+ smiles_matches = re.findall(r"(?<![A-Za-z0-9])[A-Za-z0-9@+\-\[\]\(\)=#$]{5,}(?![A-Za-z0-9])", smiles_result)
25
  smiles = None
26
+ for match in smiles_matches:
27
  mol_test = Chem.MolFromSmiles(match)
28
  if mol_test:
29
  smiles = match
30
  break
31
  if not smiles:
32
+ smiles = "C1=CC=CC=C1" # fallback to benzene if all fail
33
 
34
  # Generate RDKit molecule
35
  mol = Chem.MolFromSmiles(smiles)
 
126
  )
127
 
128
  iface.launch(share=True)