Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
|
| 2 |
import os
|
| 3 |
import json
|
|
|
|
| 4 |
|
| 5 |
import gradio as gr
|
| 6 |
from gradio_moleculeview import moleculeview
|
|
@@ -327,23 +328,22 @@ def predict(input_mol, style, contour_level, view_str, chains):
|
|
| 327 |
chain_str = ""
|
| 328 |
chain_dict = json.loads(chains)
|
| 329 |
|
|
|
|
| 330 |
# sort keys in dict and add colors to chain_str
|
| 331 |
for chain in sorted(chain_dict.keys()):
|
| 332 |
chain_str += f" '{chain_dict[chain]}'"
|
| 333 |
if style == "Goodsell3D":
|
| 334 |
-
os.system(f"cellscape cartoon --pdb {input_mol.name} --outline residue --color_by chain --depth_shading --depth_lines --colors {chain_str} --depth flat --back_outline --view view_matrix --save
|
| 335 |
elif style == "Contour":
|
| 336 |
-
os.system(f"cellscape cartoon --pdb {input_mol.name} --outline chain --color_by chain --depth_contour_interval {contour_level} --colors {chain_str} --depth contours --back_outline --view view_matrix --save
|
| 337 |
else:
|
| 338 |
-
os.system(f"cellscape cartoon --pdb {input_mol.name} --outline chain --colors {chain_str} --depth flat --back_outline --view view_matrix --save
|
| 339 |
|
| 340 |
#read content of file
|
| 341 |
-
|
| 342 |
-
os.system("inkscape outline_all.svg --actions='select-all;path-simplify;export-plain-svg' --export-filename pdb_opt.svg")
|
| 343 |
-
print(os.stat("outline_all.svg").st_size / (1024 * 1024))
|
| 344 |
|
| 345 |
|
| 346 |
-
return html_output(
|
| 347 |
|
| 348 |
|
| 349 |
|
|
|
|
| 1 |
|
| 2 |
import os
|
| 3 |
import json
|
| 4 |
+
import uuid
|
| 5 |
|
| 6 |
import gradio as gr
|
| 7 |
from gradio_moleculeview import moleculeview
|
|
|
|
| 328 |
chain_str = ""
|
| 329 |
chain_dict = json.loads(chains)
|
| 330 |
|
| 331 |
+
outputfile = str(uuid.uuid4())+".svg"
|
| 332 |
# sort keys in dict and add colors to chain_str
|
| 333 |
for chain in sorted(chain_dict.keys()):
|
| 334 |
chain_str += f" '{chain_dict[chain]}'"
|
| 335 |
if style == "Goodsell3D":
|
| 336 |
+
os.system(f"cellscape cartoon --pdb {input_mol.name} --outline residue --color_by chain --depth_shading --depth_lines --colors {chain_str} --depth flat --back_outline --view view_matrix --save {outputfile}")
|
| 337 |
elif style == "Contour":
|
| 338 |
+
os.system(f"cellscape cartoon --pdb {input_mol.name} --outline chain --color_by chain --depth_contour_interval {contour_level} --colors {chain_str} --depth contours --back_outline --view view_matrix --save {outputfile}")
|
| 339 |
else:
|
| 340 |
+
os.system(f"cellscape cartoon --pdb {input_mol.name} --outline chain --colors {chain_str} --depth flat --back_outline --view view_matrix --save {outputfile}")
|
| 341 |
|
| 342 |
#read content of file
|
| 343 |
+
os.system(f"inkscape {outputfile} --actions='select-all;path-simplify;export-plain-svg' --export-filename {outputfile.replace('.svg', '_opt.svg')}")
|
|
|
|
|
|
|
| 344 |
|
| 345 |
|
| 346 |
+
return html_output(outputfile.replace('.svg', '_opt.svg'))
|
| 347 |
|
| 348 |
|
| 349 |
|