Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1004,11 +1004,6 @@ def unwrap_text(text):
|
|
| 1004 |
return text.strip.replece('\n', '')
|
| 1005 |
|
| 1006 |
|
| 1007 |
-
def smiles_from_sdf(sdf_path):
|
| 1008 |
-
with Chem.SDMolSupplier(sdf_path) as suppl:
|
| 1009 |
-
return Chem.MolToSmiles(suppl[0])
|
| 1010 |
-
|
| 1011 |
-
|
| 1012 |
def drug_library_from_sdf(sdf_path):
|
| 1013 |
return PandasTools.LoadSDF(
|
| 1014 |
sdf_path,
|
|
@@ -1528,8 +1523,15 @@ with gr.Blocks(theme=theme, title='DeepSEQreen', css=CSS) as demo:
|
|
| 1528 |
finally:
|
| 1529 |
return fasta_seq
|
| 1530 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1531 |
|
| 1532 |
-
target_upload_btn.upload(fn=
|
| 1533 |
target_query_btn.click(uniprot_query,
|
| 1534 |
inputs=[target_input_type, target_id, target_gene, target_organism],
|
| 1535 |
outputs=target_fasta)
|
|
@@ -1633,12 +1635,17 @@ QALAHAYFAQYHDPDDEPVADPYDQSFESRDLLIDEWKSLTYDEVISFVPPPLDQEEMES
|
|
| 1633 |
|
| 1634 |
|
| 1635 |
def compound_upload_process(input_type, input_upload):
|
| 1636 |
-
|
| 1637 |
-
|
| 1638 |
-
|
| 1639 |
-
|
| 1640 |
-
|
| 1641 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1642 |
|
| 1643 |
|
| 1644 |
compound_upload_btn.upload(fn=compound_upload_process,
|
|
|
|
| 1004 |
return text.strip.replece('\n', '')
|
| 1005 |
|
| 1006 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1007 |
def drug_library_from_sdf(sdf_path):
|
| 1008 |
return PandasTools.LoadSDF(
|
| 1009 |
sdf_path,
|
|
|
|
| 1523 |
finally:
|
| 1524 |
return fasta_seq
|
| 1525 |
|
| 1526 |
+
def process_fasta_upload(fasta_upload):
|
| 1527 |
+
fasta = ''
|
| 1528 |
+
try:
|
| 1529 |
+
fasta = fasta_upload.decode()
|
| 1530 |
+
except Exception as e:
|
| 1531 |
+
gr.Warning(f"Please upload a valid FASTA file. Error: {str(e)}")
|
| 1532 |
+
return fasta
|
| 1533 |
|
| 1534 |
+
target_upload_btn.upload(fn=process_fasta_upload, inputs=target_upload_btn, outputs=target_fasta)
|
| 1535 |
target_query_btn.click(uniprot_query,
|
| 1536 |
inputs=[target_input_type, target_id, target_gene, target_organism],
|
| 1537 |
outputs=target_fasta)
|
|
|
|
| 1635 |
|
| 1636 |
|
| 1637 |
def compound_upload_process(input_type, input_upload):
|
| 1638 |
+
smiles = ''
|
| 1639 |
+
try:
|
| 1640 |
+
match input_type:
|
| 1641 |
+
case 'SMILES':
|
| 1642 |
+
smiles = input_upload.decode()
|
| 1643 |
+
case 'SDF':
|
| 1644 |
+
suppl = Chem.ForwardSDMolSupplier(io.BytesIO(input_upload))
|
| 1645 |
+
smiles = Chem.MolToSmiles(next(suppl))
|
| 1646 |
+
except Exception as e:
|
| 1647 |
+
gr.Warning(f"Please upload a valid {input_type} file. Error: {str(e)}")
|
| 1648 |
+
return smiles
|
| 1649 |
|
| 1650 |
|
| 1651 |
compound_upload_btn.upload(fn=compound_upload_process,
|