Skip to main content

Generate coarse-grained molecular dynamics models from atomistic trajectories.

Project description


License Python package Documentation DOI PyPi Version conda-forge Version

Generate coarse-grained molecular dynamics models from atomistic trajectories.

PyCGTOOL is a tool to aid in parametrising coarse-grained (CG) molecular mechanics models of small molecules, for example for simulations using the popular MARTINI model. It generates coarse-grained model parameters from atomistic simulation trajectories using a user-provided mapping. Equilibrium values and force constants of bonded terms are calculated by Boltzmann Inversion of bond distributions collected from the input trajectory.

Alternatively map-only mode (behaving similarly to MARTINIZE) may be used to generate initial coordinates to use with existing CG topologies such as the MARTINI lipid models. For instance, a pre-equilibrated atomistic membrane may be used to create starting coordinates for a CG membrane simulation.

PyCGTOOL makes it quick and easy to test multiple variations in mapping and bond topology by making simple changes to the config files.

If you find PyCGTOOL useful, please cite our JCIM paper ( and the code itself (

   author = {James A. Graham and Jonathan W. Essex and Syma Khalid},
   doi = {10.1021/acs.jcim.7b00096},
   issn = {1549-9596},
   issue = {4},
   journal = {Journal of Chemical Information and Modeling},
   month = {4},
   pages = {650-656},
   title = {PyCGTOOL: Automated Generation of Coarse-Grained Molecular Dynamics Models from Atomistic Trajectories},
   volume = {57},
   url = {},
   year = {2017},


PyCGTOOL requires Python 3.6 or higher and may be installed using either pip or conda:

pip install pycgtool
conda install -c conda-forge pycgtool

Alternatively, you may download a pre-packaged version for your operating system from the releases page on GitHub. These pre-packaged versions include all dependencies and should be suitable in cases where you cannot install packages using one of the above methods. Warning: This installation method is not extensively tested - installing via pip or conda should be prefered in most cases.

MDTraj on macOS

On some versions macOS, with some versions of the Clang compiler, MDTraj may fail to load GROMACS XTC simulation trajectories. If you encounter this issue, please make sure you have the latest version of MDTraj installed.

For more information see MDTraj/#1572.


Input to PyCGTOOL is an atomistic simulation trajectory in the form of a topology (e.g. PDB, GRO, etc.) and a trajectory file (e.g. XTC, DCD, etc.), along with two custom files which describe the CG model to be generated: mapping (.map) and bonding (.bnd). These files provide the atomistic-to-CG mapping and bonded topology respectively and use a format similar to GROMACS .itp files. Topology and trajectory files are processed using MDTraj so most common formats are accepted.

Example mapping and bond files are present in the test/data directory. The format of these files is described fully in the documentation page on file formats.

For more information, see the tutorial. It is important to perform validation of any new parameter set - a brief example is present at the end of the tutorial.

For a full list of options, see the documentation or use:

pycgtool -h

Generate a Model

To generate a CG model from an atomistic simulation:

pycgtool <topology file> <trajectory file> -m <MAP file> -b <BND file>

Map Only

To use PyCGTOOL to convert a set of atomistic simulation coordinates to CG coordinates:

pycgtool <topology file> -m <MAP file>

Or to convert a complete simulation trajectory:

pycgtool <topology file> <trajectory file> -m <MAP file>


James Graham (@jag1g13)


If you experience problems using PyCGTOOL or wish to see a new feature added please open an issue.

To help develop PyCGTOOL, you can create a fork of this repository, clone your fork and install PyCGTOOL in development mode using Poetry:

poetry install

This will result in an editable mode install (similar to pip install -e .) along with all the necessary runtime and development dependencies. Testing and linting is handled by Tox - use tox to run the full test suite and linter as they are configured in the Continuous Integration pipeline.

When you're ready for your work to be merged, please submit a Pull Request.


GPL-3.0 © James Graham, University of Southampton

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycgtool-2.0.0.tar.gz (57.1 kB view hashes)

Uploaded Source

Built Distribution

pycgtool-2.0.0-py3-none-any.whl (57.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page