Commit 303e0fe3 authored by Robert McGibbon's avatar Robert McGibbon
Browse files

intermediate commit, work on virtualsites

parent 2c83421c
...@@ -20,6 +20,7 @@ from amberinpcrdfile import AmberInpcrdFile ...@@ -20,6 +20,7 @@ from amberinpcrdfile import AmberInpcrdFile
from dcdfile import DCDFile from dcdfile import DCDFile
from gromacsgrofile import GromacsGroFile from gromacsgrofile import GromacsGroFile
from gromacstopfile import GromacsTopFile from gromacstopfile import GromacsTopFile
from desmonddmsfile import DesmondDMSFile
from dcdreporter import DCDReporter from dcdreporter import DCDReporter
from modeller import Modeller from modeller import Modeller
from statedatareporter import StateDataReporter from statedatareporter import StateDataReporter
......
...@@ -25,6 +25,7 @@ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE ...@@ -25,6 +25,7 @@ OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE. USE OR OTHER DEALINGS IN THE SOFTWARE.
''' '''
import os
import math import math
from simtk import openmm as mm from simtk import openmm as mm
...@@ -57,15 +58,21 @@ class DesmondDMSFile(object): ...@@ -57,15 +58,21 @@ class DesmondDMSFile(object):
self._open = False self._open = False
self._tables = None self._tables = None
if not os.path.exists(str(file)):
raise IOError("No such file or directory: '%s'" % str(file))
self._conn = sqlite3.connect(file) self._conn = sqlite3.connect(file)
self._open = True self._open = True
self._readSchemas() self._readSchemas()
if len(self._tables) == 0:
raise IOError('DMS file was not loaded sucessfully. No tables found')
if 'nbtype' not in self._tables['particle']: if 'nbtype' not in self._tables['particle']:
raise ValueError('No nonbonded parameters associated with this ' raise ValueError('No nonbonded parameters associated with this '
'DMS file. You can add a forcefield with the ' 'DMS file. You can add a forcefield with the '
'viparr command line tool distributed with desmond') 'viparr command line tool distributed with desmond')
print dict(zip(self._tables['particle'], self._conn.execute('SELECT * from particle WHERE name="Vrt0"').fetchone()))
# Build the topology # Build the topology
self.topology, self.positions = self._createTopology() self.topology, self.positions = self._createTopology()
self._topologyAtoms = list(self.topology.atoms()) self._topologyAtoms = list(self.topology.atoms())
...@@ -114,10 +121,14 @@ class DesmondDMSFile(object): ...@@ -114,10 +121,14 @@ class DesmondDMSFile(object):
else: else:
atomReplacements = {} atomReplacements = {}
if atomNumber == 0 and atomName.startswith('Vrt'):
elem = None
else:
elem = Element.getByAtomicNumber(atomNumber)
if atomName in atomReplacements: if atomName in atomReplacements:
atomName = atomReplacements[atomName] atomName = atomReplacements[atomName]
elem = Element.getByAtomicNumber(atomNumber)
atoms[atomId] = top.addAtom(atomName, elem, r) atoms[atomId] = top.addAtom(atomName, elem, r)
positions.append(mm.Vec3(x, y, z)*angstrom) positions.append(mm.Vec3(x, y, z)*angstrom)
...@@ -161,6 +172,7 @@ class DesmondDMSFile(object): ...@@ -161,6 +172,7 @@ class DesmondDMSFile(object):
self._addPeriodicTorsionsToSystem(sys) self._addPeriodicTorsionsToSystem(sys)
self._addImproperHarmonicTorsionsToSystem(sys) self._addImproperHarmonicTorsionsToSystem(sys)
self._addCMAPToSystem(sys) self._addCMAPToSystem(sys)
self._addVirtualSitesToSystem(sys)
nb = self._addNonbondedForceToSystem(sys) nb = self._addNonbondedForceToSystem(sys)
# Finish configuring the NonbondedForce. # Finish configuring the NonbondedForce.
...@@ -371,6 +383,18 @@ class DesmondDMSFile(object): ...@@ -371,6 +383,18 @@ class DesmondDMSFile(object):
return nb return nb
def _addVirtualSitesToSystem(self, sys):
if not any(t.startswith('virtual_') for t in self._tables.keys()):
return
if 'virtual_out3_term' in self._tables:
q = '''SELECT p0, p1, p2, p3, c1, c2, c3
FROM virtual_out3_term INNER JOIN virtual_out3_param
ON virtual_out3_term.param=virtual_out3_param.id;'''
for p0, p1, p2, p3, c1, c2, c3 in self._conn.execute(q):
vsite = mm.OutOfPlaneSite
def _hasTable(self, table_name): def _hasTable(self, table_name):
'''Does our DMS file contain this table? '''Does our DMS file contain this table?
''' '''
...@@ -400,6 +424,16 @@ class DesmondDMSFile(object): ...@@ -400,6 +424,16 @@ class DesmondDMSFile(object):
raise NotImplementedError('Flat bottom potential terms ' raise NotImplementedError('Flat bottom potential terms '
'are not implemeneted') 'are not implemeneted')
nbinfo = dict(zip(self._tables['nonbonded_info'],
self._conn.execute('SELECT * FROM nonbonded_info').fetchone()))
if nbinfo['vdw_funct'] != u'vdw_12_6':
raise NotImplementedError('Only Leonard-Jones van der Waals interactions are '
'supported')
if nbinfo['vdw_rule'] != u'arithmetic/geometric':
raise NotImplementedError('Only Lorentz-Berthelot nonbonded combining rules '
'are supported')
def close(self): def close(self):
'''Close the SQL connection '''Close the SQL connection
''' '''
......
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