Spaces:
Sleeping
Sleeping
as-cle-bert
commited on
Commit
•
31d5268
1
Parent(s):
05a48dc
Update app.py
Browse files
app.py
CHANGED
@@ -77,38 +77,24 @@ def molecule(input_pdb):
|
|
77 |
allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
|
78 |
|
79 |
@spaces.GPU(duration=300)
|
80 |
-
def prediction(prompt, temperature
|
81 |
protein = ESMProtein(sequence=prompt)
|
82 |
protein = model.generate(protein, GenerationConfig(track="sequence", num_steps=8, temperature=temperature))
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
html1 = molecule("./round_tripped.pdb")
|
95 |
-
return seq, protein.sequence, html, html1, "./generation.pdb", "./round_tripped.pdb"
|
96 |
-
else:
|
97 |
-
html1 = "<h3>Inverse folding and re-generation not enabled</h3>"
|
98 |
-
f = open("./round_tripped.pdb", "w")
|
99 |
-
f.write("\n")
|
100 |
-
f.close()
|
101 |
-
return protein.sequence, "Inverse folding and re-generation not enabled", html, html1, "./generation.pdb", "./round_tripped.pdb"
|
102 |
-
else:
|
103 |
-
f = open("./empty.pdb", "w")
|
104 |
-
f.write("\n")
|
105 |
-
f.close()
|
106 |
-
return protein.sequence, "Inverse folding and re-generation not enabled", "<h3>Structure reconstruction not enabled</h3>", "<h3>Inverse folding and re-generation not enabled</h3>", "./empty.pdb", "./empty.pdb"
|
107 |
-
|
108 |
|
109 |
-
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")
|
110 |
<h2 align='center'>Predict the whole sequence and 3D structure of masked protein sequences!</h2>
|
111 |
<h3 align='center'>Support this space with a ⭐ on <a href='https://github.com/AstraBert/proteins-w-esm'>GitHub</a></h3>
|
112 |
-
<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
|
113 |
|
114 |
demo.launch()
|
|
|
77 |
allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>"""
|
78 |
|
79 |
@spaces.GPU(duration=300)
|
80 |
+
def prediction(prompt, temperature):
|
81 |
protein = ESMProtein(sequence=prompt)
|
82 |
protein = model.generate(protein, GenerationConfig(track="sequence", num_steps=8, temperature=temperature))
|
83 |
+
seq = protein.sequence
|
84 |
+
protein = model.generate(protein, GenerationConfig(track="structure", num_steps=8))
|
85 |
+
protein.to_pdb("./generation.pdb")
|
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 |
+
html = molecule("./generation.pdb")
|
93 |
+
return seq, protein.sequence, html, html1, "./generation.pdb", "./round_tripped.pdb"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
+
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")], outputs = [gr.Textbox(label="Originally predicted sequence"),gr.Textbox(label="Inverse folding predicted sequence"),gr.HTML(label="Predicted 3D structure"),gr.HTML(label="Inverse-folding predicted 3D structure"), Molecule3D(label="Predicted molecular structure"), Molecule3D(label="Inverse-folding predicted molecular structure")], title="""<h1 align='center'>Proteins with ESM</h1>
|
96 |
<h2 align='center'>Predict the whole sequence and 3D structure of masked protein sequences!</h2>
|
97 |
<h3 align='center'>Support this space with a ⭐ on <a href='https://github.com/AstraBert/proteins-w-esm'>GitHub</a></h3>
|
98 |
+
<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], ["__________________________________________________________AGQEEYSAMRDQYMRTGEGFLCVFAINNTKSFEDIHQYREQIKRVKDSDDVPMVLVGNKCDLAARTVESRQAQDLARSYGIPYIETSAKTRQGVEDAFYTLVRE___________________________", 0.2], ["__________KTITLEVEPSDTIENVKAKIQDKEGIPPDQQRLIFAGKQLEDGRTLSDYNIQKESTLH________", 0.5]], cache_examples=False)
|
99 |
|
100 |
demo.launch()
|