A package to update the coordinates of molecular systems to match bond-length constraints. The package is designed to work with the MoSDeF tools and ParmEd.
constrainmol is still in early development (0.x releases). The API may change unexpectedly.
constrainmol usage is encapsulated in a single ConstrainedMolecule
class. Here we demonstrate a simple example: load a single molecule
from file, create the constrained molecule, solve for the new coordinates,
update the coordinates of molecule to their constrained values, and save
the result to file.
from constrainmol import ConstrainedMolecule
molecule = parmed.load_file("molecule.top", xyz="molecule.gro") # load a molecule w/ bond length info
constrained_mol = ConstrainedMolecule(molecule) # create the constrained molecule
constrained_mol.solve() # solve for the constrained coordinates
molecule.coordinates = constrained_mol.xyz # update the coordinates to their constrained values
molecule.save("constrained_molecule.gro") # save the new coordinates to disk
If there is a system with many molecules (with the same desired geometry),
the coordinates can be updated and repeatedly solved. This is faster
than creating a new ConstrainedMolecule
every time.
constrained_mol = ConstrainedMolecule(molecule)
constrained_mol.solve()
constrained_mol.update_xyz(new_coordinates)
constrained_mol.solve()
More examples are provided in the examples/
directory of this repository.
A conda installation is available. To create a new conda environment
(constrain
) and install constrainmol
into the environment, use:
conda create --name constrain constrainmol -c conda-forge
conda activate constrain
Installation from source is also supported:
git clone git@github.com/rsdefever/constrainmol.git
cd constrainmol/
conda create --name constrain --file requirements.txt -c conda-forge
conda activate constrain
pip install .
If you want to test your installation you can replace the steps above with the following:
git clone git@github.com/rsdefever/constrainmol.git
cd constrainmol/
conda create --name constrain --file requirements-dev.txt -c conda-forge -c mosdef -c omnia
conda activate constrain
pip install .
pytest constrainmol/tests
Development of constrainmol was supported by the National Science Foundation under grant NSF Grant Number 1835874. Any opinions, findings, and conclusions or recommendations expressed in this material are those of the author(s) and do not necessarily reflect the views of the National Science Foundation.