Commit 2744212e by Josh A. Mitchell Committed by GitHub

Neutralise systems with formal charges from the PDB (#301)

* Add API to download formal charges for missing templates

* Use formal charges in _createForceField

* Add tests for formal charges

* Download charges from CCD when attempting to solvate

* Fix charges for default ion atom names

* Simplify formal charges logic

* Expose downloadFormalCharges and remove getAllFormalCharges

* Unify and cache CCD lookups

* Fix bugs

* Cache a failed CCD download

* Remove old formalCharges argument from registerTemplate

* Only attempt to download formal charges if they will be used

* Add SMILES to CCD cache

* Clean up new code and add docstrings

* Only apply formal charges when all and only atom names match between the CCD and PDB

* Allow formal charges to be set with or without leaving atoms

* Address concerns from code review

* Remove leftover reference to checkCache

* Do not cap chains in test_charge_and_solvate

* Add forceField optional argument to addSolvent

* Cap with glycine in tests

* Add another test with a charged ligand

* Cosmetic commit to re-trigger tests

* Update pdbfixer/pdbfixer.py
parent f9aae0bc
import pytest
from pdbfixer import PDBFixer
import openmm.unit
@pytest.mark.parametrize(
"pdbCode,soluteCharge",
[
("1PO0", -21),
("1A11", 1),
("110D", -5),
("1CNR", 0),
("1ESD", -21),
("25c8", -2),
],
)
def test_charge_and_solvate(pdbCode, soluteCharge):
"""
Test that addSolvent successfully neutralises systems
Parameters
----------
pdbCode : str
The PDB ID to test
soluteCharge : int
The formal charge of the solute - should equal the number of chloride
ions minus the number of sodium ions in the neutralised system. Note
that this may include ions from the original PDB entry.
"""
fixer = PDBFixer(pdbid=pdbCode)
fixer.findMissingResidues()
chainLengths = [len([*chain.residues()]) for chain in fixer.topology.chains()]
for chainidx, residx in list(fixer.missingResidues):
if residx == 0:
fixer.missingResidues[chainidx, residx] = ["GLY"]
elif residx == chainLengths[chainidx]:
fixer.missingResidues[chainidx, residx] = ["GLY"]
fixer.findMissingAtoms()
fixer.addMissingAtoms()
fixer.addMissingHydrogens(pH=7.4)
fixer.addSolvent(
padding=2.0 * openmm.unit.nanometer,
ionicStrength=0.1 * openmm.unit.molar,
boxShape="dodecahedron",
)
numCl = sum(1 for res in fixer.topology.residues() if res.name.lower() == "cl")
numNa = sum(1 for res in fixer.topology.residues() if res.name.lower() == "na")
assert soluteCharge == numCl - numNa
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment