Saving Topology after OpenMM simulation

The functionality of OpenMM will (eventually) include everything that one would need to run modern molecular simulation.
POST REPLY
User avatar
Peter Rüthemann
Posts: 2
Joined: Tue Jan 02, 2024 9:39 am

Saving Topology after OpenMM simulation

Post by Peter Rüthemann » Tue Jan 02, 2024 9:51 am

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

User avatar
Peter Eastman
Posts: 2602
Joined: Thu Aug 09, 2007 1:25 pm

Re: Saving Topology after OpenMM simulation

Post by Peter Eastman » Tue Jan 02, 2024 10:55 am

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.

User avatar
Peter Rüthemann
Posts: 2
Joined: Tue Jan 02, 2024 9:39 am

Re: Saving Topology after OpenMM simulation

Post by Peter Rüthemann » Wed Jan 10, 2024 8:31 am

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.

User avatar
P S
Posts: 3
Joined: Mon Apr 08, 2024 1:09 pm

Re: Saving Topology after OpenMM simulation

Post by P S » Mon Apr 08, 2024 1:34 pm

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)

POST REPLY