-
Notifications
You must be signed in to change notification settings - Fork 135
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
Saving a trajectory as a gif file #1158
Comments
can you please paste exact code you used in here? thanks. |
Hello, Of course, Here is the code I used in VSCode: ######################################## from nglview.contrib.movie import MovieMaker loc_DCD = os.path.expanduser("~/Documents/Prof_Venditti/ssDNA_0_ALKB7_50/filtered_traj.dcd") filtered_u = mda.Universe(PSF,loc_DCD) Use ParmEd to load the PDB and PSF files and select protein residuespmd = load_parmed(fname=f"{main_file}/{sim_folder}/{PSF_file_name}") # Performed to obtain the protein residues in from the PDB file protein_res = [] # Initialize list to store the no. of protein residues for index,atom in enumerate(pmd.atoms): # Set iterative loop to collect atoms from the pmd object Apply selection to universe objectselection_string = "resid " + " ".join(map(str, protein_res)) # Set selection string protein_residues = universe.select_atoms(selection_string) # Select protein residues from the Universe object Createblock_size = 221 # Obtain protein residue view1 = nv.show_mdanalysis(filtered_u) Add unit cellview1.add_unitcell() # Add unit cell on simulation Add representation of ssDNA to view objectview1.add_representation('ball+stick', selection = '._NC', color='red', radius=0.7) # Set representation of ssDNA for i in range(num_blocks):
Step 3: Display the NGLView widgetview1._remote_call('setSize', target='Widget', args=['640px', '640px']) Creating a gif from the trajectorymovie = MovieMaker(view1, output='my.gif', in_memory=True) |
Hello,
So, I have a trajectory of a MD simulation, that I have visualized using the nglview.show_MDAnalysis method after providing the relevant PSF and DCD files. I have also coloured the trajectory to my liking before visualization and now wish to save this coloured trajectory as a .gif file. I did try using the MovieMaker class as was suggested in the GitHub page, but that did not create anything although the code rand without any errors. Is there any easier way to save a trajectory as a .gif using nglview? I can provide my code if required.
Oh, I should also point out that I'm using nglview on VSCode.
The text was updated successfully, but these errors were encountered: