Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show multi-model of NMR structures #765

Closed
platinhom opened this issue Jan 29, 2019 · 10 comments
Closed

Show multi-model of NMR structures #765

platinhom opened this issue Jan 29, 2019 · 10 comments
Labels

Comments

@platinhom
Copy link

platinhom commented Jan 29, 2019

I want to show a NMR structure (such as 1d3z.pdb) with many models. However, when I display the structure, it only show the first model.

First run view

If I use the display again , it can show normally.

2nd run view

The question is: how can I show all the models normally at the first time?

I have tried to use add_representation(selection='/0'), add_representation(selection='/1') ... to add many representations, but it also fail.

import nglview as nv
view=nv.show_pdbid('1d3z', color='modelindex')
view.update_cartoon(color='modelindex')

# It will only show one model
view

# It will show all models normally
view

Thanks in advance!

  • Version report

NGLview version 1.1.7

@hainm hainm added the question label Jan 29, 2019
@hainm
Copy link
Collaborator

hainm commented Feb 1, 2019

The question is: how can I show all the models normally at the first time?

hi @platinhom, nglview displays 1st model as default. Please use default_representation=False).
model

If I use the display again , it can show normally.

This seems like a bug in nglview.

@platinhom
Copy link
Author

platinhom commented Feb 1, 2019

@hainm Thanks to your reply! I have tried :

view1 = nv.show_pdbid('1l2y',default_representation=False)
view1

But nothing shown at all. Python version 3.6.5, ipywidgets==7.2.1, ipykernel==4.8.2, notebook==5.5.0

image

I also tried it in Py2.7.15. It still only show the first model:

image

@hainm
Copy link
Collaborator

hainm commented Feb 1, 2019 via email

@platinhom
Copy link
Author

platinhom commented Feb 1, 2019

@hainm It works well now. Thanks! I spell wrong on "representation" in my previous case 😂.
It work well on 1ly2 case. But in the case 1d3z it still fail. Maybe something wrong on that structure.

@hainm
Copy link
Collaborator

hainm commented Feb 4, 2019

Hi can you upload that file?

@platinhom
Copy link
Author

just try:

view = nv.show_pdbid('1d3z',default_representation=False)
view.add_cartoon(color='chainindex')
view

or download from PDB: 1d3z

Thanks~

@hainm
Copy link
Collaborator

hainm commented Feb 6, 2019

thanks. Seems like an issue with nglview (works fine with NGL: http://nglviewer.org/ngl/)

@hainm
Copy link
Collaborator

hainm commented Feb 6, 2019

@platinhom ah ah, I know why now. You need to use 'view.center` to center the molecule too. (default representation does that).

model1

@hainm hainm closed this as completed Feb 7, 2019
@hainm
Copy link
Collaborator

hainm commented Feb 8, 2019

Just FYI, once you can show multi model, you can select to display one of them.

model 1

view._remote_call('setSelection', target='compList', args=["/1"], 
               kwargs=dict(component_index=0))

all models

view._remote_call('setSelection', target='compList', args=["*"], 
               kwargs=dict(component_index=0))

@platinhom
Copy link
Author

@hainm Thanks. It's great idea to control the display by given selection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants