Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -130,21 +130,27 @@ def similars_node(state: State) -> State:
|
|
| 130 |
print(state['query_name'])
|
| 131 |
try:
|
| 132 |
#while x == 2:
|
| 133 |
-
if (state['query_smiles'] != None)
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
| 140 |
try:
|
| 141 |
name = state["query_name"]
|
| 142 |
print('trying with name', name)
|
| 143 |
-
res = pcp.get_compounds(name, "name", searchtype="similarity",listkey_count=
|
| 144 |
props_string = f'The following molecules are similar to {name}: \n'
|
|
|
|
| 145 |
except:
|
| 146 |
-
print('
|
| 147 |
-
|
|
|
|
|
|
|
| 148 |
|
| 149 |
sub_smiles = []
|
| 150 |
|
|
@@ -479,7 +485,7 @@ builder.add_edge("reflect_node", END)
|
|
| 479 |
graph = builder.compile()
|
| 480 |
|
| 481 |
@spaces.GPU
|
| 482 |
-
def MoleculeAgent(smiles, name
|
| 483 |
|
| 484 |
#if Similars_image.png exists, remove it
|
| 485 |
if os.path.exists('Similars_image.png'):
|
|
@@ -536,6 +542,7 @@ with gr.Blocks(fill_height=True) as forest:
|
|
| 536 |
pic = gr.Image(label="Molecule")
|
| 537 |
|
| 538 |
|
| 539 |
-
calc_btn.click(MoleculeAgent, inputs = [smiles, name
|
|
|
|
| 540 |
|
| 541 |
forest.launch(debug=False, mcp_server=True)
|
|
|
|
| 130 |
print(state['query_name'])
|
| 131 |
try:
|
| 132 |
#while x == 2:
|
| 133 |
+
if (state['query_smiles'] != None):
|
| 134 |
+
try:
|
| 135 |
+
smiles = state["query_smiles"]
|
| 136 |
+
print('trying with smiles')
|
| 137 |
+
res = pcp.get_compounds(smiles, "smiles", searchtype="similarity",listkey_count=50)
|
| 138 |
+
props_string = f'The following molecules are similar to {smiles}: \n'
|
| 139 |
+
print('got similar molecules with smiles')
|
| 140 |
+
except:
|
| 141 |
+
print('No SMILES.')
|
| 142 |
+
elif (state['query_name'] != None):
|
| 143 |
try:
|
| 144 |
name = state["query_name"]
|
| 145 |
print('trying with name', name)
|
| 146 |
+
res = pcp.get_compounds(name, "name", searchtype="similarity",listkey_count=50)
|
| 147 |
props_string = f'The following molecules are similar to {name}: \n'
|
| 148 |
+
print('got similar molecules with name')
|
| 149 |
except:
|
| 150 |
+
print('No Name.')
|
| 151 |
+
else:
|
| 152 |
+
print('Not enough information to run similars tool')
|
| 153 |
+
return state
|
| 154 |
|
| 155 |
sub_smiles = []
|
| 156 |
|
|
|
|
| 485 |
graph = builder.compile()
|
| 486 |
|
| 487 |
@spaces.GPU
|
| 488 |
+
def MoleculeAgent(task, smiles, name):
|
| 489 |
|
| 490 |
#if Similars_image.png exists, remove it
|
| 491 |
if os.path.exists('Similars_image.png'):
|
|
|
|
| 542 |
pic = gr.Image(label="Molecule")
|
| 543 |
|
| 544 |
|
| 545 |
+
calc_btn.click(MoleculeAgent, inputs = [task, smiles, name], outputs = [props, pic])
|
| 546 |
+
task.submit(MoleculeAgent, inputs = [task, smiles, name], outputs = [props, pic])
|
| 547 |
|
| 548 |
forest.launch(debug=False, mcp_server=True)
|