-
For any questions relating to how/why/ ... Or anything you don't know where to ask. Or click the |
Beta Was this translation helpful? Give feedback.
Replies: 30 comments 54 replies
-
Shape does not appear in even-numbered displaysWhen I add a shape to NGLWidget, it appears at first. However, it sometimes does not appear in code blocks (see the below screenshot). Is it expected behavior? Apologies in advance if this is an already-answered question in previous Q&As. ScreenshotCodeimport nglview
from ase import Atoms
print(nglview.__version__)
positions=[(0, 0, 0), (4, 0, 0)]
co = Atoms('H2', positions)
view = nglview.show_ase(co)
view.shape.add_cylinder(positions[0], positions[1], [1, 0, 0], 0.1)
print(view._ngl_component_names)
view # first
print(view._ngl_component_names)
view # second: cylinder disapears
print(view._ngl_component_names)
view # third: cylinder shows again |
Beta Was this translation helpful? Give feedback.
-
hi @lan496: I think it's a bug in |
Beta Was this translation helpful? Give feedback.
-
hi, I have been searching for how to depict bond orders in nglview and so far without success, what would I need to do to get the double bond to show up in this example?
|
Beta Was this translation helpful? Give feedback.
-
hi @hjuinj Please see one solution in here (but I am not sure if that helps): #948 (comment) |
Beta Was this translation helpful? Give feedback.
-
On Tue, Nov 23, 2021 at 3:55 AM hjuinj ***@***.***> wrote:
thanks, seems to work in my case, does this mean double triple bond
depiction is not officially support within nglview right now?
I am not sure about that for NGL. Maybe.
|
Beta Was this translation helpful? Give feedback.
-
Hi @hainm, thanks for the great work here! thank you! |
Beta Was this translation helpful? Give feedback.
-
Hello, first of all, awesome project! Now to my question: Is it possible to make a shape assume a different position in each frame? |
Beta Was this translation helpful? Give feedback.
-
Hi, I noticed that nglview doesn't store the widget state when executed through nbconvert. Is there a way to make this work? |
Beta Was this translation helpful? Give feedback.
-
Okay, I will need to find a different solution then.
…On Thu, Feb 17, 2022 at 4:12 PM Hai Nguyen ***@***.***> wrote:
No, that won't work as I explained above.
—
Reply to this email directly, view it on GitHub
<#1002 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AF67WIMBIQYP2RKBQERBXYLU3UF7PANCNFSM5GOTBSNQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
--
Dr. Martin Schlipf
Brünner Straße 10/62
1210 Wien
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hi ! I was experimenting with @garboit solution to have moving shapes. # Working
from ase.io.trajectory import Trajectory
from ase import Atoms
import nglview as nv
traj=[Atoms('C2',[[0,0,0],[1,0,0]]), Atoms('C2',[[0,0,0],[2,0,0]]), Atoms('C2',[[0,0,0],[3,0,0]])]
traj_=[Atoms('C2',[[0,0,1],[1,0,1]]), Atoms('C2',[[0,0,1],[2,0,1]]), Atoms('C2',[[0,0,1],[3,0,1]])]
traj_w=Trajectory('traj.traj','w')
for atom in traj_:
traj_w.write(atom)
traj2=Trajectory('traj.traj','r')
view = nv.show_asetraj(traj)
view.add_trajectory(traj2) # <-------------------
view._js('''
var shape = new NGL.Shape("my_shape")
var arrowBuffer = new NGL.ArrowBuffer({
position1: new Float32Array([1,0,0,0,0,0]),
position2: new Float32Array([1,2,0,0,2,0]),
color: new Float32Array([ 0, 1, 0, 0,1,0 ]),
radius: new Float32Array([ 0.2, 0.2 ]),
})
shape.addBuffer(arrowBuffer)
globalThis.arrowBuffer = arrowBuffer;
var shapeComp = this.stage.addComponentFromObject(shape)
shapeComp.addRepresentation("buffer")
shapeComp.autoView()
''')
view With the trajectory declared after the shapes: # Not working
from ase.io.trajectory import Trajectory
from ase import Atoms
import nglview as nv
traj=[Atoms('C2',[[0,0,0],[1,0,0]]), Atoms('C2',[[0,0,0],[2,0,0]]), Atoms('C2',[[0,0,0],[3,0,0]])]
traj_=[Atoms('C2',[[0,0,1],[1,0,1]]), Atoms('C2',[[0,0,1],[2,0,1]]), Atoms('C2',[[0,0,1],[3,0,1]])]
traj_w=Trajectory('traj.traj','w')
for atom in traj_:
traj_w.write(atom)
traj2=Trajectory('traj.traj','r')
view = nv.show_asetraj(traj)
view._js('''
var shape = new NGL.Shape("my_shape")
var arrowBuffer = new NGL.ArrowBuffer({
position1: new Float32Array([1,0,0,0,0,0]),
position2: new Float32Array([1,2,0,0,2,0]),
color: new Float32Array([ 0, 1, 0, 0,1,0 ]),
radius: new Float32Array([ 0.2, 0.2 ]),
})
shape.addBuffer(arrowBuffer)
globalThis.arrowBuffer = arrowBuffer;
var shapeComp = this.stage.addComponentFromObject(shape)
shapeComp.addRepresentation("buffer")
shapeComp.autoView()
''')
view.add_trajectory(traj2) # <-------------------
view |
Beta Was this translation helpful? Give feedback.
-
Hi, I'm having issues with the Also, I am wondering how to download/upload rendered images to the remote kernel side instead of downloading to browser side. Thank you. |
Beta Was this translation helpful? Give feedback.
-
Can you show exact command? Thanks.
…On Sat, May 7, 2022 at 2:27 AM Nabil Faruk ***@***.***> wrote:
Hi, I'm having issues with the MovieMaker with nglview 3.0.3 on python
3.7.11. I get just a black frame output for in_memory=True for both .gif
and .mp4 output. However, if download the rendered images with
view.download_image and create the clip from those using moviepy (as
shown here
<https://ambermd.org/tutorials/analysis/tutorial_notebooks/nglview_movie/index.html>,
it works.
Also, I am wondering how to download/upload rendered images to the remote
kernel side instead of downloading to browser side. Thank you.
—
Reply to this email directly, view it on GitHub
<#1002 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABB645JTJKQSVQ2JENZMBJTVIYELJANCNFSM5GOTBSNQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Thank you @hainm for this great widget. I wrote a blog post describing how to show neighbours (neighbors) using the snippet from the NGL js manual in nglview. I am using the private method Thanks |
Beta Was this translation helpful? Give feedback.
-
Hello, Beyond the !pip install nglview
from google.colab import output
output.enable_custom_widget_manager()
from IPython.display import display
import ipywidgets as widgets
import requests
import nglview as nv
view = nv.NGLWidget()
caffeine_block = requests.get('https://www.ebi.ac.uk/chembl/api/data/molecule/CHEMBL113.sdf').text
comp = view.add_component(caffeine_block, ext='sdf')
# adding `time.sleep(1)` here is useless
comp.clear_representations()
comp.add_ball_and_stick(colorValue='brown')
view
comp.update_ball_and_stick(colorValue='#e97451') # burnt sienna to be fancy
output_binary.js?vrz=colab-20220608-060045-RC00_453648962:105 Uncaught (in promise) ie {message: 'Widget nglview-js-widgets NGLModel is not supported', stack: 'CustomError: Widget nglview-js-widgets NGLModel is…vrz=colab-20220608-060045-RC00_453648962:101:954)'} But the widget is made fine. Then on component addition this happens: manager.min.js:1655 Could not create a view for model id 5940e60ca8384104b287106ee46294f9
manager.min.js:1655 Error: Could not create child view
at manager.min.js:1655:5152
at async Promise.all (35yv38sdpnv-496ff2e9c6d22116-0-colab.googleusercontent.com/index 1) And line 212 of the widget does not log to console the words So is this just a product of a missing step or bad import order —like |
Beta Was this translation helpful? Give feedback.
-
Hello, I have the following simple task: save a rendered NGLView frame into a .png file and then read the file. Following this manual I can successfully save an image and open it manually from file explorer. However, in my flow I need to open in using Python and use in downstream jobs right after it was saved. I have the following snippet in my Jupyter Notebook:
The problem is that executing cell#2 I get Adding How can I make an image to be rendered and saved before reading the file? python-3.8.10; nglview-3.0.3; OS - Win, MacOS |
Beta Was this translation helpful? Give feedback.
-
Hi, I wonder how could I select multiple discontinue residues by index when using For example, this will work just fine:
Also this:
But not this:
Do you have any idea about this? Thanks |
Beta Was this translation helpful? Give feedback.
-
@hainm Hi! I would love to visualize two mdtraj trajectories in the same widget, is that possible ? Is it possible ? and if so, how ? |
Beta Was this translation helpful? Give feedback.
-
Hi,
Please try `view.add_trajectory(traj)`
… Message ID: <nglviewer/nglview/repo-discussions/1002/comments/4729393@
github.com>
|
Beta Was this translation helpful? Give feedback.
-
Hi @hainm! is there a way to directly add volumetric data as a surface? |
Beta Was this translation helpful? Give feedback.
-
Hi hainm! I am plotting cyrstal structures using nglview. In the ball and stick representation it does not alway plot the bonds I want. Some plotted bonds are too long and other short ones are not displayed. What is the bond plotting algorithm? Is there a way we could supply a minimum and maximum bond length to the bond length algorithm? Perhaps even better for crystal structures, bonds are always between anions and cations. Could the algorithm use this information as well? I know that pymatgen has NearNeighbors local environment strategies, such as the class CrystalNN where cation_anion can be supplied as boolean to indicate that bonds form between cations and anions. I am afraid it is not really possible, but something like this would of course be very helpful! |
Beta Was this translation helpful? Give feedback.
-
Hi, I am using NGLview to visualize antibody structure predictions. I would like to highlight the location of specific parts of the antibody sequence (CDRs) by having them in different colors to the rest of the molecule (for example the structure is in red, but I want residues 100-114 to be in blue. Is it possible to do this? Could you provide some code example? |
Beta Was this translation helpful? Give feedback.
-
Dear Hai, So, I thought things might work better if I were to make a single representation with different atoms radii and colors. I see you have a nice example in Binder ("custom_color.ipynb") to use a function to define the color of each atom. That should already solve half the problem. Can one do something similar for the atom radii? Thanks for your help, Albert |
Beta Was this translation helpful? Give feedback.
-
Hi, is there any way to show several nglview.widget.NGLWidget side by side in jupyter? |
Beta Was this translation helpful? Give feedback.
-
I'm using It seems like the position arguments are related to the camera orientation and not the Cartesian coordinates. Is that right? Is there an example setting positions using Cartesian coordinates? |
Beta Was this translation helpful? Give feedback.
-
Hello, I'm having a problem with getting an actual image to display instead of just a generic thumbnail. |
Beta Was this translation helpful? Give feedback.
-
Hello, I wonder if it is possible to draw a bounding box. It is useful for checking whether the docking site is correctly selected. Thank you very much. |
Beta Was this translation helpful? Give feedback.
-
I'm having some issues with empty view objects like #726. I'm running view = nv.show_mdanalysis(u) in a Jupyter notebook and attempting to use the provided examples to save a rendered image using threading. However, the threads seem to run infinitely, since the view object is always "empty": This behavior is ALWAYS fixed by running the view code block again manually, or by interrupting the execution of the notebook. Upon further triaging It seems like the only time this behavior occurs is when running the entire notebook - running sections (for example, running up to the selected cell) works fine. Does this indicate that this might be a jupyter notebook/widget problem? I'm running jupyterlab==4.2.3, MDAnalysis==2.7.0, nglview==3.1.2, notebook==7.2.1. |
Beta Was this translation helpful? Give feedback.
-
I'm also wondering if there's any way to utilize this in a regular .py script. For example, by rendering the image and then saving directly; but it seems like the render relies in the view loading in properly... |
Beta Was this translation helpful? Give feedback.
-
Hi, can anyone help me how can I rotate the structure below so that it faces a specific crystal pole? I want to see the plane.
|
Beta Was this translation helpful? Give feedback.
hi @lan496: I think it's a bug in
nglview
. I've opened a new issue to keep track #1003. Thank you for reporting.