Spaces:
Runtime error
Runtime error
Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from rdkit import Chem
|
| 3 |
from rdkit.Chem import Descriptors, Draw
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
def _mol_from_smiles(smiles: str):
|
|
@@ -36,12 +37,12 @@ def mol_image(smiles: str):
|
|
| 36 |
|
| 37 |
|
| 38 |
def name_to_smiles(name: str) -> str:
|
| 39 |
-
"""Convert chemical name to SMILES using
|
| 40 |
try:
|
| 41 |
-
|
| 42 |
-
if
|
| 43 |
-
raise gr.Error(f"Could not
|
| 44 |
-
return
|
| 45 |
except Exception as e:
|
| 46 |
raise gr.Error(f"Error converting name to SMILES: {str(e)}")
|
| 47 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from rdkit import Chem
|
| 3 |
from rdkit.Chem import Descriptors, Draw
|
| 4 |
+
import cirpy
|
| 5 |
|
| 6 |
|
| 7 |
def _mol_from_smiles(smiles: str):
|
|
|
|
| 37 |
|
| 38 |
|
| 39 |
def name_to_smiles(name: str) -> str:
|
| 40 |
+
"""Convert chemical name to SMILES using Chemical Identifier Resolver (CIR)"""
|
| 41 |
try:
|
| 42 |
+
smiles = cirpy.resolve(name, 'smiles')
|
| 43 |
+
if smiles is None:
|
| 44 |
+
raise gr.Error(f"Could not find SMILES for chemical name: {name}")
|
| 45 |
+
return smiles
|
| 46 |
except Exception as e:
|
| 47 |
raise gr.Error(f"Error converting name to SMILES: {str(e)}")
|
| 48 |
|