nglviewer / nglview

Jupyter widget to interactively view molecular structures and trajectories
http://nglviewer.org/nglview/latest/
Other
810 stars 132 forks source link

Remove reference backbone from movie #1031

Closed johnnytam100 closed 2 years ago

johnnytam100 commented 2 years ago

I'm sorry for raising a question again.

As I make a movie from a trajectory, the movie also includes the reference backbone (the topology?).

Is there any way to remove the reference backbone?

ezgif com-gif-maker

My script is like this:

from google.colab import output
output.enable_custom_widget_manager()
import pytraj as pt
import nglview as nv
import mdtraj as md
from nglview.contrib.movie import MovieMaker
import MDAnalysis as mda

traj_filename = './example_traj/protein_fit.xtc'
pdb_filename = './example_traj/protein_fit.tpr'

u = mda.Universe(pdb_filename, traj_filename)
u.transfer_to_memory(step=10)
view = nv.show_mdanalysis(u)

view

then

movie = MovieMaker(view, fps=10, in_memory=True, output='peptide_raw.gif')
movie.make()
hainm commented 2 years ago

Try to avoid colab for now, using traditional notebook or lab. I filed the case several months ago: https://github.com/googlecolab/colabtools/issues/2853#issuecomment-1171699299

hainm commented 2 years ago

Close this issue since there is nothing we can do now.

kimjc95 commented 1 month ago

I made a quick workaround. You can turn off the default representation and then add the representation for your molecules.

u = mda.Universe(pdb_filename, traj_filename) u.transfer_to_memory(step=10) view = nv.show_mdanalysis(u, defaultRepresentation=False) view.add_cartoon("protein") view

hainm commented 1 month ago

I made a quick workaround. You can turn off the default representation and then add the representation for your molecules.

u = mda.Universe(pdb_filename, traj_filename) u.transfer_to_memory(step=10) view = nv.show_mdanalysis(u, defaultRepresentation=False) view.add_cartoon("protein") view

@kimjc95 You might also want to add view.center() too because the default representation is not used.

kimjc95 commented 1 month ago

@hainm You are right! I missed that part. By the way, how do I recreate the default representation of nucleic acids? I tried add_cartoon("nucleic"), and it did show the phosphate backbone as ribbons, but did not show the bases as sticks.

hainm commented 1 month ago

@hainm You are right! I missed that part. By the way, how do I recreate the default representation of nucleic acids? I tried add_cartoon("nucleic"), and it did show the phosphate backbone as ribbons, but did not show the bases as sticks.

@kimjc95 I admit I don't know the answer, but here is the code in NGL (which nglview is using under the hood) for default one: https://github.com/nglviewer/ngl/blob/417581fa92971fe98560b2d0e1ac9d00046b7ba6/src/stage/stage.ts#L291-L418

kimjc95 commented 1 month ago

@hainm Thanks for the link. It came out to be add_simplified_base("nucleic") .