Skip to content

Commit

Permalink
Merge branch 'develop_2' of gitlab.com:croningroup/cheminformatics/el…
Browse files Browse the repository at this point in the history
…ectrondensity2 into develop_2
  • Loading branch information
Juanma committed Jan 18, 2022
2 parents b38fffe + 5253b84 commit 01ab2b5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
25 changes: 19 additions & 6 deletions src/utils/ed_to_smiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,32 @@ def load_transformer_model(modelpath, datapath):

print(smiles)

# check if these molecules are commercially avaiable
# i want to print the commercial the last, for easier visualisation
commercial_smiles = [ s for s in smiles if s in commercialDB.values]
noncommercial_smiles = [ s for s in smiles if s not in commercialDB.values ]

# now smiles to molecules
mols = [Chem.MolFromSmiles(m) for m in smiles]
comm_mols = [Chem.MolFromSmiles(m) for m in commercial_smiles]
noncomm_mols = [Chem.MolFromSmiles(m) for m in noncommercial_smiles]
mols = noncomm_mols + comm_mols

# calculate synthetic scores
scores = [sascorer.calculateScore(m) if m is not None else 10 for m in mols]
comm_scores = [sascorer.calculateScore(m) if m is not None else 10 for m in comm_mols]
noncomm_scores = [sascorer.calculateScore(m) if m is not None else 10 for m in noncomm_mols]
# transform them to strings
scores = [ f"{s:.1f}" for s in scores]
comm_scores = [ f"{s:.1f}" for s in comm_scores]
noncomm_scores = [ f"{s:.1f}" for s in noncomm_scores]

# check if these molecules are commercially avaiable
legend = [ s+" Y" if s in commercialDB.values else s+" N" for s in smiles ]
# create legend with commercial availability
comm_legend = [ s+" Y" for s in commercial_smiles ]
noncomm_legend = [ s+" N" for s in noncommercial_smiles ]

# add the scores
legend = [ t[0]+" "+t[1] for t in zip(legend, scores)]
comm_legend = [ t[0]+" "+t[1] for t in zip(comm_legend, comm_scores)]
noncomm_legend = [ t[0]+" "+t[1] for t in zip(noncomm_legend, noncomm_scores)]

legend = noncomm_legend + comm_legend

# molecules to image
img = Draw.MolsToGridImage(mols, molsPerRow=8, subImgSize=(200, 200),
Expand Down
7 changes: 4 additions & 3 deletions src/utils/edesp_to_smiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,13 @@ def load_transformer_model(modelpath, datapath):

# check if these molecules are commercially avaiable
# i want to print the commercial the last, for easier visualisation
commercial_smiles = [ s in commercialDB.values for s in smiles ]
noncommercial_smiles = [ s not in commercialDB.values for s in smiles ]
commercial_smiles = [ s for s in smiles if s in commercialDB.values]
noncommercial_smiles = [ s for s in smiles if s not in commercialDB.values ]

# now smiles to molecules
comm_mols = [Chem.MolFromSmiles(m) for m in commercial_smiles]
noncomm_mols = [Chem.MolFromSmiles(m) for m in noncommercial_smiles]
mols = noncomm_mols + comm_mols

# calculate synthetic scores
comm_scores = [sascorer.calculateScore(m) if m is not None else 10 for m in comm_mols]
Expand All @@ -148,7 +149,7 @@ def load_transformer_model(modelpath, datapath):

# create legend with commercial availability
comm_legend = [ s+" Y" for s in commercial_smiles ]
noncomm_legend = [ s+" Y" for s in noncommercial_smiles ]
noncomm_legend = [ s+" N" for s in noncommercial_smiles ]

# add the scores
comm_legend = [ t[0]+" "+t[1] for t in zip(comm_legend, comm_scores)]
Expand Down

0 comments on commit 01ab2b5

Please sign in to comment.