Skip to content

Commit d8b6cd7

Browse files
authored
Merge pull request #52 from jag1g13/dev
Pre PyCGTOOL v2.0.0 merge
2 parents 4960788 + fdce365 commit d8b6cd7

File tree

154 files changed

+132820
-5037
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

154 files changed

+132820
-5037
lines changed

.coveragerc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# .coveragerc to control coverage.py
2+
[run]
3+
branch = True
4+
source = pycgtool
5+
6+
[report]
7+
# Regexes for lines to exclude from consideration
8+
exclude_lines =
9+
# Have to re-enable the standard pragma
10+
pragma: no cover
11+
12+
# Don't complain about missing debug-only code:
13+
def __repr__
14+
15+
# Don't complain if tests don't hit defensive assertion code:
16+
raise AssertionError
17+
raise NotImplementedError
18+
19+
ignore_errors = True
20+
show_missing = True
21+
sort = miss

.github/workflows/publish.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish
2+
3+
on:
4+
release:
5+
types:
6+
- created
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Set up Python
16+
uses: actions/setup-python@v1
17+
with:
18+
python-version: "3.8"
19+
20+
- name: Install Poetry
21+
uses: snok/install-poetry@v1.1.4
22+
23+
- name: Publish
24+
env:
25+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
26+
run: |
27+
poetry config pypi-token.pypi $PYPI_TOKEN
28+
poetry publish --build
29+
30+
build-release-artifacts:
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
os: [ubuntu-latest, macos-latest]
35+
36+
runs-on: ${{ matrix.os }}
37+
38+
steps:
39+
- uses: actions/checkout@v2
40+
41+
- name: Set up Python
42+
uses: actions/setup-python@v1
43+
with:
44+
python-version: "3.8"
45+
46+
- name: Install prerequisites
47+
run: |
48+
python -m pip install --upgrade pip
49+
pip install pyinstaller
50+
pip install .
51+
52+
- name: Build distributable
53+
run: |
54+
pyinstaller pycgtool/__main__.py --name pycgtool-${{ matrix.os }} --onefile --collect-data mdtraj --hidden-import xdrlib
55+
56+
- uses: ncipollo/release-action@v1
57+
with:
58+
allowUpdates: true
59+
artifacts: dist/pycgtool-${{ matrix.os }}
60+
omitBodyDuringUpdate: true
61+
token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/python-package.yml

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ name: Python package
55

66
on:
77
push:
8-
branches: [ master ]
8+
branches: [ master, dev ]
99
pull_request:
10-
branches: [ master ]
10+
branches: [ master, dev ]
1111

1212
jobs:
1313
build:
1414
strategy:
1515
fail-fast: false
1616
matrix:
17-
python-version: [3.7, 3.8, 3.9]
17+
python-version: ["3.6", "3.7", "3.8", "3.9"]
1818
os: [ubuntu-latest, macos-latest]
1919

2020
runs-on: ${{ matrix.os }}
@@ -27,13 +27,30 @@ jobs:
2727
with:
2828
python-version: ${{ matrix.python-version }}
2929

30-
- name: Install project and dependencies
30+
- name: Update pip
3131
run: |
32-
pip install --upgrade pip
33-
pip install -r requirements.txt mdtraj
34-
pip install pytest coverage
32+
python -m pip install --upgrade pip
3533
36-
- name: Test with pytest
34+
- name: Get pip cache dir
35+
id: pip-cache
3736
run: |
38-
coverage run --source=pycgtool -m pytest
39-
coverage report --skip-covered
37+
echo "::set-output name=dir::$(pip cache dir)"
38+
39+
- name: Cache pip
40+
uses: actions/cache@v2
41+
with:
42+
# This path is specific to Ubuntu
43+
path: ${{ steps.pip-cache.outputs.dir }}
44+
# Look to see if there is a cache hit for the corresponding requirements file
45+
key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
46+
restore-keys: |
47+
${{ runner.os }}-pip-
48+
${{ runner.os }}-
49+
50+
- name: Install dependencies
51+
run: |
52+
pip install tox
53+
54+
- name: Run tests / linter
55+
run: |
56+
tox

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ settings.json
3636
.cache/
3737
/notes/
3838
*.offsets
39-
*.pkl
39+
*.pkl

.readthedocs.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: 2
2+
3+
sphinx:
4+
configuration: docs/conf.py
5+
6+
python:
7+
version: 3.7
8+
install:
9+
- method: pip
10+
path: .
11+
extra_requirements:
12+
- docs

