RajarshiMondal commited on
Commit
83361d4
1 Parent(s): d89cdc6

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +24 -11
main.py CHANGED
@@ -15,6 +15,7 @@ from transformMD import GNNTransformMD
15
  import sys
16
  import pytraj as pt
17
  import pickle
 
18
 
19
  # JavaScript functions
20
  resid_hover = """function(atom,viewer) {{
@@ -187,11 +188,18 @@ def predict(pdb_code, pdb_file, topN):
187
  topN_ind = np.argsort(adaptability)[::-1][:topN]
188
 
189
  pdb = open(pdb_file.name, "r").read()
 
 
 
 
 
190
 
191
- view = py3Dmol.view(width=600, height=400)
192
- view.setBackgroundColor('white')
193
- view.addModel(pdb, "pdb")
194
- view.setStyle({'stick': {'colorscheme': {'prop': 'resi', 'C': 'turquoise'}}})
 
 
195
  # Commenting since the visualizer is not rendered
196
  # view.addLight([0, 0, 10], [1, 1, 1], 1) # Add directional light from the z-axis
197
  # view.setSpecular(0.5) # Adjust the specular lighting effect
@@ -210,17 +218,22 @@ def predict(pdb_code, pdb_file, topN):
210
  'color': color,
211
  'alpha': 0.75
212
  })
 
 
213
 
214
- view.zoomTo()
215
 
216
- output = view._make_html().replace("'", '"')
217
 
218
  x = f"""<!DOCTYPE html><html> {output} </html>""" # do not use ' in this input
219
- return f"""<iframe style="width: 100%; height:420px" name="result" allow="midi; geolocation; microphone; camera;
220
- display-capture; encrypted-media;" sandbox="allow-modals allow-forms
221
- allow-scripts allow-same-origin allow-popups
222
- allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
223
- allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>""", pd.DataFrame(data, columns=['index','element','x','y','z','Adaptability'])
 
 
 
224
 
225
 
226
  callback = gr.CSVLogger()
 
15
  import sys
16
  import pytraj as pt
17
  import pickle
18
+ import nglview as nv
19
 
20
  # JavaScript functions
21
  resid_hover = """function(atom,viewer) {{
 
188
  topN_ind = np.argsort(adaptability)[::-1][:topN]
189
 
190
  pdb = open(pdb_file.name, "r").read()
191
+
192
+ view = nv.NGLWidget()
193
+ view._remote_call("setSize", target="Widget", args=["800px", "600px"])
194
+ view.add_pdbstr(pdb, defaultRepresentation=True)
195
+ view.add_representation("hyperball", selection="all", color_scheme="residueindex")
196
 
197
+
198
+ # view = py3Dmol.view(width=600, height=400)
199
+ # view.setBackgroundColor('white')
200
+ # view.addModel(pdb, "pdb")
201
+ # view.setStyle({'stick': {'colorscheme': {'prop': 'resi', 'C': 'turquoise'}}})
202
+
203
  # Commenting since the visualizer is not rendered
204
  # view.addLight([0, 0, 10], [1, 1, 1], 1) # Add directional light from the z-axis
205
  # view.setSpecular(0.5) # Adjust the specular lighting effect
 
218
  'color': color,
219
  'alpha': 0.75
220
  })
221
+
222
+ output = view.render_notebook()
223
 
224
+ #view.zoomTo()
225
 
226
+ #output = view._make_html().replace("'", '"')
227
 
228
  x = f"""<!DOCTYPE html><html> {output} </html>""" # do not use ' in this input
229
+
230
+ return output, pd.DataFrame(data, columns=['index','element','x','y','z','Adaptability'])
231
+
232
+ #return f"""<iframe style="width: 100%; height:420px" name="result" allow="midi; geolocation; microphone; camera;
233
+ #display-capture; encrypted-media;" sandbox="allow-modals allow-forms
234
+ #allow-scripts allow-same-origin allow-popups
235
+ #allow-top-navigation-by-user-activation allow-downloads" allowfullscreen=""
236
+ #allowpaymentrequest="" frameborder="0" srcdoc='{x}'></iframe>""", pd.DataFrame(data, columns=['index','element','x','y','z','Adaptability'])
237
 
238
 
239
  callback = gr.CSVLogger()