Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -202,6 +202,8 @@ def getbioactives_node(state: State) -> State:
|
|
| 202 |
|
| 203 |
chembl_id = state["query_chembl"].strip()
|
| 204 |
current_props_string = state["props_string"]
|
|
|
|
|
|
|
| 205 |
|
| 206 |
#check if f'{chembl_id}_bioactives.csv' exists
|
| 207 |
if os.path.exists(f'{chembl_id}_bioactives.csv'):
|
|
@@ -285,14 +287,15 @@ def getbioactives_node(state: State) -> State:
|
|
| 285 |
smile = smile.replace('#','~')
|
| 286 |
bioact_string += f'Molecule SMILES: {smile}, IC50 (nM): {ic50}\n'
|
| 287 |
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
|
|
|
| 292 |
# pic = img.data
|
| 293 |
# with open(filename,'wb+') as outf:
|
| 294 |
# outf.write(pic)
|
| 295 |
-
|
| 296 |
|
| 297 |
current_props_string += bioact_string
|
| 298 |
state["props_string"] = current_props_string
|
|
|
|
| 202 |
|
| 203 |
chembl_id = state["query_chembl"].strip()
|
| 204 |
current_props_string = state["props_string"]
|
| 205 |
+
if (chembl_id == None) or (chembl_id.lower() == 'none') or (chembl_id == '':)
|
| 206 |
+
return state
|
| 207 |
|
| 208 |
#check if f'{chembl_id}_bioactives.csv' exists
|
| 209 |
if os.path.exists(f'{chembl_id}_bioactives.csv'):
|
|
|
|
| 287 |
smile = smile.replace('#','~')
|
| 288 |
bioact_string += f'Molecule SMILES: {smile}, IC50 (nM): {ic50}\n'
|
| 289 |
|
| 290 |
+
if len(total_bioact_df) > 0:
|
| 291 |
+
mols = [Chem.MolFromSmiles(smile) for smile in total_bioact_df['SMILES'].to_list()]
|
| 292 |
+
legends = [f'IC50: {ic50}' for ic50 in total_bioact_df['IC50s'].to_list()]
|
| 293 |
+
img = MolsToGridImage(mols, molsPerRow=5, legends=legends, subImgSize=(200,200))
|
| 294 |
+
filename = "Substitution_image.png"
|
| 295 |
# pic = img.data
|
| 296 |
# with open(filename,'wb+') as outf:
|
| 297 |
# outf.write(pic)
|
| 298 |
+
img.save(filename)
|
| 299 |
|
| 300 |
current_props_string += bioact_string
|
| 301 |
state["props_string"] = current_props_string
|