Commit 95711b88 authored by huangj's avatar huangj
Browse files

Add a test case for the colinear lonepair facility in CHARMM psf parser.

parent cbbc7911
...@@ -714,6 +714,7 @@ class CharmmPsfFile(object): ...@@ -714,6 +714,7 @@ class CharmmPsfFile(object):
if atom.type is not None: if atom.type is not None:
# This is the most reliable way of determining the element # This is the most reliable way of determining the element
atomic_num = atom.type.atomic_number atomic_num = atom.type.atomic_number
if atomic_num != 0:
elem = element.Element.getByAtomicNumber(atomic_num) elem = element.Element.getByAtomicNumber(atomic_num)
else: else:
# Figure it out from the mass # Figure it out from the mass
...@@ -911,6 +912,7 @@ class CharmmPsfFile(object): ...@@ -911,6 +912,7 @@ class CharmmPsfFile(object):
bond.bond_type.req*length_conv) bond.bond_type.req*length_conv)
# Add virtual sites # Add virtual sites
if hasattr(self, 'lonepair_list'):
if verbose: print('Adding lonepairs...') if verbose: print('Adding lonepairs...')
for lpsite in self.lonepair_list: for lpsite in self.lonepair_list:
index=lpsite[0] index=lpsite[0]
......
...@@ -141,17 +141,20 @@ class TestCharmmFiles(unittest.TestCase): ...@@ -141,17 +141,20 @@ class TestCharmmFiles(unittest.TestCase):
warnings.filterwarnings('ignore', category=CharmmPSFWarning) warnings.filterwarnings('ignore', category=CharmmPSFWarning)
psf = CharmmPsfFile('systems/chlb_cgenff.psf') psf = CharmmPsfFile('systems/chlb_cgenff.psf')
crd = CharmmCrdFile('systems/chlb_cgenff.crd') crd = CharmmCrdFile('systems/chlb_cgenff.crd')
# move the position of the lonepair on Cholride params = CharmmParameterSet('systems/top_all36_cgenff.rtf',
params = CharmmParameterSet('systems/par_all36_cgenff.prm', 'systems/par_all36_cgenff.prm')
'systems/top_all36_cgenff.rtf')
# Box dimensions (found from bounding box)
plat = Platform.getPlatformByName('Reference') plat = Platform.getPlatformByName('Reference')
system = psf.createSystem(params, nonbondedMethod=PME, system = psf.createSystem(params)
nonbondedCutoff=8*angstroms)
con = Context(system, VerletIntegrator(2*femtoseconds), plat) con = Context(system, VerletIntegrator(2*femtoseconds), plat)
con.setPositions(crd.positions) con.setPositions(crd.positions)
init_coor = con.getState(getPositions=True).getPositions()
# move the position of the lonepair and recompute its coordinates
crd.positions[12] = Vec3(0.5, 1.0, 1.5) * angstrom
con.setPositions(crd.positions)
con.computeVirtualSites()
new_coor = con.getState(getPositions=True).getPositions()
self.assertEqual(init_coor, new_coor)
def test_InsCode(self): def test_InsCode(self):
""" Test the parsing of PSF files that contain insertion codes in their residue numbers """ """ Test the parsing of PSF files that contain insertion codes in their residue numbers """
......
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