simonduerr commited on
Commit
59e713c
·
verified ·
1 Parent(s): cf30207

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -8,7 +8,7 @@ from gradio_moleculeview import moleculeview
8
 
9
  import cellscape
10
 
11
- def predict(input_mol, style, view_str, chains):
12
  # write view to file
13
  with open("view_matrix", "w") as f:
14
  f.write(json.loads(view_str))
@@ -22,7 +22,7 @@ def predict(input_mol, style, view_str, chains):
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 chain --color_by chain --depth_contour_interval 20 --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
 
@@ -37,10 +37,17 @@ def predict(input_mol, style, view_str, chains):
37
 
38
 
39
 
 
 
 
 
 
40
 
41
  with gr.Blocks() as demo:
42
  gr.Markdown("# PDB2Vector")
43
  style = gr.Radio(value="Flat", choices=["Flat", "Contour", "Goodsell3D"], label="Style")
 
 
44
  inp = moleculeview(label="Molecule3D")
45
 
46
  view_str = gr.Textbox("viewMatrixResult", label="View Matrix", visible=False)
@@ -53,7 +60,7 @@ with gr.Blocks() as demo:
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
 
 
8
 
9
  import cellscape
10
 
11
+ def predict(input_mol, style, contour_level, view_str, chains):
12
  # write view to file
13
  with open("view_matrix", "w") as f:
14
  f.write(json.loads(view_str))
 
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 chain --color_by chain --depth_contour_interval {contour_level} --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
 
 
37
 
38
 
39
 
40
+ def show_contour_level(style):
41
+ if style=="Contour":
42
+ return gr.Slider(0,10,1, label="Contour level", visible=True)
43
+ else:
44
+ return gr.Slider(0,10,1, label="Contour level", visible=False)
45
 
46
  with gr.Blocks() as demo:
47
  gr.Markdown("# PDB2Vector")
48
  style = gr.Radio(value="Flat", choices=["Flat", "Contour", "Goodsell3D"], label="Style")
49
+ contour_level = gr.Slider(0,10,1, label="Contour level", visible=False)
50
+ style.change(show_contour_level, style, contour_level)
51
  inp = moleculeview(label="Molecule3D")
52
 
53
  view_str = gr.Textbox("viewMatrixResult", label="View Matrix", visible=False)
 
60
  out_file = gr.File(label="Download SVG")
61
  btn.click(None, style, [view_str, chains, hidden_style, timestamp], js="(style) => [document.getElementById('viewMatrixResult').value, document.getElementById('chains').value, style, Date.now()]") #
62
 
63
+ timestamp.change(predict, [inp, style, contour_level, view_str, chains], [html, out_file])
64
  # on change of chains trigger, rendering
65
 
66