Joey Callanan commited on
Commit
8c26fbc
·
1 Parent(s): d4f0a95

changes using model

Browse files
src/molecules/generated_variations.py CHANGED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import subprocess
2
+ import pandas as pd
3
+ from rdkit import Chem
4
+ from rdkit.Chem import Draw
5
+
6
+ def generate_variations_from_model(user_smiles, n_to_gen=12):
7
+ """
8
+ Runs Gen_SMILES2.py using the given user SMILES in place of scaf_smi
9
+ and returns RDKit images.
10
+ """
11
+
12
+ # Run Gen_SMILES2.py with an argument
13
+ subprocess.run([
14
+ "python", "app/Gen_PartialSMILES2.py",
15
+ "--scaffold", user_smiles,
16
+ "--n_to_gen", str(n_to_gen)
17
+ ], check=True)
18
+
19
+ # Read the generated CSV
20
+ df = pd.read_csv("generated_molecules.csv")
21
+
22
+ images = []
23
+ for smi in df["smiles"].head(n_to_gen):
24
+ mol = Chem.MolFromSmiles(smi)
25
+ if mol:
26
+ img = Draw.MolToImage(mol, size=(250, 250))
27
+ images.append({"smiles": smi, "image": img, "style": "generated"})
28
+
29
+ return images