Skip to content

rsdefever/resp_library

Repository files navigation

RESP Library

License

Overview

RESP Library is a repository for calculating and distributing partial charges for molecular simulations with the restrained electrostatic potential (RESP) and RESP2 methods. The goal is to provide a growing library of molecules already-computed charges so that there is greater consistency and reproducibility of the partial charges used in molecular simulations.

Warning

RESP Library is in early development (0.x releases). The API may change unexpectedly.

Usage

There are a few ways to use RESP Library. If the molecule that you are interested in already exists, you can simply take the charges as provided in resp_library/lib/{molecule_name} and proceed. Molecules are listed by their IUPAC name (where spaces have been replaced by underscores. Charges are provided from the original method (RESP1) and the new RESP2 method. There is also a way to query the library:

import resp_library
smiles = "CC"
rdmol = resp_library.retrieve_charges(smiles, "RESP1")
for atom in rdmol.GetAtoms():
  print(f"{atom.GetSymbol()}: {atom.GetProp('q')}")

The retrieve_charges method returns an rdkit molecule with the partial charges specified as the atomic property q. If the molecule does not yet exist in resp_library, a RESPLibraryError is raised.

In this case, you can compute the charges for a new molecule and add them to the RESP Library with a pull request. This is a two-step procedure. First, you setup the calculation as follows:

import resp_library
smiles = "CCO"
resp_library.prepare_charge_calculation(smiles)

This creates a new directory with the IUPAC name corresponding to the SMILES string under resp_library/lib. The IUPAC name is autogenerated from the SMILES string from the NIH CACTUS server. Two subdirectories are created, RESP1 and RESP2. Inside of each, you will find a resp.yaml file. This file is mostly completed, but you will need to edit the charge_constraints and equality constraints to be correct for your molecule. The RESP procedure specifies that charge equality be enforced for symmetric groups and that the charges of polar centers and attached hydrogens be fixed for the second round of the RESP calculation. These two sections of the YAML file are used to specify these constraints. For example, in the case of ethanol, the oxygen and hydrogen bonded to oxygen would be constrained in the second-stage fitting, the 3 hydrogens bound to the first aliphatic carbon are constrained to have the same charge, and the two hydrogens bound to the middle carbon are constrained to have the same charge. Therefore, that section of the yaml file would be edited to become:

charge_constraints:
  - [3]  # O
  - [9]  # H
equality_constraints:
  - [4, 5, 6]  # H, H, H
  - [7, 8]  # H, H

The file resp_library/lib/{molecule_name}/template.pdb is generated by prepare_charge_calculation to provide the atom ordering. The atom numbering in the YAML file is 1-indexed. The other line of the YAML file that may need to be edited is the number of conformers to be generated; if the molecule has less than 5 atoms you should reduce this number from 5 to 2. rdkit will not be able to generate enough distinct conformers for very small molecules.

After updating the YAML files you may run the charge calculations. Depending on the size of the molecule this may take some time.

import resp_library
resp_library.calculate_charges("CCO", "RESP1")
resp_library.calculate_charges("CCO", "RESP2")

Unless you see errors, it is likely that the charge calculation was successful. The charges can be found under resp_library/lib/{molecule_name}/RESP1/results and resp_library/lib/{molecule_name}/RESP2/results. The RESP2 charges include both vacuum and implicit solvent (pcm) results.

To add the charges to the library, add and commit the new directory to a branch. For example:

git checkout -b add/ethanol
git add resp_library/ethanol/*
git commit -m "Add ethanol to RESP library"

RESP charges are only reliable to ~0.01q. Therefore, we provided rounded charges in the results folder. However, sometimes, during the charge rounding, the symmetry specified in the YAML file is broken. Please check and fix any broken symmetry manually while preserving the net charge of the molecule. These changes should be added as a second commit to clearly document the manual modifications.

Installation

Currently, installation from source is the only option. We recommend creating a conda environment to manage the depenedencies. Some dependencies are only available via pip. Note that it is important to do an editable installation from your fork of the repository if you plan on adding to the RESP library.

git clone git@github.com/rsdefever/resp_library.git
cd resp_library
conda create --name resp_lib --file requirements-conda.txt -c psi4/label/dev -c conda-forge
conda activate resp_lib
pip install -r requirements-pip.txt
pip install -e .

Credits

Development of RESP Library 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.

About

Store and retrieve RESP/RESP2 partial charges for small molecules

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages