biasmv / pv

WebGL protein viewer
https://pv.readthedocs.org
MIT License
315 stars 85 forks source link

RFC: Jupyter/IPython Notebook Features #125

Open biasmv opened 8 years ago

biasmv commented 8 years ago

Hi All,

I've pushed an initial version of an alternative Jupiter/IPython notebook module for PV to master. It's a little more powerful than the previous version and allows to load structures from local files. In theory everything that can be converted to a PDB string can be loaded in the viewer. Later one, one could think of using a richer serialisation format.

The module only supports the basics: creating the viewer, adding molecules to it. For example:

from pvviewer.viewer import *
from pvviewer.mol import Mol
structure = Mol.from_pdb_id('2por')
viewer = Viewer()
viewer.cartoon('porin', structure)
viewer.auto_zoom()
viewer

This will load the PDB 2por from PDB.org and display it in the viewer using the cartoon render mode.

@aebrahim, @hainm: Since you seem to be using Jupyter/IPython Notebooks, I thought I might ping you regarding the recent changes.

What would the most important features to you?

biasmv commented 8 years ago

Here is the new API, the above sample probably doesn't work anymore :).

import pvviewer as pv

structure = pv.mol.from_pdb_id('2por')
viewer = pv.Viewer()
viewer.cartoon('porin', structure, color=pv.color.ss_succession())
viewer.auto_zoom()
viewer.show()
hainm commented 8 years ago

@biasmv great, thanks for the ping.

What would the most important features to you?

how's about rendering a trajectory from simulation? like chemview package here

We have an engine, pytraj/cpptraj, can parse different types of format from different simulation packages, it would be really great if there is an way to plug our to your.

biasmv commented 8 years ago

That sounds like a plan. I'll look into it to see what is required to making that happen.

satary commented 8 years ago

Hello @biasmv! Thank you for your work, looks amazing! Are there any prerequisites for installation? I've used setup.py to install pv, there were no errors, it imports and executes fine (no errors in Jupyter server). The problem is - it creates an empty canvas and that's it. Am I doing something conceptually wrong? image

hainm commented 8 years ago

may be you can right click then choose "Inspect", then choose Console to see error message from Javascript?

ajfarkas commented 8 years ago

I suspect that you're getting an error for calling viewer.show() without an argument. If you're trying to show the whole model, you shouldn't need to call show.

On Thu, Jun 16, 2016 at 8:03 AM, Hai Nguyen notifications@github.com wrote:

may be you can right click then choose "Inspect", then choose Console to see error message from Javascript?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/biasmv/pv/issues/125#issuecomment-226513086, or mute the thread https://github.com/notifications/unsubscribe/AHenfRIzWLSVNeArJFYqe9heHF83NsdVks5qMWXegaJpZM4GZd8I .

biasmv commented 8 years ago

@satary: It's hard to say what's going on. As @hainm pointed out, you might see what's wrong by taking a look at the JavaScript console of your browser.

@ajfarkas: The viewer.show() above is part of the Python API. It's doesn't work the same way as the JS show you are thinking of. The show call above essentially spits out a bunch of html and JS code that then gets inserted into the DOM :).

satary commented 8 years ago

Thanks @hainm! It sure is a Javascript issue.

Refused to execute script from 'http://raw.githubusercontent.com/biasmv/pv/master/bio-pv.min.js?v=20160616195731' because its MIME type ('text/plain') is not executable, and strict MIME type checking is enabled. Uncaught Error: Script error for "pv" http://requirejs.org/docs/errors.html#scripterror

I don't know if it is google chrome issue or something else

UPD. @biasmv thanks for your response! I found that changing 13 paths: { 14 pv: '//raw.githubusercontent.com/biasmv/pv/master/bio-pv.min' 15 } to 13 paths: { 14 pv: '//rawgit.com/biasmv/pv/master/bio-pv.min' 15 } in viewer.py does the trick. I have no clue why =) image

biasmv commented 8 years ago

@satary: I've update the python module to use rawgit. Can you try if the latest version is working for you?

Best, Marco

hainm commented 8 years ago

@biasmv may be let pv to use local js file?

biasmv commented 8 years ago

@hainm: yes, that's certainly the better solution. I'll look into it. Won't happen before the weekend, though.