Skip to content

Commit c63a956

Browse files
committed
Tidying up
1 parent 5836c87 commit c63a956

5 files changed

Lines changed: 49 additions & 35 deletions

File tree

.github/workflows/python-app.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
python-version: ["3.13"]
2323

2424
env:
25-
KEY_MODELLER: MODELIRANJE
25+
KEY_MODELLER: ${{ secrets.MODELLER_KEY }}
2626

2727
steps:
2828
- name: Checkout repo
@@ -58,4 +58,4 @@ jobs:
5858

5959
- name: Run test suite
6060
shell: bash -l {0}
61-
run: prep-license MODELIRANJE && pytest -v
61+
run: prep-license ${{ secrets.MODELLER_KEY }} && pytest -v

.github/workflows/release.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ jobs:
3535
uses: actions/checkout@v4
3636
with:
3737
ref: main
38+
39+
- name: Update modeller key
40+
shell: bash -l {0}
41+
run: |
42+
sed -i -e 's/SECRET-MODELLER-LICENSE-KEY/${{ secrets.MODELLER_KEY }}/g' conda-build/meta.yml
3843
3944
- name: Setup Conda (conda-forge only)
4045
uses: conda-incubator/setup-miniconda@v3

README.md

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ A utility to automatically prepare structures from the PDB for molecular dynamic
1818
## Installation
1919

