openmm / pdbfixer

PDBFixer fixes problems in PDB files
Other
461 stars 115 forks source link

Weird coordinates and unable to add Hydrogens upon adding tyrosines #304

Open sukritsingh opened 3 weeks ago

sukritsingh commented 3 weeks ago

I've noticed the following weird behaviors with pdbfixer upon mutating to a Tyrosine. The first one is on the latest stable release, the other is on the latest dev build:

First issue: If I take an input PDB file and then run the following commands on a stable installation:

from pdbfixer import PDBFixer
from openmm.app import PDBFile
fixer = PDBFixer(filename='test-ser-noPhos.pdb')
fixer.applyMutations(["SER-173-TYR"], "A")
fixer.findMissingResidues()
fixer.findMissingAtoms()
fixer.addMissingAtoms()
fixer.addMissingHydrogens(7.0)
PDBFile.writeFile(fixer.topology, fixer.positions, open('test-tyr-output.pdb', 'w'))

The commands run, but the coordinates for TYR173 look absolutely wrong. The extra bonds are probably just artifacts from pymol but it's putting the coordinates of the ring much closer together than normal. Screenshot below of "output tyrosine": image

Second issue: Weirdly, upon running the above code block from issue 1 with the latest dev version (Basically, since non-standard residue mutations were added), the above command block fails at fixer.addMissingHydrogens(7.0), giving the following stack trace:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[6], line 1
----> 1 fixer.addMissingHydrogens(7.0)

File ~/miniconda3/envs/dev-pdbfixer/lib/python3.9/site-packages/pdbfixer-1.9.0-py3.9.egg/pdbfixer/pdbfixer.py:1233, in PDBFixer.addMissingHydrogens(self, pH, forcefield)
   1210 def addMissingHydrogens(self, pH=7.0, forcefield=None):
   1211     """Add missing hydrogen atoms to the structure.
   1212 
   1213     Parameters
   (...)
   1231     >>> fixer.addMissingHydrogens(pH=8.0)
   1232     """
-> 1233     extraDefinitions = self._downloadNonstandardDefinitions()
   1234     variants = [self._describeVariant(res, extraDefinitions) for res in self.topology.residues()]
   1235     modeller = app.Modeller(self.topology, self.positions)

File ~/miniconda3/envs/dev-pdbfixer/lib/python3.9/site-packages/pdbfixer-1.9.0-py3.9.egg/pdbfixer/pdbfixer.py:1244, in PDBFixer._downloadNonstandardDefinitions(self)
   1240 def _downloadNonstandardDefinitions(self):
   1241     """If the file contains any nonstandard residues, download their definitions and build
   1242     the information needed to add hydrogens to them.
   1243     """
-> 1244     app.Modeller._loadStandardHydrogenDefinitions()
   1245     resnames = set(residue.name for residue in self.topology.residues())
   1246     definitions = {}

AttributeError: type object 'Modeller' has no attribute '_loadStandardHydrogenDefinitions'

I also appear to be getting this issue as well on Tryptophans. Any insight as to what might be going on?

peastman commented 3 weeks ago

The latest dev code for PDBFixer requires the latest dev build for OpenMM. It requires a function that was added since the last release.

sukritsingh commented 3 weeks ago

Oh! Let me try getting both dev builds – sounds like that will resolve both of these issues!

peastman commented 3 weeks ago

It might or might not fix the distorted ring. But if you just do a local energy minimization on the output structure, does that fix it?

sukritsingh commented 3 weeks ago

But if you just do a local energy minimization on the output structure, does that fix it?

I imagine it would, but will need to test it. That said, I can envision use cases where one might want to avoid (relatively expensive) minimization process, even if it was just in vacuo. Is there a way to just do minimization on just the ring?

peastman commented 3 weeks ago

You should assume anything coming out of PDBFixer needs energy minimization before it's ready to use.