A Python library for parsing and editing GROMACS topology files.
Project description
gmxtopology
Description
gmxtopology is a Python package for parsing and editing GROMACS topology
files.
Package layout
The main flow is organized around a few top-level modules:
gmxtopology.topology: topology data modelsgmxtopology.io: topology file reading and writinggmxtopology.parser: section parsing and dispatchgmxtopology.lookup: parameter lookup and virtual-site reduction helpersgmxtopology.schema: schema objects used by the parsergmxtopology.interaction_specs: GROMACS interaction tables
Installation
pip install gmxtopology
For Jupyter/IPython kernel support, install the optional notebook extra:
pip install "gmxtopology[notebook]"
From source:
pip install git+https://github.com/vojtechkostal/gmxtopology.git
Usage
See examples/example.ipynb for a fuller walkthrough. The packaged walkthrough uses the single self-contained examples/example.top file.
from gmxtopology import Topology
# load topology from file
fn_top = "./examples/example.top"
top = Topology(fn_top)
# modifying topology parameters
for atom in top.molecules['MOL'][0].atoms:
atom.update(charge=0.0)
for atomtype in top.atomtypes:
atomtype.update(sigma=0.31)
# remove virtual sites from a molecule
top.molecules['SOL'][0].remove_vsites()
# write topology into a file
top.write("./examples/topol-processed.top", overwrite=True)
Topology preprocessing
The reader follows local #include directives relative to the including file
and preserves conditional topology sections when writing a modified topology.
Supported directives include:
#define NAMEand#define NAME replacement text#ifdef NAMEand#ifndef NAME#elseand#endif, including nested blocks#include "relative/path.itp"
Missing includes remain errors unless they occur inside a conditional block.
This allows topologies with absent optional restraint files to load when those
files are referenced only behind flags such as #ifdef REST_ON.
For free-energy topologies, [ atoms ] records and supported bonded
interactions may also include the optional topology-B parameters documented by
GROMACS. They are exposed with _b suffixes, such as charge_b, b0_b, and
kb_b.
Sections that gmxtopology does not edit are carried through as opaque records
when writing a flattened topology. This preserves force-field-specific data
such as CHARMM [ cmaptypes ], [ implicit_genborn_params ], and molecular
[ cmap ] sections.
Written topologies contain only the [ atomtypes ] used by molecules in the
[ molecules ] section or referenced by preserved opaque global sections.
Bonded parameter tables such as [ bondtypes ], [ angletypes ], and
[ dihedraltypes ] are resolved onto molecular interactions and omitted from
the output. Relevant [ nonbond_params ] entries remain global because they
cannot be expanded onto bonded records.
Testing
Run the parser regression suite with:
python -m pytest
The repository test suite includes pinned
official GROMACS fixtures covering
SPC/E, TIP3P, TIP4P, and urea topologies, plus
prosECCo75 CHARMM36-derived fixtures
covering POPC and CMAP tables. A curated
ParmEd GmxTests snapshot adds
real-world water, peptide, solvated protein, mixed-solvent, and DPPC cases.
PyPI distributions intentionally contain only the package code, documentation, the example notebook, and its small self-contained topology. Clone the repository explicitly when you need the larger examples and regression fixtures:
git clone --depth 1 https://github.com/vojtechkostal/gmxtopology.git
Changelog
See CHANGELOG.md for release highlights.
Publishing
GitHub Trusted Publishing is set up via
publish.yml. The one-time PyPI and TestPyPI
configuration steps are documented in docs/publishing.md.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gmxtopology-0.2.0.tar.gz.
File metadata
- Download URL: gmxtopology-0.2.0.tar.gz
- Upload date:
- Size: 34.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d0f44520a36a84958e2b4c5db884cc20532b6c917b8ecc3ae6c791455543586
|
|
| MD5 |
70fdc6c7b26f924bd535167b8a4c2aff
|
|
| BLAKE2b-256 |
9bc6a3f3bcd51fdf8c5954296769c89807ff41b50b82615fa39c2d1609c3b32e
|
Provenance
The following attestation bundles were made for gmxtopology-0.2.0.tar.gz:
Publisher:
publish.yml on vojtechkostal/gmxtopology
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gmxtopology-0.2.0.tar.gz -
Subject digest:
8d0f44520a36a84958e2b4c5db884cc20532b6c917b8ecc3ae6c791455543586 - Sigstore transparency entry: 1696250368
- Sigstore integration time:
-
Permalink:
vojtechkostal/gmxtopology@fef90bb906819ca79311f2d2b627d4db9dfe35d6 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/vojtechkostal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fef90bb906819ca79311f2d2b627d4db9dfe35d6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file gmxtopology-0.2.0-py3-none-any.whl.
File metadata
- Download URL: gmxtopology-0.2.0-py3-none-any.whl
- Upload date:
- Size: 31.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53c0bb42d8886570954d8c54048978535c9a34d9f240de14e7617e41926a6be0
|
|
| MD5 |
f3894d17a39d29af04c02713d9903ad8
|
|
| BLAKE2b-256 |
49bdff743eabbe582d9f59a8e52e235959887cc6a3b8a376de233cb1d0b8109e
|
Provenance
The following attestation bundles were made for gmxtopology-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on vojtechkostal/gmxtopology
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
gmxtopology-0.2.0-py3-none-any.whl -
Subject digest:
53c0bb42d8886570954d8c54048978535c9a34d9f240de14e7617e41926a6be0 - Sigstore transparency entry: 1696250515
- Sigstore integration time:
-
Permalink:
vojtechkostal/gmxtopology@fef90bb906819ca79311f2d2b627d4db9dfe35d6 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/vojtechkostal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@fef90bb906819ca79311f2d2b627d4db9dfe35d6 -
Trigger Event:
release
-
Statement type: