Spaces:
Running
Running
File size: 1,354 Bytes
7476d14 6790366 7476d14 06bfe5a 7476d14 81922bf 7476d14 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
import gradio as gr
from utils import ChemicalConverter, validate_smiles2iupac, plot_mol, login
def convert(access_code, chemical_name, style, validate, plot):
# Initialize the ChemicalConverter
converter = ChemicalConverter(mode="SMILES2IUPAC")
converted_name = ""
validation_score = ""
plot_image = None
style_prefix = "<" + style[:4] + ">"
converted_name = converter.convert(style_prefix + chemical_name)
if validate:
validation_score = validate_smiles2iupac(chemical_name, converted_name)
if plot:
plot_image = plot_mol(chemical_name)
return converted_name, validation_score, plot_image
smiles2iupac = gr.Interface(
fn=convert,
allow_flagging='auto',
inputs=[
gr.Textbox(label="Enter your SMILES name", placeholder="Enter your SMILES name here"),
gr.Radio(
choices=["BASE", "SYSTEMATIC", "TRADITIONAL"],
label="Choose desired IUPAC style",
),
gr.Checkbox(label="Validate with molecular similarity", value=False),
gr.Checkbox(label="Plot molecule", value=True)
],
outputs=[gr.Text(label="Converted Name"),
gr.Text(label="Input-Target similarity score"),
gr.Image(type='pil', label="Molecule Plot", height=170, width=890)],
examples=[
["CCO", "BASE", True, False]
],
) |