Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -20,11 +20,12 @@ def predict(input_mol, style, view_str, chains):
|
|
20 |
for chain in sorted(chain_dict.keys()):
|
21 |
chain_str += f" '{chain_dict[chain]}'"
|
22 |
if style == "Goodsell3D":
|
23 |
-
os.system(f"cellscape cartoon --pdb {input_mol.name} --outline residue --depth_shading --depth_lines --colors {chain_str} --depth flat --back_outline --view view_matrix --save outline_all.svg")
|
24 |
elif style == "Contour":
|
25 |
-
os.system(f"cellscape cartoon --pdb {input_mol.name} --outline residue --depth_contour_interval 10 --colors {chain_str} --depth contours --back_outline --view view_matrix --save outline_all.svg")
|
26 |
else:
|
27 |
os.system(f"cellscape cartoon --pdb {input_mol.name} --outline chain --colors {chain_str} --depth flat --back_outline --view view_matrix --save outline_all.svg")
|
|
|
28 |
#read content of file
|
29 |
print(os.stat("outline_all.svg").st_size / (1024 * 1024))
|
30 |
os.system("inkscape outline_all.svg --actions='select-all;path-simplify;export-plain-svg' --export-filename pdb_opt.svg")
|
@@ -45,17 +46,15 @@ with gr.Blocks() as demo:
|
|
45 |
view_str = gr.Textbox("viewMatrixResult", label="View Matrix", visible=False)
|
46 |
chains = gr.Textbox("chainsResult", label="Chains", visible=False)
|
47 |
hidden_style = gr.Textbox(visible=False)
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
html = gr.HTML("")
|
52 |
out_file = gr.File(label="Download SVG")
|
53 |
-
btn.click(None, style, [view_str, chains, hidden_style], js="(style) => [document.getElementById('viewMatrixResult').value, document.getElementById('chains').value, style]") #
|
54 |
-
|
|
|
55 |
# on change of chains trigger, rendering
|
56 |
-
# view_str.change(predict, [inp, style, view_str, chains], [html, out_file])
|
57 |
-
# chains.change(predict, [inp, style, view_str, chains], [html, out_file])
|
58 |
-
# hidden_style.change(predict, [inp, style, view_str, chains], [html, out_file])
|
59 |
|
60 |
|
61 |
if __name__ == "__main__":
|
|
|
20 |
for chain in sorted(chain_dict.keys()):
|
21 |
chain_str += f" '{chain_dict[chain]}'"
|
22 |
if style == "Goodsell3D":
|
23 |
+
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 outline_all.svg")
|
24 |
elif style == "Contour":
|
25 |
+
os.system(f"cellscape cartoon --pdb {input_mol.name} --outline residue --color_by chain --depth_contour_interval 10 --colors {chain_str} --depth contours --back_outline --view view_matrix --save outline_all.svg")
|
26 |
else:
|
27 |
os.system(f"cellscape cartoon --pdb {input_mol.name} --outline chain --colors {chain_str} --depth flat --back_outline --view view_matrix --save outline_all.svg")
|
28 |
+
|
29 |
#read content of file
|
30 |
print(os.stat("outline_all.svg").st_size / (1024 * 1024))
|
31 |
os.system("inkscape outline_all.svg --actions='select-all;path-simplify;export-plain-svg' --export-filename pdb_opt.svg")
|
|
|
46 |
view_str = gr.Textbox("viewMatrixResult", label="View Matrix", visible=False)
|
47 |
chains = gr.Textbox("chainsResult", label="Chains", visible=False)
|
48 |
hidden_style = gr.Textbox(visible=False)
|
49 |
+
timestamp = gr.Textbox(visible=False)
|
50 |
+
|
51 |
+
btn = gr.Button("Vectorize")
|
52 |
html = gr.HTML("")
|
53 |
out_file = gr.File(label="Download SVG")
|
54 |
+
btn.click(None, style, [view_str, chains, hidden_style, timestamp], js="(style) => [document.getElementById('viewMatrixResult').value, document.getElementById('chains').value, style, Date.now()]") #
|
55 |
+
|
56 |
+
timestamp.change(predict, [inp, style, view_str, chains], [html, out_file])
|
57 |
# on change of chains trigger, rendering
|
|
|
|
|
|
|
58 |
|
59 |
|
60 |
if __name__ == "__main__":
|