Update app.py
Browse files
app.py
CHANGED
|
@@ -5,14 +5,15 @@ import shutil
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
def fold(id, sequence):
|
| 8 |
-
sequence = sequence.upper().
|
| 9 |
if len(sequence) > 512:
|
| 10 |
-
return "", "
|
|
|
|
|
|
|
| 11 |
shutil.rmtree("output", ignore_errors=True)
|
| 12 |
ct_file = f"output/{id}.ct"
|
| 13 |
structure_draw = f"output/{id}.png"
|
| 14 |
fasta_file = f"output/{id}.fasta"
|
| 15 |
-
msg = "Completed."
|
| 16 |
|
| 17 |
resolution = 1
|
| 18 |
if len(sequence)>100:
|
|
@@ -26,12 +27,12 @@ def fold(id, sequence):
|
|
| 26 |
if not dotbracket:
|
| 27 |
dotbracket = None
|
| 28 |
structure_draw = None
|
| 29 |
-
|
| 30 |
|
| 31 |
with open(fasta_file, "w") as f:
|
| 32 |
f.write(f">{id}\n{sequence}\n{dotbracket}")
|
| 33 |
|
| 34 |
-
return
|
| 35 |
|
| 36 |
|
| 37 |
def run():
|
|
@@ -45,11 +46,10 @@ def run():
|
|
| 45 |
gr.Textbox(label="RNA Sequence",
|
| 46 |
value="GAUAAACCUUUAGCAAUAAACGAAAGUUUAACUAAGCCAUACUAACCCCAGGGUUGGUCAAUUUCGUGCCAGCCACCGCGGUCACACGAUUAACCCAAGCCAAUAGAAAUCGGCGUAAAGAGUGUUUUAGAUCAAUCCCCCAAUAAAGCUAAAAUUCACCUG")],
|
| 47 |
outputs=[
|
|
|
|
|
|
|
| 48 |
gr.Image(label="Structure"),
|
| 49 |
-
gr.
|
| 50 |
-
gr.File(label="Fasta file"),
|
| 51 |
-
gr.File(label="CT file"),
|
| 52 |
-
gr.Textbox(label="Output"),
|
| 53 |
],
|
| 54 |
examples=[
|
| 55 |
["srp_Bruc.abor._AE017223", "AACCGGGUCAGGUCCGGAAGGAAGCAGCCCUAA"],
|
|
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
def fold(id, sequence):
|
| 8 |
+
sequence = sequence.upper().replace(" ", "").replace("\n", "").replace("T", "U")
|
| 9 |
if len(sequence) > 512:
|
| 10 |
+
return "", "Max sequence length is 512", "", ""
|
| 11 |
+
if len(sequence) < 3:
|
| 12 |
+
return "", "Min sequence length is 3", "", ""
|
| 13 |
shutil.rmtree("output", ignore_errors=True)
|
| 14 |
ct_file = f"output/{id}.ct"
|
| 15 |
structure_draw = f"output/{id}.png"
|
| 16 |
fasta_file = f"output/{id}.fasta"
|
|
|
|
| 17 |
|
| 18 |
resolution = 1
|
| 19 |
if len(sequence)>100:
|
|
|
|
| 27 |
if not dotbracket:
|
| 28 |
dotbracket = None
|
| 29 |
structure_draw = None
|
| 30 |
+
dotbracket = "CT to dotbracket conversion failed (.ct file should be ok)"
|
| 31 |
|
| 32 |
with open(fasta_file, "w") as f:
|
| 33 |
f.write(f">{id}\n{sequence}\n{dotbracket}")
|
| 34 |
|
| 35 |
+
return ct_file, dotbracket, structure_draw, fasta_file
|
| 36 |
|
| 37 |
|
| 38 |
def run():
|
|
|
|
| 46 |
gr.Textbox(label="RNA Sequence",
|
| 47 |
value="GAUAAACCUUUAGCAAUAAACGAAAGUUUAACUAAGCCAUACUAACCCCAGGGUUGGUCAAUUUCGUGCCAGCCACCGCGGUCACACGAUUAACCCAAGCCAAUAGAAAUCGGCGUAAAGAGUGUUUUAGAUCAAUCCCCCAAUAAAGCUAAAAUUCACCUG")],
|
| 48 |
outputs=[
|
| 49 |
+
gr.File(label="Model output"),
|
| 50 |
+
gr.Textbox(label="Dot-bracket"),
|
| 51 |
gr.Image(label="Structure"),
|
| 52 |
+
gr.File(label="Fasta format"),
|
|
|
|
|
|
|
|
|
|
| 53 |
],
|
| 54 |
examples=[
|
| 55 |
["srp_Bruc.abor._AE017223", "AACCGGGUCAGGUCCGGAAGGAAGCAGCCCUAA"],
|