Spaces:
Sleeping
Sleeping
as-cle-bert
commited on
Commit
•
bbe157e
1
Parent(s):
c7dfcd4
Update app.py
Browse files
app.py
CHANGED
@@ -75,28 +75,21 @@ def molecule(input_pdb):
|
|
75 |
allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
|
76 |
allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
|
77 |
|
78 |
-
def prediction(prompt, temperature, do_structure
|
79 |
protein = ESMProtein(sequence=prompt)
|
80 |
protein = model.generate(protein, GenerationConfig(track="sequence", num_steps=8, temperature=temperature))
|
81 |
if do_structure == "Yes":
|
82 |
protein = model.generate(protein, GenerationConfig(track="structure", num_steps=8))
|
83 |
protein.to_pdb("./generation.pdb")
|
84 |
html = molecule("./generation.pdb")
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
return seq, protein.sequence, html, html1, "./round_tripped.pdb", "./generation.pdb",
|
94 |
-
else:
|
95 |
-
html1 = "<h3>Inverse folding and re-generation not enabled</h3>"
|
96 |
-
f = open("./round_tripped.pdb", "w")
|
97 |
-
f.write("\n")
|
98 |
-
f.close()
|
99 |
-
return protein.sequence, "Inverse folding and re-generation not enabled", html, html1, "./round_tripped.pdb", "./generation.pdb"
|
100 |
else:
|
101 |
f = open("./empty.pdb", "w")
|
102 |
f.write("\n")
|
@@ -117,9 +110,9 @@ reps = [
|
|
117 |
}
|
118 |
]
|
119 |
|
120 |
-
demo = gr.Interface(fn = prediction, inputs = [gr.Textbox(label="Masked protein sequence", info="Use '_' as masking character", value="___________________________________________________DQATSLRILNNGHAFNVEFDDSQDKAVLKGGPLDGTYRLIQFHFHWGSLDGQGSEHTVDKKKYAAELHLVHWNTKYGDFGKAVQQPDGLAVLGIFLKVGSAKPGLQKVVDVLDSIKTKGKSADFTNFDPRGLLPESLDYWTYPGSLTTPP___________________________________________________________"), gr.Slider(0,1,label="Temperature"), gr.Radio(["Yes", "No"], label="Reconstruct structure", info="Choose wheter to reconstruct structure or not
|
121 |
<h2 align='center'>Predict the whole sequence and 3D structure of masked protein sequences!</h2>
|
122 |
<h3 align='center'>Support this space with a ⭐ on <a href='https://github.com/AstraBert/proteins-w-esm'>GitHub</a></h3>
|
123 |
-
<h3 align='center'>Support Evolutionary Scale's ESM with a ⭐ on <a href='https://github.com/evolutionaryscale/esm'>GitHub</a></h3>""", examples = [["___________________________________________________DQATSLRILNNGHAFNVEFDDSQDKAVLKGGPLDGTYRLIQFHFHWGSLDGQGSEHTVDKKKYAAELHLVHWNTKYGDFGKAVQQPDGLAVLGIFLKVGSAKPGLQKVVDVLDSIKTKGKSADFTNFDPRGLLPESLDYWTYPGSLTTPP___________________________________________________________", 0.7, "No"
|
124 |
|
125 |
demo.launch()
|
|
|
75 |
allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
|
76 |
allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
|
77 |
|
78 |
+
def prediction(prompt, temperature, do_structure):
|
79 |
protein = ESMProtein(sequence=prompt)
|
80 |
protein = model.generate(protein, GenerationConfig(track="sequence", num_steps=8, temperature=temperature))
|
81 |
if do_structure == "Yes":
|
82 |
protein = model.generate(protein, GenerationConfig(track="structure", num_steps=8))
|
83 |
protein.to_pdb("./generation.pdb")
|
84 |
html = molecule("./generation.pdb")
|
85 |
+
seq = protein.sequence
|
86 |
+
protein.sequence = None
|
87 |
+
protein = model.generate(protein, GenerationConfig(track="sequence", num_steps=8))
|
88 |
+
protein.coordinates = None
|
89 |
+
protein = model.generate(protein, GenerationConfig(track="structure", num_steps=8))
|
90 |
+
protein.to_pdb("./round_tripped.pdb")
|
91 |
+
html1 = molecule("./round_tripped.pdb")
|
92 |
+
return seq, protein.sequence, html, html1, "./round_tripped.pdb", "./generation.pdb",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
else:
|
94 |
f = open("./empty.pdb", "w")
|
95 |
f.write("\n")
|
|
|
110 |
}
|
111 |
]
|
112 |
|
113 |
+
demo = gr.Interface(fn = prediction, inputs = [gr.Textbox(label="Masked protein sequence", info="Use '_' as masking character", value="___________________________________________________DQATSLRILNNGHAFNVEFDDSQDKAVLKGGPLDGTYRLIQFHFHWGSLDGQGSEHTVDKKKYAAELHLVHWNTKYGDFGKAVQQPDGLAVLGIFLKVGSAKPGLQKVVDVLDSIKTKGKSADFTNFDPRGLLPESLDYWTYPGSLTTPP___________________________________________________________"), gr.Slider(0,1,label="Temperature"), gr.Radio(["Yes", "No"], label="Reconstruct structure", info="Choose wheter to reconstruct structure or not, allowing also inverse folding-powered double check")], outputs = [gr.Textbox(label="Originally predicted sequence", show_copy_button=True),gr.Textbox(label="Inverse folding predicted sequence", show_copy_button=True),gr.HTML(label="Predicted 3D structure"),gr.HTML(label="Inverse-folding predicted 3D structure"), Molecule3D(label="Inverse-folding predicted molecular structure", reps=reps), Molecule3D(label="Predicted molecular structure", reps=reps)], title="""<h1 align='center'>Proteins with ESM</h1>
|
114 |
<h2 align='center'>Predict the whole sequence and 3D structure of masked protein sequences!</h2>
|
115 |
<h3 align='center'>Support this space with a ⭐ on <a href='https://github.com/AstraBert/proteins-w-esm'>GitHub</a></h3>
|
116 |
+
<h3 align='center'>Support Evolutionary Scale's ESM with a ⭐ on <a href='https://github.com/evolutionaryscale/esm'>GitHub</a></h3>""", examples = [["___________________________________________________DQATSLRILNNGHAFNVEFDDSQDKAVLKGGPLDGTYRLIQFHFHWGSLDGQGSEHTVDKKKYAAELHLVHWNTKYGDFGKAVQQPDGLAVLGIFLKVGSAKPGLQKVVDVLDSIKTKGKSADFTNFDPRGLLPESLDYWTYPGSLTTPP___________________________________________________________", 0.7, "No"], ["__________________________________________________________AGQEEYSAMRDQYMRTGEGFLCVFAINNTKSFEDIHQYREQIKRVKDSDDVPMVLVGNKCDLAARTVESRQAQDLARSYGIPYIETSAKTRQGVEDAFYTLVRE___________________________", 0.2, "Yes"], ["__________KTITLEVEPSDTIENVKAKIQDKEGIPPDQQRLIFAGKQLEDGRTLSDYNIQKESTLH________", 0.5, "Yes",]], cache_examples=False)
|
117 |
|
118 |
demo.launch()
|