### Install Sphinx and ReadTheDocs Theme Source: https://github.com/openmm/openmmforcefields/blob/main/docs/README.md Install the necessary Sphinx and ReadTheDocs theme packages using Conda. This is a prerequisite for compiling the documentation. ```bash conda install sphinx sphinx_rtd_theme ``` -------------------------------- ### Example CHARMM Force Field Source: https://github.com/openmm/openmmforcefields/blob/main/docs/index.md This is a placeholder for a CHARMM force field example. Note that this conversion has not yet been fully validated. ```text * ``` -------------------------------- ### Install AmberTools and run conversion script Source: https://github.com/openmm/openmmforcefields/blob/main/amber/README.md Install the necessary AmberTools package from conda-forge and then execute the main driver script `convert.sh` to regenerate all force fields. The outputs will be placed in `openmmforcefields/ffxml/amber`. ```bash conda install -c conda-forge --yes ambertools ./convert.sh ``` -------------------------------- ### Run CHARMM Docker Image Interactively Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/README.md Manually starts the Docker image for interactive testing. This command allows direct access to the CHARMM environment within the container. ```bash docker run -i -t test_charmm ``` -------------------------------- ### Create and Register EspalomaTemplateGenerator for Benzene Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Demonstrates creating an EspalomaTemplateGenerator for a single molecule (benzene) from SMILES and registering it with an OpenMM ForceField object. Requires OpenFF Toolkit and espaloma to be installed. ```python # Create an OpenFF Molecule object for benzene from SMILES from openff.toolkit import Molecule molecule = Molecule.from_smiles("c1ccccc1") # Create the SMIRNOFF template generator with the released espaloma-0.3.2 force field from openmmforcefields.generators import ( EspalomaTemplateGenerator, ) espaloma = EspalomaTemplateGenerator(molecules=molecule, forcefield="espaloma-0.3.2") # Create an OpenMM ForceField object with AMBER ff14SB and TIP3P with compatible ions from openmm.app import ForceField forcefield = ForceField( "amber/protein.ff14SB.xml", "amber/tip3p_standard.xml", "amber/tip3p_HFE_multivalent.xml", ) # Register the SMIRNOFF template generator forcefield.registerTemplateGenerator(espaloma.generator) ``` -------------------------------- ### List Available Installed Force Fields Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Accesses a class attribute to list the abbreviated names of SMIRNOFF force fields installed with the OpenFF Toolkit. ```python >>> SMIRNOFFTemplateGenerator.INSTALLED_FORCEFIELDS ['openff-1.0.0', 'openff-1.0.1', 'openff-1.1.0', 'openff-1.1.1', ...] ``` -------------------------------- ### Install OpenMMForceFields using Conda Source: https://github.com/openmm/openmmforcefields/blob/main/docs/getting_started.md Installs the OpenMMForceFields package and its dependencies using the conda package manager. Ensure you are using the conda-forge channel. ```bash conda install --yes -c conda-forge openmmforcefields ``` -------------------------------- ### YAML configuration for LEAPRC mode with tests Source: https://github.com/openmm/openmmforcefields/blob/main/amber/README.md Example YAML configuration for `LEAPRC` mode, specifying the source `leaprc` file, its reference, and the types of tests to perform on the resulting OpenMM force field. This is commonly used for biopolymer force fields. ```yaml - Source: leaprc.ff14SB Reference: - >- Maier, J.A., Martinez, C., Kasavajhala, K., Wickstrom, L., Hauser, K.E., and Simmerling, C. (2015). ff14SB: Improving the Accuracy of Protein Side Chain and Backbone Parameters from ff99SB. J. Chem. Theory Comput. 11, 3696-3713. Test: - protein - nucleic ``` -------------------------------- ### Initialize Input and Output Streams Source: https://github.com/openmm/openmmforcefields/blob/main/openmmforcefields/data/minidrugbank/Filter unspecified stereochemistry.ipynb Set up input and output streams for SDF files. The input file is 'MiniDrugBank.sdf' and the output file will be 'MiniDrugBank-without-unspecifie-stereochemistry.sdf'. ```python ifs = oechem.oemolistream("MiniDrugBank.sdf") ofs = oechem.oemolostream("MiniDrugBank-without-unspecifie-stereochemistry.sdf") ``` -------------------------------- ### Show convert_amber.py help options Source: https://github.com/openmm/openmmforcefields/blob/main/amber/README.md Run this command to see all available command-line options for the `convert_amber.py` script, which is used for converting Amber force fields to OpenMM format. ```bash python convert_amber.py -h ``` -------------------------------- ### Compile Documentation with Makefile Source: https://github.com/openmm/openmmforcefields/blob/main/docs/README.md Use the provided Makefile to compile the static HTML documentation pages. The compiled output will be located in the '_build' directory. ```bash make html ``` -------------------------------- ### Build CHARMM Docker Image Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/README.md Builds a Docker image containing the CHARMM binary. Ensure Docker is running and CHARMM is downloaded as 'charmm.tar.gz'. The image name can be customized. ```bash docker build -t test_charmm . ``` -------------------------------- ### Create EspalomaTemplateGenerator from Local File Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Demonstrates creating an EspalomaTemplateGenerator using a local path to an espaloma model file. ```python espaloma = EspalomaTemplateGenerator( molecules=molecules, forcefield="/path/to/espaloma-0.3.2.pt", ) ``` -------------------------------- ### Generate GAFF Parameters for Benzene and Create OpenMM System Source: https://github.com/openmm/openmmforcefields/blob/main/README.md This snippet demonstrates creating an OpenFF Molecule for benzene, initializing a GAFFTemplateGenerator, setting up an OpenMM ForceField, registering the generator, and finally creating an OpenMM System from a PDB file. It shows the complete workflow for parameterizing a molecule with GAFF. ```python from openff.toolkit import Molecule molecule = Molecule.from_smiles("c1ccccc1") from openmmforcefields.generators import ( GAFFTemplateGenerator, ) gaff = GAFFTemplateGenerator(molecules=molecule, forcefield="gaff-2.2.20") from openmm.app import ForceField forcefield = ForceField( "amber/protein.ff14SB.xml", "amber/tip3p_standard.xml", "amber/tip3p_HFE_multivalent.xml", ) forcefield.registerTemplateGenerator(gaff.generator) from openmm.app import PDBFile pdbfile = PDBFile("t4-lysozyme-L99A-with-benzene.pdb") system = forcefield.createSystem(pdbfile.topology) ``` -------------------------------- ### Run convert_amber.py with a YAML input file Source: https://github.com/openmm/openmmforcefields/blob/main/amber/README.md Execute the `convert_amber.py` script directly, providing a YAML file that specifies the desired conversion task. This offers more granular control over the conversion process. ```bash python convert_amber.py --input name_of_your_yaml.yaml ``` -------------------------------- ### Create EspalomaTemplateGenerator from URL Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Illustrates creating an EspalomaTemplateGenerator by providing a URL to an espaloma model file. ```python espaloma = EspalomaTemplateGenerator( molecules=molecules, forcefield="https://github.com/choderalab/espaloma/releases/download/0.3.2/espaloma-0.3.2.pt", ) ``` -------------------------------- ### Load AMBER Force Field with TIP3P and Salt Models Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Load the ff14SB force field with TIP3P solvent models and recommended Joung and Cheatham salt models, including divalent counterions. ```python forcefield = ForceField( "amber/protein.ff14SB.xml", "amber/tip3p_standard.xml", "amber/tip3p_HFE_multivalent.xml", ) ``` -------------------------------- ### Create EspalomaTemplateGenerator with Cache Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Illustrates initializing an EspalomaTemplateGenerator with a cache file to store and retrieve pre-parameterized molecules, improving efficiency for repeated use. ```python espaloma = EspalomaTemplateGenerator( cache="espaloma-molecules.json", forcefield="espaloma-0.3.2", ) ``` -------------------------------- ### Initialize SMIRNOFFTemplateGenerator with Multiple Molecules from SDF Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Reads multiple molecules from an SDF file and initializes the SMIRNOFFTemplateGenerator with them. ```python molecules = Molecule.from_file("molecules.sdf") smirnoff = SMIRNOFFTemplateGenerator(molecules=molecules, forcefield="openff-2.3.0") ``` -------------------------------- ### Configure SystemGenerator for Periodic and Non-Periodic Systems Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Configures a SystemGenerator to use PME for periodic systems and NoCutoff for non-periodic systems. This allows fine-tuning of non-bonded method parameters based on system periodicity. ```python from openmm import app system_generator = SystemGenerator( forcefields=[ "amber/ff14SB.xml", "amber/tip3p_standard.xml", ], periodic_forcefield_kwargs={"nonbondedMethod": app.LJPME}, nonperiodic_forcefield_kwargs={"nonbondedMethod": app.CutoffNonPeriodic}, ) ``` -------------------------------- ### Create EspalomaTemplateGenerator from SDF File Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Shows how to create an EspalomaTemplateGenerator for multiple molecules loaded from an SDF file, using a specified espaloma force field release. ```python molecules = Molecule.from_file("molecules.sdf") # Create an espaloma residue template generator from the espaloma-0.3.2 release, # retrieving it automatically from GitHub release artifacts espaloma = EspalomaTemplateGenerator(molecules=molecules, forcefield="espaloma-0.3.2") ``` -------------------------------- ### Download CHARMM Force Field Files Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/README.md Use wget to download the CHARMM force field parameter files and tar to unpack them. Some Drude parameters are in a separate tarball. ```bash wget -O toppar.tgz http://mackerell.umaryland.edu/download.php?filename=CHARMM_ff_params_files/toppar_c36_jul24.tgz tar -xzf toppar.tgz (cd toppar/drude; tar -xzf drude_toppar_2023.tgz) ``` -------------------------------- ### Generate SMIRNOFF Parameters for Benzene Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Creates an OpenFF Molecule for benzene, initializes a SMIRNOFFTemplateGenerator, sets up an OpenMM ForceField, and registers the generator to create a System. ```python from openff.toolkit import Molecule molecule = Molecule.from_smiles("c1ccccc1") from openmmforcefields.generators import SMIRNOFFTemplateGenerator smirnoff = SMIRNOFFTemplateGenerator(molecules=molecule, forcefield="openff-2.3.0") from openmm.app import ForceField forcefield = ForceField( "amber/protein.ff14SB.xml", "amber/tip3p_standard.xml", "amber/tip3p_HFE_multivalent.xml", ) forcefield.registerTemplateGenerator(smirnoff.generator) import openmm.unit system = forcefield.createSystem( topology=molecule.to_topology().to_openmm(), nonbondedCutoff=0.9 * openmm.unit.nanometer, switchDistance=0.8 * openmm.unit.nanometer, ) ``` -------------------------------- ### Test Converted Force Fields Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/README.md Run the testing script to validate the converted force fields by comparing energies and forces against original CHARMM files and OpenMM's direct reading capabilities. This may also take several minutes. ```bash ./test_charmm.sh ``` -------------------------------- ### Initialize SystemGenerator with GAFF and AMBER Force Fields Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Initializes a SystemGenerator using GAFF 2.2.20 and AMBER ff14SB force fields. This is useful for parameterizing small molecules with standard AMBER protein force fields and compatible solvent models. Parameterized molecules are cached in 'db.json'. ```python from openmm import unit from openmm import app forcefield_kwargs = { "constraints": app.HBonds, "rigidWater": True, "removeCMMotion": False, "hydrogenMass": 4 * unit.amu, } from openmmforcefields.generators import SystemGenerator system_generator = SystemGenerator( forcefields=[ "amber/ff14SB.xml", "amber/tip3p_standard.xml", ], small_molecule_forcefield="gaff-2.2.20", forcefield_kwargs=forcefield_kwargs, cache="db.json", ) system = system_generator.create_system(openmm_topology) molecules = Molecule.from_file("molecules.sdf", file_format="sdf") system = system_generator.create_system(openmm_topology, molecules=molecules) ``` -------------------------------- ### Align Ligand in PyMOL Source: https://github.com/openmm/openmmforcefields/blob/main/openmmforcefields/data/perses_jacs_systems/README.md Use these PyMOL commands to select and align ligand atoms before saving the shifted ligand conformation to an SDF file. ```python PyMOL>`select to_move, X_ligands and symbol c` PyMOL>`select target, target and symbol c` PyMOL>`fit t0_move, target, matchmaker=4` PyMOL>`save X_ligands_shifted.sdf, X_ligands,state=0` ``` -------------------------------- ### Initialize SMIRNOFFTemplateGenerator with Cache Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Initializes the SMIRNOFFTemplateGenerator with a cache file. Newly parameterized molecules will be written to this cache for future use. ```python smirnoff = SMIRNOFFTemplateGenerator( cache="smirnoff-molecules.json", forcefield="openff-2.3.0", ) ``` -------------------------------- ### YAML configuration for LEAPRC mode with options Source: https://github.com/openmm/openmmforcefields/blob/main/amber/README.md This YAML configuration demonstrates how to specify optional parameters for a `LEAPRC` mode conversion, such as filtering warnings or writing unused parameters. It also includes reference information and test types. ```yaml - Source: leaprc.phosaa10 Reference: - >- Steinbrecher, T., Latzer, J., and Case, D.A. (2012). Revised AMBER parameters for bioorganic phosphates. J. Chem. Theory Comput. 8, 4405-4412. Options: filter_warnings: always write_unused: True Test: - protein_phospho ``` -------------------------------- ### Import OpenEye OEChem Toolkit Source: https://github.com/openmm/openmmforcefields/blob/main/openmmforcefields/data/minidrugbank/Filter unspecified stereochemistry.ipynb Import the necessary OEChem module from the OpenEye Python toolkit. ```python from openeye import oechem ``` -------------------------------- ### Tagging a Release with Git Source: https://github.com/openmm/openmmforcefields/blob/main/devtools/README.md Use this command to tag the latest commit for a new release. Ensure you follow semantic versioning. ```bash git tag -a X.Y.Z [latest pushed commit] && git push --follow-tags ``` -------------------------------- ### Create GAFF Template Generator for Multiple Molecules from SDF Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Initializes a GAFFTemplateGenerator with multiple molecules loaded from an SDF file. This is useful for parameterizing systems containing several small molecules. ```python molecules = Molecule.from_file("molecules.sdf") gaff = GAFFTemplateGenerator(molecules=molecules, forcefield="gaff-2.2.20") ``` -------------------------------- ### Load CHARMM Force Field Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Load the CHARMM36 force field for biomolecular system parameterization. ```python forcefield = ForceField("charmm/charmm36.xml") ``` -------------------------------- ### Convert CHARMM Force Fields Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/README.md Execute the conversion script to transform CHARMM force field files into OpenMM ffxml format. This process may take several minutes. ```bash ./convert_charmm.sh ``` -------------------------------- ### List Supported GAFF Versions Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Prints the available GAFF force field versions that can be used with GAFFTemplateGenerator. This helps in selecting the correct GAFF version for parameterization. ```python print(GAFFTemplateGenerator.INSTALLED_FORCEFIELDS) ``` -------------------------------- ### Pass Docker Image to Test Scripts Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/README.md Executes test scripts using a CHARMM Docker image. Specify the image name using the --charmm-docker-image flag. ```bash test_charmm.py --charmm-docker-image test_charmm ``` ```bash test_charmm.sh --charmm-docker-image test_charmm ``` -------------------------------- ### Standard Water and Ion Combination Configuration Source: https://github.com/openmm/openmmforcefields/blob/main/amber/README.md Defines a standard combination of water model (tip3p) with monovalent and +2 ions. This configuration is used as a base for further overloading. ```yaml - Source: - parm/frcmod.ionsjc_tip3p - parm/frcmod.ionslrcm_cm_tip3p - lib/atomic_ions.lib Solvent_source: tip3p.xml Solvent: tip3p Name: tip3p_standard Reference: - >- Joung, I.S., and Cheatham, Thomas E. (2008). Determination of Alkali and Halide Monovalent Ion Parameters for Use in Explicitly Solvated Biomolecular Simulations. J. Phys. Chem. B 112, 9020-9041. - >- Joung, I.S., and Cheatham, T.E. (2009). Molecular Dynamics Simulations of the Dynamic and Energetic Properties of Alkali and Halide Ions Using Water-Model-Specific Ion Parameters. J. Phys. Chem. B 113, 13279-13290. - >- Li, P., Roberts, B.P., Chakravorty, D.K., and Merz, K.M. (2013). Rational Design of Particle Mesh Ewald Compatible Lennard-Jones Parameters for +2 Metal Cations in Explicit Solvent. J. Chem. Theory Comput. 9, 2733-2748. - >- Jorgensen, W.L., Chandrasekhar, J., Madura, J.D., Impey, R.W., and Klein, M.L. (1983). Comparison of simple potential functions for simulating liquid water. The Journal of Chemical Physics 79, 926-935. Test: - water_ion ``` -------------------------------- ### Initialize GAFFTemplateGenerator with a Cache File Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Creates a GAFFTemplateGenerator that uses a specified JSON file for caching pre-computed molecule parameters. This speeds up subsequent parameterization by reusing cached data. ```python generator = GAFFTemplateGenerator(cache="gaff-molecules.json", forcefield="gaff-1.8") ``` -------------------------------- ### Run convert_amber.py with a leaprc input file Source: https://github.com/openmm/openmmforcefields/blob/main/amber/README.md Use the `convert_amber.py` script to convert a force field specified in a `leaprc` file. This method is an alternative to using YAML configuration files. ```bash python convert_amber.py --input name_of_your_leaprc --input-format leaprc ``` -------------------------------- ### Select and Save Protein with CONECT Lines (PyMOL) Source: https://github.com/openmm/openmmforcefields/blob/main/openmmforcefields/data/perses_jacs_systems/cdk2/README.md Use this PyMOL command to select the protein from a merged PDB file and save it as a new PDB. Ensure CONECT lines are retained, which is crucial for non-native amino acids. ```pymol select protein, `*merged.pdb` and polymer ``` ```pymol save protein.pdb, protein, conect=1 ``` -------------------------------- ### Add Harmonic Improprials to OpenMM System Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/convert_charmm_improper_script.txt Creates a CustomTorsionForce for harmonic improprials, defines its parameters (k and theta0), and adds each identified harmonic improper to this force. ```python if harmonic_impropers: harmonic_force = openmm.CustomTorsionForce( f"k*min(dtheta, 2*pi - dtheta)^2; dtheta = abs(theta - theta0); pi = {{math.pi}}" ) harmonic_force.addPerTorsionParameter("k") harmonic_force.addPerTorsionParameter("theta0") for improper in harmonic_impropers: harmonic_force.addTorsion(*improper) sys.addForce(harmonic_force) ``` -------------------------------- ### Load AMBER ff14SB Force Field Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Load the recommended ff14SB force field along with accompanying ions and solvent models for biomolecular systems. ```python forcefield = ForceField("amber/protein.ff14SB.xml") ``` -------------------------------- ### YAML MODE declaration for RECIPE conversion Source: https://github.com/openmm/openmmforcefields/blob/main/amber/README.md Set the `MODE` to `RECIPE` in the YAML file for converting water and ion force fields. This mode uses a combination of `.dat`, `frcmod`, and `.lib` files instead of a `leaprc` file. ```yaml - MODE: RECIPE ``` -------------------------------- ### Multivalent Ion Overloading Configuration for tip3p Water Source: https://github.com/openmm/openmmforcefields/blob/main/amber/README.md Defines an 'overloading' set for tip3p water, including +2, +3, and +4 ions. This configuration is loaded after a standard set to modify ion parameters. ```yaml - Source: - parm/frcmod.ionslrcm_hfe_tip3p - parm/frcmod.ions34lsm_hfe_tip3p - lib/atomic_ions.lib Standard: tip3p_standard Solvent: tip3p Name: tip3p_HFE_multivalent Reference: - >- Li, P., Roberts, B.P., Chakravorty, D.K., and Merz, K.M. (2013). Rational Design of Particle Mesh Ewald Compatible Lennard-Jones Parameters for +2 Metal Cations in Explicit Solvent. J. Chem. Theory Comput. 9, 2733-2748. - >- Li, P., Song, L.F., and Merz, K.M. (2015). Parameterization of Highly Charged Metal Ions Using the 12-6-4 LJ-Type Nonbonded Model in Explicit Water. J. Phys. Chem. B 119, 883-895. Test: - water_ion ``` -------------------------------- ### Add Molecules to Existing Generator Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Demonstrates adding individual molecules or a list of molecules to a SMIRNOFFTemplateGenerator after its initialization. ```python smirnoff.add_molecules(molecule) smirnoff.add_molecules([molecule1, molecule2]) ``` -------------------------------- ### OpenMM Source Package Version Source: https://github.com/openmm/openmmforcefields/blob/main/amber/README.md Specifies the OpenMM version used as a source for water models. ```yaml - sourcePackage2: OpenMM sourcePackageVersion2: 7.5.0 ``` -------------------------------- ### YAML structure for AmberTools source package Source: https://github.com/openmm/openmmforcefields/blob/main/amber/README.md The first entry in the YAML configuration file must declare the source package as AmberTools and specify its version. This sets the context for the subsequent conversion instructions. ```yaml - sourcePackage: AmberTools sourcePackageVersion: 15 ``` -------------------------------- ### Specify SMIRNOFF Force Field Sources Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Shows various ways to specify the SMIRNOFF force field, including versioned names, OFFXML file paths, and loading from multiple sources. ```python # Create a SMIRNOFF residue template generator from an older Sage or Parsley version smirnoff = SMIRNOFFTemplateGenerator(molecules=molecules, forcefield="openff-1.3.0") # Request a specific SMIRNOFF force field installed with OpenFF by its full name smirnoff = SMIRNOFFTemplateGenerator(molecules=molecules, forcefield="openff_unconstrained-1.3.0.offxml") # Use a local .offxml file instead smirnoff = SMIRNOFFTemplateGenerator(molecules=molecules, forcefield="local-file.offxml") # Load from multiple sources at once smirnoff = SMIRNOFFTemplateGenerator(molecules=molecule, forcefield=['openff-2.3.0', 'tip5p.offxml']) ``` -------------------------------- ### Load AMBER ff14SB Force Field (Core Only) Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Load only the ff14SB force field, converted from oldff/leaprc.ff14SB. ```python forcefield = ForceField("amber/ff14SB.xml") ``` -------------------------------- ### Add Molecules to an Existing GAFFTemplateGenerator Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Demonstrates how to add individual molecules or a list of molecules to a GAFFTemplateGenerator after its initial creation. This allows for dynamic updates to the generator's molecule set. ```python gaff.add_molecules(molecule) gaff.add_molecules([molecule1, molecule2]) ``` -------------------------------- ### Read, Filter, and Write Molecules Source: https://github.com/openmm/openmmforcefields/blob/main/openmmforcefields/data/minidrugbank/Filter unspecified stereochemistry.ipynb Iterate through molecules from the input stream. For each molecule, it is read and then written to the output stream. This specific snippet does not include the filtering logic for stereochemistry, implying it's a placeholder or part of a larger process. ```python mol = oechem.OEGraphMol() while oechem.OEReadMolecule(ifs, mol): oechem.OEWriteMolecule(ofs, mol) ``` -------------------------------- ### Versioneer Versioning Regex Source: https://github.com/openmm/openmmforcefields/blob/main/devtools/README.md This regular expression is used by Versioneer to parse PEP 440 compliant version strings from git tags. ```regexp \d+.\d+.\d+(?P\+\d+-[a-z0-9]+) ``` -------------------------------- ### Display Loaded SMIRNOFF Filenames Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Retrieves and displays the full paths of the SMIRNOFF force field files that have been loaded by the generator. ```python >>> smirnoff.smirnoff_filenames ['/.../offxml/openff_unconstrained-2.3.0.offxml', '/.../offxml/tip5p.offxml'] ``` -------------------------------- ### Add Periodic Improprials to OpenMM System Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/convert_charmm_improper_script.txt If periodic improprials are found, this code ensures a PeriodicTorsionForce exists in the OpenMM System and adds each identified improper to it. ```python if periodic_impropers: periodic_force = None for force in sys.getForces(): if isinstance(force, openmm.PeriodicTorsionForce): periodic_force = force break if periodic_force is None: periodic_force = openmm.PeriodicTorsionForce() sys.addForce(periodic_force) for improper in periodic_impropers: periodic_force.addTorsion(*improper) ``` -------------------------------- ### Configure Static Path in conf.py Source: https://github.com/openmm/openmmforcefields/blob/main/docs/_static/README.md Set the `templates_path` in your Sphinx `conf.py` file to specify the directory for custom static files. Files in this directory will overwrite built-in files with the same name. ```python templates_path = ["_static"] ``` -------------------------------- ### Configure HTML Static Path in Sphinx Source: https://github.com/openmm/openmmforcefields/blob/main/docs/_templates/README.md Set the `html_static_path` in your Sphinx `conf.py` file to include the `_templates` directory. This allows Sphinx to find and use custom HTML templates. ```python html_static_path = ["_templates"] ``` -------------------------------- ### Process Residue and Patch Anisotropies Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/convert_charmm_anisotropy_script.txt Iterates through topology residues, extracts template names, and identifies relevant residue and patch anisotropies based on predefined dictionaries. It also handles multi-residue patches by parsing atom names. ```python residue_data = [] for residue in topology.residues(): # Extract the residue or patch names and atom names. templates = set() if residue not in templateForResidue: # Multi-residue patch; fall back to parsing atom names. atom_names = [] skip_residue = False for atom in residue.atoms(): atom_name = extract_atom_name(data.atomType[atom], templates) if atom_name is None: # Skip residues containing atoms without template name data # (they might be from, e.g., another solvent force field file). skip_residue = True break atom_names.append(atom_name) if skip_residue: residue_data.append(([], [], [])) continue else: # Extract names from template name. template_data = templateForResidue[residue] for template_index, template_name in enumerate(template_data.name.split("-")): if template_index: # Patch name. templates.add(template_name.rsplit("_", maxsplit=1)[0]) else: # Residue name. templates.add(template_name) atom_names = [template_data.atoms[data.atomTemplateIndexes[atom]].name for atom in residue.atoms()] # Get all unique residue or patch names that have anisotropies. residue_templates = sorted( (template for template in templates if template in residue_anisotropies), key=residue_order.get ) patch_templates = sorted( (template for template in templates if template in patch_anisotropies), key=patch_order.get ) # Get atom indices and classes for lookup, and ensure atom name uniqueness. atom_data = { atom_name: (atom.index, self._atomTypes[data.atomType[atom]].atomClass) for atom, atom_name in zip(residue.atoms(), atom_names) } if len(atom_data) != len(atom_names): raise ValueError(f"CHARMM: atom name collision in residue with index {residue.index}") residue_data.append((atom_data, residue_templates, patch_templates)) ``` -------------------------------- ### Build Anisotropy Table Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/convert_charmm_anisotropy_script.txt Constructs a table of anisotropies by iterating through processed residue and patch data. It merges anisotropies, removes specified Drude atoms, and maps atom data to anisotropy parameters. ```python anisotropy_table = {} for residue_index, (atom_data, residue_templates, patch_templates) in enumerate(residue_data): # Determine all anisotropies to try to add to this residue. anisotropies = {} for residue in residue_templates: anisotropies.update(residue_anisotropies.get(residue, {})) for patch in patch_templates: for drude_atom in delete_anisotropies.get(patch, []): if drude_atom in anisotropies: del anisotropies[drude_atom] anisotropies.update(patch_anisotropies.get(patch, {})) # Find the atoms, and skip if any cannot be found. for atom_1, (atom_2, atom_3, atom_4, aniso12, aniso34) in anisotropies.items(): atom_data_1 = atom_data.get(atom_1) atom_data_2 = atom_data.get(atom_2) atom_data_3 = atom_data.get(atom_3) atom_data_4 = atom_data.get(atom_4) if atom_data_1 is None or atom_data_2 is None or atom_data_3 is None or atom_data_4 is None: continue anisotropy_table[atom_data_1[0]] = (atom_data_2[0], atom_data_3[0], atom_data_4[0], aniso12, aniso34) ``` -------------------------------- ### Load AMBER ff99SBildn Force Field Source: https://github.com/openmm/openmmforcefields/blob/main/README.md Load the older, now outdated, ff99SBildn force field converted from oldff/leaprc.ff14SB. ```python forcefield = ForceField("amber/ff99SBildn.xml") ``` -------------------------------- ### Apply Anisotropies to Drude Force Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/convert_charmm_anisotropy_script.txt Applies the generated anisotropy table to the Drude force in an OpenMM system. It iterates through Drude force particles and updates their parameters if they are present in the anisotropy table. ```python # Add anisotropies to Drude particles. for force in sys.getForces(): if not isinstance(force, openmm.DrudeForce): continue for particle_index in range(force.getNumParticles()): particle, particle1, particle2, particle3, particle4, charge, polarizability, aniso12, aniso34 = force.getParticleParameters(particle_index) if particle1 in anisotropy_table: particle2, particle3, particle4, aniso12, aniso34 = anisotropy_table[particle1] force.setParticleParameters(particle_index, particle, particle1, particle2, particle3, particle4, charge, polarizability, aniso12, aniso34) ``` -------------------------------- ### Process Residue Topology Data Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/convert_charmm_improper_script.txt Iterates through topology residues to extract template names and atom names, preparing data for improper identification. Handles multi-residue patches by parsing atom names. ```python residue_data = [] for residue in topology.residues(): # Extract the residue or patch names and atom names. templates = set() if residue not in templateForResidue: # Multi-residue patch; fall back to parsing atom names. atom_names = [] skip_residue = False for atom in residue.atoms(): atom_name = extract_atom_name(data.atomType[atom], templates) if atom_name is None: # Skip residues containing atoms without template name data # (they might be from, e.g., another solvent force field file). skip_residue = True break atom_names.append(atom_name) if skip_residue: residue_data.append(([], [], [])) continue else: # Extract names from template name. template_data = templateForResidue[residue] for template_index, template_name in enumerate(template_data.name.split("-")): if template_index: # Patch name. templates.add(template_name.rsplit("_", maxsplit=1)[0]) else: # Residue name. templates.add(template_name) atom_names = [template_data.atoms[data.atomTemplateIndexes[atom]].name for atom in residue.atoms()] # Get all unique residue or patch names that have impropers. residue_templates = sorted( (template for template in templates if template in residue_impropers), key=residue_order.get ) patch_templates = sorted( (template for template in templates if template in patch_impropers), key=patch_order.get ) # Get atom indices and classes for lookup, and ensure atom name uniqueness. atom_data = { atom_name: (atom.index, self._atomTypes[data.atomType[atom]].atomClass) for atom, atom_name in zip(residue.atoms(), atom_names) } if len(atom_data) != len(atom_names): raise ValueError(f"CHARMM: atom name collision in residue with index {residue.index}") residue_data.append((atom_data, residue_templates, patch_templates)) ``` -------------------------------- ### Process CHARMM Improper Definitions Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/convert_charmm_improper_script.txt Iterates through residue data to identify and classify improper torsion definitions. It checks for valid atom indices and classes, then determines if the improper is periodic or harmonic. Raises errors for ambiguous cases. ```python for offset, atom_name in improper: offset_index = residue_index + offset if not 0 <= offset_index < len(residue_data): skip = True break offset_atom_data = residue_data[offset_index][0] if atom_name not in offset_atom_data: skip = True break atom_index, atom_class = offset_atom_data[atom_name] atom_indices.append(atom_index) atom_classes.append(atom_class) if skip: continue # Skip if this is not a legitimate improper (this could happen if it # refers to an adjacent residue in, e.g., an entirely different chain). if not is_valid_improper(atom_indices): continue periodic_improper = find_improper(periodic_improper_types, atom_classes) harmonic_improper = find_improper(harmonic_improper_types, atom_classes) if periodic_improper is None: if harmonic_improper is None: raise ValueError(f"CHARMM: neither periodic nor harmonic improper found for {{atom_classes}}") else: harmonic_impropers.append((*atom_indices, *harmonic_improper)) else: if harmonic_improper is None: periodic_impropers.append((*atom_indices, *periodic_improper)) else: raise ValueError(f"CHARMM: both periodic and harmonic impropers found for {{atom_classes}}") ``` -------------------------------- ### Determine Improprieties for a Residue Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/convert_charmm_improper_script.txt Collects all relevant improper definitions for a given residue, considering both residue-specific and patch-specific impropers, and handling deletions specified by patches. ```python periodic_impropers = [] harmonic_impropers = [] for residue_index, (atom_data, residue_templates, patch_templates) in enumerate(residue_data): # Determine all impropers to try to add to this residue. Use a list to # try to maintain a consistent order. There should not be many impropers # per residue so this should not be a significant performance issue. impropers = [] for residue in residue_templates: for improper in residue_impropers.get(residue, []): if improper not in impropers: impropers.append(improper) for patch in patch_templates: for improper in delete_impropers.get(patch, []): if improper in impropers: impropers.remove(improper) for improper in patch_impropers.get(patch, []): if improper not in impropers: impropers.append(improper) for improper in impropers: # Find the atoms in the improper. Skip if any cannot be found. atom_indices = [] atom_classes = [] skip = False ``` -------------------------------- ### Extract Atom Name from Raw Name Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/convert_charmm_anisotropy_script.txt Parses raw atom names, handling Drude particles and extracting template information. Returns None if the atom name cannot be parsed. ```python def extract_atom_name(raw_atom_name, templates): # Process Drude particles. atom_name_prefix = "" if raw_atom_name.startswith("Drude-"): raw_atom_name = raw_atom_name[len("Drude-"):] atom_name_prefix = "D" # Return None to indicate an atom without template name information. atom_name_parts = raw_atom_name.rsplit("-", maxsplit=1) if len(atom_name_parts) < 2: return None templates.add(atom_name_parts[0]) return f"{atom_name_prefix}{atom_name_parts[1]}" ``` -------------------------------- ### YAML MODE declaration for LEAPRC conversion Source: https://github.com/openmm/openmmforcefields/blob/main/amber/README.md Specify the `LEAPRC` mode in the YAML file to indicate that the conversion should be performed using parameters from a `leaprc` file. This mode is typically used for protein and nucleic acid force fields. ```yaml - MODE: LEAPRC ``` -------------------------------- ### Find Improper Type by Atom Classes Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/convert_charmm_improper_script.txt Searches for an improper type definition using a list of atom classes, supporting wildcards (represented by None). ```python def find_improper(improper_types, atom_classes): # Try all combinations of wildcards. for wildcard_count in range(len(atom_classes) + 1): for wildcard_indices in itertools.combinations(range(len(atom_classes)), wildcard_count): lookup_key = list(atom_classes) for wildcard_index in wildcard_indices: lookup_key[wildcard_index] = None lookup_key = tuple(lookup_key) if lookup_key in improper_types: return improper_types[lookup_key] return None ``` -------------------------------- ### Validate Improper Atom Indices Source: https://github.com/openmm/openmmforcefields/blob/main/charmm/convert_charmm_improper_script.txt Checks if a given set of atom indices constitutes a valid improper torsion based on bonded atom information. ```python def is_valid_improper(atom_indices): index_1, index_2, index_3, index_4 = atom_indices bonded_to_1 = data.bondedToAtom[index_1] bonded_to_4 = data.bondedToAtom[index_4] is_improper_1 = index_2 in bonded_to_1 and index_3 in bonded_to_1 and index_4 in bonded_to_1 is_improper_4 = index_1 in bonded_to_4 and index_2 in bonded_to_4 and index_3 in bonded_to_4 return is_improper_1 or is_improper_4 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.