Commit 489551d6 authored by Jason Swails's avatar Jason Swails
Browse files

Fix remaining bugs with CHARMM integration.

parent f5df12e8
...@@ -36,3 +36,6 @@ class CmapError(CharmmError): ...@@ -36,3 +36,6 @@ class CmapError(CharmmError):
class BondError(CharmmError): class BondError(CharmmError):
""" Prevent an atom from bonding to itself """ """ Prevent an atom from bonding to itself """
class MoleculeError(CharmmError):
""" For (impossibly) messed up connectivity """
...@@ -12,8 +12,8 @@ from simtk.openmm.app.charmm.topologyobjects import (AtomType, BondType, ...@@ -12,8 +12,8 @@ from simtk.openmm.app.charmm.topologyobjects import (AtomType, BondType,
AngleType, DihedralType, ImproperType, CmapType, AngleType, DihedralType, ImproperType, CmapType,
UreyBradleyType, NoUreyBradley) UreyBradleyType, NoUreyBradley)
from simtk.openmm.app.charmm.exceptions import CharmmFileError from simtk.openmm.app.charmm.exceptions import CharmmFileError
from simtk.openmm.element import Element, get_by_symbol from simtk.openmm.app.element import Element, get_by_symbol
from simtk.units import dalton from simtk.unit import daltons
import warnings import warnings
class ParameterSet(object): class ParameterSet(object):
...@@ -512,7 +512,7 @@ def element_by_mass(mass): ...@@ -512,7 +512,7 @@ def element_by_mass(mass):
for key in Element._elements_by_atomic_number: for key in Element._elements_by_atomic_number:
element = Element._elements_by_atomic_number[key] element = Element._elements_by_atomic_number[key]
massdiff = abs(element.mass.value_in_unit(u.daltons) - mass) massdiff = abs(element.mass.value_in_unit(daltons) - mass)
if massdiff < diff: if massdiff < diff:
best_guess = element best_guess = element
diff = massdiff diff = massdiff
......
...@@ -9,14 +9,8 @@ Date: April 9, 2014 ...@@ -9,14 +9,8 @@ Date: April 9, 2014
from __future__ import division from __future__ import division
from functools import wraps from functools import wraps
from simtk.openmm.app.charmm._charmmfile import CharmmFile from math import pi, cos, sin, sqrt
from simtk.openmm.app.charmm.topologyobjects import (ResidueList, AtomList,
TrackedList, Bond, Angle, Dihedral, Improper, AcceptorDonor,
Group, Cmap, UreyBradley, NoUreyBradley)
from simtk.openmm.app.charmm.exceptions import (CharmmPSFError, MoleculeError,
CharmmPSFWarning, MissingParameter)
import os import os
import warnings
import simtk.openmm as mm import simtk.openmm as mm
from simtk.openmm.vec3 import Vec3 from simtk.openmm.vec3 import Vec3
import simtk.unit as u import simtk.unit as u
...@@ -24,6 +18,14 @@ from simtk.openmm.app import (forcefield as ff, Topology, element) ...@@ -24,6 +18,14 @@ from simtk.openmm.app import (forcefield as ff, Topology, element)
from simtk.openmm.app.amberprmtopfile import HCT, OBC1, OBC2, GBn, GBn2 from simtk.openmm.app.amberprmtopfile import HCT, OBC1, OBC2, GBn, GBn2
from simtk.openmm.app.internal.customgbforces import (GBSAHCTForce, from simtk.openmm.app.internal.customgbforces import (GBSAHCTForce,
GBSAOBC1Force, GBSAOBC2Force, GBSAGBnForce, GBSAGBn2Force) GBSAOBC1Force, GBSAOBC2Force, GBSAGBnForce, GBSAGBn2Force)
# CHARMM imports
from simtk.openmm.app.charmm._charmmfile import CharmmFile
from simtk.openmm.app.charmm.topologyobjects import (ResidueList, AtomList,
TrackedList, Bond, Angle, Dihedral, Improper, AcceptorDonor,
Group, Cmap, UreyBradley, NoUreyBradley)
from simtk.openmm.app.charmm.exceptions import (CharmmPSFError, MoleculeError,
CharmmPSFWarning, MissingParameter)
import warnings
TINY = 1e-8 TINY = 1e-8
WATNAMES = ('WAT', 'HOH', 'TIP3', 'TIP4', 'TIP5', 'SPCE', 'SPC') WATNAMES = ('WAT', 'HOH', 'TIP3', 'TIP4', 'TIP5', 'SPCE', 'SPC')
...@@ -778,8 +780,8 @@ class ProteinStructure(object): ...@@ -778,8 +780,8 @@ class ProteinStructure(object):
if atom.residue.idx != last_residue: if atom.residue.idx != last_residue:
last_residue = atom.residue.idx last_residue = atom.residue.idx
residue = topology.addResidue(atom.residue.resname, chain) residue = topology.addResidue(atom.residue.resname, chain)
element_name = element_by_mass(atom.mass) atomic_num = atom.type.atomic_number
elem = element.get_by_symbol(element_name) elem = element.Element.getByAtomicNumber(atomic_num)
topology.addAtom(atom.name, elem, residue) topology.addAtom(atom.name, elem, residue)
# Add all of the bonds # Add all of the bonds
...@@ -1338,8 +1340,9 @@ class ProteinStructure(object): ...@@ -1338,8 +1340,9 @@ class ProteinStructure(object):
try: try:
return self._system return self._system
except AttributeError: except AttributeError:
raise APIError('You must initialize the system with createSystem ' raise AttributeError('You must initialize the system with '
'before accessing the cached object.') 'createSystem before accessing the cached '
'object.')
@property @property
def positions(self): def positions(self):
......
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