.requirements-test.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4+
5+
## [2.0.0-beta.5](https://github.com/jag1g13/pycgtool/compare/v1.0.2...v2.0.0-beta.5) (2021-11-14)
6+
7+
8+
### Features
9+
10+
* add flag to get version number ([f3660f7](https://github.com/jag1g13/pycgtool/commit/f3660f7081b7265a39569338e693d32a1d4030ec))
11+
12+
13+
### Bug Fixes
14+
15+
* catch updated exception from MDTraj 1.9.7 ([b1d1e6d](https://github.com/jag1g13/pycgtool/commit/b1d1e6db76a1ce5c9273f6cf0833440c337aa302))
16+
* skip NaNs in bond sample output ([ef5a977](https://github.com/jag1g13/pycgtool/commit/ef5a97750dde27d48f83dc0f8472b4cc88f645aa))
17+
18+
## [2.0.0-beta.4](https://github.com/jag1g13/pycgtool/compare/v2.0.0-beta.3...v2.0.0-beta.4) (2021-10-09)
19+
20+
21+
### Bug Fixes
22+
23+
* add data files to installable package ([a9fdae8](https://github.com/jag1g13/pycgtool/commit/a9fdae85d5f9d2bff9dcfd4fe0fbc8a683dbe773))
24+
* backup forcefield directories instead of overwrite ([19b4054](https://github.com/jag1g13/pycgtool/commit/19b40540b0254c47d7a70eef12c2200bb96a4b9d))
25+
* backup frame and forcefield output files ([626cc3a](https://github.com/jag1g13/pycgtool/commit/626cc3a839a21699ac4c28eab55f385c6a199327))
26+
* create output directory if it doesn't exist ([c4694e8](https://github.com/jag1g13/pycgtool/commit/c4694e811201c7538819757bc52ea21ecd9f196f))
27+
* **tests:** add missing mapping test file ([db0be76](https://github.com/jag1g13/pycgtool/commit/db0be763bab6f629706597da1cb43d4ce3ff0914))
28+
* use correct reference coordinate for virtual bead calc ([a0a61f2](https://github.com/jag1g13/pycgtool/commit/a0a61f2dd2ae38d63b6de5a516f324865e93fe04))
29+
30+
## [2.0.0-beta.3](https://github.com/jag1g13/pycgtool/compare/v2.0.0-beta.2...v2.0.0-beta.3) (2021-08-14)
31+
32+
33+
### Bug Fixes
34+
35+
* avoid bond calc and traj output when no atoms ([ba0e5ab](https://github.com/jag1g13/pycgtool/commit/ba0e5ab1339f1f2821a0edb08a5b7f661c9ac29f)), closes [#51](https://github.com/jag1g13/pycgtool/issues/51)
36+
* catch zero volume PDB box and warn ([61a5b80](https://github.com/jag1g13/pycgtool/commit/61a5b809e0cd4dffaf3e2e2bbe2ab74fcc0488aa))
37+
* handle empty output frames correctly ([3d4b9ad](https://github.com/jag1g13/pycgtool/commit/3d4b9adccce32c95d4114c994133d3db6efd1556)), closes [#51](https://github.com/jag1g13/pycgtool/issues/51)
38+
39+
## [2.0.0-beta.2](https://github.com/jag1g13/pycgtool/compare/v2.0.0-beta.1...v2.0.0-beta.2) (2021-05-28)
40+
41+
42+
### Bug Fixes
43+
44+
* use absolute imports in entrypoint script ([1509247](https://github.com/jag1g13/pycgtool/commit/15092476496724e61a7c2f1367cdaa8ebe5fe0f2))
45+
46+
## [2.0.0-beta.1](https://github.com/jag1g13/pycgtool/compare/v2.0.0-alpha.5...v2.0.0-beta.1) (2021-05-10)
47+
48+
49+
### Features
50+
51+
* add initial trial for backmapping ([ab97010](https://github.com/jag1g13/pycgtool/commit/ab97010846815df7309b646d0bfe9f9e246890ba))
52+
53+
54+
### Bug Fixes
55+
56+
* add missing changes to poetry lockfile ([3edf562](https://github.com/jag1g13/pycgtool/commit/3edf562f1dfb71599dc40d78e5b824c0c2417eca))
57+
* attempt fix to ci config ([4551eb5](https://github.com/jag1g13/pycgtool/commit/4551eb5c46d70c9dadbc1397150705a1bd726b82))
58+
* avoid warnings with unnecessary topology file ([717c227](https://github.com/jag1g13/pycgtool/commit/717c22723c4b5857f5e4a2bd7f956ecafb3258d3))
59+
* cast unitcell to float32 to avoid numpy warn ([a89d2ce](https://github.com/jag1g13/pycgtool/commit/a89d2cee5e789ad7c85f593f1a8b9d73ba1e50e6))
60+
* **ci:** remove unused numpy import ([bb27619](https://github.com/jag1g13/pycgtool/commit/bb276195d9f1f76668d3133607a49f07ce4a8de4))
61+
* fix count of frames in trajectory ([d02cd34](https://github.com/jag1g13/pycgtool/commit/d02cd3485cd474cf539a7e628dddfc4eaa953e51))
62+
* Move bond dump files to output directory ([1439235](https://github.com/jag1g13/pycgtool/commit/1439235f3a48da84af4b3fe064e1da9b39aa71e9))
63+
* python 3.10 this time - not 3.1 ([5143191](https://github.com/jag1g13/pycgtool/commit/51431910aeb8b70bef90aba82183d040282d6912))
64+
* remove 3.10 - it's not in the cache yet ([80a90e1](https://github.com/jag1g13/pycgtool/commit/80a90e1c62f245dab2f85e2533612c8b19a7c9d0))
65+
* replace reference to requirements.txt in CI ([3d1bd7f](https://github.com/jag1g13/pycgtool/commit/3d1bd7f5fde17b5c0300f70300cfa3b0f42cb3f1))
66+
* update tests to match refactoring in __main__ ([0dbce7d](https://github.com/jag1g13/pycgtool/commit/0dbce7d50e35fa1ffed959a40f7c9a2aa6dda873))
67+
68+
## [2.0.0-alpha.5](https://github.com/jag1g13/pycgtool/compare/v1.0.1...v2.0.0-alpha.5) (2020-09-23)
69+
70+
71+
### Features
72+
73+
* Add option for performance profiling ([cbd56ed](https://github.com/jag1g13/pycgtool/commit/cbd56ed8177e17bfc43284d4b09320fc24b8b939))
74+
75+
76+
### Bug Fixes
77+
78+
* Account for MDTraj renaming in mol mappings ([6c7c07f](https://github.com/jag1g13/pycgtool/commit/6c7c07f748c5aabd21b3ba8997dfd9ae7d97f1b9))
79+
* Call CI tools from inside Poetry env ([60e3e9d](https://github.com/jag1g13/pycgtool/commit/60e3e9db94f61dfb33840bd17716d5e48499f5c9))
80+
* Distinguish between failure cases in traj cmp ([0ede47c](https://github.com/jag1g13/pycgtool/commit/0ede47c99d8667cae1ff38023c1a877b22ca0db7))
81+
* Drop support for Python 3.5 ([d50adb2](https://github.com/jag1g13/pycgtool/commit/d50adb2820b8519eaa3d77af95f4f45deb399e35))
82+
* Fix CI failing to find Flake8 ([4b8e375](https://github.com/jag1g13/pycgtool/commit/4b8e37563cd5f7ce8e4d3b0c55f0bf869f39c3b9))
83+
* Fix err in file comparison when diff lengths ([6994993](https://github.com/jag1g13/pycgtool/commit/69949934801986578e52a73e3da0e18dd546be2f))
84+
* Fix error when reading zero size box ([c44f621](https://github.com/jag1g13/pycgtool/commit/c44f62171a5d9b37b591736f3869e892e3d49a32))
85+
* Fix failing bond dump test ([8d7d06f](https://github.com/jag1g13/pycgtool/commit/8d7d06f9e90ca5cbceadc29630e8d8208829eff3))
86+
* Fix linting errors raised by pyflakes ([d275329](https://github.com/jag1g13/pycgtool/commit/d2753290f96181b1b4ed00d92a70cad244abd2a3))
87+
* Fix remaining test failures ([50ec715](https://github.com/jag1g13/pycgtool/commit/50ec7156e790a8ed475414c95196e5861027e006))
88+
* Replace time.clock with time.process_time ([d1f6981](https://github.com/jag1g13/pycgtool/commit/d1f69810475e2e3af4beb2652688c05d11b73a86))
89+
* Update Poetry lock file ([f08dd83](https://github.com/jag1g13/pycgtool/commit/f08dd839fde66c739e52920a1ca92d5b7ec2b135))

LICENSE.md renamed to LICENSE

File renamed without changes.

README.md

Lines changed: 85 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
1-
[![Build Status](https://travis-ci.org/jag1g13/pycgtool.svg?branch=master)](https://travis-ci.org/jag1g13/pycgtool) [![Documentation Status](https://readthedocs.org/projects/pycgtool/badge/?version=master)](http://pycgtool.readthedocs.io/en/master/?badge=master) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.259330.svg)](https://doi.org/10.5281/zenodo.259330)
2-
31
# PyCGTOOL
42

5-
Please see http://pycgtool.readthedocs.io/en/master/ for full documentation.
6-
7-
A Python program for automated generation of coarse-grained molecular dynamics models from atomistic simulation trajectories.
8-
9-
The aim of this project is to provide a tool to aid in parametrising coarse-grained (CG) molecular mechanics models. PyCGTOOL generates coarse-grained models 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.
3+
[![License](https://img.shields.io/github/license/jag1g13/pycgtool.svg)](LICENSE)
4+
[![Python package](https://github.com/jag1g13/pycgtool/actions/workflows/python-package.yml/badge.svg?branch=dev)](https://github.com/jag1g13/pycgtool/actions)
5+
[![Documentation](https://readthedocs.org/projects/pycgtool/badge/?version=dev)](http://pycgtool.readthedocs.io/en/dev)
6+
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.598143.svg)](https://doi.org/10.5281/zenodo.598143)
7+
[![PyPi Version](https://img.shields.io/pypi/v/pycgtool.svg)](https://pypi.python.org/pypi/pycgtool/)
8+
[![conda-forge Version](https://anaconda.org/conda-forge/pycgtool/badges/version.svg)](https://anaconda.org/conda-forge/pycgtool/badges/version.svg)
109

11-
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 MARTINI membrane simulation.
10+
Generate coarse-grained molecular dynamics models from atomistic trajectories.
1211

13-
PyCGTOOL makes it easy to test multiple variations in mapping and bond topology by making simple changes to the config files.
12+
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.
13+
It generates coarse-grained model parameters from atomistic simulation trajectories using a user-provided mapping.
14+
Equilibrium values and force constants of bonded terms are calculated by Boltzmann Inversion of bond distributions collected from the input trajectory.
1415

15-
This version has several advantages over the original C++ implementation CGTOOL:
16-
* PyCGTOOL is able to run anywhere the necessary library dependencies are available (all available from pip)
17-
* Does not require that residues are present in contiguous sorted blocks
18-
* May map multiple residues with a single pass
19-
* Support for polymers such as DNA or proteins making use of GROMACS' pdb2gmx
20-
* Much more automated testing ensures that regressions will be identified quickly
16+
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.
17+
For instance, a pre-equilibrated atomistic membrane may be used to create starting coordinates for a CG membrane simulation.
2118

22-
If you experience problems or wish to see a new feature added please [file an issue](https://github.com/jag1g13/pycgtool/issues).
19+
PyCGTOOL makes it quick and easy to test multiple variations in mapping and bond topology by making simple changes to the config files.
2320

24-
If you find PyCGTOOL useful, please cite our JCIM paper https://doi.org/10.1021/acs.jcim.7b00096.
21+
If you find PyCGTOOL useful, please cite our JCIM paper (https://doi.org/10.1021/acs.jcim.7b00096) and the code itself (https://doi.org/10.5281/zenodo.598143).
2522

2623
```bibtex
2724
@article{Graham2017,
@@ -39,28 +36,82 @@ If you find PyCGTOOL useful, please cite our JCIM paper https://doi.org/10.1021/
3936
}
4037
```
4138

42-
## Usage
43-
Input to PyCGTOOL is GROMACS GRO and XTC files, along with two custom files: MAP and BND. These files provide the atomistic-to-CG mapping and bonded topology respectively. Example files are present in the [test/data](https://github.com/jag1g13/pycgtool/tree/master/test/data) directory. The format of these files is described in the [full documentation](http://pycgtool.readthedocs.io/en/master/).
39+
## Install
40+
41+
PyCGTOOL requires Python 3.6 or higher and may be installed using either `pip` or `conda`:
42+
```
43+
pip install pycgtool
44+
```
45+
46+
```
47+
conda install -c conda-forge pycgtool
48+
```
4449

45-
To run PyCGTOOL:
46-
`pycgtool.py -g <GRO file> -x <XTC file> -m <MAP file> -b <BND file>`
50+
Alternatively, you may download a pre-packaged version for your operating system from the [releases page](https://github.com/jag1g13/pycgtool/releases) on GitHub.
51+
These pre-packaged versions include all dependencies and should be suitable in cases where you cannot install packages using one of the above methods.
52+
**Warning**: This installation method is not extensively tested - installing via `pip` or `conda` should be prefered in most cases.
4753

48-
To run PyCGTOOL in map-only mode:
49-
`pycgtool.py -g <GRO file> -m <MAP file>`
54+
### MDTraj on macOS
5055

51-
To see the help text:
52-
`pycgtool.py -h`
56+
On some versions macOS, with some versions of the Clang compiler, MDTraj may fail to load GROMACS XTC simulation trajectories.
57+
If you encounter this issue, please make sure you have the latest version of MDTraj installed.
58+
59+
For more information see [MDTraj/#1572](https://github.com/mdtraj/mdtraj/issues/1572).
60+
61+
## Usage
62+
63+
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`).
64+
These files provide the atomistic-to-CG mapping and bonded topology respectively and use a format similar to GROMACS `.itp` files.
65+
Topology and trajectory files are processed using [MDTraj](https://www.mdtraj.org) so most common formats are accepted.
66+
67+
Example mapping and bond files are present in the [test/data](https://github.com/jag1g13/pycgtool/tree/master/test/data) directory.
68+
The format of these files is described fully in the [documentation page on file formats](https://pycgtool.readthedocs.io/en/dev/file-formats.html).
5369

5470
For more information, see [the tutorial](https://pycgtool.readthedocs.io/en/master/tutorial.html).
55-
It is important to perform validation of any new parameter set; a brief example is present at the end of the tutorial.
71+
It is important to perform validation of any new parameter set - a brief example is present at the end of the tutorial.
72+
73+
For a full list of options, see the [documentation](https://pycgtool.readthedocs.io/en/master/index.html) or use:
74+
```
75+
pycgtool -h
76+
```
77+
78+
### Generate a Model
79+
80+
To generate a CG model from an atomistic simulation:
81+
```
82+
pycgtool <topology file> <trajectory file> -m <MAP file> -b <BND file>
83+
```
84+
85+
### Map Only
86+
87+
To use PyCGTOOL to convert a set of atomistic simulation coordinates to CG coordinates:
88+
```
89+
pycgtool <topology file> -m <MAP file>
90+
```
91+
92+
Or to convert a complete simulation trajectory:
93+
```
94+
pycgtool <topology file> <trajectory file> -m <MAP file>
95+
```
96+
97+
## Maintainers
98+
99+
James Graham ([@jag1g13](https://github.com/jag1g13))
100+
101+
## Contributing
102+
103+
If you experience problems using PyCGTOOL or wish to see a new feature added please [open an issue](https://github.com/jag1g13/pycgtool/issues/new).
104+
105+
To help develop PyCGTOOL, you can create a fork of this repository, clone your fork and install PyCGTOOL in development mode using [Poetry](https://python-poetry.org/):
106+
```
107+
poetry install
108+
```
109+
110+
This will result in an editable mode install (similar to `pip install -e .`) along with all the necessary runtime and development dependencies.
111+
Testing and linting is handled by [Tox](https://tox.readthedocs.io/en/latest/) - use `tox` to run the full test suite and linter as they are configured in the Continuous Integration pipeline.
56112

57-
## Requirements
58-
PyCGTOOL requires:
59-
* Python3
60-
* [NumPy](http://www.numpy.org/)
61-
* [simpletraj](https://github.com/arose/simpletraj)
113+
When you're ready for your work to be merged, please submit a Pull Request.
62114

63-
The bundled test code may be run using your preferred Python testing frontend although py.test or nose2 is recommended.
64-
All library dependencies may be installed from pip using the command `pip install -r requirements.txt`
115+
## License
65116

66-
This program is a reimplementation of the earlier [CGTOOL](https://bitbucket.org/jag1g13/cgtool).
117+
[GPL-3.0](LICENSE) © James Graham, University of Southampton

0 commit comments

Comments
 (0)