Page 1 of 1

Saving Topology after OpenMM simulation

Posted: Tue Jan 02, 2024 9:51 am
by pixelline
Hi everyone,

I love OpenMM but I am struggeling with one issue. I hope to get some input here:

I am using MDAnalysis to analyze my trajectories. I have noticed that if I prepare everything with amber and run OpenMM from the prmtop and crd file, I am able to center my protein in the center of the water box using MDAnalysis. However if I start from a pdb file and do the following steps in OpenMM, the MDAnalysis protein centering fails in the sense of that MDAnalysis is not able to perform the alignment correctly.


1. Create a amber14-all forcefield
2. Define a integrator (LangevinMiddleIntegrator
3. Import pdb and create model
4. Apply forcefield to model
5. Add Hydrogens and addSolvent
6. Create OpenMM System
7. Define Simulation, minimize, equilibrate, simulate. Save trajectory
8. Save a "topology" as mmcif and the trajectory as dcd
9. Import the mmcif and dcd in MDAnalysis
10. Perform protein centering.

Before I paste the code. Has anyone already a suggestion what might be the issue? Or how to address the problem.

What I want?
- Use OpenMM from a pdb file
- Add solvent in OpenMM
- Get an adequate topology and trajectory file to use in MDAnalysis

Re: Saving Topology after OpenMM simulation

Posted: Tue Jan 02, 2024 10:55 am
by peastman
What do you mean when you say it is "not able to perform the alignment correctly"? What happens when you try?

I haven't used MDAnalysis and I don't know how its centering code works. I've always used MDTraj. It has an image_molecules() function that works nicely for centering a protein in the middle of a water box.

Re: Saving Topology after OpenMM simulation

Posted: Wed Jan 10, 2024 8:31 am
by pixelline
Hi Peter,

Thank you so much for your fast reply. Changing from MDAnalysis to MDTraj for centering the Trajectory was the best idea and solved my issue.

I should have done it earlier.

Re: Saving Topology after OpenMM simulation

Posted: Mon Apr 08, 2024 1:34 pm
by pgsideris
This is my example of how I am saving using MDAnalysis (where "mda.")

Of course I am using different formats but still

Code: Select all

def write_trajectory_vid():
    print('Writing trajectory to video')
    u = mda.Universe(formatted_folder_name + '/exit_state.pdb', formatted_folder_name + '/trajectory.dcd')
    with mda.Writer(formatted_folder_name + '/video.pdb', multiframe=True, bonds=None, n_atoms=u.atoms.n_atoms) as W:
        for ts in u.trajectory:
            W.write(u.atoms)