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):
class BondError(CharmmError):
""" 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,
AngleType, DihedralType, ImproperType, CmapType,
UreyBradleyType, NoUreyBradley)
from simtk.openmm.app.charmm.exceptions import CharmmFileError
from simtk.openmm.element import Element, get_by_symbol
from simtk.units import dalton
from simtk.openmm.app.element import Element, get_by_symbol
from simtk.unit import daltons
import warnings
class ParameterSet(object):
......@@ -512,7 +512,7 @@ def element_by_mass(mass):
for key in Element._elements_by_atomic_number:
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:
best_guess = element
diff = massdiff
......
......@@ -9,14 +9,8 @@ Date: April 9, 2014
from __future__ import division
from functools import wraps
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)
from math import pi, cos, sin, sqrt
import os
import warnings
import simtk.openmm as mm
from simtk.openmm.vec3 import Vec3
import simtk.unit as u
......@@ -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.internal.customgbforces import (GBSAHCTForce,
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
WATNAMES = ('WAT', 'HOH', 'TIP3', 'TIP4', 'TIP5', 'SPCE', 'SPC')
......@@ -778,8 +780,8 @@ class ProteinStructure(object):
if atom.residue.idx != last_residue:
last_residue = atom.residue.idx
residue = topology.addResidue(atom.residue.resname, chain)
element_name = element_by_mass(atom.mass)
elem = element.get_by_symbol(element_name)
atomic_num = atom.type.atomic_number
elem = element.Element.getByAtomicNumber(atomic_num)
topology.addAtom(atom.name, elem, residue)
# Add all of the bonds
......@@ -1338,8 +1340,9 @@ class ProteinStructure(object):
try:
return self._system
except AttributeError:
raise APIError('You must initialize the system with createSystem '
'before accessing the cached object.')
raise AttributeError('You must initialize the system with '
'createSystem before accessing the cached '
'object.')
@property
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