2020
### Install via conda
21-
* Install [Conda](https://github.com/conda-forge/miniforge?tab=readme-ov-file#install) (if you don't already have it)
21+
* Install [Conda](https://github.com/conda-forge/miniforge?tab=readme-ov-file#install) (if you don't already have it). If you have an existing conda install, make sure it can install packages from conda-forge.
2222
* Recommended: create a new virtual environment: `conda env create --name prepmd && conda activate prepmd`
23-
* Install prepmd from the CCPBioSim conda channel: `conda install -c conda-forge -c prepmd`
24-
* Add your [modeller license key](https://salilab.org/modeller/registration.html) by running `prep-license <your license key`
23+
* Install prepmd from the CCPBioSim conda channel: `conda install -c CCPBioSim prepmd`
24+
* Add your [modeller license key](https://salilab.org/modeller/registration.html) by running `prep-license <your license key>`
2525

2626
### Manual install
2727
* Install [Conda](https://github.com/conda-forge/miniforge?tab=readme-ov-file#install) (if you don't already have it)
@@ -32,21 +32,23 @@ A utility to automatically prepare structures from the PDB for molecular dynamic
3232

3333
## Quickstart
3434

35-
`prepmd 6xov 6xov_processed.cif` will download the structure for PDB entry `6xov`, process it and write it to `6xov_processed.cif`. If you have a local structure file, you can use the `--structure` parameter, though you'll still need to list a PDB code (it's not important what the code is, but some of the file foramts used by prepmd require a code to be present.
36-
Note: .pdb support is provided for legacy compatibility, but using the mmCif format is strongly recommended, as the pdb format is deprecated.
37-
`runmd 6xov_processed.cif --traj_out traj.xtc --md_steps 5000` will minimise and run a simulation of structure.cif using OpenMM, writing a trajectory to `traj_out.xtc`, for 5000 steps. By default, `runmd` uses a minimal set of simulation parameters, which aren't likely to be accurate - check the `runmd` section of this documentation for more options
35+
`prepmd --ignore_hetatms 6xov 6xov_processed.cif` will download the structure for PDB entry `6xov`, process it and write it to `6xov_processed.cif`.
36+
37+
`runmd 6xov_processed.cif --traj_out traj.xtc --md_steps 5000` will minimise and run a simulation of 6xov_processed.cif writing a trajectory to `traj_out.xtc`, for 5000 steps. By default, `runmd` uses a minimal set of simulation parameters, which aren't likely to be accurate - check the `runmd` section of this documentation for more options
3838

3939
## Preparing structure files for simulation with prepmd
4040

41+
Note: When runnig `prepmd`, we recommend using .mmCif files where possible. The .pdb file format is deprecated, and is provided for legacy compatibility.
42+
4143
### prepmd workflow
4244
Steps in the `prepmd` workflow:
43-
* The structure file(s) are downloaded (if not supplied) into a working directory. PDB and mmCif are supported, though mmCif is recommended. `prepmd` automatically infers the file format from the file extension of the input/output files.
44-
* `prepmd` extracts the sequence from the residues in the PDB directly and compares them to a reference sequence. By default this is the sequence described in the SEQRES entries of the structure file. The two sequences are alligned and [MODELLER]() is used to fill in the missing residues.
45+
* The structure file(s) are downloaded (if not supplied) into a working directory. `prepmd` automatically infers the file format from the file extension of the input/output files.
46+
* `prepmd` extracts the sequence from the residues in the PDB directly and compares them to a reference sequence. By default this is the sequence described in the SEQRES entries of the structure file. The two sequences are alligned and [MODELLER](https://salilab.org/modeller/) is used to fill in the missing residues.
4547
* Optionally, multiple models can be created, and scored based on MODELLER's internal metrics or their similarity to a reference EM density map.
46-
* HETATMS are extracted from the structure file and saved to .sdf files. [rdkit]() is used to add hydrogens and correct the geometry of the ligands.
47-
* PDBFixer is used to add misisng hydrogens and remove nonstandard residues.
48-
* Optionally, at this point, a PQR file can be output using PDB2PQR.
49-
* Finally, OpenMM is used to perform a test minimisation and simulation. This step ensures that the resulting file is ready for simulation and that there are no steric clashes. If the minimisation or test simulation fails, it will be retried with OpenMM's variable langevin integrator. In testing, this has successfully minimised structure files with high clash scores.
48+
* HETATMS are extracted from the structure file and saved to .sdf files. [rdkit](https://www.rdkit.org/) is used to add hydrogens and correct the geometry of the ligands.
49+
* [PDBFixer](https://github.com/openmm/pdbfixer) is used to add missing hydrogens and remove nonstandard residues.
50+
* Optionally, at this point, a PQR file can be output using [PDB2PQR](https://www.cgl.ucsf.edu/chimera/docs/ContributedSoftware/apbs/pdb2pqr.html).
51+
* Finally, (OpenMM)[https://openmm.org/] is used to perform a test minimisation and simulation. This step ensures that the resulting file is ready for simulation and that there are no steric clashes. If the minimisation or test simulation fails, it will be retried with OpenMM's variable langevin integrator. In testing, this has successfully minimised structure files with high clash scores.
5052
* The final, mimimised structure file will be written out. Note: if ligands are present, the non-minimised structure will be written instead - this is to allow the user to choose which ligand files to include in their final structure, which can be minimised using `runmd`.
5153

5254
### prepmd command-line reference
@@ -63,16 +65,16 @@ Steps in the `prepmd` workflow:
6365
#### Use your own alignments and sequences to fill missing loops
6466
By default, `prepmd` will read missing residues from the pdb/mmcif SEQRES records, attempt to align the missing residues with the currently present residues, and then build missing loops with MODELLER. You can manually provide an aligned FASTA file containing the the complete and incomplete sequences with `--fasta`. You can also ask prepmd to get the sequence data from UNIPROT instead, with `--download`, though this is not recommended, as the raw sequence data can be substantially different from the PDB and cause the alignment to fail.
6567
#### Handling ligands
66-
* By default, `prepmd` removes ligands and other molecules from the input and saves each HETATM residue to its own SDF file. You can disable this behaviour with the `--ignore_hetatams` flag. The co-ordinates inside the SDF files correspond to the co-ordinates of the ligands in the structure file, so the ligands can be added back into the original structure easily. `prepmd` uses [rdkit]() to add hydrogens and correct the geometry of small molecules.
68+
By default, `prepmd` removes ligands and other molecules from the input and saves each HETATM residue to its own SDF file. If you don't intend to include the hetatms, you can disable this behaviour with the `--ignore_hetatams` flag. The co-ordinates inside the SDF files correspond to the co-ordinates of the ligands in the structure file, so the ligands can be added back into the original structure easily. `prepmd` uses [rdkit]() to add hydrogens and correct the geometry of small molecules.
6769
#### Working directory
68-
* By default, `prepmd` will leave intermediate files in a randomly-named temporary directory. You can set the name of this directory: `prepmd --wdir 6xov_temp 6xov 6xov.cif`.
70+
By default, `prepmd` will leave intermediate files in a randomly-named temporary directory. You can set the name of this directory: `prepmd --wdir 6xov_temp 6xov 6xov.cif`.
6971

7072
## Running MD simulations with runmd
7173
Steps in the `runmd` workflow:
7274
* Validate user input - runmd will attempt to infer the best parameters and halt if incompatible/impossible settings are used.
73-
* Create an OpenMM system object. If small molecules are present, `runmd` will also load the OpenFF Sage small molecule force field.
75+
* Create an OpenMM system object. If small molecules are present, `runmd` will also load the [OpenFF](https://openforcefield.org/) Sage small molecule force field.
7476
* If there is explicit solvent, set up the simulation box and solvate the system.
75-
* If the run is a metadynamics run, setup bias variables and forces using [openmmtools]().
77+
* If the run is a metadynamics run, setup bias variables and forces using [openmmtools](https://openmmtools.readthedocs.io/en/stable/).
7678
* Attempt to minimise and run the simulation with OpenMM. If the run/minimisation crashes, the numerical integrator will automatically be switched to the variable langevin integrator and the simulation will be restarted.
7779
* If the run is a metadynamics run, and the metadynamics collective variables aren't minimised, the simulation will restart.
7880

@@ -97,19 +99,23 @@ If you have two files for the same structure which aren't aligned (e.g. they hav
9799
### Numerical integrators
98100
* Set the numerical integrator with the `-i` flag. This can be either `VariableLangevinIntegrator` or `LangevinMiddleIntegrator`. By default, `runmd` will attempt to use the latter, and fall back to the former if the simulation becomes numerically unstable. The parameter `--minimise-err` sets the error tolerance or the variable langevin integrator. Its value is arbitrary - 0.001 is a good starting point, increasing it will make the simulation run faster at the expense of accuracy.
99101
### Other settings
100-
* By default, `runmd` will try to select the most optimal nonbonded interaction method, but this can be overridden with `-nb` or `--nonbonded`, which can be one of `PME`, `CutoffPeriodic`, or `CutoffNonPeriodic`
101-
* By default, `runmd` will constrain the length of all bonds involving a hydrogen atom, which can allow for longer timesteps at the cost of some accuracy. This can be disabled by setting `-c None` or `--constraints None`. This setting is also disabled if the backbone is fixed.
102+
By default, `runmd` will try to select the most optimal nonbonded interaction method, but this can be overridden with `-nb` or `--nonbonded`, which can be one of `PME`, `CutoffPeriodic`, or `CutoffNonPeriodic`. Similarly, it will constrain the length of all bonds involving a hydrogen atom, which can allow for longer timesteps at the cost of some accuracy. This can be disabled by setting `-c None` or `--constraints None`. This setting is also disabled if the backbone is fixed.
102103

103104
## What next?
104-
* Though you can run simple MD simulations, minimisations and validation with prepmd, for more in-depth MD we recommend using software such as GROMACS, AMBER, NAMD and OpenMM.
105+
* Though you can run simple MD simulations, minimisations and validation with `prepmd`, for more in-depth MD we recommend using software such as GROMACS, AMBER, NAMD and OpenMM.
105106
* If you're looking to generate an atomistic structure file that matches your EM map as closely as possible, you can use a flexible fitting tool such as [TEMPy-ReFF](https://gitlab.com/topf-lab/tempy-reff).
106107

107108
## Python API
108-
prepmd's is also accessible via a python API:
109-
```
110-
from prepmd.prep import prep, run
111-
prep.prep("6xov", "6xov.cif", "working_dir")
112-
run.run("6xov.cif", traj_out="traj.xtc")
109+
prepmd is also accessible via a python API:
110+
```python
111+
from prepmd.add_modeller_license import setup_license
112+
setup_license(<your license key>) # only needs to be done once
113+
114+
from prepmd.prep import prep
115+
prep("6xov", "6xov.cif", "working_dir")
116+
117+
from prepmd.run import run
118+
run("6xov.cif", traj_out="traj.xtc")
113119
```
114120

115121
## Licence

conda-recipe/meta.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ requirements:
2525
- pdb2pqr
2626
test:
2727
commands:
28-
- prep-license MODELIRANJE
28+
- prep-license SECRET-MODELLER-LICENSE-KEY
2929
imports:
3030
- prepmd
3131

prepmd/add_modeller_license.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,7 @@
1313

1414
HELP_MSG = "Usage: prep-license LICENSE-KEY (will replace current key)"
1515

16-
def entry_point():
17-
if len(sys.argv) != 2:
18-
print(HELP_MSG)
19-
sys.exit(0)
20-
if sys.argv[1] == "--help" or sys.argv[1] == "-h":
21-
print(HELP_MSG)
22-
sys.exit(0)
23-
key = sys.argv[1]
16+
def setup_license(key):
2417
modeller_init_path = Path(importlib.util.find_spec("modeller").origin)
2518
modeller_lib = modeller_init_path.parent.parent.absolute() / "modeller" / "config.py"
2619
with open(modeller_lib) as file:
@@ -30,6 +23,16 @@ def entry_point():
3023
contents[1] = contents_1_new
3124
with open(modeller_lib, "w") as file:
3225
file.writelines(contents)
26+
27+
def entry_point():
28+
if len(sys.argv) != 2:
29+
print(HELP_MSG)
30+
sys.exit(0)
31+
if sys.argv[1] == "--help" or sys.argv[1] == "-h":
32+
print(HELP_MSG)
33+
sys.exit(0)
34+
key = sys.argv[1]
35+
setup_license(key)
3336
print("Updated modeller license info.")
3437

3538
if __name__ == "__main__":

0 commit comments

Comments
 (0)