Convert an atomistic trajectory to a coarse-grained trajectory using MDTraj and user-defined mapping files.
The package can be installed locally using pip
.
Here is how to install cg_mapping
in a new conda environment:
git clone https://github.com/uppittu11/cg_mapping.git
conda create -n cg_mapping_env -c conda-forge --file requirements.txt -y
conda activate cg_mapping_env
cd cg_mapping && pip install -e .
The CG mapping module can be scripted and run from a python interpreter. Here is an example:
import mdtraj as md
from cg_mapping.mapper import Mapper
# Load in the mdtraj.Trajectory from disk
atomistic_trajectory = md.load("traj.xtc", top="start.gro")
# Initialize mapper and load in default mappings
my_mapper = Mapper()
my_mapper.load_mapping_dir()
# Load atomistic trajectory into the mapper
my_mapper.load_trajectory(atomistic_trajectory)
# Map the atomistic trajectory to the CG level
cg_trajectory = my_mapper.cg_map()
# Save the CG trajectory out to disk
cg_trajectory[0].save("cg_traj.gro")
cg_trajectory.save("cg_traj.xtc")