gbsa_pipeline
¶
GBSA pipeline package.
Optimize GBSA calculations for speed
Modules:
-
change_defaults–Creating custom protocol with one setter per GROMACS parameter.
-
change_defaults_enum–Classes for availible options in gms parameters.
-
change_params–General parameter change helpers for GROMACS .mdp files.
-
cli–Command-line interface for the GBSA pipeline.
-
config–Top-level RunConfig model for driving the pipeline from a TOML file.
-
docking–Lightweight docking adapter layer for Vina and helpers.
-
equilibration–Preparing and running a heating procedure.
-
frcmod_parametrization–Utilities for loading AMBER parameters into the GBSA pipeline.
-
gmx_edit_defaults–Adapting the general change funtion for GROMACS formatting.
-
gromacs_index–Module to generate gromacs index files for a system.
-
ligand_preparation–Reading ligand from SDF file, standardizing with MolVS and adding hydrogens with RDKIT.
-
minimization–Preparing minimization protocol and running.
-
parametrization–Parametrize protein-ligand complexes.
-
parametrization_enum–Force field and charge method enumerations for parametrization.
-
pipeline–Functional pipeline runner — orchestrates all MD simulation stages.
-
solvation_box–Solvation helpers with configurable solvent, box shape, padding, and ions.
-
solvation_openmm–OpenMM/ParmEd solvation that bypasses BioSimSpace IO.
Classes:
-
AmberFFInput–Inputs for converting AMBER frcmod + mol2 files to an OpenMM XML.
-
AmberInput–Validated inputs for loading a pre-parametrized AMBER system.
-
ParametrisedComplex–Parametrised protein-ligand complex ready for solvation and MD.
-
ParametrizationConfig–Force field and charge method choices for a parametrization run.
-
ParametrizationInput–Validated inputs for a parametrization run.
-
RunConfig–Top-level configuration for a complete GBSA pipeline run.
-
SolvatedComplex–Solvated protein-ligand complex produced by :func:
solvate_openmm.
Functions:
-
build_amber_ff_xml–Build a unified OpenMM ForceField XML from AMBER frcmod and mol2 files.
-
load_amber_complex–Load an AMBER prmtop + inpcrd and export to GROMACS
.gro/.top. -
parametrize–Parametrize a protein-ligand complex without running tleap.
-
run_pipeline–Run the full GBSA pipeline from a validated :class:
~gbsa_pipeline.config.RunConfig. -
solvate_openmm–Solvate a parametrised complex with OpenMM + ParmEd (no BSS IO).
AmberFFInput
¶
Bases: BaseModel
Inputs for converting AMBER frcmod + mol2 files to an OpenMM XML.
The generated XML contains all atom types, bonded parameters, LJ
parameters, and residue templates needed by OpenMM's ForceField.
Pass the output path to
:class:~gbsa_pipeline.parametrization.ParametrizationConfig via
extra_ff_files alongside the standard protein/water XML files.
Parameters¶
frcmod_files:
One or more AMBER frcmod files (e.g. from MCPB.py) that supply
custom bond, angle, dihedral, and LJ parameters.
residue_mol2s:
Mol2 files for non-standard residues (e.g. metal-coordinating CYS/HIS
modified by MCPB.py, bare metal ions). Each file must contain exactly
one @<TRIPOS>MOLECULE block.
protein_ff:
Protein force field. Determines which base AMBER parameter files are
loaded (parm19.dat + frcmod.ff14SB for FF14SB, etc.).
ligand_ff:
Ligand force field. Determines gaff.dat vs gaff2.dat.
output_xml:
Path where the unified XML is written. A file inside a temporary
directory is used when None.
AmberInput
¶
Bases: BaseModel
Validated inputs for loading a pre-parametrized AMBER system.
Parameters¶
prmtop:
AMBER parameter/topology file (.prmtop / .parm7), produced
by e.g. tleap, MCPB.py, or antechamber.
inpcrd:
AMBER coordinate file (.inpcrd / .rst7).
output_dir:
Directory for GROMACS output files. A temporary directory is
created when None.
ParametrisedComplex
dataclass
¶
ParametrisedComplex(
gro_file: Path,
top_file: Path,
config: ParametrizationConfig,
forcefield: Any = None,
parmed_structure: Any = None,
)
Parametrised protein-ligand complex ready for solvation and MD.
Attributes:¶
gro_file:
GROMACS coordinate file (.gro) produced by ParmEd.
top_file:
GROMACS topology file (.top) produced by ParmEd.
config:
The force field configuration used to produce this complex.
Stored so that downstream steps can record or reproduce the run.
forcefield:
The OpenMM ForceField (with GAFF registered and ligand charges
already assigned) used during parametrization. Passed directly to
:func:~gbsa_pipeline.solvation_openmm.solvate_openmm so that
water XML can be loaded into it without rebuilding from scratch or
re-running AM1-BCC. None when the complex was loaded from disk
(e.g. :func:~gbsa_pipeline.frcmod_parametrization.load_amber_complex).
parmed_structure:
The ParmEd Structure holding every protein+ligand force field
parameter produced during parametrization. Passed directly to
:func:~gbsa_pipeline.solvation_openmm.solvate_openmm to avoid
reloading from the GROMACS files. None when loaded from disk.
ParametrizationConfig
¶
Bases: BaseModel
Force field and charge method choices for a parametrization run.
Defaults to AMBER ff14SB + GAFF2 + AM1-BCC. Use the class-method presets for the most common combinations, or construct directly to override individual axes.
Examples:¶
ParametrizationConfig() # all defaults ParametrizationConfig(protein_ff=ProteinFF.FF19SB) # swap protein FF ParametrizationConfig.amber14_gaff2_nagl() # preset with NAGL charges
Methods:
-
amber14_gaff2–AMBER ff14SB + GAFF2 + AM1-BCC charges (default).
-
amber14_gaff2_nagl–AMBER ff14SB + GAFF2 + NAGL graph-neural-network charges.
-
amber19_gaff2–AMBER ff19SB + GAFF2 + AM1-BCC charges.
amber14_gaff2
classmethod
¶
amber14_gaff2() -> ParametrizationConfig
AMBER ff14SB + GAFF2 + AM1-BCC charges (default).
Source code in src/gbsa_pipeline/parametrization.py
70 71 72 73 | |
amber14_gaff2_nagl
classmethod
¶
amber14_gaff2_nagl() -> ParametrizationConfig
AMBER ff14SB + GAFF2 + NAGL graph-neural-network charges.
Source code in src/gbsa_pipeline/parametrization.py
80 81 82 83 | |
amber19_gaff2
classmethod
¶
amber19_gaff2() -> ParametrizationConfig
AMBER ff19SB + GAFF2 + AM1-BCC charges.
Source code in src/gbsa_pipeline/parametrization.py
75 76 77 78 | |
ParametrizationInput
¶
Bases: BaseModel
Validated inputs for a parametrization run.
Parameters¶
protein_pdb:
Path to the protein PDB file. Must exist.
ligand_sdf:
Path to the ligand SDF file with embedded 3-D coordinates. Must exist.
config:
Force field and charge method selection. Defaults to
ParametrizationConfig() (ff14SB + GAFF2 + AM1-BCC).
net_charge:
Formal charge of the ligand in elementary charge units.
None lets the charge assignment toolkit determine it automatically.
work_dir:
Directory where intermediate and output files are written.
When None a temporary directory is created automatically.
RunConfig
¶
Bases: BaseModel
Top-level configuration for a complete GBSA pipeline run.
Load from a TOML file with :meth:from_toml. Each section maps to a
nested model. The [md] section accepts any field of
:class:~gbsa_pipeline.change_defaults.GromacsParams.
Example:¶
[system]
protein = "protein.pdb"
ligand = "ligand.sdf"
[solvation]
water_model = "tip3p"
padding = 10.0
[md]
nsteps = 500000
dt = 0.002
tcoupl = "v-rescale"
ref_t = 300.0
Methods:
-
from_toml–Load and validate a :class:
RunConfigfrom a TOML file. -
to_parametrization_input–Build a :class:
~gbsa_pipeline.parametrization.ParametrizationInputfrom this config.
from_toml
classmethod
¶
Load and validate a :class:RunConfig from a TOML file.
Parameters¶
path:
Path to the .toml configuration file.
Returns:¶
RunConfig Validated configuration object.
Source code in src/gbsa_pipeline/config.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | |
to_parametrization_input
¶
to_parametrization_input(
work_dir: Path,
) -> ParametrizationInput
Build a :class:~gbsa_pipeline.parametrization.ParametrizationInput from this config.
Parameters¶
work_dir: Directory where parametrization output files will be written.
Returns:¶
ParametrizationInput
Ready to pass to :func:~gbsa_pipeline.parametrization.parametrize.
Raises:¶
ValueError
If system.ligand is None (ligand is required for parametrization).
Source code in src/gbsa_pipeline/config.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
SolvatedComplex
dataclass
¶
Solvated protein-ligand complex produced by :func:solvate_openmm.
Carries both the on-disk GROMACS files (written for inspection and checkpoint purposes) and the in-memory ParmEd structure so that downstream steps can use either without repeating disk I/O.
Attributes:¶
gro_file:
GROMACS coordinate file (.gro) of the solvated system.
top_file:
GROMACS topology file (.top) of the solvated system.
parmed_structure:
In-memory ParmEd Structure with all force-field parameters.
None when the object is constructed from existing files rather
than from a live parametrization run.
Methods:
-
load_bss–Load this complex as a BioSimSpace System for MD stages.
load_bss
¶
load_bss() -> Any
Load this complex as a BioSimSpace System for MD stages.
Reads from the GROMACS files already written to disk. The returned system is ready for minimization, equilibration, and production MD.
Returns:¶
BioSimSpace._SireWrappers.System The solvated system loaded into BioSimSpace.
Source code in src/gbsa_pipeline/solvation_openmm.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
build_amber_ff_xml
¶
build_amber_ff_xml(inp: AmberFFInput) -> Path
Build a unified OpenMM ForceField XML from AMBER frcmod and mol2 files.
Loads the base AMBER parameter files for the requested force fields, adds
the custom frcmod parameters, merges mol2 residue templates directly into
the :class:parmed.openmm.OpenMMParameterSet, and writes a single XML
file that OpenMM's ForceField can read.
Parameters¶
inp: Validated inputs.
Returns:
-
Path–Path to the written XML file.
Raises:
-
RuntimeError–If the AMBER parameter directory cannot be found.
-
ValueError–If any atom type referenced in a residue template is not defined in the combined parameter set.
Source code in src/gbsa_pipeline/frcmod_parametrization.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
load_amber_complex
¶
load_amber_complex(inp: AmberInput) -> ParametrisedComplex
Load an AMBER prmtop + inpcrd and export to GROMACS .gro / .top.
Uses ParmEd to read the AMBER files directly and write the GROMACS files.
Parameters¶
inp: Validated inputs.
Returns:
-
ParametrisedComplex–class:
~gbsa_pipeline.parametrization.ParametrisedComplexwith -
ParametrisedComplex–paths to the GROMACS coordinate and topology files.
Source code in src/gbsa_pipeline/frcmod_parametrization.py
209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
parametrize
¶
parametrize(
inp: ParametrizationInput,
) -> ParametrisedComplex
Parametrize a protein-ligand complex without running tleap.
Uses OpenMM force field XML files for the protein and
GAFFTemplateGenerator for the ligand. Partial charges are assigned
via the method specified in inp.config.charge_method (default:
AM1-BCC via sqm). The system is exported to GROMACS .gro and
.top files via ParmEd.
Parameters¶
inp: Validated parametrization inputs including file paths, force field configuration, and optional work directory.
Returns:¶
ParametrisedComplex Frozen dataclass holding the paths to the output GROMACS files and the configuration used.
Source code in src/gbsa_pipeline/parametrization.py
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
run_pipeline
¶
Run the full GBSA pipeline from a validated :class:~gbsa_pipeline.config.RunConfig.
Stages (each writes output to a numbered subdirectory):
- Parametrize — assign force field parameters to protein + ligand.
- Solvate — add water box and counter-ions.
- Minimize — energy minimization.
- Equilibrate — NVT heating from 0 K to 300 K.
- Production MD — NpT simulation driven by
[md]section params.
Parameters¶
config:
Validated run configuration (usually loaded via
:meth:~gbsa_pipeline.config.RunConfig.from_toml).
output_dir:
Root directory for all output. Created if it does not exist.
Source code in src/gbsa_pipeline/pipeline.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
solvate_openmm
¶
solvate_openmm(
parametrized: ParametrisedComplex,
params: SolvationParams,
output_gro: Path,
output_top: Path,
) -> SolvatedComplex
Solvate a parametrised complex with OpenMM + ParmEd (no BSS IO).
Reuses the ForceField and ParmEd Structure carried by
parametrized — built in the parametrization stage — so that AM1-BCC
charge assignment is not repeated. Writes GROMACS .gro and .top
files and returns a :class:SolvatedComplex that carries both the file
paths and the in-memory ParmEd structure.
Parameters¶
parametrized:
Output of :func:~gbsa_pipeline.parametrization.parametrize.
Must carry forcefield and parmed_structure (populated by the
OpenMM parametrization path).
params:
Solvation settings (water model, box shape/size, ion concentration).
output_gro:
Destination path for the solvated GROMACS coordinate file.
output_top:
Destination path for the solvated GROMACS topology file.
Returns:¶
SolvatedComplex Dataclass holding the written file paths and the in-memory ParmEd structure of the solvated system.
Raises:¶
ValueError
If parametrized was not produced by the OpenMM parametrization path
(i.e. forcefield or parmed_structure is None).
Source code in src/gbsa_pipeline/solvation_openmm.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | |