File failed to load: http://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/extensions/TeX/AmsMath.js

Thursday, August 9, 2012

One Way To Center a Molecule from a Gromacs calculation

When you run an MD the molecule or ligand of interest might drift a little inside your box. Sometimes (oftentimes?) you want to center that ligand and force it to be there always. Searching the internet gave me inspiration but no solution. So thinking of a solution (and reading the manual a little more carefully) I ended up figuring out that one needs to run the trjconv tool multiple times to achieve proper results. It is only specified indirectly in some of the manuals and help-documents I've been able to find.

Here is a script that will ask you what you want to center (be sure that it has a proper index in the topology file).

#!/usr/bin/env bash
TRAJIN=traj.xtc
TRAJOUT=trajfin.xtc
# delete the trajectory so gromacs wont display silly backup messages
if [ -e $TRAJOUT ]
then
rm -f $TRAJOUT
fi
# center molecule (you will be asked!)
trjconv -pbc mol -center -ur compact -s md.tpr -f $TRAJIN -o tmp.xtc
# make everything rotate and translate around that molecule (you will be asked!)
trjconv -fit rot+trans -s md.tpr -f tmp.xtc -o $TRAJOUT
rm -f tmp.xtc
view raw center.sh hosted with ❤ by GitHub

Happy centering.

No comments: