From b3a43c640e4903dfc20b3b25eaf1af83b9fa3f67 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Sat, 22 Aug 2020 01:13:38 -0400 Subject: [PATCH 01/47] Topology from omm topology and simulation objects. Coordinates from omm simulation --- package/MDAnalysis/coordinates/OpenMM.py | 102 +++++++++++++ package/MDAnalysis/coordinates/__init__.py | 1 + package/MDAnalysis/topology/OpenMMParser.py | 160 ++++++++++++++++++++ package/MDAnalysis/topology/__init__.py | 3 +- 4 files changed, 265 insertions(+), 1 deletion(-) create mode 100644 package/MDAnalysis/coordinates/OpenMM.py create mode 100644 package/MDAnalysis/topology/OpenMMParser.py diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py new file mode 100644 index 00000000000..bf8ff46913b --- /dev/null +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -0,0 +1,102 @@ +# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*- +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 +# +# MDAnalysis --- https://www.mdanalysis.org +# Copyright (c) 2006-2017 The MDAnalysis Development Team and contributors +# (see the file AUTHORS for the full list of names) +# +# Released under the GNU Public Licence, v2 or any higher version +# +# Please cite your use of MDAnalysis in published work: +# +# R. J. Gowers, M. Linke, J. Barnoud, T. J. E. Reddy, M. N. Melo, S. L. Seyler, +# D. L. Dotson, J. Domanski, S. Buchoux, I. M. Kenney, and O. Beckstein. +# MDAnalysis: A Python package for the rapid analysis of molecular dynamics +# simulations. In S. Benthall and S. Rostrup editors, Proceedings of the 15th +# Python in Science Conference, pages 102-109, Austin, TX, 2016. SciPy. +# doi: 10.25080/majora-629e541a-00e +# +# N. Michaud-Agrawal, E. J. Denning, T. B. Woolf, and O. Beckstein. +# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations. +# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787 +# + +import numpy as np + +from . import base + + +class OpenMMSimulationReader(base.ReaderBase): + """Reader for the OpenMM Simulation objects + + """ + format = 'OPENMMSIMULATION' + units = {'time': 'ps', 'length': 'nm', 'velocity': 'nm/ps', + 'force': 'kJ/(mol*nm)'} + + @staticmethod + def _format_hint(thing): + """Can this reader read *thing*? + .. versionadded:: 1.0.0 + """ + try: + from simtk.openmm.app import Simulation + except ImportError: + return False + else: + return isinstance(thing, Simulation) + + def __init__(self, filename, **kwargs): + super(OpenMMSimulationReader, self).__init__(filename, **kwargs) + self.filename = filename + self.n_atoms = self.filename.system.getNumParticles() + self.ts = self._Timestep(self.n_atoms, **self._ts_kwargs) + self.ts.dt = (self.filename.context.getState(1).getTime()._value - + self.filename.context.getState(0).getTime()._value + ) + print('first {}'.format(self.ts.dt)) + + self._frame = 1 + self._read_frame(self._frame) + + @property + def n_frames(self): + return self.filename.currentStep + + def _read_frame(self, frame): + print('called read frame on {}'.format(frame)) + self._frame = frame + self.ts.frame = self._frame + + state = self.filename.context.getState(self._frame, getVelocities=True, getForces=True, getEnergy=True) + self.ts.dt = (self.filename.context.getState(self._frame).getTime()._value - + self.filename.context.getState(self._frame - 1).getTime()._value + ) + + self.ts.data['time'] = state.getTime() + self.ts.data['potential_energy'] = state.getPotentialEnergy() + self.ts.data['kinetic_energy'] = state.getKineticEnergy() + self.ts.triclinic_dimensions = state.getPeriodicBoxVectors(asNumpy=True)._value + self.ts.positions = state.getPositions(asNumpy=True)._value + self.ts.velocities = state.getVelocities(asNumpy=True)._value + self.ts.forces = state.getForces(asNumpy=True)._value + + if self.convert_units: + self.convert_pos_from_native(self.ts._pos) + self.ts.triclinic_dimensions = self.convert_pos_from_native( + self.ts.triclinic_dimensions, inplace=False + ) + self.convert_velocities_from_native(self.ts._velocities) + self.convert_forces_from_native(self.ts._forces) + self.convert_time_from_native(self.ts.dt) + + return self.ts + + def _read_next_timestep(self): + return self._read_frame(self._frame + 1) + + #def _reopen(self): + #self.ts.frame = 0 + #self._frame = 0 + + diff --git a/package/MDAnalysis/coordinates/__init__.py b/package/MDAnalysis/coordinates/__init__.py index b7ca28be9f7..ab3bcdce2fd 100644 --- a/package/MDAnalysis/coordinates/__init__.py +++ b/package/MDAnalysis/coordinates/__init__.py @@ -726,6 +726,7 @@ class can choose an appropriate reader automatically. from . import INPCRD from . import LAMMPS from . import MOL2 +from . import OpenMM from . import ParmEd from . import PDB from . import PDBQT diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py new file mode 100644 index 00000000000..39a09161454 --- /dev/null +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -0,0 +1,160 @@ +# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*- +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 +# +# MDAnalysis --- https://www.mdanalysis.org +# Copyright (c) 2006-2017 The MDAnalysis Development Team and contributors +# (see the file AUTHORS for the full list of names) +# +# Released under the GNU Public Licence, v2 or any higher version +# +# Please cite your use of MDAnalysis in published work: +# +# R. J. Gowers, M. Linke, J. Barnoud, T. J. E. Reddy, M. N. Melo, S. L. Seyler, +# D. L. Dotson, J. Domanski, S. Buchoux, I. M. Kenney, and O. Beckstein. +# MDAnalysis: A Python package for the rapid analysis of molecular dynamics +# simulations. In S. Benthall and S. Rostrup editors, Proceedings of the 15th +# Python in Science Conference, pages 102-109, Austin, TX, 2016. SciPy. +# doi: 10.25080/majora-629e541a-00e +# +# N. Michaud-Agrawal, E. J. Denning, T. B. Woolf, and O. Beckstein. +# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations. +# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787 +# + +import numpy as np + +from .base import TopologyReaderBase +from ..core.topology import Topology +from ..core.topologyattrs import ( + Atomids, + Atomnames, + Bonds, + ChainIDs, + Elements, + Masses, + Resids, + Resnums, + Resnames, + Segids, +) + + +class OpenMMTopologyParser(TopologyReaderBase): + format = 'OPENMMTOPOLOGY' + + @staticmethod + def _format_hint(thing): + """Can this Parser read object *thing*? + + .. versionadded:: 1.0.0 + """ + try: + from simtk.openmm import app + except ImportError: + return False + else: + return isinstance(thing, app.Topology) + + + def parse(self, **kwargs): + omm_topology = self.filename + + atom_resindex = [a.residue.index for a in omm_topology.atoms()] + residue_segindex = [r.chain.index for r in omm_topology.residues()] + atomids = [a.id for a in omm_topology.atoms()] + atomnames = [a.name for a in omm_topology.atoms()] + chainids = [a.residue.chain.id for a in omm_topology.atoms()] + elements = [a.element.symbol for a in omm_topology.atoms()] + masses = [a.element.mass._value for a in omm_topology.atoms()] + resnames = [r.name for r in omm_topology.residues()] + resids = [r.index for r in omm_topology.residues()] + resnums = resids.copy() + segids = [c.index for c in omm_topology.chains()] + bonds = [(b.atom1.index, b.atom2.index) for b in omm_topology.bonds()] + bond_orders =[b.order for b in omm_topology.bonds()] + bond_types = [b.type for b in omm_topology.bonds()] + + n_atoms = len(atomids) + n_residues = len(resids) + n_segments = len(segids) + + attrs = [ + Atomids(np.array(atomids, dtype=np.int32)), + Atomnames(np.array(atomnames, dtype=object)), + Bonds(bonds, types=bond_types, order=bond_orders, guessed=False), + ChainIDs(np.array(chainids, dtype=object)), + Elements(np.array(elements, dtype=object)), + Masses(np.array(masses, dtype=np.float32)), + Resids(resids), + Resnums(resnums), + Resnames(resnames), + Segids(segids) + ] + + top = Topology(n_atoms, n_residues, n_segments, + attrs=attrs, + atom_resindex=atom_resindex, + residue_segindex=residue_segindex + ) + + return top + +class OpenMMSimulationParser(TopologyReaderBase): + format = 'OPENMMSIMULATION' + + @staticmethod + def _format_hint(thing): + """Can this Parser read object *thing*? + + .. versionadded:: 1.0.0 + """ + try: + from simtk.openmm import app + except ImportError: + return False + else: + return isinstance(thing, app.Simulation) + + + def parse(self, **kwargs): + omm_topology = self.filename.topology + + atom_resindex = [a.residue.index for a in omm_topology.atoms()] + residue_segindex = [r.chain.index for r in omm_topology.residues()] + atomids = [a.id for a in omm_topology.atoms()] + atomnames = [a.name for a in omm_topology.atoms()] + chainids = [a.residue.chain.id for a in omm_topology.atoms()] + elements = [a.element.symbol for a in omm_topology.atoms()] + masses = [a.element.mass._value for a in omm_topology.atoms()] + resnames = [r.name for r in omm_topology.residues()] + resids = [r.index for r in omm_topology.residues()] + resnums = resids.copy() + segids = [c.index for c in omm_topology.chains()] + bonds = [(b.atom1.index, b.atom2.index) for b in omm_topology.bonds()] + bond_orders =[b.order for b in omm_topology.bonds()] + bond_types = [b.type for b in omm_topology.bonds()] + + n_atoms = len(atomids) + n_residues = len(resids) + n_segments = len(segids) + + attrs = [ + Atomids(np.array(atomids, dtype=np.int32)), + Atomnames(np.array(atomnames, dtype=object)), + Bonds(bonds, types=bond_types, order=bond_orders, guessed=False), + ChainIDs(np.array(chainids, dtype=object)), + Elements(np.array(elements, dtype=object)), + Masses(np.array(masses, dtype=np.float32)), + Resids(resids), + Resnums(resnums), + Resnames(resnames), + Segids(segids) + ] + + top = Topology(n_atoms, n_residues, n_segments, + attrs=attrs, + atom_resindex=atom_resindex, + residue_segindex=residue_segindex + ) + + return top diff --git a/package/MDAnalysis/topology/__init__.py b/package/MDAnalysis/topology/__init__.py index 8d7628693e9..4bb82f0773c 100644 --- a/package/MDAnalysis/topology/__init__.py +++ b/package/MDAnalysis/topology/__init__.py @@ -307,7 +307,7 @@ 'CRDParser', 'TOPParser', 'PDBQTParser', 'TPRParser', 'LAMMPSParser', 'XYZParser', 'GMSParser', 'DLPolyParser', 'HoomdXMLParser','GSDParser', 'ITPParser', 'ParmEdParser', - 'RDKitParser'] + 'RDKitParser', 'OpenMMTopologyParser', 'OpenMMSimulationParser'] from . import core from . import PSFParser @@ -331,6 +331,7 @@ from . import GSDParser from . import MinimalParser from . import ITPParser +from . import OpenMMParser from . import ParmEdParser from . import RDKitParser from . import FHIAIMSParser From f103d916ded67052b73d1c79fe9267e91af09f9a Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Sat, 22 Aug 2020 01:14:36 -0400 Subject: [PATCH 02/47] Remove debug lines --- package/MDAnalysis/coordinates/OpenMM.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index bf8ff46913b..e6324d357aa 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -54,7 +54,6 @@ def __init__(self, filename, **kwargs): self.ts.dt = (self.filename.context.getState(1).getTime()._value - self.filename.context.getState(0).getTime()._value ) - print('first {}'.format(self.ts.dt)) self._frame = 1 self._read_frame(self._frame) @@ -64,7 +63,6 @@ def n_frames(self): return self.filename.currentStep def _read_frame(self, frame): - print('called read frame on {}'.format(frame)) self._frame = frame self.ts.frame = self._frame From caadfab421865e59528b4057d2bec29b41adaff9 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Sat, 22 Aug 2020 13:43:14 -0400 Subject: [PATCH 03/47] Move omm topology parsing code outside class for re-use in multiple omm reader objects --- package/MDAnalysis/topology/OpenMMParser.py | 122 ++++++++------------ 1 file changed, 48 insertions(+), 74 deletions(-) diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py index 39a09161454..6f8124cf08f 100644 --- a/package/MDAnalysis/topology/OpenMMParser.py +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -59,43 +59,7 @@ def _format_hint(thing): def parse(self, **kwargs): omm_topology = self.filename - atom_resindex = [a.residue.index for a in omm_topology.atoms()] - residue_segindex = [r.chain.index for r in omm_topology.residues()] - atomids = [a.id for a in omm_topology.atoms()] - atomnames = [a.name for a in omm_topology.atoms()] - chainids = [a.residue.chain.id for a in omm_topology.atoms()] - elements = [a.element.symbol for a in omm_topology.atoms()] - masses = [a.element.mass._value for a in omm_topology.atoms()] - resnames = [r.name for r in omm_topology.residues()] - resids = [r.index for r in omm_topology.residues()] - resnums = resids.copy() - segids = [c.index for c in omm_topology.chains()] - bonds = [(b.atom1.index, b.atom2.index) for b in omm_topology.bonds()] - bond_orders =[b.order for b in omm_topology.bonds()] - bond_types = [b.type for b in omm_topology.bonds()] - - n_atoms = len(atomids) - n_residues = len(resids) - n_segments = len(segids) - - attrs = [ - Atomids(np.array(atomids, dtype=np.int32)), - Atomnames(np.array(atomnames, dtype=object)), - Bonds(bonds, types=bond_types, order=bond_orders, guessed=False), - ChainIDs(np.array(chainids, dtype=object)), - Elements(np.array(elements, dtype=object)), - Masses(np.array(masses, dtype=np.float32)), - Resids(resids), - Resnums(resnums), - Resnames(resnames), - Segids(segids) - ] - - top = Topology(n_atoms, n_residues, n_segments, - attrs=attrs, - atom_resindex=atom_resindex, - residue_segindex=residue_segindex - ) + top = _mda_topology_from_omm_topology(omm_topology) return top @@ -119,42 +83,52 @@ def _format_hint(thing): def parse(self, **kwargs): omm_topology = self.filename.topology - atom_resindex = [a.residue.index for a in omm_topology.atoms()] - residue_segindex = [r.chain.index for r in omm_topology.residues()] - atomids = [a.id for a in omm_topology.atoms()] - atomnames = [a.name for a in omm_topology.atoms()] - chainids = [a.residue.chain.id for a in omm_topology.atoms()] - elements = [a.element.symbol for a in omm_topology.atoms()] - masses = [a.element.mass._value for a in omm_topology.atoms()] - resnames = [r.name for r in omm_topology.residues()] - resids = [r.index for r in omm_topology.residues()] - resnums = resids.copy() - segids = [c.index for c in omm_topology.chains()] - bonds = [(b.atom1.index, b.atom2.index) for b in omm_topology.bonds()] - bond_orders =[b.order for b in omm_topology.bonds()] - bond_types = [b.type for b in omm_topology.bonds()] - - n_atoms = len(atomids) - n_residues = len(resids) - n_segments = len(segids) - - attrs = [ - Atomids(np.array(atomids, dtype=np.int32)), - Atomnames(np.array(atomnames, dtype=object)), - Bonds(bonds, types=bond_types, order=bond_orders, guessed=False), - ChainIDs(np.array(chainids, dtype=object)), - Elements(np.array(elements, dtype=object)), - Masses(np.array(masses, dtype=np.float32)), - Resids(resids), - Resnums(resnums), - Resnames(resnames), - Segids(segids) - ] - - top = Topology(n_atoms, n_residues, n_segments, - attrs=attrs, - atom_resindex=atom_resindex, - residue_segindex=residue_segindex - ) + top = _mda_topology_from_omm_topology(omm_topology) return top + +def _mda_topology_from_omm_topology(omm_topology): + """ Construct mda topology from omm topology + + Can be used for any openmm object that contains a topology object""" + atom_resindex = [a.residue.index for a in omm_topology.atoms()] + residue_segindex = [r.chain.index for r in omm_topology.residues()] + atomids = [a.id for a in omm_topology.atoms()] + atomnames = [a.name for a in omm_topology.atoms()] + chainids = [a.residue.chain.id for a in omm_topology.atoms()] + elements = [a.element.symbol for a in omm_topology.atoms()] + masses = [a.element.mass._value for a in omm_topology.atoms()] + resnames = [r.name for r in omm_topology.residues()] + resids = [r.index for r in omm_topology.residues()] + resnums = resids.copy() + segids = [c.index for c in omm_topology.chains()] + bonds = [(b.atom1.index, b.atom2.index) for b in omm_topology.bonds()] + bond_orders =[b.order for b in omm_topology.bonds()] + bond_types = [b.type for b in omm_topology.bonds()] + + n_atoms = len(atomids) + n_residues = len(resids) + n_segments = len(segids) + + attrs = [ + Atomids(np.array(atomids, dtype=np.int32)), + Atomnames(np.array(atomnames, dtype=object)), + Bonds(bonds, types=bond_types, order=bond_orders, guessed=False), + ChainIDs(np.array(chainids, dtype=object)), + Elements(np.array(elements, dtype=object)), + Masses(np.array(masses, dtype=np.float32)), + Resids(resids), + Resnums(resnums), + Resnames(resnames), + Segids(segids) + ] + + top = Topology(n_atoms, n_residues, n_segments, + attrs=attrs, + atom_resindex=atom_resindex, + residue_segindex=residue_segindex + ) + + return top + + From b1097151dba2e9953acfc07a5837df3831bfd24e Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Sat, 22 Aug 2020 13:43:30 -0400 Subject: [PATCH 04/47] Change openmm trajectory reader into single frame reader --- package/MDAnalysis/coordinates/OpenMM.py | 71 +++++++++++------------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index e6324d357aa..3b546ee92bc 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -26,7 +26,7 @@ from . import base -class OpenMMSimulationReader(base.ReaderBase): +class OpenMMSimulationReader(base.SingleFrameReaderBase): """Reader for the OpenMM Simulation objects """ @@ -46,38 +46,12 @@ def _format_hint(thing): else: return isinstance(thing, Simulation) - def __init__(self, filename, **kwargs): - super(OpenMMSimulationReader, self).__init__(filename, **kwargs) - self.filename = filename + + def _read_first_frame(self): self.n_atoms = self.filename.system.getNumParticles() - self.ts = self._Timestep(self.n_atoms, **self._ts_kwargs) - self.ts.dt = (self.filename.context.getState(1).getTime()._value - - self.filename.context.getState(0).getTime()._value - ) - - self._frame = 1 - self._read_frame(self._frame) - - @property - def n_frames(self): - return self.filename.currentStep - - def _read_frame(self, frame): - self._frame = frame - self.ts.frame = self._frame - - state = self.filename.context.getState(self._frame, getVelocities=True, getForces=True, getEnergy=True) - self.ts.dt = (self.filename.context.getState(self._frame).getTime()._value - - self.filename.context.getState(self._frame - 1).getTime()._value - ) - - self.ts.data['time'] = state.getTime() - self.ts.data['potential_energy'] = state.getPotentialEnergy() - self.ts.data['kinetic_energy'] = state.getKineticEnergy() - self.ts.triclinic_dimensions = state.getPeriodicBoxVectors(asNumpy=True)._value - self.ts.positions = state.getPositions(asNumpy=True)._value - self.ts.velocities = state.getVelocities(asNumpy=True)._value - self.ts.forces = state.getForces(asNumpy=True)._value + + self.ts = _mda_timestep_from_omm_context(self.filename.context, + self._Timestep, **self._ts_kwargs) if self.convert_units: self.convert_pos_from_native(self.ts._pos) @@ -88,13 +62,32 @@ def _read_frame(self, frame): self.convert_forces_from_native(self.ts._forces) self.convert_time_from_native(self.ts.dt) - return self.ts - - def _read_next_timestep(self): - return self._read_frame(self._frame + 1) - #def _reopen(self): - #self.ts.frame = 0 - #self._frame = 0 +def _mda_timestep_from_omm_context(omm_context, timestep_module, **ts_kwargs): + """ Construct Timestep object from Openmm context + + Parameters + ---------- + omm_context: simtk.openmm.context + timestep_module: MDAnalysis.coordinates.base.timestep + This is the module, but the object gets created within this function """ + + state = omm_context.getState(-1, getVelocities=True, + getForces=True, getEnergy=True + ) + + n_atoms = omm_context.getSystem().getNumParticles() + + ts = timestep_module(n_atoms, **ts_kwargs) + ts.data['time'] = state.getTime() + ts.data['potential_energy'] = state.getPotentialEnergy() + ts.data['kinetic_energy'] = state.getKineticEnergy() + ts.triclinic_dimensions = state.getPeriodicBoxVectors(asNumpy=True)._value + ts.positions = state.getPositions(asNumpy=True)._value + ts.velocities = state.getVelocities(asNumpy=True)._value + ts.forces = state.getForces(asNumpy=True)._value + + + return ts From 4665de1a2867bef6cfa43c30ba37cab7ad9b6bfd Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Sat, 22 Aug 2020 23:54:39 -0400 Subject: [PATCH 05/47] Add coordinates conversions for openmm modeller and pdbfile classes --- package/MDAnalysis/coordinates/OpenMM.py | 83 +++++++++++++++++++++++- 1 file changed, 82 insertions(+), 1 deletion(-) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index 3b546ee92bc..f27cf3174cc 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -48,7 +48,7 @@ def _format_hint(thing): def _read_first_frame(self): - self.n_atoms = self.filename.system.getNumParticles() + self.n_atoms = self.filename.topology.getNumAtoms() self.ts = _mda_timestep_from_omm_context(self.filename.context, self._Timestep, **self._ts_kwargs) @@ -62,6 +62,71 @@ def _read_first_frame(self): self.convert_forces_from_native(self.ts._forces) self.convert_time_from_native(self.ts.dt) +class OpenMMPDBFileReader(base.SingleFrameReaderBase): + """Reader for the OpenMM Simulation objects + + """ + format = 'OPENMMPDBFILE' + units = {'time': 'ps', 'length': 'nm'} + + @staticmethod + def _format_hint(thing): + """Can this reader read *thing*? + .. versionadded:: 1.0.0 + """ + try: + from simtk.openmm.app import PDBFile + except ImportError: + return False + else: + return isinstance(thing, PDBFile) + + + def _read_first_frame(self): + self.n_atoms = self.filename.topology.getNumAtoms() + + self.ts = _mda_timestep_from_omm_modeller_pdbfile(self.filename, + self._Timestep, **self._ts_kwargs) + + if self.convert_units: + self.convert_pos_from_native(self.ts._pos) + self.ts.triclinic_dimensions = self.convert_pos_from_native( + self.ts.triclinic_dimensions, inplace=False + ) + +class OpenMMModellerReader(base.SingleFrameReaderBase): + """Reader for the OpenMM Simulation objects + + """ + format = 'OPENMMMODELLER' + units = {'time': 'ps', 'length': 'nm'} + + @staticmethod + def _format_hint(thing): + """Can this reader read *thing*? + .. versionadded:: 1.0.0 + """ + try: + from simtk.openmm.app import Modeller + except ImportError: + return False + else: + return isinstance(thing, Modeller) + + + def _read_first_frame(self): + self.n_atoms = self.filename.topology.getNumAtoms() + + self.ts = _mda_timestep_from_omm_modeller_pdbfile(self.filename, + self._Timestep, **self._ts_kwargs) + + if self.convert_units: + self.convert_pos_from_native(self.ts._pos) + self.ts.triclinic_dimensions = self.convert_pos_from_native( + self.ts.triclinic_dimensions, inplace=False + ) + + def _mda_timestep_from_omm_context(omm_context, timestep_module, **ts_kwargs): """ Construct Timestep object from Openmm context @@ -90,4 +155,20 @@ def _mda_timestep_from_omm_context(omm_context, timestep_module, **ts_kwargs): return ts +def _mda_timestep_from_omm_modeller_pdbfile(omm_object, timestep_module, **ts_kwargs): + """ Construct Timestep object from Openmm context + Parameters + ---------- + omm_object: simtk.openmm.app.PDBFile or simtk.openmm.app.Modeller + timestep_module: MDAnalysis.coordinates.base.timestep + This is the module, but the object gets created within this function """ + + n_atoms = omm_object.topology.getNumAtoms() + + ts = timestep_module(n_atoms, **ts_kwargs) + ts.triclinic_dimensions = np.array(omm_object.topology.getPeriodicBoxVectors()._value) + ts.positions = np.array(omm_object.getPositions()._value) + + return ts + From b5f4aaba8baddeb41dd51aaf8fe36373890cb3a2 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Sat, 22 Aug 2020 23:55:11 -0400 Subject: [PATCH 06/47] Add topology parsing for openmm pdbfile and modeller objects --- package/MDAnalysis/topology/OpenMMParser.py | 50 +++++++++++++++++++++ package/MDAnalysis/topology/__init__.py | 3 +- 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py index 6f8124cf08f..f9c45209d44 100644 --- a/package/MDAnalysis/topology/OpenMMParser.py +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -87,6 +87,56 @@ def parse(self, **kwargs): return top +class OpenMMPDBFileParser(TopologyReaderBase): + format = 'OPENMMPDBFILE' + + @staticmethod + def _format_hint(thing): + """Can this Parser read object *thing*? + + .. versionadded:: 1.0.0 + """ + try: + from simtk.openmm import app + except ImportError: + return False + else: + return isinstance(thing, app.PDBFile) + + + def parse(self, **kwargs): + omm_pdbfile = self.filename + + top = _mda_topology_from_omm_topology(omm_pdbfile.topology) + + return top + +class OpenMMModellerParser(TopologyReaderBase): + format = 'OPENMMMODELLER' + + @staticmethod + def _format_hint(thing): + """Can this Parser read object *thing*? + + .. versionadded:: 1.0.0 + """ + try: + from simtk.openmm import app + except ImportError: + return False + else: + return isinstance(thing, app.Modeller) + + + def parse(self, **kwargs): + omm_modeller = self.filename + + top = _mda_topology_from_omm_topology(omm_modeller.topology) + + return top + + + def _mda_topology_from_omm_topology(omm_topology): """ Construct mda topology from omm topology diff --git a/package/MDAnalysis/topology/__init__.py b/package/MDAnalysis/topology/__init__.py index 4bb82f0773c..9f4789e5327 100644 --- a/package/MDAnalysis/topology/__init__.py +++ b/package/MDAnalysis/topology/__init__.py @@ -307,7 +307,8 @@ 'CRDParser', 'TOPParser', 'PDBQTParser', 'TPRParser', 'LAMMPSParser', 'XYZParser', 'GMSParser', 'DLPolyParser', 'HoomdXMLParser','GSDParser', 'ITPParser', 'ParmEdParser', - 'RDKitParser', 'OpenMMTopologyParser', 'OpenMMSimulationParser'] + 'RDKitParser', 'OpenMMTopologyParser', 'OpenMMSimulationParser', + 'OpenMMPDBFileParser', 'OpenMMModellerParser'] from . import core from . import PSFParser From ba759c169251669a1f25785c8df1ac887e030882 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Sun, 23 Aug 2020 00:47:56 -0400 Subject: [PATCH 07/47] Tests for openmmtopology parser --- .../MDAnalysisTests/topology/test_openmm.py | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 testsuite/MDAnalysisTests/topology/test_openmm.py diff --git a/testsuite/MDAnalysisTests/topology/test_openmm.py b/testsuite/MDAnalysisTests/topology/test_openmm.py new file mode 100644 index 00000000000..98c37da9ab4 --- /dev/null +++ b/testsuite/MDAnalysisTests/topology/test_openmm.py @@ -0,0 +1,96 @@ +# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*- +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 fileencoding=utf-8 +# +# MDAnalysis --- https://www.mdanalysis.org +# Copyright (c) 2006-2017 The MDAnalysis Development Team and contributors +# (see the file AUTHORS for the full list of names) +# +# Released under the GNU Public Licence, v2 or any higher version +# +# Please cite your use of MDAnalysis in published work: +# +# R. J. Gowers, M. Linke, J. Barnoud, T. J. E. Reddy, M. N. Melo, S. L. Seyler, +# D. L. Dotson, J. Domanski, S. Buchoux, I. M. Kenney, and O. Beckstein. +# MDAnalysis: A Python package for the rapid analysis of molecular dynamics +# simulations. In S. Benthall and S. Rostrup editors, Proceedings of the 15th +# Python in Science Conference, pages 102-109, Austin, TX, 2016. SciPy. +# doi: 10.25080/majora-629e541a-00e +# +# N. Michaud-Agrawal, E. J. Denning, T. B. Woolf, and O. Beckstein. +# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations. +# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787 +# +import pytest +import numpy as np +from simtk.openmm import app + +import MDAnalysis as mda + +from MDAnalysisTests.topology.base import ParserBase +from MDAnalysisTests.datafiles import PDB, PDB_conect + +class OpenMMTopologyBase(ParserBase): + parser = mda.topology.OpenMMParser.OpenMMTopologyParser + expected_attrs = ['ids', 'names', 'resids', 'resnames', 'masses', + 'bonds'] + expected_n_bonds = 0 + + def test_attr_size(self, top): + assert len(top.ids) == top.n_atoms + assert len(top.names) == top.n_atoms + assert len(top.resids) == top.n_residues + assert len(top.resnames) == top.n_residues + + def test_atoms(self, top): + assert top.n_atoms == self.expected_n_atoms + + def test_bonds(self, top): + assert len(top.bonds.values) == self.expected_n_bonds + if self.expected_n_bonds: + assert isinstance(top.bonds.values[0], tuple) + else: + assert top.bonds.values == [] + + def test_resids(self, top): + assert len(top.resids.values) == self.expected_n_residues + if self.expected_n_residues: + assert isinstance(top.resids.values, np.ndarray) + else: + assert top.resids.values == [] + + def test_resnames(self, top): + assert len(top.resnames.values) == self.expected_n_residues + if self.expected_n_residues: + assert isinstance(top.resnames.values, np.ndarray) + else: + assert top.resnames.values == [] + + def test_resnums(self, top): + assert len(top.resnums.values) == self.expected_n_residues + if self.expected_n_residues: + assert isinstance(top.resnums.values, np.ndarray) + else: + assert top.resnums.values == [] + + def test_segids(self, top): + assert len(top.segids.values) == self.expected_n_segments + if self.expected_n_segments: + assert isinstance(top.segids.values, np.ndarray) + else: + assert top.segids.values == [] + + +class TestOpenMMTopologyParser(OpenMMTopologyBase): + ref_filename = app.PDBFile(PDB).topology + expected_n_atoms = 47681 + expected_n_residues = 11302 + expected_n_segments = 1 + +class TestOpenMMTopologyParserBonds(OpenMMTopologyBase): + ref_filename = app.PDBFile(PDB_conect).topology + expected_n_atoms = 10 + expected_n_bonds = 8 + expected_n_residues = 1 + expected_n_segments = 1 + + From 9f1723ef477b631a3eb7a3d9f43729d614de9947 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Sun, 23 Aug 2020 01:05:11 -0400 Subject: [PATCH 08/47] Revert init --- package/MDAnalysis/topology/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/package/MDAnalysis/topology/__init__.py b/package/MDAnalysis/topology/__init__.py index 9f4789e5327..a8cd14a0bbd 100644 --- a/package/MDAnalysis/topology/__init__.py +++ b/package/MDAnalysis/topology/__init__.py @@ -307,9 +307,7 @@ 'CRDParser', 'TOPParser', 'PDBQTParser', 'TPRParser', 'LAMMPSParser', 'XYZParser', 'GMSParser', 'DLPolyParser', 'HoomdXMLParser','GSDParser', 'ITPParser', 'ParmEdParser', - 'RDKitParser', 'OpenMMTopologyParser', 'OpenMMSimulationParser', - 'OpenMMPDBFileParser', 'OpenMMModellerParser'] - + 'RDKitParser', 'OpenMMParser'] from . import core from . import PSFParser from . import TOPParser From 9de805c49f7d3e6bcec458fb25ae0c99decc16ac Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Sun, 23 Aug 2020 15:15:44 -0400 Subject: [PATCH 09/47] Test openmm topology parsing on pdb file with connections, add atomtypes --- package/MDAnalysis/topology/OpenMMParser.py | 3 +++ .../MDAnalysisTests/topology/test_openmm.py | 26 +++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py index f9c45209d44..3c231b40b6e 100644 --- a/package/MDAnalysis/topology/OpenMMParser.py +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -28,6 +28,7 @@ from ..core.topologyattrs import ( Atomids, Atomnames, + Atomtypes, Bonds, ChainIDs, Elements, @@ -145,6 +146,7 @@ def _mda_topology_from_omm_topology(omm_topology): residue_segindex = [r.chain.index for r in omm_topology.residues()] atomids = [a.id for a in omm_topology.atoms()] atomnames = [a.name for a in omm_topology.atoms()] + atomtypes = [a.name for a in omm_topology.atoms()] chainids = [a.residue.chain.id for a in omm_topology.atoms()] elements = [a.element.symbol for a in omm_topology.atoms()] masses = [a.element.mass._value for a in omm_topology.atoms()] @@ -163,6 +165,7 @@ def _mda_topology_from_omm_topology(omm_topology): attrs = [ Atomids(np.array(atomids, dtype=np.int32)), Atomnames(np.array(atomnames, dtype=object)), + Atomtypes(np.array(atomtypes, dtype=object)), Bonds(bonds, types=bond_types, order=bond_orders, guessed=False), ChainIDs(np.array(chainids, dtype=object)), Elements(np.array(elements, dtype=object)), diff --git a/testsuite/MDAnalysisTests/topology/test_openmm.py b/testsuite/MDAnalysisTests/topology/test_openmm.py index 98c37da9ab4..4ec554ee88f 100644 --- a/testsuite/MDAnalysisTests/topology/test_openmm.py +++ b/testsuite/MDAnalysisTests/topology/test_openmm.py @@ -27,14 +27,19 @@ import MDAnalysis as mda from MDAnalysisTests.topology.base import ParserBase -from MDAnalysisTests.datafiles import PDB, PDB_conect +from MDAnalysisTests.datafiles import CONECT class OpenMMTopologyBase(ParserBase): parser = mda.topology.OpenMMParser.OpenMMTopologyParser expected_attrs = ['ids', 'names', 'resids', 'resnames', 'masses', - 'bonds'] + 'bonds', 'chainIDs', 'elements'] expected_n_bonds = 0 + def test_creates_universe(self, filename): + """Check that Universe works with this Parser""" + u = mda.Universe(filename, topology_format='OPENMMTOPOLOGY') + assert isinstance(u, mda.Universe) + def test_attr_size(self, top): assert len(top.ids) == top.n_atoms assert len(top.names) == top.n_atoms @@ -81,16 +86,9 @@ def test_segids(self, top): class TestOpenMMTopologyParser(OpenMMTopologyBase): - ref_filename = app.PDBFile(PDB).topology - expected_n_atoms = 47681 - expected_n_residues = 11302 - expected_n_segments = 1 - -class TestOpenMMTopologyParserBonds(OpenMMTopologyBase): - ref_filename = app.PDBFile(PDB_conect).topology - expected_n_atoms = 10 - expected_n_bonds = 8 - expected_n_residues = 1 - expected_n_segments = 1 - + ref_filename = app.PDBFile(CONECT).topology + expected_n_atoms = 1890 + expected_n_residues = 199 + expected_n_segments = 3 + expected_n_bonds = 1922 From 2c25a3d320bb51be9a22576ae0e8478fb768ef6d Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Sun, 23 Aug 2020 15:20:47 -0400 Subject: [PATCH 10/47] Use guesser for guessing atomtypes from atomnames --- package/MDAnalysis/topology/OpenMMParser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py index 3c231b40b6e..cade3f26704 100644 --- a/package/MDAnalysis/topology/OpenMMParser.py +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -24,6 +24,7 @@ import numpy as np from .base import TopologyReaderBase +from .guessers import guess_types from ..core.topology import Topology from ..core.topologyattrs import ( Atomids, @@ -146,7 +147,7 @@ def _mda_topology_from_omm_topology(omm_topology): residue_segindex = [r.chain.index for r in omm_topology.residues()] atomids = [a.id for a in omm_topology.atoms()] atomnames = [a.name for a in omm_topology.atoms()] - atomtypes = [a.name for a in omm_topology.atoms()] + atomtypes = guess_types(atomnames) chainids = [a.residue.chain.id for a in omm_topology.atoms()] elements = [a.element.symbol for a in omm_topology.atoms()] masses = [a.element.mass._value for a in omm_topology.atoms()] From 4bab35c73434146555ac7ebba3ab938c289edeb6 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Mon, 24 Aug 2020 09:02:36 -0400 Subject: [PATCH 11/47] Off by one errors for 1-indexed resids --- package/MDAnalysis/topology/OpenMMParser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py index cade3f26704..26dad881008 100644 --- a/package/MDAnalysis/topology/OpenMMParser.py +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -152,7 +152,7 @@ def _mda_topology_from_omm_topology(omm_topology): elements = [a.element.symbol for a in omm_topology.atoms()] masses = [a.element.mass._value for a in omm_topology.atoms()] resnames = [r.name for r in omm_topology.residues()] - resids = [r.index for r in omm_topology.residues()] + resids = [r.index + 1 for r in omm_topology.residues()] resnums = resids.copy() segids = [c.index for c in omm_topology.chains()] bonds = [(b.atom1.index, b.atom2.index) for b in omm_topology.bonds()] From 7b7c9313b60db4ac90cdb0b95d67838a64abd360 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Mon, 24 Aug 2020 09:02:48 -0400 Subject: [PATCH 12/47] Set frame to 0 for first timestep --- package/MDAnalysis/coordinates/OpenMM.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index f27cf3174cc..b88428d0539 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -144,6 +144,7 @@ def _mda_timestep_from_omm_context(omm_context, timestep_module, **ts_kwargs): n_atoms = omm_context.getSystem().getNumParticles() ts = timestep_module(n_atoms, **ts_kwargs) + ts.frame = 0 ts.data['time'] = state.getTime() ts.data['potential_energy'] = state.getPotentialEnergy() ts.data['kinetic_energy'] = state.getKineticEnergy() @@ -167,8 +168,10 @@ def _mda_timestep_from_omm_modeller_pdbfile(omm_object, timestep_module, **ts_kw n_atoms = omm_object.topology.getNumAtoms() ts = timestep_module(n_atoms, **ts_kwargs) + ts.frame = 0 ts.triclinic_dimensions = np.array(omm_object.topology.getPeriodicBoxVectors()._value) ts.positions = np.array(omm_object.getPositions()._value) + return ts From 660e88c4c4d1b1df0507d6b1f4dc66d0fdc479ee Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Mon, 24 Aug 2020 20:45:10 -0400 Subject: [PATCH 13/47] Unwrap simtk quantity for time --- package/MDAnalysis/coordinates/OpenMM.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index b88428d0539..30455eabcae 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -145,7 +145,7 @@ def _mda_timestep_from_omm_context(omm_context, timestep_module, **ts_kwargs): ts = timestep_module(n_atoms, **ts_kwargs) ts.frame = 0 - ts.data['time'] = state.getTime() + ts.data['time'] = state.getTime()._value ts.data['potential_energy'] = state.getPotentialEnergy() ts.data['kinetic_energy'] = state.getKineticEnergy() ts.triclinic_dimensions = state.getPeriodicBoxVectors(asNumpy=True)._value From 6feb097f3d4ea6895f40624dcf5fa8afd770ca54 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Mon, 24 Aug 2020 20:45:22 -0400 Subject: [PATCH 14/47] Coordinates tests for openmm pdbfile, modeller, simulation objects --- .../coordinates/test_openmm.py | 113 ++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 testsuite/MDAnalysisTests/coordinates/test_openmm.py diff --git a/testsuite/MDAnalysisTests/coordinates/test_openmm.py b/testsuite/MDAnalysisTests/coordinates/test_openmm.py new file mode 100644 index 00000000000..832a34476fe --- /dev/null +++ b/testsuite/MDAnalysisTests/coordinates/test_openmm.py @@ -0,0 +1,113 @@ +# -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*- +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 fileencoding=utf-8 +# +# MDAnalysis --- https://www.mdanalysis.org +# Copyright (c) 2006-2017 The MDAnalysis Development Team and contributors +# (see the file AUTHORS for the full list of names) +# +# Released under the GNU Public Licence, v2 or any higher version +# +# Please cite your use of MDAnalysis in published work: +# +# R. J. Gowers, M. Linke, J. Barnoud, T. J. E. Reddy, M. N. Melo, S. L. Seyler, +# D. L. Dotson, J. Domanski, S. Buchoux, I. M. Kenney, and O. Beckstein. +# MDAnalysis: A Python package for the rapid analysis of molecular dynamics +# simulations. In S. Benthall and S. Rostrup editors, Proceedings of the 15th +# Python in Science Conference, pages 102-109, Austin, TX, 2016. SciPy. +# doi: 10.25080/majora-629e541a-00e +# +# N. Michaud-Agrawal, E. J. Denning, T. B. Woolf, and O. Beckstein. +# MDAnalysis: A Toolkit for the Analysis of Molecular Dynamics Simulations. +# J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787 +# +import pytest +from numpy.testing import assert_almost_equal + +from MDAnalysisTests.datafiles import CONECT +from MDAnalysisTests.coordinates.reference import (RefAdKSmall, + RefAdK) + +from MDAnalysisTests.coordinates.base import _SingleFrameReader + +import MDAnalysis as mda + +mm = pytest.importorskip('simtk.openmm') +unit = pytest.importorskip('simtk.unit') +app = pytest.importorskip('simtk.openmm.app') +pmd = pytest.importorskip('parmed') + +class TestOpenMMPDBFileReader(_SingleFrameReader): + __test__ = True + def setUp(self): + self.universe = mda.Universe(app.PDBFile(RefAdKSmall.filename)) + self.ref = mda.Universe(RefAdKSmall.filename) + self.prec = 3 + + def test_dimensions(self): + assert_almost_equal( + # Angles seem to parse differently when openmm reads the pdb file + self.universe.trajectory.ts.dimensions[0:3], + self.ref.trajectory.ts.dimensions[0:3], + self.prec, + "OpenMMPDBFileReader failed to get unitcell dimensions from OpenMMPDBFile") + + def test_coordinates(self): + up = self.universe.atoms.positions + rp = self.ref.atoms.positions + assert_almost_equal(up, rp, decimal=3) + +class TestOpenMMModellerReader(_SingleFrameReader): + __test__ = True + def setUp(self): + pdb_obj = app.PDBFile(RefAdKSmall.filename) + modeller = app.Modeller(pdb_obj.topology, pdb_obj.positions) + self.universe = mda.Universe(modeller) + self.ref = mda.Universe(RefAdKSmall.filename) + self.prec = 3 + + def test_dimensions(self): + assert_almost_equal( + # Angles seem to parse differently when openmm reads the pdb file + self.universe.trajectory.ts.dimensions[0:3], + self.ref.trajectory.ts.dimensions[0:3], + self.prec, + "OpenMMModellerReader failed to get unitcell dimensions from OpenMMModeller") + + def test_coordinates(self): + up = self.universe.atoms.positions + rp = self.ref.atoms.positions + assert_almost_equal(up, rp, decimal=3) + + +class TestOpenMMSimulationReader(_SingleFrameReader): + __test__ = True + + def setUp(self): + pdb = app.PDBFile(RefAdKSmall.filename) + forcefield = app.ForceField('amber99sbildn.xml') + system = forcefield.createSystem(pdb.topology, nonbondedMethod=app.NoCutoff, + constraints=app.HBonds) + integrator = mm.LangevinIntegrator( + 300*unit.kelvin, 1/unit.picoseconds, 2.0*unit.femtoseconds + ) + sim = app.Simulation(pdb.topology, system, integrator) + sim.context.setPositions(pdb.positions) + self.universe = mda.Universe(sim) + self.ref = mda.Universe(RefAdKSmall.filename) + self.prec = 3 + + def test_dimensions(self): + assert_almost_equal( + # Angles seem to parse differently when openmm reads the pdb file + self.universe.trajectory.ts.dimensions[0:3], + self.ref.trajectory.ts.dimensions[0:3], + self.prec, + "OpenMMPDBFileReader failed to get unitcell dimensions from OpenMMPDBFile") + + def test_coordinates(self): + up = self.universe.atoms.positions + rp = self.ref.atoms.positions + assert_almost_equal(up, rp, decimal=3) + + def test_pickle_singleframe_reader(self): pass + From 1725d180d435a55e1d660b995d639e8b8c459ba9 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Mon, 24 Aug 2020 20:47:06 -0400 Subject: [PATCH 15/47] update error messsage --- testsuite/MDAnalysisTests/coordinates/test_openmm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/MDAnalysisTests/coordinates/test_openmm.py b/testsuite/MDAnalysisTests/coordinates/test_openmm.py index 832a34476fe..21398e0cd6c 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_openmm.py +++ b/testsuite/MDAnalysisTests/coordinates/test_openmm.py @@ -102,7 +102,7 @@ def test_dimensions(self): self.universe.trajectory.ts.dimensions[0:3], self.ref.trajectory.ts.dimensions[0:3], self.prec, - "OpenMMPDBFileReader failed to get unitcell dimensions from OpenMMPDBFile") + "OpenMMSimulationReader failed to get unitcell dimensions from OpenMMSimulation") def test_coordinates(self): up = self.universe.atoms.positions From d1e7cead3de7cbf90749dd6e1960152c556786cd Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Mon, 24 Aug 2020 21:20:23 -0400 Subject: [PATCH 16/47] Update documentation --- package/AUTHORS | 1 + package/MDAnalysis/coordinates/OpenMM.py | 69 +++++++++++++++++++- package/MDAnalysis/topology/OpenMMParser.py | 72 +++++++++++++++++++++ 3 files changed, 140 insertions(+), 2 deletions(-) diff --git a/package/AUTHORS b/package/AUTHORS index 41bfd346411..bb2e48008e2 100644 --- a/package/AUTHORS +++ b/package/AUTHORS @@ -150,6 +150,7 @@ Chronological list of authors - Edis Jakupovic - Nicholas Craven - Mieczyslaw Torchala + - Alexander Yang External code ------------- diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index 30455eabcae..8b95fea125d 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -21,6 +21,38 @@ # J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787 # +"""OpenMM structure I/O --- :mod:`MDAnalysis.coordinates.OpenMM` +================================================================ + +Read coordinates data from a `OpenMM `_ :class:`simtk.openmm.app.simulation.Simulation` with :class:`OpenMMReader` +into a MDAnalysis Universe. + +Also converts: + + - `simtk.openmm.app.pdbfile.PDBFile `_ + - `simtk.openmm.app.modeller.Modeller `_ + - `simtk.openmm.app.pdbxfile.PDBxFile `_ + + +Classes +------- + +.. autoclass:: OpenMMSimulationReader + :members: + +.. autoclass:: OpenMMPDBFileReader + :members: + +.. autoclass:: OpenMMPDBxFileReader + :members: + +.. autoclass:: OpenMMModellerReader + :members: + + +""" + + import numpy as np from . import base @@ -63,7 +95,7 @@ def _read_first_frame(self): self.convert_time_from_native(self.ts.dt) class OpenMMPDBFileReader(base.SingleFrameReaderBase): - """Reader for the OpenMM Simulation objects + """Reader for the OpenMM PDBFile objects """ format = 'OPENMMPDBFILE' @@ -94,8 +126,41 @@ def _read_first_frame(self): self.ts.triclinic_dimensions, inplace=False ) +class OpenMMPDBxFileReader(base.SingleFrameReaderBase): + """Reader for the OpenMM PDBxFile objects + + """ + format = 'OPENMMPDBXFILE' + units = {'time': 'ps', 'length': 'nm'} + + @staticmethod + def _format_hint(thing): + """Can this reader read *thing*? + .. versionadded:: 1.0.0 + """ + try: + from simtk.openmm.app import PDBxFile + except ImportError: + return False + else: + return isinstance(thing, PDBxFile) + + + def _read_first_frame(self): + self.n_atoms = self.filename.topology.getNumAtoms() + + self.ts = _mda_timestep_from_omm_modeller_pdbfile(self.filename, + self._Timestep, **self._ts_kwargs) + + if self.convert_units: + self.convert_pos_from_native(self.ts._pos) + self.ts.triclinic_dimensions = self.convert_pos_from_native( + self.ts.triclinic_dimensions, inplace=False + ) + + class OpenMMModellerReader(base.SingleFrameReaderBase): - """Reader for the OpenMM Simulation objects + """Reader for the OpenMM Modeller objects """ format = 'OPENMMMODELLER' diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py index 26dad881008..10ce687ece3 100644 --- a/package/MDAnalysis/topology/OpenMMParser.py +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -21,6 +21,55 @@ # J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787 # +"""OpenMM topology parser +========================= + +.. versionadded:: 0.17.0 + + +Converts an `OpenMM `_ :class:`simtk.openmm.app.topology.Topology` into a :class:`MDAnalysis.core.Topology`. + +Also converts: + + - `simtk.openmm.app.pdbfile.PDBFile `_ + - `simtk.openmm.app.simulation.Simulation `_ + - `simtk.openmm.app.modeller.Modeller `_ + - `simtk.openmm.app.pdbxfile.PDBxFile `_ + +The :class:`OpenMMTopologyParser` generates a topology from an OpenMM Topology object files. + +.. _OpenMM: http://docs.openmm.org/latest/api-python/app.html + + + +Classes +------- + +.. autoclass:: OpenMMTopologyParser + :members: + :inherited-members: + +.. autoclass:: OpenMMSimulationParser + :members: + :inherited-members: + +.. autoclass:: OpenMMPDBFileParser + :members: + :inherited-members: + +.. autoclass:: OpenMMModellerParser + :members: + :inherited-members: + +.. autoclass:: OpenMMPDBxFileParser + :members: + :inherited-members: + + + + +""" + import numpy as np from .base import TopologyReaderBase @@ -137,6 +186,29 @@ def parse(self, **kwargs): return top +class OpenMMPDBxFileParser(TopologyReaderBase): + format = 'OPENMMMPDBXFILE' + + @staticmethod + def _format_hint(thing): + """Can this Parser read object *thing*? + + .. versionadded:: 1.0.0 + """ + try: + from simtk.openmm import app + except ImportError: + return False + else: + return isinstance(thing, app.PDBxFile) + + + def parse(self, **kwargs): + omm_pdbxfile = self.filename + + top = _mda_topology_from_omm_topology(omm_pdbxfile.topology) + + return top def _mda_topology_from_omm_topology(omm_topology): From 1bb0fd01d09f7dbfc9c98caa8f08b5b970ac9523 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Mon, 24 Aug 2020 21:20:40 -0400 Subject: [PATCH 17/47] Try updating some yaml files --- .appveyor.yml | 4 ++-- .travis.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 37cbd9db0d8..c751ca1dcbc 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -9,8 +9,8 @@ cache: environment: global: - CONDA_CHANNELS: conda-forge - CONDA_DEPENDENCIES: pip setuptools wheel cython biopython networkx joblib matplotlib scipy vs2015_runtime pytest mmtf-python GridDataFormats hypothesis pytest-cov codecov chemfiles tqdm tidynamics>=1.0.0 rdkit>=2020.03.1 h5py + CONDA_CHANNELS: conda-forge omnia + CONDA_DEPENDENCIES: pip setuptools wheel cython biopython networkx joblib matplotlib scipy vs2015_runtime pytest mmtf-python GridDataFormats hypothesis pytest-cov codecov chemfiles tqdm tidynamics>=1.0.0 rdkit>=2020.03.1 h5py openmm PIP_DEPENDENCIES: gsd==1.9.3 duecredit parmed DEBUG: "False" MINGW_64: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin diff --git a/.travis.yml b/.travis.yml index d94dc955f0a..adee8770e83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,8 +30,8 @@ env: - SETUP_CMD="${PYTEST_FLAGS}" - BUILD_CMD="pip install -e package/ && (cd testsuite/ && python setup.py build)" - CONDA_MIN_DEPENDENCIES="mmtf-python biopython networkx cython matplotlib scipy griddataformats hypothesis gsd codecov" - - CONDA_DEPENDENCIES="${CONDA_MIN_DEPENDENCIES} seaborn>=0.7.0 clustalw=2.1 netcdf4 scikit-learn joblib>=0.12 chemfiles tqdm>=4.43.0 tidynamics>=1.0.0 rdkit>=2020.03.1 h5py" - - CONDA_CHANNELS='biobuilds conda-forge' + - CONDA_DEPENDENCIES="${CONDA_MIN_DEPENDENCIES} seaborn>=0.7.0 clustalw=2.1 netcdf4 scikit-learn joblib>=0.12 chemfiles tqdm>=4.43.0 tidynamics>=1.0.0 rdkit>=2020.03.1 h5py openmm" + - CONDA_CHANNELS='biobuilds conda-forge omnia' - CONDA_CHANNEL_PRIORITY=True - PIP_DEPENDENCIES="duecredit parmed" - NUMPY_VERSION=stable From 1f138bdf8c24048cc72bf13a6f8fbd9e88c71849 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Mon, 24 Aug 2020 21:47:28 -0400 Subject: [PATCH 18/47] Include datafiles and tests for pdbx files --- package/MDAnalysis/coordinates/OpenMM.py | 3 +- .../coordinates/test_openmm.py | 77 +++++++++++++++- testsuite/MDAnalysisTests/data/4x8u.pdbx | 88 +++++++++++++++++++ testsuite/MDAnalysisTests/datafiles.py | 6 +- .../MDAnalysisTests/topology/test_openmm.py | 10 ++- 5 files changed, 178 insertions(+), 6 deletions(-) create mode 100644 testsuite/MDAnalysisTests/data/4x8u.pdbx diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index 8b95fea125d..c5cef3c8a3f 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -234,7 +234,8 @@ def _mda_timestep_from_omm_modeller_pdbfile(omm_object, timestep_module, **ts_kw ts = timestep_module(n_atoms, **ts_kwargs) ts.frame = 0 - ts.triclinic_dimensions = np.array(omm_object.topology.getPeriodicBoxVectors()._value) + if omm_object.topology.getPeriodicBoxVectors() is not None: + ts.triclinic_dimensions = np.array(omm_object.topology.getPeriodicBoxVectors()._value) ts.positions = np.array(omm_object.getPositions()._value) diff --git a/testsuite/MDAnalysisTests/coordinates/test_openmm.py b/testsuite/MDAnalysisTests/coordinates/test_openmm.py index 21398e0cd6c..38a2d066b7e 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_openmm.py +++ b/testsuite/MDAnalysisTests/coordinates/test_openmm.py @@ -21,11 +21,11 @@ # J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787 # import pytest +import numpy as np from numpy.testing import assert_almost_equal -from MDAnalysisTests.datafiles import CONECT -from MDAnalysisTests.coordinates.reference import (RefAdKSmall, - RefAdK) +from MDAnalysisTests.datafiles import PDBX +from MDAnalysisTests.coordinates.reference import RefAdKSmall from MDAnalysisTests.coordinates.base import _SingleFrameReader @@ -111,3 +111,74 @@ def test_coordinates(self): def test_pickle_singleframe_reader(self): pass + +@pytest.fixture +def PDBX_U(): + return mda.Universe(app.PDBxFile(PDBX)) + + +def test_pdbx_coordinates(PDBX_U): + ref_pos = 10*np.array([[0.6537, 3.7168, 1.4751], + [0.6141, 3.7813, 1.3496], + [0.4851, 3.8633, 1.3566], + [0.4428, 3.914 , 1.2532], + [0.6074, 3.6749, 1.2371], + [0.7366, 3.5948, 1.2334], + [0.8485, 3.6434, 1.1667], + [0.7494, 3.477 , 1.3064], + [0.9699, 3.5741, 1.1709], + [0.8706, 3.4079, 1.3107], + [0.9803, 3.4575, 1.2437], + [0.4265, 3.8799, 1.476 ], + [0.3019, 3.9561, 1.4964], + [0.3076, 4.1011, 1.4488], + [0.2061, 4.1541, 1.4068], + [0.2633, 3.9555, 1.6453], + [0.1999, 3.8275, 1.6944], + [0.1911, 3.7306, 1.6147], + [0.1619, 3.8224, 1.8133], + [0.424 , 4.1656, 1.4575], + [0.4388, 4.3071, 1.4222], + [0.5294, 4.3324, 1.3023], + [0.5726, 4.4457, 1.2828], + [0.4853, 4.387 , 1.5449], + [0.3731, 4.4096, 1.6449], + [0.4257, 4.4404, 1.7833], + [0.3124, 4.4673, 1.8792], + [0.5552, 4.2303, 1.2196], + [0.6382, 4.2504, 1.1005], + [0.555 , 4.3159, 0.9885], + [0.4442, 4.2696, 0.9581], + [0.7097, 4.119 , 1.0495], + [0.7974, 4.0487, 1.1586], + [0.7916, 4.1436, 0.9212], + [0.9078, 4.133 , 1.2278], + [0.6112, 4.4208, 0.9256], + [0.5533, 4.4859, 0.8069], + [0.6548, 4.4763, 0.6937], + [0.6177, 4.4543, 0.5787], + [0.5139, 4.6313, 0.8343], + [0.3789, 4.6433, 0.904 ], + [0.7844, 4.4865, 0.7289], + [0.8992, 4.4777, 0.6384], + [0.9414, 4.3301, 0.6208], + [1.0515, 4.2927, 0.6608], + [1.0151, 4.5643, 0.6923], + [0.8528, 4.2473, 0.5599], + [0.8763, 4.1044, 0.5361], + [1.0028, 4.0746, 0.4537], + [1.0652, 3.9719, 0.478 ], + [0.7534, 4.0355, 0.4762], + [0.6391, 4.0245, 0.5727], + [0.5337, 4.1106, 0.5851], + [0.6204, 3.9232, 0.6731], + [0.4486, 4.0675, 0.6847], + [0.5002, 3.9534, 0.7413], + [0.695 , 3.8109, 0.714 ], + [0.4534, 3.8758, 0.8486], + [0.6468, 3.7325, 0.8175], + [0.5277, 3.7648, 0.8837]]) + rp = PDBX_U.atoms.positions + assert_almost_equal(ref_pos, rp, decimal=3) + + diff --git a/testsuite/MDAnalysisTests/data/4x8u.pdbx b/testsuite/MDAnalysisTests/data/4x8u.pdbx new file mode 100644 index 00000000000..5ef564d4929 --- /dev/null +++ b/testsuite/MDAnalysisTests/data/4x8u.pdbx @@ -0,0 +1,88 @@ +# extract from 4X8U involving insertion codes +# +data_4X8U +# +_entry.id 4X8U +# +loop_ +_atom_site.group_PDB +_atom_site.id +_atom_site.type_symbol +_atom_site.label_atom_id +_atom_site.label_alt_id +_atom_site.label_comp_id +_atom_site.label_asym_id +_atom_site.label_entity_id +_atom_site.label_seq_id +_atom_site.pdbx_PDB_ins_code +_atom_site.Cartn_x +_atom_site.Cartn_y +_atom_site.Cartn_z +_atom_site.occupancy +_atom_site.B_iso_or_equiv +_atom_site.pdbx_formal_charge +_atom_site.auth_seq_id +_atom_site.auth_comp_id +_atom_site.auth_asym_id +_atom_site.auth_atom_id +_atom_site.pdbx_PDB_model_num +ATOM 315 N N . PHE A 1 43 ? 6.537 37.168 14.751 1.00 16.93 ? 59 PHE H N 1 +ATOM 316 C CA . PHE A 1 43 ? 6.141 37.813 13.496 1.00 16.64 ? 59 PHE H CA 1 +ATOM 317 C C . PHE A 1 43 ? 4.851 38.633 13.566 1.00 21.61 ? 59 PHE H C 1 +ATOM 318 O O . PHE A 1 43 ? 4.428 39.140 12.532 1.00 22.06 ? 59 PHE H O 1 +ATOM 319 C CB . PHE A 1 43 ? 6.074 36.749 12.371 1.00 17.35 ? 59 PHE H CB 1 +ATOM 320 C CG . PHE A 1 43 ? 7.366 35.948 12.334 1.00 17.99 ? 59 PHE H CG 1 +ATOM 321 C CD1 . PHE A 1 43 ? 8.485 36.434 11.667 1.00 21.29 ? 59 PHE H CD1 1 +ATOM 322 C CD2 . PHE A 1 43 ? 7.494 34.770 13.064 1.00 18.58 ? 59 PHE H CD2 1 +ATOM 323 C CE1 . PHE A 1 43 ? 9.699 35.741 11.709 1.00 22.04 ? 59 PHE H CE1 1 +ATOM 324 C CE2 . PHE A 1 43 ? 8.706 34.079 13.107 1.00 20.43 ? 59 PHE H CE2 1 +ATOM 325 C CZ . PHE A 1 43 ? 9.803 34.575 12.437 1.00 18.31 ? 59 PHE H CZ 1 +ATOM 326 N N . ASP A 1 44 ? 4.265 38.799 14.760 1.00 19.41 ? 60 ASP H N 1 +ATOM 327 C CA . ASP A 1 44 ? 3.019 39.561 14.964 1.00 21.98 ? 60 ASP H CA 1 +ATOM 328 C C . ASP A 1 44 ? 3.076 41.011 14.488 1.00 31.37 ? 60 ASP H C 1 +ATOM 329 O O . ASP A 1 44 ? 2.061 41.541 14.068 1.00 32.54 ? 60 ASP H O 1 +ATOM 330 C CB . ASP A 1 44 ? 2.633 39.555 16.453 1.00 23.09 ? 60 ASP H CB 1 +ATOM 331 C CG . ASP A 1 44 ? 1.999 38.275 16.944 1.00 28.33 ? 60 ASP H CG 1 +ATOM 332 O OD1 . ASP A 1 44 ? 1.911 37.306 16.147 1.00 29.31 ? 60 ASP H OD1 1 +ATOM 333 O OD2 . ASP A 1 44 ? 1.619 38.224 18.133 1.00 29.53 ? 60 ASP H OD2 1 +ATOM 334 N N . LYS A 1 45 A 4.240 41.656 14.575 1.00 30.66 ? 60 LYS H N 1 +ATOM 335 C CA . LYS A 1 45 A 4.388 43.071 14.222 1.00 31.68 ? 60 LYS H CA 1 +ATOM 336 C C . LYS A 1 45 A 5.294 43.324 13.023 1.00 38.11 ? 60 LYS H C 1 +ATOM 337 O O . LYS A 1 45 A 5.726 44.457 12.828 1.00 39.40 ? 60 LYS H O 1 +ATOM 338 C CB . LYS A 1 45 A 4.853 43.870 15.449 1.00 33.51 ? 60 LYS H CB 1 +ATOM 339 C CG . LYS A 1 45 A 3.731 44.096 16.449 1.00 48.38 ? 60 LYS H CG 1 +ATOM 340 C CD . LYS A 1 45 A 4.257 44.404 17.833 1.00 64.54 ? 60 LYS H CD 1 +ATOM 341 C CE . LYS A 1 45 A 3.124 44.673 18.792 1.00 76.49 ? 60 LYS H CE 1 +ATOM 342 N N . ILE A 1 46 B 5.552 42.303 12.196 1.00 34.95 ? 60 ILE H N 1 +ATOM 343 C CA . ILE A 1 46 B 6.382 42.504 11.005 1.00 35.67 ? 60 ILE H CA 1 +ATOM 344 C C . ILE A 1 46 B 5.550 43.159 9.885 1.00 40.88 ? 60 ILE H C 1 +ATOM 345 O O . ILE A 1 46 B 4.442 42.696 9.581 1.00 39.95 ? 60 ILE H O 1 +ATOM 346 C CB . ILE A 1 46 B 7.097 41.190 10.495 1.00 38.06 ? 60 ILE H CB 1 +ATOM 347 C CG1 . ILE A 1 46 B 7.974 40.487 11.586 1.00 37.99 ? 60 ILE H CG1 1 +ATOM 348 C CG2 . ILE A 1 46 B 7.916 41.436 9.212 1.00 37.97 ? 60 ILE H CG2 1 +ATOM 349 C CD1 . ILE A 1 46 B 9.078 41.330 12.278 1.00 43.63 ? 60 ILE H CD1 1 +ATOM 350 N N . LYS A 1 47 C 6.112 44.208 9.256 1.00 38.12 ? 60 LYS H N 1 +ATOM 351 C CA . LYS A 1 47 C 5.533 44.859 8.069 1.00 39.21 ? 60 LYS H CA 1 +ATOM 352 C C . LYS A 1 47 C 6.548 44.763 6.937 1.00 45.85 ? 60 LYS H C 1 +ATOM 353 O O . LYS A 1 47 C 6.177 44.543 5.787 1.00 46.49 ? 60 LYS H O 1 +ATOM 354 C CB . LYS A 1 47 C 5.139 46.313 8.343 1.00 41.67 ? 60 LYS H CB 1 +ATOM 355 C CG . LYS A 1 47 C 3.789 46.433 9.040 1.00 58.21 ? 60 LYS H CG 1 +ATOM 356 N N . ASN A 1 48 D 7.844 44.865 7.289 1.00 43.92 ? 60 ASN H N 1 +ATOM 357 C CA . ASN A 1 48 D 8.992 44.777 6.384 1.00 43.65 ? 60 ASN H CA 1 +ATOM 358 C C . ASN A 1 48 D 9.414 43.301 6.208 1.00 44.11 ? 60 ASN H C 1 +ATOM 359 O O . ASN A 1 48 D 10.515 42.927 6.608 1.00 42.37 ? 60 ASN H O 1 +ATOM 360 C CB . ASN A 1 48 D 10.151 45.643 6.923 1.00 45.00 ? 60 ASN H CB 1 +ATOM 361 N N . TRP A 1 49 ? 8.528 42.473 5.599 1.00 39.73 ? 61 TRP H N 1 +ATOM 362 C CA . TRP A 1 49 ? 8.763 41.044 5.361 1.00 39.08 ? 61 TRP H CA 1 +ATOM 363 C C . TRP A 1 49 ? 10.028 40.746 4.537 1.00 42.50 ? 61 TRP H C 1 +ATOM 364 O O . TRP A 1 49 ? 10.652 39.719 4.780 1.00 44.39 ? 61 TRP H O 1 +ATOM 365 C CB . TRP A 1 49 ? 7.534 40.355 4.762 1.00 37.55 ? 61 TRP H CB 1 +ATOM 366 C CG . TRP A 1 49 ? 6.391 40.245 5.727 1.00 38.53 ? 61 TRP H CG 1 +ATOM 367 C CD1 . TRP A 1 49 ? 5.337 41.106 5.851 1.00 41.76 ? 61 TRP H CD1 1 +ATOM 368 C CD2 . TRP A 1 49 ? 6.204 39.232 6.731 1.00 37.95 ? 61 TRP H CD2 1 +ATOM 369 N NE1 . TRP A 1 49 ? 4.486 40.675 6.847 1.00 41.50 ? 61 TRP H NE1 1 +ATOM 370 C CE2 . TRP A 1 49 ? 5.002 39.534 7.413 1.00 42.54 ? 61 TRP H CE2 1 +ATOM 371 C CE3 . TRP A 1 49 ? 6.950 38.109 7.140 1.00 38.20 ? 61 TRP H CE3 1 +ATOM 372 C CZ2 . TRP A 1 49 ? 4.534 38.758 8.486 1.00 41.36 ? 61 TRP H CZ2 1 +ATOM 373 C CZ3 . TRP A 1 49 ? 6.468 37.325 8.175 1.00 38.85 ? 61 TRP H CZ3 1 +ATOM 374 C CH2 . TRP A 1 49 ? 5.277 37.648 8.837 1.00 39.68 ? 61 TRP H CH2 1 diff --git a/testsuite/MDAnalysisTests/datafiles.py b/testsuite/MDAnalysisTests/datafiles.py index 898bd05b1ce..6217ec48f7e 100644 --- a/testsuite/MDAnalysisTests/datafiles.py +++ b/testsuite/MDAnalysisTests/datafiles.py @@ -197,7 +197,8 @@ "PDB_CHECK_RIGHTHAND_PA", # for testing right handedness of principal_axes "MMTF_NOCRYST", # File with meaningless CRYST1 record (Issue #2679, PR #2685) "FHIAIMS", # to test FHIAIMS coordinate files - "SDF_molecule" # MDL SDFile for rdkit + "SDF_molecule", # MDL SDFile for rdkit + "PDBX" # PDBxfile ] from pkg_resources import resource_filename @@ -545,5 +546,8 @@ SDF_molecule = resource_filename(__name__, 'data/molecule.sdf') +PDBX = resource_filename(__name__, 'data/4x8u.pdbx') + + # This should be the last line: clean up namespace del resource_filename diff --git a/testsuite/MDAnalysisTests/topology/test_openmm.py b/testsuite/MDAnalysisTests/topology/test_openmm.py index 4ec554ee88f..1eaec76c29a 100644 --- a/testsuite/MDAnalysisTests/topology/test_openmm.py +++ b/testsuite/MDAnalysisTests/topology/test_openmm.py @@ -27,7 +27,7 @@ import MDAnalysis as mda from MDAnalysisTests.topology.base import ParserBase -from MDAnalysisTests.datafiles import CONECT +from MDAnalysisTests.datafiles import CONECT, PDBX class OpenMMTopologyBase(ParserBase): parser = mda.topology.OpenMMParser.OpenMMTopologyParser @@ -92,3 +92,11 @@ class TestOpenMMTopologyParser(OpenMMTopologyBase): expected_n_segments = 3 expected_n_bonds = 1922 + +class TestOpenMMPDBxFileParser(OpenMMTopologyBase): + ref_filename = app.PDBxFile(PDBX).topology + expected_n_atoms = 60 + expected_n_residues = 7 + expected_n_segments = 1 + expected_n_bonds = 62 + From 138ad65d51783aa493139830e513405b1db98459 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Mon, 24 Aug 2020 21:48:24 -0400 Subject: [PATCH 19/47] More documentation for pdbx --- package/MDAnalysis/coordinates/OpenMM.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index c5cef3c8a3f..d7e81c6c2a4 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -226,7 +226,7 @@ def _mda_timestep_from_omm_modeller_pdbfile(omm_object, timestep_module, **ts_kw Parameters ---------- - omm_object: simtk.openmm.app.PDBFile or simtk.openmm.app.Modeller + omm_object: simtk.openmm.app.PDBFile, simtk.openmm.app.Modeller, or simtk.openmm.app.PDBxFile timestep_module: MDAnalysis.coordinates.base.timestep This is the module, but the object gets created within this function """ From 4c11d06bb261af625c002eaf538f89ecb9285a31 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Mon, 24 Aug 2020 21:49:27 -0400 Subject: [PATCH 20/47] Typo in format --- package/MDAnalysis/topology/OpenMMParser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py index 10ce687ece3..473a032ff19 100644 --- a/package/MDAnalysis/topology/OpenMMParser.py +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -187,7 +187,7 @@ def parse(self, **kwargs): return top class OpenMMPDBxFileParser(TopologyReaderBase): - format = 'OPENMMMPDBXFILE' + format = 'OPENMMPDBXFILE' @staticmethod def _format_hint(thing): From 15807fca04d87c73ecd6b7f663abc49cbb079f7d Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Mon, 24 Aug 2020 22:11:40 -0400 Subject: [PATCH 21/47] Blacken code --- package/MDAnalysis/coordinates/OpenMM.py | 76 +- package/MDAnalysis/topology/OpenMMParser.py | 48 +- .../coordinates/test_openmm.py | 171 ++-- testsuite/MDAnalysisTests/datafiles.py | 820 ++++++++++-------- .../MDAnalysisTests/topology/test_openmm.py | 18 +- 5 files changed, 643 insertions(+), 490 deletions(-) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index d7e81c6c2a4..cb136c5deaa 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -62,9 +62,9 @@ class OpenMMSimulationReader(base.SingleFrameReaderBase): """Reader for the OpenMM Simulation objects """ - format = 'OPENMMSIMULATION' - units = {'time': 'ps', 'length': 'nm', 'velocity': 'nm/ps', - 'force': 'kJ/(mol*nm)'} + + format = "OPENMMSIMULATION" + units = {"time": "ps", "length": "nm", "velocity": "nm/ps", "force": "kJ/(mol*nm)"} @staticmethod def _format_hint(thing): @@ -76,14 +76,14 @@ def _format_hint(thing): except ImportError: return False else: - return isinstance(thing, Simulation) - + return isinstance(thing, Simulation) def _read_first_frame(self): self.n_atoms = self.filename.topology.getNumAtoms() - self.ts = _mda_timestep_from_omm_context(self.filename.context, - self._Timestep, **self._ts_kwargs) + self.ts = _mda_timestep_from_omm_context( + self.filename.context, self._Timestep, **self._ts_kwargs + ) if self.convert_units: self.convert_pos_from_native(self.ts._pos) @@ -94,12 +94,14 @@ def _read_first_frame(self): self.convert_forces_from_native(self.ts._forces) self.convert_time_from_native(self.ts.dt) + class OpenMMPDBFileReader(base.SingleFrameReaderBase): """Reader for the OpenMM PDBFile objects """ - format = 'OPENMMPDBFILE' - units = {'time': 'ps', 'length': 'nm'} + + format = "OPENMMPDBFILE" + units = {"time": "ps", "length": "nm"} @staticmethod def _format_hint(thing): @@ -111,14 +113,14 @@ def _format_hint(thing): except ImportError: return False else: - return isinstance(thing, PDBFile) - + return isinstance(thing, PDBFile) def _read_first_frame(self): self.n_atoms = self.filename.topology.getNumAtoms() - self.ts = _mda_timestep_from_omm_modeller_pdbfile(self.filename, - self._Timestep, **self._ts_kwargs) + self.ts = _mda_timestep_from_omm_modeller_pdbfile( + self.filename, self._Timestep, **self._ts_kwargs + ) if self.convert_units: self.convert_pos_from_native(self.ts._pos) @@ -126,12 +128,14 @@ def _read_first_frame(self): self.ts.triclinic_dimensions, inplace=False ) + class OpenMMPDBxFileReader(base.SingleFrameReaderBase): """Reader for the OpenMM PDBxFile objects """ - format = 'OPENMMPDBXFILE' - units = {'time': 'ps', 'length': 'nm'} + + format = "OPENMMPDBXFILE" + units = {"time": "ps", "length": "nm"} @staticmethod def _format_hint(thing): @@ -143,14 +147,14 @@ def _format_hint(thing): except ImportError: return False else: - return isinstance(thing, PDBxFile) - + return isinstance(thing, PDBxFile) def _read_first_frame(self): self.n_atoms = self.filename.topology.getNumAtoms() - self.ts = _mda_timestep_from_omm_modeller_pdbfile(self.filename, - self._Timestep, **self._ts_kwargs) + self.ts = _mda_timestep_from_omm_modeller_pdbfile( + self.filename, self._Timestep, **self._ts_kwargs + ) if self.convert_units: self.convert_pos_from_native(self.ts._pos) @@ -163,8 +167,9 @@ class OpenMMModellerReader(base.SingleFrameReaderBase): """Reader for the OpenMM Modeller objects """ - format = 'OPENMMMODELLER' - units = {'time': 'ps', 'length': 'nm'} + + format = "OPENMMMODELLER" + units = {"time": "ps", "length": "nm"} @staticmethod def _format_hint(thing): @@ -176,14 +181,14 @@ def _format_hint(thing): except ImportError: return False else: - return isinstance(thing, Modeller) - + return isinstance(thing, Modeller) def _read_first_frame(self): self.n_atoms = self.filename.topology.getNumAtoms() - self.ts = _mda_timestep_from_omm_modeller_pdbfile(self.filename, - self._Timestep, **self._ts_kwargs) + self.ts = _mda_timestep_from_omm_modeller_pdbfile( + self.filename, self._Timestep, **self._ts_kwargs + ) if self.convert_units: self.convert_pos_from_native(self.ts._pos) @@ -192,7 +197,6 @@ def _read_first_frame(self): ) - def _mda_timestep_from_omm_context(omm_context, timestep_module, **ts_kwargs): """ Construct Timestep object from Openmm context @@ -202,25 +206,23 @@ def _mda_timestep_from_omm_context(omm_context, timestep_module, **ts_kwargs): timestep_module: MDAnalysis.coordinates.base.timestep This is the module, but the object gets created within this function """ - state = omm_context.getState(-1, getVelocities=True, - getForces=True, getEnergy=True - ) + state = omm_context.getState(-1, getVelocities=True, getForces=True, getEnergy=True) n_atoms = omm_context.getSystem().getNumParticles() ts = timestep_module(n_atoms, **ts_kwargs) ts.frame = 0 - ts.data['time'] = state.getTime()._value - ts.data['potential_energy'] = state.getPotentialEnergy() - ts.data['kinetic_energy'] = state.getKineticEnergy() + ts.data["time"] = state.getTime()._value + ts.data["potential_energy"] = state.getPotentialEnergy() + ts.data["kinetic_energy"] = state.getKineticEnergy() ts.triclinic_dimensions = state.getPeriodicBoxVectors(asNumpy=True)._value ts.positions = state.getPositions(asNumpy=True)._value ts.velocities = state.getVelocities(asNumpy=True)._value ts.forces = state.getForces(asNumpy=True)._value - return ts - + + def _mda_timestep_from_omm_modeller_pdbfile(omm_object, timestep_module, **ts_kwargs): """ Construct Timestep object from Openmm context @@ -235,9 +237,9 @@ def _mda_timestep_from_omm_modeller_pdbfile(omm_object, timestep_module, **ts_kw ts = timestep_module(n_atoms, **ts_kwargs) ts.frame = 0 if omm_object.topology.getPeriodicBoxVectors() is not None: - ts.triclinic_dimensions = np.array(omm_object.topology.getPeriodicBoxVectors()._value) + ts.triclinic_dimensions = np.array( + omm_object.topology.getPeriodicBoxVectors()._value + ) ts.positions = np.array(omm_object.getPositions()._value) - return ts - diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py index 473a032ff19..bdcb8ca9fbe 100644 --- a/package/MDAnalysis/topology/OpenMMParser.py +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -1,5 +1,5 @@ # -*- Mode: python; tab-width: 4; indent-tabs-mode:nil; coding:utf-8 -*- -# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 +# vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 # # MDAnalysis --- https://www.mdanalysis.org # Copyright (c) 2006-2017 The MDAnalysis Development Team and contributors @@ -91,7 +91,7 @@ class OpenMMTopologyParser(TopologyReaderBase): - format = 'OPENMMTOPOLOGY' + format = "OPENMMTOPOLOGY" @staticmethod def _format_hint(thing): @@ -101,12 +101,11 @@ def _format_hint(thing): """ try: from simtk.openmm import app - except ImportError: + except ImportError: return False else: return isinstance(thing, app.Topology) - def parse(self, **kwargs): omm_topology = self.filename @@ -114,8 +113,9 @@ def parse(self, **kwargs): return top + class OpenMMSimulationParser(TopologyReaderBase): - format = 'OPENMMSIMULATION' + format = "OPENMMSIMULATION" @staticmethod def _format_hint(thing): @@ -125,12 +125,11 @@ def _format_hint(thing): """ try: from simtk.openmm import app - except ImportError: + except ImportError: return False else: return isinstance(thing, app.Simulation) - def parse(self, **kwargs): omm_topology = self.filename.topology @@ -138,8 +137,9 @@ def parse(self, **kwargs): return top + class OpenMMPDBFileParser(TopologyReaderBase): - format = 'OPENMMPDBFILE' + format = "OPENMMPDBFILE" @staticmethod def _format_hint(thing): @@ -149,12 +149,11 @@ def _format_hint(thing): """ try: from simtk.openmm import app - except ImportError: + except ImportError: return False else: return isinstance(thing, app.PDBFile) - def parse(self, **kwargs): omm_pdbfile = self.filename @@ -162,8 +161,9 @@ def parse(self, **kwargs): return top + class OpenMMModellerParser(TopologyReaderBase): - format = 'OPENMMMODELLER' + format = "OPENMMMODELLER" @staticmethod def _format_hint(thing): @@ -173,12 +173,11 @@ def _format_hint(thing): """ try: from simtk.openmm import app - except ImportError: + except ImportError: return False else: return isinstance(thing, app.Modeller) - def parse(self, **kwargs): omm_modeller = self.filename @@ -186,8 +185,9 @@ def parse(self, **kwargs): return top + class OpenMMPDBxFileParser(TopologyReaderBase): - format = 'OPENMMPDBXFILE' + format = "OPENMMPDBXFILE" @staticmethod def _format_hint(thing): @@ -197,12 +197,11 @@ def _format_hint(thing): """ try: from simtk.openmm import app - except ImportError: + except ImportError: return False else: return isinstance(thing, app.PDBxFile) - def parse(self, **kwargs): omm_pdbxfile = self.filename @@ -228,13 +227,13 @@ def _mda_topology_from_omm_topology(omm_topology): resnums = resids.copy() segids = [c.index for c in omm_topology.chains()] bonds = [(b.atom1.index, b.atom2.index) for b in omm_topology.bonds()] - bond_orders =[b.order for b in omm_topology.bonds()] + bond_orders = [b.order for b in omm_topology.bonds()] bond_types = [b.type for b in omm_topology.bonds()] - + n_atoms = len(atomids) n_residues = len(resids) n_segments = len(segids) - + attrs = [ Atomids(np.array(atomids, dtype=np.int32)), Atomnames(np.array(atomnames, dtype=object)), @@ -246,15 +245,16 @@ def _mda_topology_from_omm_topology(omm_topology): Resids(resids), Resnums(resnums), Resnames(resnames), - Segids(segids) + Segids(segids), ] - top = Topology(n_atoms, n_residues, n_segments, + top = Topology( + n_atoms, + n_residues, + n_segments, attrs=attrs, atom_resindex=atom_resindex, - residue_segindex=residue_segindex + residue_segindex=residue_segindex, ) return top - - diff --git a/testsuite/MDAnalysisTests/coordinates/test_openmm.py b/testsuite/MDAnalysisTests/coordinates/test_openmm.py index 38a2d066b7e..bc74128bfd6 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_openmm.py +++ b/testsuite/MDAnalysisTests/coordinates/test_openmm.py @@ -31,13 +31,15 @@ import MDAnalysis as mda -mm = pytest.importorskip('simtk.openmm') -unit = pytest.importorskip('simtk.unit') -app = pytest.importorskip('simtk.openmm.app') -pmd = pytest.importorskip('parmed') +mm = pytest.importorskip("simtk.openmm") +unit = pytest.importorskip("simtk.unit") +app = pytest.importorskip("simtk.openmm.app") +pmd = pytest.importorskip("parmed") + class TestOpenMMPDBFileReader(_SingleFrameReader): __test__ = True + def setUp(self): self.universe = mda.Universe(app.PDBFile(RefAdKSmall.filename)) self.ref = mda.Universe(RefAdKSmall.filename) @@ -49,15 +51,18 @@ def test_dimensions(self): self.universe.trajectory.ts.dimensions[0:3], self.ref.trajectory.ts.dimensions[0:3], self.prec, - "OpenMMPDBFileReader failed to get unitcell dimensions from OpenMMPDBFile") - + "OpenMMPDBFileReader failed to get unitcell dimensions from OpenMMPDBFile", + ) + def test_coordinates(self): up = self.universe.atoms.positions rp = self.ref.atoms.positions assert_almost_equal(up, rp, decimal=3) + class TestOpenMMModellerReader(_SingleFrameReader): __test__ = True + def setUp(self): pdb_obj = app.PDBFile(RefAdKSmall.filename) modeller = app.Modeller(pdb_obj.topology, pdb_obj.positions) @@ -71,8 +76,9 @@ def test_dimensions(self): self.universe.trajectory.ts.dimensions[0:3], self.ref.trajectory.ts.dimensions[0:3], self.prec, - "OpenMMModellerReader failed to get unitcell dimensions from OpenMMModeller") - + "OpenMMModellerReader failed to get unitcell dimensions from OpenMMModeller", + ) + def test_coordinates(self): up = self.universe.atoms.positions rp = self.ref.atoms.positions @@ -84,11 +90,12 @@ class TestOpenMMSimulationReader(_SingleFrameReader): def setUp(self): pdb = app.PDBFile(RefAdKSmall.filename) - forcefield = app.ForceField('amber99sbildn.xml') - system = forcefield.createSystem(pdb.topology, nonbondedMethod=app.NoCutoff, - constraints=app.HBonds) + forcefield = app.ForceField("amber99sbildn.xml") + system = forcefield.createSystem( + pdb.topology, nonbondedMethod=app.NoCutoff, constraints=app.HBonds + ) integrator = mm.LangevinIntegrator( - 300*unit.kelvin, 1/unit.picoseconds, 2.0*unit.femtoseconds + 300 * unit.kelvin, 1 / unit.picoseconds, 2.0 * unit.femtoseconds ) sim = app.Simulation(pdb.topology, system, integrator) sim.context.setPositions(pdb.positions) @@ -102,83 +109,87 @@ def test_dimensions(self): self.universe.trajectory.ts.dimensions[0:3], self.ref.trajectory.ts.dimensions[0:3], self.prec, - "OpenMMSimulationReader failed to get unitcell dimensions from OpenMMSimulation") - + "OpenMMSimulationReader failed to get unitcell dimensions from OpenMMSimulation", + ) + def test_coordinates(self): up = self.universe.atoms.positions rp = self.ref.atoms.positions assert_almost_equal(up, rp, decimal=3) - def test_pickle_singleframe_reader(self): pass + def test_pickle_singleframe_reader(self): + pass @pytest.fixture def PDBX_U(): return mda.Universe(app.PDBxFile(PDBX)) - -def test_pdbx_coordinates(PDBX_U): - ref_pos = 10*np.array([[0.6537, 3.7168, 1.4751], - [0.6141, 3.7813, 1.3496], - [0.4851, 3.8633, 1.3566], - [0.4428, 3.914 , 1.2532], - [0.6074, 3.6749, 1.2371], - [0.7366, 3.5948, 1.2334], - [0.8485, 3.6434, 1.1667], - [0.7494, 3.477 , 1.3064], - [0.9699, 3.5741, 1.1709], - [0.8706, 3.4079, 1.3107], - [0.9803, 3.4575, 1.2437], - [0.4265, 3.8799, 1.476 ], - [0.3019, 3.9561, 1.4964], - [0.3076, 4.1011, 1.4488], - [0.2061, 4.1541, 1.4068], - [0.2633, 3.9555, 1.6453], - [0.1999, 3.8275, 1.6944], - [0.1911, 3.7306, 1.6147], - [0.1619, 3.8224, 1.8133], - [0.424 , 4.1656, 1.4575], - [0.4388, 4.3071, 1.4222], - [0.5294, 4.3324, 1.3023], - [0.5726, 4.4457, 1.2828], - [0.4853, 4.387 , 1.5449], - [0.3731, 4.4096, 1.6449], - [0.4257, 4.4404, 1.7833], - [0.3124, 4.4673, 1.8792], - [0.5552, 4.2303, 1.2196], - [0.6382, 4.2504, 1.1005], - [0.555 , 4.3159, 0.9885], - [0.4442, 4.2696, 0.9581], - [0.7097, 4.119 , 1.0495], - [0.7974, 4.0487, 1.1586], - [0.7916, 4.1436, 0.9212], - [0.9078, 4.133 , 1.2278], - [0.6112, 4.4208, 0.9256], - [0.5533, 4.4859, 0.8069], - [0.6548, 4.4763, 0.6937], - [0.6177, 4.4543, 0.5787], - [0.5139, 4.6313, 0.8343], - [0.3789, 4.6433, 0.904 ], - [0.7844, 4.4865, 0.7289], - [0.8992, 4.4777, 0.6384], - [0.9414, 4.3301, 0.6208], - [1.0515, 4.2927, 0.6608], - [1.0151, 4.5643, 0.6923], - [0.8528, 4.2473, 0.5599], - [0.8763, 4.1044, 0.5361], - [1.0028, 4.0746, 0.4537], - [1.0652, 3.9719, 0.478 ], - [0.7534, 4.0355, 0.4762], - [0.6391, 4.0245, 0.5727], - [0.5337, 4.1106, 0.5851], - [0.6204, 3.9232, 0.6731], - [0.4486, 4.0675, 0.6847], - [0.5002, 3.9534, 0.7413], - [0.695 , 3.8109, 0.714 ], - [0.4534, 3.8758, 0.8486], - [0.6468, 3.7325, 0.8175], - [0.5277, 3.7648, 0.8837]]) - rp = PDBX_U.atoms.positions - assert_almost_equal(ref_pos, rp, decimal=3) - +def test_pdbx_coordinates(PDBX_U): + ref_pos = 10 * np.array( + [ + [0.6537, 3.7168, 1.4751], + [0.6141, 3.7813, 1.3496], + [0.4851, 3.8633, 1.3566], + [0.4428, 3.914, 1.2532], + [0.6074, 3.6749, 1.2371], + [0.7366, 3.5948, 1.2334], + [0.8485, 3.6434, 1.1667], + [0.7494, 3.477, 1.3064], + [0.9699, 3.5741, 1.1709], + [0.8706, 3.4079, 1.3107], + [0.9803, 3.4575, 1.2437], + [0.4265, 3.8799, 1.476], + [0.3019, 3.9561, 1.4964], + [0.3076, 4.1011, 1.4488], + [0.2061, 4.1541, 1.4068], + [0.2633, 3.9555, 1.6453], + [0.1999, 3.8275, 1.6944], + [0.1911, 3.7306, 1.6147], + [0.1619, 3.8224, 1.8133], + [0.424, 4.1656, 1.4575], + [0.4388, 4.3071, 1.4222], + [0.5294, 4.3324, 1.3023], + [0.5726, 4.4457, 1.2828], + [0.4853, 4.387, 1.5449], + [0.3731, 4.4096, 1.6449], + [0.4257, 4.4404, 1.7833], + [0.3124, 4.4673, 1.8792], + [0.5552, 4.2303, 1.2196], + [0.6382, 4.2504, 1.1005], + [0.555, 4.3159, 0.9885], + [0.4442, 4.2696, 0.9581], + [0.7097, 4.119, 1.0495], + [0.7974, 4.0487, 1.1586], + [0.7916, 4.1436, 0.9212], + [0.9078, 4.133, 1.2278], + [0.6112, 4.4208, 0.9256], + [0.5533, 4.4859, 0.8069], + [0.6548, 4.4763, 0.6937], + [0.6177, 4.4543, 0.5787], + [0.5139, 4.6313, 0.8343], + [0.3789, 4.6433, 0.904], + [0.7844, 4.4865, 0.7289], + [0.8992, 4.4777, 0.6384], + [0.9414, 4.3301, 0.6208], + [1.0515, 4.2927, 0.6608], + [1.0151, 4.5643, 0.6923], + [0.8528, 4.2473, 0.5599], + [0.8763, 4.1044, 0.5361], + [1.0028, 4.0746, 0.4537], + [1.0652, 3.9719, 0.478], + [0.7534, 4.0355, 0.4762], + [0.6391, 4.0245, 0.5727], + [0.5337, 4.1106, 0.5851], + [0.6204, 3.9232, 0.6731], + [0.4486, 4.0675, 0.6847], + [0.5002, 3.9534, 0.7413], + [0.695, 3.8109, 0.714], + [0.4534, 3.8758, 0.8486], + [0.6468, 3.7325, 0.8175], + [0.5277, 3.7648, 0.8837], + ] + ) + rp = PDBX_U.atoms.positions + assert_almost_equal(ref_pos, rp, decimal=3) diff --git a/testsuite/MDAnalysisTests/datafiles.py b/testsuite/MDAnalysisTests/datafiles.py index 6217ec48f7e..3c2ef594d36 100644 --- a/testsuite/MDAnalysisTests/datafiles.py +++ b/testsuite/MDAnalysisTests/datafiles.py @@ -37,14 +37,21 @@ """ __all__ = [ - "PSF", "DCD", "CRD", # CHARMM (AdK example, DIMS trajectory from JMB 2009 paper) - "DCD2", # CHARMM (AdK example, DIMS trajectory from PLOS Comput Biol paper) - "PSF_notop", "PSF_BAD", # Same as PSF but no bonds etc, malformed version of previous + "PSF", + "DCD", + "CRD", # CHARMM (AdK example, DIMS trajectory from JMB 2009 paper) + "DCD2", # CHARMM (AdK example, DIMS trajectory from PLOS Comput Biol paper) + "PSF_notop", + "PSF_BAD", # Same as PSF but no bonds etc, malformed version of previous "DCD_empty", - "PSF_TRICLINIC", "DCD_TRICLINIC", # CHARMM c36 new unitcell, NPT 125 TIP3P (box vectors, see Issue 187 for details) - "PSF_NAMD", "PDB_NAMD", # NAMD - "PSF_NAMD_TRICLINIC", "DCD_NAMD_TRICLINIC", # NAMD, triclinic unitcell (Issue 187) - "PSF_NAMD_GBIS", "DCD_NAMD_GBIS", # NAMD, implicit solvent, 100 steps, #1819 + "PSF_TRICLINIC", + "DCD_TRICLINIC", # CHARMM c36 new unitcell, NPT 125 TIP3P (box vectors, see Issue 187 for details) + "PSF_NAMD", + "PDB_NAMD", # NAMD + "PSF_NAMD_TRICLINIC", + "DCD_NAMD_TRICLINIC", # NAMD, triclinic unitcell (Issue 187) + "PSF_NAMD_GBIS", + "DCD_NAMD_GBIS", # NAMD, implicit solvent, 100 steps, #1819 "PSF_nosegid", # psf without a segid, Issue 121 "PSF_cmap", # ala3 PSF from ParmEd test files with cmap "PDB_small", # PDB @@ -56,94 +63,178 @@ "PDB_singleconect", # Conect record with one entry (Issue 937) "PDB_icodes", # stripped down version of 1osm, has icodes! "XPDB_small", - "PDB_full", # PDB 4E43 (full HEADER, TITLE, COMPND, REMARK, altloc) + "PDB_full", # PDB 4E43 (full HEADER, TITLE, COMPND, REMARK, altloc) "ALIGN", # Various way to align atom names in PDB files - "RNA_PSF", "RNA_PDB", # nucleic acid (PDB 1K5I in CHARMM36m) + "RNA_PSF", + "RNA_PDB", # nucleic acid (PDB 1K5I in CHARMM36m) "INC_PDB", # incomplete PDB file (Issue #396) # for testing cryst before/after model headers - "PDB_cm", "PDB_cm_bz2", "PDB_cm_gz", - "PDB_mc", "PDB_mc_bz2", "PDB_mc_gz", + "PDB_cm", + "PDB_cm_bz2", + "PDB_cm_gz", + "PDB_mc", + "PDB_mc_bz2", + "PDB_mc_gz", "PDB_chainidnewres", # Issue 1110 - "PDB_sameresid_diffresname", #Case where two residues share the same resid + "PDB_sameresid_diffresname", # Case where two residues share the same resid "PDB_chainidrepeat", # Issue #1107 - "PDB", "GRO", "XTC", "TRR", "TPR", "GRO_velocity", # Gromacs (AdK) + "PDB", + "GRO", + "XTC", + "TRR", + "TPR", + "GRO_velocity", # Gromacs (AdK) "GRO_incomplete_vels", "COORDINATES_GRO_BZ2", - "GRO_large", #atom number truncation at > 100,000 particles, Issue 550 + "GRO_large", # atom number truncation at > 100,000 particles, Issue 550 "GRO_residwrap", # resids wrapping because of 5 digit field (Issue #728) "GRO_residwrap_0base", # corner case of #728 with resid=0 for first atom - "GRO_sameresid_diffresname", # Case where two residues share the same resid - "PDB_xvf", "TPR_xvf", "TRR_xvf", # Gromacs coords/veloc/forces (cobrotoxin, OPLS-AA, Gromacs 4.5.5 tpr) + "GRO_sameresid_diffresname", # Case where two residues share the same resid + "PDB_xvf", + "TPR_xvf", + "TRR_xvf", # Gromacs coords/veloc/forces (cobrotoxin, OPLS-AA, Gromacs 4.5.5 tpr) "H5MD_xvf", # TPR_xvf + TRR_xvf converted to h5md format "XVG_BZ2", # Compressed xvg file about cobrotoxin "PDB_xlserial", - "TPR400", "TPR402", "TPR403", "TPR404", "TPR405", "TPR406", "TPR407", - "TPR450", "TPR451", "TPR452", "TPR453", "TPR454", "TPR455", "TPR455Double", - "TPR460", "TPR461", "TPR502", "TPR504", "TPR505", "TPR510", "TPR2016", - "TPR2018", "TPR2019B3", "TPR2020B2", "TPR2020", "TPR2020Double", - "TPR510_bonded", "TPR2016_bonded", "TPR2018_bonded", "TPR2019B3_bonded", - "TPR2020B2_bonded", "TPR2020_bonded", "TPR2020_double_bonded", + "TPR400", + "TPR402", + "TPR403", + "TPR404", + "TPR405", + "TPR406", + "TPR407", + "TPR450", + "TPR451", + "TPR452", + "TPR453", + "TPR454", + "TPR455", + "TPR455Double", + "TPR460", + "TPR461", + "TPR502", + "TPR504", + "TPR505", + "TPR510", + "TPR2016", + "TPR2018", + "TPR2019B3", + "TPR2020B2", + "TPR2020", + "TPR2020Double", + "TPR510_bonded", + "TPR2016_bonded", + "TPR2018_bonded", + "TPR2019B3_bonded", + "TPR2020B2_bonded", + "TPR2020_bonded", + "TPR2020_double_bonded", "TPR334_bonded", - "TPR_EXTRA_2020", "TPR_EXTRA_2018", "TPR_EXTRA_2016", "TPR_EXTRA_407", - "PDB_sub_sol", "PDB_sub_dry", # TRRReader sub selection + "TPR_EXTRA_2020", + "TPR_EXTRA_2018", + "TPR_EXTRA_2016", + "TPR_EXTRA_407", + "PDB_sub_sol", + "PDB_sub_dry", # TRRReader sub selection "TRR_sub_sol", "XTC_sub_sol", - "XYZ", "XYZ_psf", "XYZ_bz2", - "XYZ_mini", "XYZ_five", # 3 and 5 atoms xyzs for an easy topology - "TXYZ", "ARC", "ARC_PBC", # Tinker files - "PRM", "TRJ", "TRJ_bz2", # Amber (no periodic box) + "XYZ", + "XYZ_psf", + "XYZ_bz2", + "XYZ_mini", + "XYZ_five", # 3 and 5 atoms xyzs for an easy topology + "TXYZ", + "ARC", + "ARC_PBC", # Tinker files + "PRM", + "TRJ", + "TRJ_bz2", # Amber (no periodic box) "INPCRD", - "PRMpbc", "TRJpbc_bz2", # Amber (periodic box) - "PRM7", "NCDFtruncoct", # Amber (cpptrj test trajectory, see Issue 488) - "PRM12", "TRJ12_bz2", # Amber (v12 format, Issue 100) - "PRMncdf", "TRJncdf", "NCDF", # Amber (netcdf) - "PFncdf_Top", "PFncdf_Trj", # Amber ncdf with Positions and Forces - "PRMcs", # Amber (format, Issue 1331) - "PRMNCRST", # Amber ncrst with positions/forces/velocities - "PRM_NCBOX", "TRJ_NCBOX", # Amber parm7 + nc w/ pos/forces/vels/box - "PRMNEGATIVE", # Amber negative ATOMIC_NUMBER (Issue 2306) - "PRMErr1", "PRMErr2", "PRMErr3", # Amber TOP files to check raised errors - "PRM_UreyBradley", # prmtop from ParmEd test files with Urey-Bradley angles - "PRM7_ala2", "RST7_ala2", # prmtop and rst files from ParmEd example files - "PRM19SBOPC", # prmtop w/ ff19SB CMAP terms and OPC water (Issue #2449) + "PRMpbc", + "TRJpbc_bz2", # Amber (periodic box) + "PRM7", + "NCDFtruncoct", # Amber (cpptrj test trajectory, see Issue 488) + "PRM12", + "TRJ12_bz2", # Amber (v12 format, Issue 100) + "PRMncdf", + "TRJncdf", + "NCDF", # Amber (netcdf) + "PFncdf_Top", + "PFncdf_Trj", # Amber ncdf with Positions and Forces + "PRMcs", # Amber (format, Issue 1331) + "PRMNCRST", # Amber ncrst with positions/forces/velocities + "PRM_NCBOX", + "TRJ_NCBOX", # Amber parm7 + nc w/ pos/forces/vels/box + "PRMNEGATIVE", # Amber negative ATOMIC_NUMBER (Issue 2306) + "PRMErr1", + "PRMErr2", + "PRMErr3", # Amber TOP files to check raised errors + "PRM_UreyBradley", # prmtop from ParmEd test files with Urey-Bradley angles + "PRM7_ala2", + "RST7_ala2", # prmtop and rst files from ParmEd example files + "PRM19SBOPC", # prmtop w/ ff19SB CMAP terms and OPC water (Issue #2449) "PQR", # PQR v1 "PQR_icodes", # PQR v2 with icodes "PDBQT_input", # PDBQT "PDBQT_querypdb", "FASTA", # sequence alignment, Issue 112 + 113 "HELANAL_BENDING_MATRIX", # HELANAL test (from PSF+DCD (AdK) helix 8) - "HELANAL_BENDING_MATRIX_SUBSET", # As above, slice of frames 10 to 79 + "HELANAL_BENDING_MATRIX_SUBSET", # As above, slice of frames 10 to 79 "PDB_HOLE", # gramicidin A - "MULTIPDB_HOLE", # gramicidin A, normal mode 7 from ElNemo + "MULTIPDB_HOLE", # gramicidin A, normal mode 7 from ElNemo "DMS", "DMS_DOMAINS", # ADK closed with multiple segids "DMS_NO_SEGID", # ADK closed with no segids or chains "CONECT", # HIV Reverse Transcriptase with inhibitor - "TRZ", "TRZ_psf", + "TRZ", + "TRZ_psf", "TRIC", "XTC_multi_frame", "TRR_multi_frame", - "merge_protein", "merge_ligand", "merge_water", - "mol2_molecules", "mol2_molecule", "mol2_broken_molecule", - "mol2_zinc", "mol2_comments_header", "mol2_ligand", - "capping_input", "capping_output", "capping_ace", "capping_nma", - "contacts_villin_folded", "contacts_villin_unfolded", "contacts_file", - "LAMMPSdata", "trz4data", "LAMMPSdata_mini", - "LAMMPSdata2", "LAMMPSdcd2", - "LAMMPScnt", "LAMMPScnt2", # triclinic box - "LAMMPShyd", "LAMMPShyd2", + "merge_protein", + "merge_ligand", + "merge_water", + "mol2_molecules", + "mol2_molecule", + "mol2_broken_molecule", + "mol2_zinc", + "mol2_comments_header", + "mol2_ligand", + "capping_input", + "capping_output", + "capping_ace", + "capping_nma", + "contacts_villin_folded", + "contacts_villin_unfolded", + "contacts_file", + "LAMMPSdata", + "trz4data", + "LAMMPSdata_mini", + "LAMMPSdata2", + "LAMMPSdcd2", + "LAMMPScnt", + "LAMMPScnt2", # triclinic box + "LAMMPShyd", + "LAMMPShyd2", "LAMMPSdata_deletedatoms", # with deleted atoms "LAMMPSDUMP", "unordered_res", # pdb file with resids non sequential "GMS_ASYMOPT", # GAMESS C1 optimization - "GMS_SYMOPT", # GAMESS D4h optimization - "GMS_ASYMSURF", # GAMESS C1 surface - "two_water_gro", "two_water_gro_nonames", # for bond guessing, 2 water molecules, one with weird names + "GMS_SYMOPT", # GAMESS D4h optimization + "GMS_ASYMSURF", # GAMESS C1 surface + "two_water_gro", + "two_water_gro_nonames", # for bond guessing, 2 water molecules, one with weird names "two_water_gro_multiframe", "two_water_gro_widebox", # Issue #548 - "DLP_CONFIG", "DLP_CONFIG_order", "DLP_CONFIG_minimal", # dl_poly 4 config file - "DLP_HISTORY", "DLP_HISTORY_order", "DLP_HISTORY_minimal", # dl_poly 4 history file - "waterPSF","waterDCD","rmsfArray", + "DLP_CONFIG", + "DLP_CONFIG_order", + "DLP_CONFIG_minimal", # dl_poly 4 config file + "DLP_HISTORY", + "DLP_HISTORY_order", + "DLP_HISTORY_minimal", # dl_poly 4 history file + "waterPSF", + "waterDCD", + "rmsfArray", "HoomdXMLdata", "Make_Whole", # for testing the function lib.mdamath.make_whole, has 9 atoms "fullerene", # for make_whole, a nice friendly C60 with bonds @@ -152,289 +243,322 @@ "COORDINATES_XYZ_BZ2", "COORDINATES_GRO", "COORDINATES_GRO_INCOMPLETE_VELOCITY", - "Martini_membrane_gro", # for testing the leaflet finder + "Martini_membrane_gro", # for testing the leaflet finder "COORDINATES_XTC", "COORDINATES_TRR", "COORDINATES_H5MD", "COORDINATES_DCD", "COORDINATES_TOPOLOGY", "NUCLsel", - "GRO_empty_atom", "GRO_missing_atomname", # for testing GROParser exception raise - "ENT", #for testing ENT file extension + "GRO_empty_atom", + "GRO_missing_atomname", # for testing GROParser exception raise + "ENT", # for testing ENT file extension "RANDOM_WALK", - "RANDOM_WALK_TOPO", # garbage topology to go along with XTC positions above - "AUX_XVG", "XVG_BAD_NCOL", #for testing .xvg auxiliary reader - "AUX_XVG_LOWF", "AUX_XVG_HIGHF", - "MMTF", "MMTF_gz", 'MMTF_skinny', # skinny - some optional fields stripped out + "RANDOM_WALK_TOPO", # garbage topology to go along with XTC positions above + "AUX_XVG", + "XVG_BAD_NCOL", # for testing .xvg auxiliary reader + "AUX_XVG_LOWF", + "AUX_XVG_HIGHF", + "MMTF", + "MMTF_gz", + "MMTF_skinny", # skinny - some optional fields stripped out "MMTF_skinny2", "ALIGN_BOUND", # two component bound system - "ALIGN_UNBOUND", # two component unbound system - "legacy_DCD_ADK_coords", # frames 5 and 29 read in for adk_dims.dcd using legacy DCD reader - "legacy_DCD_NAMD_coords", # frame 0 read in for SiN_tric_namd.dcd using legacy DCD reader - "legacy_DCD_c36_coords", # frames 1 and 4 read in for tip125_tric_C36.dcd using legacy DCD reader - "GSD", "GSD_bonds", "GSD_long", - "GRO_MEMPROT", "XTC_MEMPROT", # YiiP transporter in POPE:POPG lipids with Na+, Cl-, Zn2+ dummy model without water - "DihedralArray", "DihedralsArray", # time series of single dihedral - "RamaArray", "GLYRamaArray", # time series of phi/psi angles - "JaninArray", "LYSJaninArray", # time series of chi1/chi2 angles - "PDB_rama", "PDB_janin", # for testing failures of Ramachandran and Janin classes - "PDB_metal", # PDB with metal atoms - "BATArray", # time series of bond-angle-torsion coordinates array from Molecule_comments_header.mol2 + "ALIGN_UNBOUND", # two component unbound system + "legacy_DCD_ADK_coords", # frames 5 and 29 read in for adk_dims.dcd using legacy DCD reader + "legacy_DCD_NAMD_coords", # frame 0 read in for SiN_tric_namd.dcd using legacy DCD reader + "legacy_DCD_c36_coords", # frames 1 and 4 read in for tip125_tric_C36.dcd using legacy DCD reader + "GSD", + "GSD_bonds", + "GSD_long", + "GRO_MEMPROT", + "XTC_MEMPROT", # YiiP transporter in POPE:POPG lipids with Na+, Cl-, Zn2+ dummy model without water + "DihedralArray", + "DihedralsArray", # time series of single dihedral + "RamaArray", + "GLYRamaArray", # time series of phi/psi angles + "JaninArray", + "LYSJaninArray", # time series of chi1/chi2 angles + "PDB_rama", + "PDB_janin", # for testing failures of Ramachandran and Janin classes + "PDB_metal", # PDB with metal atoms + "BATArray", # time series of bond-angle-torsion coordinates array from Molecule_comments_header.mol2 # DOS line endings - "WIN_PDB_multiframe", "WIN_DLP_HISTORY", "WIN_TRJ", "WIN_LAMMPSDUMP", "WIN_ARC", - "GRO_huge_box", # for testing gro parser with hige box sizes - "ITP", # for GROMACS generated itps - "ITP_nomass", # for ATB generated itps - "NAMDBIN", # for NAMD generated binary file - "ITP_edited", # to check different directives are read properly - "ITP_tip5p", # tip5p water from opls-aa, edited with additional keywords - "ITP_spce", # spce water from gromos54a7, edited with additional keywords, - "GMX_TOP", # 2 ala10 chains + 3 spc water - "GMX_DIR", # GROMACS directory - "GMX_TOP_BAD", # file with an #include that doesn't exist - "ITP_no_endif", # file missing an #endif - "PDB_CRYOEM_BOX", # Issue 2599, Issue #2679, PR #2685 - "PDB_CHECK_RIGHTHAND_PA", # for testing right handedness of principal_axes - "MMTF_NOCRYST", # File with meaningless CRYST1 record (Issue #2679, PR #2685) - "FHIAIMS", # to test FHIAIMS coordinate files + "WIN_PDB_multiframe", + "WIN_DLP_HISTORY", + "WIN_TRJ", + "WIN_LAMMPSDUMP", + "WIN_ARC", + "GRO_huge_box", # for testing gro parser with hige box sizes + "ITP", # for GROMACS generated itps + "ITP_nomass", # for ATB generated itps + "NAMDBIN", # for NAMD generated binary file + "ITP_edited", # to check different directives are read properly + "ITP_tip5p", # tip5p water from opls-aa, edited with additional keywords + "ITP_spce", # spce water from gromos54a7, edited with additional keywords, + "GMX_TOP", # 2 ala10 chains + 3 spc water + "GMX_DIR", # GROMACS directory + "GMX_TOP_BAD", # file with an #include that doesn't exist + "ITP_no_endif", # file missing an #endif + "PDB_CRYOEM_BOX", # Issue 2599, Issue #2679, PR #2685 + "PDB_CHECK_RIGHTHAND_PA", # for testing right handedness of principal_axes + "MMTF_NOCRYST", # File with meaningless CRYST1 record (Issue #2679, PR #2685) + "FHIAIMS", # to test FHIAIMS coordinate files "SDF_molecule", # MDL SDFile for rdkit - "PDBX" # PDBxfile + "PDBX", # PDBxfile ] from pkg_resources import resource_filename -WIN_PDB_multiframe = resource_filename(__name__, - 'data/windows/WIN_nmr_neopetrosiamide.pdb') -WIN_DLP_HISTORY = resource_filename(__name__, - 'data/windows/WIN_HISTORY') -WIN_TRJ = resource_filename(__name__, - 'data/windows/WIN_ache.mdcrd') -WIN_ARC = resource_filename(__name__, - 'data/windows/WIN_test.arc') -WIN_LAMMPSDUMP = resource_filename(__name__, - 'data/windows/WIN_wat.lammpstrj') - -legacy_DCD_NAMD_coords = resource_filename(__name__, -'data/legacy_DCD_NAMD_coords.npy') -legacy_DCD_ADK_coords = resource_filename(__name__, -'data/legacy_DCD_adk_coords.npy') -legacy_DCD_c36_coords = resource_filename(__name__, -'data/legacy_DCD_c36_coords.npy') -AUX_XVG_LOWF = resource_filename(__name__, 'data/test_lowf.xvg') -AUX_XVG_HIGHF = resource_filename(__name__, 'data/test_highf.xvg') -XVG_BAD_NCOL = resource_filename(__name__, 'data/bad_num_col.xvg') -AUX_XVG = resource_filename(__name__, 'data/test.xvg') -ENT = resource_filename(__name__, 'data/testENT.ent') -GRO_missing_atomname = resource_filename(__name__, 'data/missing_atomname.gro') -GRO_empty_atom = resource_filename(__name__, 'data/empty_atom.gro') -GRO_huge_box = resource_filename(__name__, 'data/huge_box.gro') - -COORDINATES_GRO = resource_filename(__name__, 'data/coordinates/test.gro') -COORDINATES_GRO_INCOMPLETE_VELOCITY = resource_filename(__name__, 'data/coordinates/test_incomplete_vel.gro') -COORDINATES_GRO_BZ2 = resource_filename(__name__, 'data/coordinates/test.gro.bz2') -COORDINATES_XYZ = resource_filename(__name__, 'data/coordinates/test.xyz') -COORDINATES_XYZ_BZ2 = resource_filename( - __name__, 'data/coordinates/test.xyz.bz2') -COORDINATES_XTC = resource_filename(__name__, 'data/coordinates/test.xtc') -COORDINATES_TRR = resource_filename(__name__, 'data/coordinates/test.trr') -COORDINATES_H5MD = resource_filename(__name__, 'data/coordinates/test.h5md') -COORDINATES_DCD = resource_filename(__name__, 'data/coordinates/test.dcd') -COORDINATES_TOPOLOGY = resource_filename(__name__, 'data/coordinates/test_topology.pdb') - -PSF = resource_filename(__name__, 'data/adk.psf') -PSF_notop = resource_filename(__name__, 'data/adk_notop.psf') -PSF_BAD = resource_filename(__name__, 'data/adk_notop_BAD.psf') -DCD = resource_filename(__name__, 'data/adk_dims.dcd') -DCD_empty = resource_filename(__name__, 'data/empty.dcd') -CRD = resource_filename(__name__, 'data/adk_open.crd') -PSF_TRICLINIC = resource_filename(__name__, 'data/tip125_tric_C36.psf') -DCD_TRICLINIC = resource_filename(__name__, 'data/tip125_tric_C36.dcd') -DCD2 = resource_filename(__name__, 'data/adk_dims2.dcd') - -PSF_NAMD = resource_filename(__name__, 'data/namd_cgenff.psf') -PDB_NAMD = resource_filename(__name__, 'data/namd_cgenff.pdb') -PSF_NAMD_TRICLINIC = resource_filename(__name__, 'data/SiN_tric_namd.psf') -DCD_NAMD_TRICLINIC = resource_filename(__name__, 'data/SiN_tric_namd.dcd') -PSF_NAMD_GBIS = resource_filename(__name__, 'data/adk_closed_NAMD.psf') -DCD_NAMD_GBIS = resource_filename(__name__, 'data/adk_gbis_tmd-fast1_NAMD.dcd') - -PSF_nosegid = resource_filename(__name__, 'data/nosegid.psf') - -PSF_cmap = resource_filename(__name__, 'data/parmed_ala3.psf') - -PDB_small = resource_filename(__name__, 'data/adk_open.pdb') -PDB_closed = resource_filename(__name__, 'data/adk_closed.pdb') -PDB_metal = resource_filename(__name__, 'data/metals.pdb') - -ALIGN = resource_filename(__name__, 'data/align.pdb') -RNA_PSF = resource_filename(__name__, 'data/analysis/1k5i_c36.psf.gz') -RNA_PDB = resource_filename(__name__, 'data/analysis/1k5i_c36.pdb.gz') -INC_PDB = resource_filename(__name__, 'data/incomplete.pdb') -PDB_cm = resource_filename(__name__, 'data/cryst_then_model.pdb') -PDB_cm_gz = resource_filename(__name__, 'data/cryst_then_model.pdb.gz') -PDB_cm_bz2 = resource_filename(__name__, 'data/cryst_then_model.pdb.bz2') -PDB_mc = resource_filename(__name__, 'data/model_then_cryst.pdb') -PDB_mc_gz = resource_filename(__name__, 'data/model_then_cryst.pdb.gz') -PDB_mc_bz2 = resource_filename(__name__, 'data/model_then_cryst.pdb.bz2') -PDB_chainidnewres = resource_filename(__name__, 'data/chainIDnewres.pdb.gz') -PDB_sameresid_diffresname = resource_filename(__name__, 'data/sameresid_diffresname.pdb') -PDB_chainidrepeat = resource_filename(__name__, 'data/chainIDrepeat.pdb.gz') -PDB_multiframe = resource_filename(__name__, 'data/nmr_neopetrosiamide.pdb') -PDB_helix = resource_filename(__name__, 'data/A6PA6_alpha.pdb') -PDB_conect = resource_filename(__name__, 'data/conect_parsing.pdb') -PDB_conect2TER = resource_filename(__name__, 'data/CONECT2TER.pdb') -PDB_singleconect = resource_filename(__name__, 'data/SINGLECONECT.pdb') -PDB_icodes = resource_filename(__name__, 'data/1osm.pdb.gz') -PDB_CRYOEM_BOX = resource_filename(__name__, 'data/5a7u.pdb') -PDB_CHECK_RIGHTHAND_PA = resource_filename(__name__, 'data/6msm.pdb.bz2') -FHIAIMS = resource_filename(__name__, 'data/fhiaims.in') - -GRO = resource_filename(__name__, 'data/adk_oplsaa.gro') -GRO_velocity = resource_filename(__name__, 'data/sample_velocity_file.gro') -GRO_incomplete_vels = resource_filename(__name__, 'data/grovels.gro') -GRO_large = resource_filename(__name__, 'data/bigbox.gro.bz2') -GRO_residwrap = resource_filename(__name__, 'data/residwrap.gro') -GRO_residwrap_0base = resource_filename(__name__, 'data/residwrap_0base.gro') -GRO_sameresid_diffresname = resource_filename(__name__, 'data/sameresid_diffresname.gro') -PDB = resource_filename(__name__, 'data/adk_oplsaa.pdb') -XTC = resource_filename(__name__, 'data/adk_oplsaa.xtc') -TRR = resource_filename(__name__, 'data/adk_oplsaa.trr') -TPR = resource_filename(__name__, 'data/adk_oplsaa.tpr') -PDB_sub_dry = resource_filename(__name__, 'data/cobrotoxin_dry_neutral_0.pdb') -TRR_sub_sol = resource_filename(__name__, 'data/cobrotoxin.trr') -XTC_sub_sol = resource_filename(__name__, 'data/cobrotoxin.xtc') -PDB_sub_sol = resource_filename(__name__, 'data/cobrotoxin.pdb') -PDB_xlserial = resource_filename(__name__, 'data/xl_serial.pdb') -GRO_MEMPROT = resource_filename(__name__, 'data/analysis/YiiP_lipids.gro.gz') -XTC_MEMPROT = resource_filename(__name__, 'data/analysis/YiiP_lipids.xtc') +WIN_PDB_multiframe = resource_filename( + __name__, "data/windows/WIN_nmr_neopetrosiamide.pdb" +) +WIN_DLP_HISTORY = resource_filename(__name__, "data/windows/WIN_HISTORY") +WIN_TRJ = resource_filename(__name__, "data/windows/WIN_ache.mdcrd") +WIN_ARC = resource_filename(__name__, "data/windows/WIN_test.arc") +WIN_LAMMPSDUMP = resource_filename(__name__, "data/windows/WIN_wat.lammpstrj") + +legacy_DCD_NAMD_coords = resource_filename(__name__, "data/legacy_DCD_NAMD_coords.npy") +legacy_DCD_ADK_coords = resource_filename(__name__, "data/legacy_DCD_adk_coords.npy") +legacy_DCD_c36_coords = resource_filename(__name__, "data/legacy_DCD_c36_coords.npy") +AUX_XVG_LOWF = resource_filename(__name__, "data/test_lowf.xvg") +AUX_XVG_HIGHF = resource_filename(__name__, "data/test_highf.xvg") +XVG_BAD_NCOL = resource_filename(__name__, "data/bad_num_col.xvg") +AUX_XVG = resource_filename(__name__, "data/test.xvg") +ENT = resource_filename(__name__, "data/testENT.ent") +GRO_missing_atomname = resource_filename(__name__, "data/missing_atomname.gro") +GRO_empty_atom = resource_filename(__name__, "data/empty_atom.gro") +GRO_huge_box = resource_filename(__name__, "data/huge_box.gro") + +COORDINATES_GRO = resource_filename(__name__, "data/coordinates/test.gro") +COORDINATES_GRO_INCOMPLETE_VELOCITY = resource_filename( + __name__, "data/coordinates/test_incomplete_vel.gro" +) +COORDINATES_GRO_BZ2 = resource_filename(__name__, "data/coordinates/test.gro.bz2") +COORDINATES_XYZ = resource_filename(__name__, "data/coordinates/test.xyz") +COORDINATES_XYZ_BZ2 = resource_filename(__name__, "data/coordinates/test.xyz.bz2") +COORDINATES_XTC = resource_filename(__name__, "data/coordinates/test.xtc") +COORDINATES_TRR = resource_filename(__name__, "data/coordinates/test.trr") +COORDINATES_H5MD = resource_filename(__name__, "data/coordinates/test.h5md") +COORDINATES_DCD = resource_filename(__name__, "data/coordinates/test.dcd") +COORDINATES_TOPOLOGY = resource_filename(__name__, "data/coordinates/test_topology.pdb") + +PSF = resource_filename(__name__, "data/adk.psf") +PSF_notop = resource_filename(__name__, "data/adk_notop.psf") +PSF_BAD = resource_filename(__name__, "data/adk_notop_BAD.psf") +DCD = resource_filename(__name__, "data/adk_dims.dcd") +DCD_empty = resource_filename(__name__, "data/empty.dcd") +CRD = resource_filename(__name__, "data/adk_open.crd") +PSF_TRICLINIC = resource_filename(__name__, "data/tip125_tric_C36.psf") +DCD_TRICLINIC = resource_filename(__name__, "data/tip125_tric_C36.dcd") +DCD2 = resource_filename(__name__, "data/adk_dims2.dcd") + +PSF_NAMD = resource_filename(__name__, "data/namd_cgenff.psf") +PDB_NAMD = resource_filename(__name__, "data/namd_cgenff.pdb") +PSF_NAMD_TRICLINIC = resource_filename(__name__, "data/SiN_tric_namd.psf") +DCD_NAMD_TRICLINIC = resource_filename(__name__, "data/SiN_tric_namd.dcd") +PSF_NAMD_GBIS = resource_filename(__name__, "data/adk_closed_NAMD.psf") +DCD_NAMD_GBIS = resource_filename(__name__, "data/adk_gbis_tmd-fast1_NAMD.dcd") + +PSF_nosegid = resource_filename(__name__, "data/nosegid.psf") + +PSF_cmap = resource_filename(__name__, "data/parmed_ala3.psf") + +PDB_small = resource_filename(__name__, "data/adk_open.pdb") +PDB_closed = resource_filename(__name__, "data/adk_closed.pdb") +PDB_metal = resource_filename(__name__, "data/metals.pdb") + +ALIGN = resource_filename(__name__, "data/align.pdb") +RNA_PSF = resource_filename(__name__, "data/analysis/1k5i_c36.psf.gz") +RNA_PDB = resource_filename(__name__, "data/analysis/1k5i_c36.pdb.gz") +INC_PDB = resource_filename(__name__, "data/incomplete.pdb") +PDB_cm = resource_filename(__name__, "data/cryst_then_model.pdb") +PDB_cm_gz = resource_filename(__name__, "data/cryst_then_model.pdb.gz") +PDB_cm_bz2 = resource_filename(__name__, "data/cryst_then_model.pdb.bz2") +PDB_mc = resource_filename(__name__, "data/model_then_cryst.pdb") +PDB_mc_gz = resource_filename(__name__, "data/model_then_cryst.pdb.gz") +PDB_mc_bz2 = resource_filename(__name__, "data/model_then_cryst.pdb.bz2") +PDB_chainidnewres = resource_filename(__name__, "data/chainIDnewres.pdb.gz") +PDB_sameresid_diffresname = resource_filename( + __name__, "data/sameresid_diffresname.pdb" +) +PDB_chainidrepeat = resource_filename(__name__, "data/chainIDrepeat.pdb.gz") +PDB_multiframe = resource_filename(__name__, "data/nmr_neopetrosiamide.pdb") +PDB_helix = resource_filename(__name__, "data/A6PA6_alpha.pdb") +PDB_conect = resource_filename(__name__, "data/conect_parsing.pdb") +PDB_conect2TER = resource_filename(__name__, "data/CONECT2TER.pdb") +PDB_singleconect = resource_filename(__name__, "data/SINGLECONECT.pdb") +PDB_icodes = resource_filename(__name__, "data/1osm.pdb.gz") +PDB_CRYOEM_BOX = resource_filename(__name__, "data/5a7u.pdb") +PDB_CHECK_RIGHTHAND_PA = resource_filename(__name__, "data/6msm.pdb.bz2") +FHIAIMS = resource_filename(__name__, "data/fhiaims.in") + +GRO = resource_filename(__name__, "data/adk_oplsaa.gro") +GRO_velocity = resource_filename(__name__, "data/sample_velocity_file.gro") +GRO_incomplete_vels = resource_filename(__name__, "data/grovels.gro") +GRO_large = resource_filename(__name__, "data/bigbox.gro.bz2") +GRO_residwrap = resource_filename(__name__, "data/residwrap.gro") +GRO_residwrap_0base = resource_filename(__name__, "data/residwrap_0base.gro") +GRO_sameresid_diffresname = resource_filename( + __name__, "data/sameresid_diffresname.gro" +) +PDB = resource_filename(__name__, "data/adk_oplsaa.pdb") +XTC = resource_filename(__name__, "data/adk_oplsaa.xtc") +TRR = resource_filename(__name__, "data/adk_oplsaa.trr") +TPR = resource_filename(__name__, "data/adk_oplsaa.tpr") +PDB_sub_dry = resource_filename(__name__, "data/cobrotoxin_dry_neutral_0.pdb") +TRR_sub_sol = resource_filename(__name__, "data/cobrotoxin.trr") +XTC_sub_sol = resource_filename(__name__, "data/cobrotoxin.xtc") +PDB_sub_sol = resource_filename(__name__, "data/cobrotoxin.pdb") +PDB_xlserial = resource_filename(__name__, "data/xl_serial.pdb") +GRO_MEMPROT = resource_filename(__name__, "data/analysis/YiiP_lipids.gro.gz") +XTC_MEMPROT = resource_filename(__name__, "data/analysis/YiiP_lipids.xtc") XTC_multi_frame = resource_filename( - __name__, 'data/xtc_test_only_10_frame_10_atoms.xtc' + __name__, "data/xtc_test_only_10_frame_10_atoms.xtc" ) TRR_multi_frame = resource_filename( - __name__, 'data/trr_test_only_10_frame_10_atoms.trr' + __name__, "data/trr_test_only_10_frame_10_atoms.trr" ) -PDB_xvf = resource_filename(__name__, 'data/cobrotoxin.pdb') -TPR_xvf = resource_filename(__name__, 'data/cobrotoxin.tpr') -TRR_xvf = resource_filename(__name__, 'data/cobrotoxin.trr') -H5MD_xvf = resource_filename(__name__, 'data/cobrotoxin.h5md') -XVG_BZ2 = resource_filename(__name__, 'data/cobrotoxin_protein_forces.xvg.bz2') +PDB_xvf = resource_filename(__name__, "data/cobrotoxin.pdb") +TPR_xvf = resource_filename(__name__, "data/cobrotoxin.tpr") +TRR_xvf = resource_filename(__name__, "data/cobrotoxin.trr") +H5MD_xvf = resource_filename(__name__, "data/cobrotoxin.h5md") +XVG_BZ2 = resource_filename(__name__, "data/cobrotoxin_protein_forces.xvg.bz2") -XPDB_small = resource_filename(__name__, 'data/5digitResid.pdb') +XPDB_small = resource_filename(__name__, "data/5digitResid.pdb") # number is the gromacs version -TPR400 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.0.tpr') -TPR402 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.0.2.tpr') -TPR403 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.0.3.tpr') -TPR404 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.0.4.tpr') -TPR405 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.0.5.tpr') -TPR406 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.0.6.tpr') -TPR407 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.0.7.tpr') -TPR450 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.5.tpr') -TPR451 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.5.1.tpr') -TPR452 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.5.2.tpr') -TPR453 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.5.3.tpr') -TPR454 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.5.4.tpr') -TPR455 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.5.5.tpr') -TPR502 = resource_filename(__name__, 'data/tprs/2lyz_gmx_5.0.2.tpr') -TPR504 = resource_filename(__name__, 'data/tprs/2lyz_gmx_5.0.4.tpr') -TPR505 = resource_filename(__name__, 'data/tprs/2lyz_gmx_5.0.5.tpr') -TPR510 = resource_filename(__name__, 'data/tprs/2lyz_gmx_5.1.tpr') -TPR2016 = resource_filename(__name__, 'data/tprs/2lyz_gmx_2016.tpr') -TPR2018 = resource_filename(__name__, 'data/tprs/2lyz_gmx_2018.tpr') -TPR2019B3 = resource_filename(__name__, 'data/tprs/2lyz_gmx_2019-beta3.tpr') -TPR2020B2 = resource_filename(__name__, 'data/tprs/2lyz_gmx_2020-beta2.tpr') -TPR2020 = resource_filename(__name__, 'data/tprs/2lyz_gmx_2020.tpr') +TPR400 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.0.tpr") +TPR402 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.0.2.tpr") +TPR403 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.0.3.tpr") +TPR404 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.0.4.tpr") +TPR405 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.0.5.tpr") +TPR406 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.0.6.tpr") +TPR407 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.0.7.tpr") +TPR450 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.5.tpr") +TPR451 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.5.1.tpr") +TPR452 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.5.2.tpr") +TPR453 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.5.3.tpr") +TPR454 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.5.4.tpr") +TPR455 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.5.5.tpr") +TPR502 = resource_filename(__name__, "data/tprs/2lyz_gmx_5.0.2.tpr") +TPR504 = resource_filename(__name__, "data/tprs/2lyz_gmx_5.0.4.tpr") +TPR505 = resource_filename(__name__, "data/tprs/2lyz_gmx_5.0.5.tpr") +TPR510 = resource_filename(__name__, "data/tprs/2lyz_gmx_5.1.tpr") +TPR2016 = resource_filename(__name__, "data/tprs/2lyz_gmx_2016.tpr") +TPR2018 = resource_filename(__name__, "data/tprs/2lyz_gmx_2018.tpr") +TPR2019B3 = resource_filename(__name__, "data/tprs/2lyz_gmx_2019-beta3.tpr") +TPR2020B2 = resource_filename(__name__, "data/tprs/2lyz_gmx_2020-beta2.tpr") +TPR2020 = resource_filename(__name__, "data/tprs/2lyz_gmx_2020.tpr") # double precision -TPR455Double = resource_filename(__name__, 'data/tprs/drew_gmx_4.5.5.double.tpr') -TPR460 = resource_filename(__name__, 'data/tprs/ab42_gmx_4.6.tpr') -TPR461 = resource_filename(__name__, 'data/tprs/ab42_gmx_4.6.1.tpr') -TPR2020Double = resource_filename(__name__, 'data/tprs/2lyz_gmx_2020_double.tpr') +TPR455Double = resource_filename(__name__, "data/tprs/drew_gmx_4.5.5.double.tpr") +TPR460 = resource_filename(__name__, "data/tprs/ab42_gmx_4.6.tpr") +TPR461 = resource_filename(__name__, "data/tprs/ab42_gmx_4.6.1.tpr") +TPR2020Double = resource_filename(__name__, "data/tprs/2lyz_gmx_2020_double.tpr") # all bonded interactions -TPR334_bonded = resource_filename(__name__, 'data/tprs/all_bonded/dummy_3.3.4.tpr') -TPR510_bonded = resource_filename(__name__, 'data/tprs/all_bonded/dummy_5.1.tpr') -TPR2016_bonded = resource_filename(__name__, 'data/tprs/all_bonded/dummy_2016.tpr') -TPR2018_bonded = resource_filename(__name__, 'data/tprs/all_bonded/dummy_2018.tpr') -TPR2019B3_bonded = resource_filename(__name__, 'data/tprs/all_bonded/dummy_2019-beta3.tpr') -TPR2020B2_bonded = resource_filename(__name__, 'data/tprs/all_bonded/dummy_2020-beta2.tpr') -TPR2020_bonded = resource_filename(__name__, 'data/tprs/all_bonded/dummy_2020.tpr') -TPR2020_double_bonded = resource_filename(__name__, 'data/tprs/all_bonded/dummy_2020_double.tpr') +TPR334_bonded = resource_filename(__name__, "data/tprs/all_bonded/dummy_3.3.4.tpr") +TPR510_bonded = resource_filename(__name__, "data/tprs/all_bonded/dummy_5.1.tpr") +TPR2016_bonded = resource_filename(__name__, "data/tprs/all_bonded/dummy_2016.tpr") +TPR2018_bonded = resource_filename(__name__, "data/tprs/all_bonded/dummy_2018.tpr") +TPR2019B3_bonded = resource_filename( + __name__, "data/tprs/all_bonded/dummy_2019-beta3.tpr" +) +TPR2020B2_bonded = resource_filename( + __name__, "data/tprs/all_bonded/dummy_2020-beta2.tpr" +) +TPR2020_bonded = resource_filename(__name__, "data/tprs/all_bonded/dummy_2020.tpr") +TPR2020_double_bonded = resource_filename( + __name__, "data/tprs/all_bonded/dummy_2020_double.tpr" +) # all interactions -TPR_EXTRA_2020 = resource_filename(__name__, 'data/tprs/virtual_sites/extra-interactions-2020.tpr') -TPR_EXTRA_2018 = resource_filename(__name__, 'data/tprs/virtual_sites/extra-interactions-2018.tpr') -TPR_EXTRA_2016 = resource_filename(__name__, 'data/tprs/virtual_sites/extra-interactions-2016.3.tpr') -TPR_EXTRA_407 = resource_filename(__name__, 'data/tprs/virtual_sites/extra-interactions-4.0.7.tpr') +TPR_EXTRA_2020 = resource_filename( + __name__, "data/tprs/virtual_sites/extra-interactions-2020.tpr" +) +TPR_EXTRA_2018 = resource_filename( + __name__, "data/tprs/virtual_sites/extra-interactions-2018.tpr" +) +TPR_EXTRA_2016 = resource_filename( + __name__, "data/tprs/virtual_sites/extra-interactions-2016.3.tpr" +) +TPR_EXTRA_407 = resource_filename( + __name__, "data/tprs/virtual_sites/extra-interactions-4.0.7.tpr" +) -XYZ_psf = resource_filename(__name__, 'data/2r9r-1b.psf') -XYZ_bz2 = resource_filename(__name__, 'data/2r9r-1b.xyz.bz2') -XYZ = resource_filename(__name__, 'data/2r9r-1b.xyz') -XYZ_mini = resource_filename(__name__, 'data/mini.xyz') -XYZ_five = resource_filename(__name__, 'data/five.xyz') -TXYZ = resource_filename(__name__, 'data/coordinates/test.txyz') -ARC = resource_filename(__name__, 'data/coordinates/test.arc') -ARC_PBC = resource_filename(__name__, 'data/coordinates/new_hexane.arc') +XYZ_psf = resource_filename(__name__, "data/2r9r-1b.psf") +XYZ_bz2 = resource_filename(__name__, "data/2r9r-1b.xyz.bz2") +XYZ = resource_filename(__name__, "data/2r9r-1b.xyz") +XYZ_mini = resource_filename(__name__, "data/mini.xyz") +XYZ_five = resource_filename(__name__, "data/five.xyz") +TXYZ = resource_filename(__name__, "data/coordinates/test.txyz") +ARC = resource_filename(__name__, "data/coordinates/test.arc") +ARC_PBC = resource_filename(__name__, "data/coordinates/new_hexane.arc") -PRM = resource_filename(__name__, 'data/Amber/ache.prmtop') -TRJ = resource_filename(__name__, 'data/Amber/ache.mdcrd') -INPCRD = resource_filename(__name__, 'data/Amber/test.inpcrd') -TRJ_bz2 = resource_filename(__name__, 'data/Amber/ache.mdcrd.bz2') -PFncdf_Top = resource_filename(__name__, 'data/Amber/posfor.top') -PFncdf_Trj = resource_filename(__name__, 'data/Amber/posfor.ncdf') +PRM = resource_filename(__name__, "data/Amber/ache.prmtop") +TRJ = resource_filename(__name__, "data/Amber/ache.mdcrd") +INPCRD = resource_filename(__name__, "data/Amber/test.inpcrd") +TRJ_bz2 = resource_filename(__name__, "data/Amber/ache.mdcrd.bz2") +PFncdf_Top = resource_filename(__name__, "data/Amber/posfor.top") +PFncdf_Trj = resource_filename(__name__, "data/Amber/posfor.ncdf") -PRMpbc = resource_filename(__name__, 'data/Amber/capped-ala.prmtop') -TRJpbc_bz2 = resource_filename(__name__, 'data/Amber/capped-ala.mdcrd.bz2') +PRMpbc = resource_filename(__name__, "data/Amber/capped-ala.prmtop") +TRJpbc_bz2 = resource_filename(__name__, "data/Amber/capped-ala.mdcrd.bz2") -PRMncdf = resource_filename(__name__, 'data/Amber/bala.prmtop') -TRJncdf = resource_filename(__name__, 'data/Amber/bala.trj') -NCDF = resource_filename(__name__, 'data/Amber/bala.ncdf') +PRMncdf = resource_filename(__name__, "data/Amber/bala.prmtop") +TRJncdf = resource_filename(__name__, "data/Amber/bala.trj") +NCDF = resource_filename(__name__, "data/Amber/bala.ncdf") -PRM12 = resource_filename(__name__, 'data/Amber/anti.top') -TRJ12_bz2 = resource_filename(__name__, 'data/Amber/anti_md1.mdcrd.bz2') +PRM12 = resource_filename(__name__, "data/Amber/anti.top") +TRJ12_bz2 = resource_filename(__name__, "data/Amber/anti_md1.mdcrd.bz2") -PRM7 = resource_filename(__name__, 'data/Amber/tz2.truncoct.parm7.bz2') -NCDFtruncoct = resource_filename(__name__, 'data/Amber/tz2.truncoct.nc') +PRM7 = resource_filename(__name__, "data/Amber/tz2.truncoct.parm7.bz2") +NCDFtruncoct = resource_filename(__name__, "data/Amber/tz2.truncoct.nc") -PRMcs = resource_filename(__name__, 'data/Amber/chitosan.prmtop') +PRMcs = resource_filename(__name__, "data/Amber/chitosan.prmtop") -PRMNCRST = resource_filename(__name__, 'data/Amber/ace_mbondi3.parm7') +PRMNCRST = resource_filename(__name__, "data/Amber/ace_mbondi3.parm7") -PRM_NCBOX = resource_filename(__name__, 'data/Amber/ace_tip3p.parm7') -TRJ_NCBOX = resource_filename(__name__, 'data/Amber/ace_tip3p.nc') +PRM_NCBOX = resource_filename(__name__, "data/Amber/ace_tip3p.parm7") +TRJ_NCBOX = resource_filename(__name__, "data/Amber/ace_tip3p.nc") -PRMNEGATIVE = resource_filename(__name__, 'data/Amber/ace_mbondi3.negative.parm7') +PRMNEGATIVE = resource_filename(__name__, "data/Amber/ace_mbondi3.negative.parm7") -PRMErr1 = resource_filename(__name__, 'data/Amber/ace_mbondi3.error1.parm7') -PRMErr2 = resource_filename(__name__, 'data/Amber/ace_mbondi3.error2.parm7') -PRMErr3 = resource_filename(__name__, 'data/Amber/ace_mbondi3.error3.parm7') +PRMErr1 = resource_filename(__name__, "data/Amber/ace_mbondi3.error1.parm7") +PRMErr2 = resource_filename(__name__, "data/Amber/ace_mbondi3.error2.parm7") +PRMErr3 = resource_filename(__name__, "data/Amber/ace_mbondi3.error3.parm7") -PRM_UreyBradley = resource_filename(__name__, 'data/Amber/parmed_fad.prmtop') -PRM7_ala2 = resource_filename(__name__, 'data/Amber/parmed_ala2_solv.parm7') -RST7_ala2 = resource_filename(__name__, 'data/Amber/parmed_ala2_solv.rst7') +PRM_UreyBradley = resource_filename(__name__, "data/Amber/parmed_fad.prmtop") +PRM7_ala2 = resource_filename(__name__, "data/Amber/parmed_ala2_solv.parm7") +RST7_ala2 = resource_filename(__name__, "data/Amber/parmed_ala2_solv.rst7") -PRM19SBOPC = resource_filename(__name__, 'data/Amber/ala.ff19SB.OPC.parm7.bz2') +PRM19SBOPC = resource_filename(__name__, "data/Amber/ala.ff19SB.OPC.parm7.bz2") -PQR = resource_filename(__name__, 'data/adk_open.pqr') -PQR_icodes = resource_filename(__name__, 'data/1A2C.pqr') +PQR = resource_filename(__name__, "data/adk_open.pqr") +PQR_icodes = resource_filename(__name__, "data/1A2C.pqr") -PDBQT_input = resource_filename(__name__, 'data/pdbqt_inputpdbqt.pdbqt') -PDBQT_querypdb = resource_filename(__name__, 'data/pdbqt_querypdb.pdb') +PDBQT_input = resource_filename(__name__, "data/pdbqt_inputpdbqt.pdbqt") +PDBQT_querypdb = resource_filename(__name__, "data/pdbqt_querypdb.pdb") -FASTA = resource_filename(__name__, 'data/test.fasta') -HELANAL_BENDING_MATRIX = resource_filename(__name__, 'data/helanal_bending_matrix_AdK_DIMS_H8.dat') -HELANAL_BENDING_MATRIX_SUBSET = resource_filename(__name__, 'data/helanal_bending_matrix_AdK_DIMS_H8_frames10to79.dat') +FASTA = resource_filename(__name__, "data/test.fasta") +HELANAL_BENDING_MATRIX = resource_filename( + __name__, "data/helanal_bending_matrix_AdK_DIMS_H8.dat" +) +HELANAL_BENDING_MATRIX_SUBSET = resource_filename( + __name__, "data/helanal_bending_matrix_AdK_DIMS_H8_frames10to79.dat" +) -PDB_HOLE = resource_filename(__name__, 'data/1grm_single.pdb') -MULTIPDB_HOLE = resource_filename(__name__, 'data/1grm_elNemo_mode7.pdb.bz2') +PDB_HOLE = resource_filename(__name__, "data/1grm_single.pdb") +MULTIPDB_HOLE = resource_filename(__name__, "data/1grm_elNemo_mode7.pdb.bz2") -DMS = resource_filename(__name__, 'data/adk_closed.dms') -DMS_DOMAINS = resource_filename(__name__, 'data/adk_closed_domains.dms') -DMS_NO_SEGID = resource_filename(__name__, 'data/adk_closed_no_segid.dms') +DMS = resource_filename(__name__, "data/adk_closed.dms") +DMS_DOMAINS = resource_filename(__name__, "data/adk_closed_domains.dms") +DMS_NO_SEGID = resource_filename(__name__, "data/adk_closed_no_segid.dms") -CONECT = resource_filename(__name__, 'data/1hvr.pdb') +CONECT = resource_filename(__name__, "data/1hvr.pdb") -TRZ = resource_filename(__name__, 'data/trzfile.trz') -TRZ_psf = resource_filename(__name__, 'data/trz_psf.psf') +TRZ = resource_filename(__name__, "data/trzfile.trz") +TRZ_psf = resource_filename(__name__, "data/trz_psf.psf") -TRIC = resource_filename(__name__, 'data/dppc_vesicle_hg.gro') +TRIC = resource_filename(__name__, "data/dppc_vesicle_hg.gro") PDB_full = resource_filename(__name__, "data/4E43.pdb") @@ -446,7 +570,9 @@ mol2_molecule = resource_filename(__name__, "data/mol2/Molecule.mol2") mol2_ligand = resource_filename(__name__, "data/mol2/Ligand.mol2") mol2_broken_molecule = resource_filename(__name__, "data/mol2/BrokenMolecule.mol2") -mol2_comments_header = resource_filename(__name__, "data/mol2/Molecule_comments_header.mol2") +mol2_comments_header = resource_filename( + __name__, "data/mol2/Molecule_comments_header.mol2" +) # MOL2 file without substructure field mol2_zinc = resource_filename(__name__, "data/mol2/zinc_856218.mol2") @@ -455,8 +581,12 @@ capping_ace = resource_filename(__name__, "data/capping/ace.pdb") capping_nma = resource_filename(__name__, "data/capping/nma.pdb") -contacts_villin_folded = resource_filename(__name__, "data/contacts/villin_folded.gro.bz2") -contacts_villin_unfolded = resource_filename(__name__, "data/contacts/villin_unfolded.gro.bz2") +contacts_villin_folded = resource_filename( + __name__, "data/contacts/villin_folded.gro.bz2" +) +contacts_villin_unfolded = resource_filename( + __name__, "data/contacts/villin_unfolded.gro.bz2" +) contacts_file = resource_filename(__name__, "data/contacts/2F4K_qlist5_remap.dat") trz4data = resource_filename(__name__, "data/lammps/datatest.trz") @@ -468,17 +598,19 @@ LAMMPScnt2 = resource_filename(__name__, "data/lammps/cnt-hexagonal-class1.data2") LAMMPShyd = resource_filename(__name__, "data/lammps/hydrogen-class1.data") LAMMPShyd2 = resource_filename(__name__, "data/lammps/hydrogen-class1.data2") -LAMMPSdata_deletedatoms = resource_filename(__name__, 'data/lammps/deletedatoms.data') +LAMMPSdata_deletedatoms = resource_filename(__name__, "data/lammps/deletedatoms.data") LAMMPSDUMP = resource_filename(__name__, "data/lammps/wat.lammpstrj.bz2") unordered_res = resource_filename(__name__, "data/unordered_res.pdb") -GMS_ASYMOPT = resource_filename(__name__, "data/gms/c1opt.gms.gz") -GMS_SYMOPT = resource_filename(__name__, "data/gms/symopt.gms") -GMS_ASYMSURF = resource_filename(__name__, "data/gms/surf2wat.gms") +GMS_ASYMOPT = resource_filename(__name__, "data/gms/c1opt.gms.gz") +GMS_SYMOPT = resource_filename(__name__, "data/gms/symopt.gms") +GMS_ASYMSURF = resource_filename(__name__, "data/gms/surf2wat.gms") two_water_gro = resource_filename(__name__, "data/two_water_gro.gro") -two_water_gro_multiframe = resource_filename(__name__, "data/two_water_gro_multiframe.gro") +two_water_gro_multiframe = resource_filename( + __name__, "data/two_water_gro_multiframe.gro" +) two_water_gro_nonames = resource_filename(__name__, "data/two_water_gro_nonames.gro") two_water_gro_widebox = resource_filename(__name__, "data/two_water_gro_widebox.gro") @@ -489,64 +621,64 @@ DLP_HISTORY_order = resource_filename(__name__, "data/dlpoly/HISTORY_order") DLP_HISTORY_minimal = resource_filename(__name__, "data/dlpoly/HISTORY_minimal") -waterPSF = resource_filename(__name__, 'data/watdyn.psf') -waterDCD = resource_filename(__name__, 'data/watdyn.dcd') +waterPSF = resource_filename(__name__, "data/watdyn.psf") +waterDCD = resource_filename(__name__, "data/watdyn.dcd") -rmsfArray = resource_filename(__name__, 'data/adk_oplsaa_CA_rmsf.npy') +rmsfArray = resource_filename(__name__, "data/adk_oplsaa_CA_rmsf.npy") -HoomdXMLdata = resource_filename(__name__, 'data/C12x64.xml.bz2') +HoomdXMLdata = resource_filename(__name__, "data/C12x64.xml.bz2") -Make_Whole = resource_filename(__name__, 'data/make_whole.gro') -fullerene = resource_filename(__name__, 'data/fullerene.pdb.gz') +Make_Whole = resource_filename(__name__, "data/make_whole.gro") +fullerene = resource_filename(__name__, "data/fullerene.pdb.gz") -Plength = resource_filename(__name__, 'data/plength.gro') -Martini_membrane_gro = resource_filename(__name__, 'data/martini_dppc_chol_bilayer.gro') +Plength = resource_filename(__name__, "data/plength.gro") +Martini_membrane_gro = resource_filename(__name__, "data/martini_dppc_chol_bilayer.gro") # Contains one of each residue in 'nucleic' selections -NUCLsel = resource_filename(__name__, 'data/nucl_res.pdb') +NUCLsel = resource_filename(__name__, "data/nucl_res.pdb") -RANDOM_WALK = resource_filename(__name__, 'data/xyz_random_walk.xtc') -RANDOM_WALK_TOPO = resource_filename(__name__, 'data/RANDOM_WALK_TOPO.pdb') +RANDOM_WALK = resource_filename(__name__, "data/xyz_random_walk.xtc") +RANDOM_WALK_TOPO = resource_filename(__name__, "data/RANDOM_WALK_TOPO.pdb") -MMTF = resource_filename(__name__, 'data/173D.mmtf') -MMTF_gz = resource_filename(__name__, 'data/5KIH.mmtf.gz') -MMTF_skinny = resource_filename(__name__, 'data/1ubq-less-optional.mmtf') -MMTF_skinny2 = resource_filename(__name__, 'data/3NJW-onlyrequired.mmtf') +MMTF = resource_filename(__name__, "data/173D.mmtf") +MMTF_gz = resource_filename(__name__, "data/5KIH.mmtf.gz") +MMTF_skinny = resource_filename(__name__, "data/1ubq-less-optional.mmtf") +MMTF_skinny2 = resource_filename(__name__, "data/3NJW-onlyrequired.mmtf") MMTF_NOCRYST = resource_filename(__name__, "data/6QYR.mmtf.gz") -ALIGN_BOUND = resource_filename(__name__, 'data/analysis/align_bound.pdb.gz') -ALIGN_UNBOUND = resource_filename(__name__, 'data/analysis/align_unbound.pdb.gz') +ALIGN_BOUND = resource_filename(__name__, "data/analysis/align_bound.pdb.gz") +ALIGN_UNBOUND = resource_filename(__name__, "data/analysis/align_unbound.pdb.gz") -GSD = resource_filename(__name__, 'data/example.gsd') -GSD_bonds = resource_filename(__name__, 'data/example_bonds.gsd') -GSD_long = resource_filename(__name__, 'data/example_longer.gsd') +GSD = resource_filename(__name__, "data/example.gsd") +GSD_bonds = resource_filename(__name__, "data/example_bonds.gsd") +GSD_long = resource_filename(__name__, "data/example_longer.gsd") -DihedralArray = resource_filename(__name__, 'data/adk_oplsaa_dihedral.npy') -DihedralsArray = resource_filename(__name__, 'data/adk_oplsaa_dihedral_list.npy') -RamaArray = resource_filename(__name__, 'data/adk_oplsaa_rama.npy') -GLYRamaArray = resource_filename(__name__, 'data/adk_oplsaa_GLY_rama.npy') -JaninArray = resource_filename(__name__, 'data/adk_oplsaa_janin.npy') -LYSJaninArray = resource_filename(__name__, 'data/adk_oplsaa_LYS_janin.npy') -PDB_rama = resource_filename(__name__, 'data/19hc.pdb.gz') -PDB_janin = resource_filename(__name__, 'data/1a28.pdb.gz') +DihedralArray = resource_filename(__name__, "data/adk_oplsaa_dihedral.npy") +DihedralsArray = resource_filename(__name__, "data/adk_oplsaa_dihedral_list.npy") +RamaArray = resource_filename(__name__, "data/adk_oplsaa_rama.npy") +GLYRamaArray = resource_filename(__name__, "data/adk_oplsaa_GLY_rama.npy") +JaninArray = resource_filename(__name__, "data/adk_oplsaa_janin.npy") +LYSJaninArray = resource_filename(__name__, "data/adk_oplsaa_LYS_janin.npy") +PDB_rama = resource_filename(__name__, "data/19hc.pdb.gz") +PDB_janin = resource_filename(__name__, "data/1a28.pdb.gz") -BATArray = resource_filename(__name__, 'data/mol2_comments_header_bat.npy') +BATArray = resource_filename(__name__, "data/mol2_comments_header_bat.npy") -ITP = resource_filename(__name__, 'data/gromacs_ala10.itp') -ITP_nomass = resource_filename(__name__, 'data/itp_nomass.itp') -ITP_edited = resource_filename(__name__, 'data/edited_itp.itp') +ITP = resource_filename(__name__, "data/gromacs_ala10.itp") +ITP_nomass = resource_filename(__name__, "data/itp_nomass.itp") +ITP_edited = resource_filename(__name__, "data/edited_itp.itp") ITP_tip5p = resource_filename(__name__, "data/tip5p.itp") -ITP_spce = resource_filename(__name__, 'data/spce.itp') -GMX_TOP = resource_filename(__name__, 'data/gromacs_ala10.top') -GMX_DIR = resource_filename(__name__, 'data/gromacs/') -GMX_TOP_BAD = resource_filename(__name__, 'data/bad_top.top') -ITP_no_endif = resource_filename(__name__, 'data/no_endif_spc.itp') +ITP_spce = resource_filename(__name__, "data/spce.itp") +GMX_TOP = resource_filename(__name__, "data/gromacs_ala10.top") +GMX_DIR = resource_filename(__name__, "data/gromacs/") +GMX_TOP_BAD = resource_filename(__name__, "data/bad_top.top") +ITP_no_endif = resource_filename(__name__, "data/no_endif_spc.itp") -NAMDBIN = resource_filename(__name__, 'data/adk_open.coor') +NAMDBIN = resource_filename(__name__, "data/adk_open.coor") -SDF_molecule = resource_filename(__name__, 'data/molecule.sdf') +SDF_molecule = resource_filename(__name__, "data/molecule.sdf") -PDBX = resource_filename(__name__, 'data/4x8u.pdbx') +PDBX = resource_filename(__name__, "data/4x8u.pdbx") # This should be the last line: clean up namespace diff --git a/testsuite/MDAnalysisTests/topology/test_openmm.py b/testsuite/MDAnalysisTests/topology/test_openmm.py index 1eaec76c29a..ca6a40c6d41 100644 --- a/testsuite/MDAnalysisTests/topology/test_openmm.py +++ b/testsuite/MDAnalysisTests/topology/test_openmm.py @@ -29,15 +29,24 @@ from MDAnalysisTests.topology.base import ParserBase from MDAnalysisTests.datafiles import CONECT, PDBX + class OpenMMTopologyBase(ParserBase): parser = mda.topology.OpenMMParser.OpenMMTopologyParser - expected_attrs = ['ids', 'names', 'resids', 'resnames', 'masses', - 'bonds', 'chainIDs', 'elements'] + expected_attrs = [ + "ids", + "names", + "resids", + "resnames", + "masses", + "bonds", + "chainIDs", + "elements", + ] expected_n_bonds = 0 def test_creates_universe(self, filename): """Check that Universe works with this Parser""" - u = mda.Universe(filename, topology_format='OPENMMTOPOLOGY') + u = mda.Universe(filename, topology_format="OPENMMTOPOLOGY") assert isinstance(u, mda.Universe) def test_attr_size(self, top): @@ -45,7 +54,7 @@ def test_attr_size(self, top): assert len(top.names) == top.n_atoms assert len(top.resids) == top.n_residues assert len(top.resnames) == top.n_residues - + def test_atoms(self, top): assert top.n_atoms == self.expected_n_atoms @@ -99,4 +108,3 @@ class TestOpenMMPDBxFileParser(OpenMMTopologyBase): expected_n_residues = 7 expected_n_segments = 1 expected_n_bonds = 62 - From e26d170c25b1338c4adef24d3781567de43c7785 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Tue, 25 Aug 2020 09:04:36 -0400 Subject: [PATCH 22/47] Refactor so generic application objects share the same readers and functions --- package/MDAnalysis/coordinates/OpenMM.py | 165 ++++----------- package/MDAnalysis/topology/OpenMMParser.py | 198 ++++++------------ .../MDAnalysisTests/topology/test_openmm.py | 31 ++- 3 files changed, 132 insertions(+), 262 deletions(-) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index cb136c5deaa..e39a959d570 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -27,7 +27,7 @@ Read coordinates data from a `OpenMM `_ :class:`simtk.openmm.app.simulation.Simulation` with :class:`OpenMMReader` into a MDAnalysis Universe. -Also converts: +Also converts other objects within the `OpenMM Application Layer `_: - `simtk.openmm.app.pdbfile.PDBFile `_ - `simtk.openmm.app.modeller.Modeller `_ @@ -40,13 +40,7 @@ .. autoclass:: OpenMMSimulationReader :members: -.. autoclass:: OpenMMPDBFileReader - :members: - -.. autoclass:: OpenMMPDBxFileReader - :members: - -.. autoclass:: OpenMMModellerReader +.. autoclass:: OpenMMAppReader :members: @@ -59,12 +53,13 @@ class OpenMMSimulationReader(base.SingleFrameReaderBase): - """Reader for the OpenMM Simulation objects + """Reader for OpenMM Simulation objects """ format = "OPENMMSIMULATION" - units = {"time": "ps", "length": "nm", "velocity": "nm/ps", "force": "kJ/(mol*nm)"} + units = {"time": "ps", "length": "nm", "velocity": "nm/ps", + "force": "kJ/(mol*nm)"} @staticmethod def _format_hint(thing): @@ -81,9 +76,7 @@ def _format_hint(thing): def _read_first_frame(self): self.n_atoms = self.filename.topology.getNumAtoms() - self.ts = _mda_timestep_from_omm_context( - self.filename.context, self._Timestep, **self._ts_kwargs - ) + self.ts = self._mda_timestep_from_omm_context() if self.convert_units: self.convert_pos_from_native(self.ts._pos) @@ -94,47 +87,34 @@ def _read_first_frame(self): self.convert_forces_from_native(self.ts._forces) self.convert_time_from_native(self.ts.dt) + def _mda_timestep_from_omm_context(self): + """ Construct Timestep object from Openmm context """ -class OpenMMPDBFileReader(base.SingleFrameReaderBase): - """Reader for the OpenMM PDBFile objects + state = self.filename.context.getState(-1, getVelocities=True, + getForces=True, getEnergy=True) - """ + n_atoms = self.filename.context.getSystem().getNumParticles() - format = "OPENMMPDBFILE" - units = {"time": "ps", "length": "nm"} + ts = self._Timestep(n_atoms, **self._ts_kwargs) + ts.frame = 0 + ts.data["time"] = state.getTime()._value + ts.data["potential_energy"] = state.getPotentialEnergy() + ts.data["kinetic_energy"] = state.getKineticEnergy() + ts.triclinic_dimensions = state.getPeriodicBoxVectors( + asNumpy=True)._value + ts.positions = state.getPositions(asNumpy=True)._value + ts.velocities = state.getVelocities(asNumpy=True)._value + ts.forces = state.getForces(asNumpy=True)._value - @staticmethod - def _format_hint(thing): - """Can this reader read *thing*? - .. versionadded:: 1.0.0 - """ - try: - from simtk.openmm.app import PDBFile - except ImportError: - return False - else: - return isinstance(thing, PDBFile) + return ts - def _read_first_frame(self): - self.n_atoms = self.filename.topology.getNumAtoms() - - self.ts = _mda_timestep_from_omm_modeller_pdbfile( - self.filename, self._Timestep, **self._ts_kwargs - ) - - if self.convert_units: - self.convert_pos_from_native(self.ts._pos) - self.ts.triclinic_dimensions = self.convert_pos_from_native( - self.ts.triclinic_dimensions, inplace=False - ) - -class OpenMMPDBxFileReader(base.SingleFrameReaderBase): - """Reader for the OpenMM PDBxFile objects +class OpenMMAppReader(base.SingleFrameReaderBase): + """Reader for OpenMM App objects """ - format = "OPENMMPDBXFILE" + format = "OPENMMAPP" units = {"time": "ps", "length": "nm"} @staticmethod @@ -143,18 +123,17 @@ def _format_hint(thing): .. versionadded:: 1.0.0 """ try: - from simtk.openmm.app import PDBxFile + from simtk.openmm import app except ImportError: return False else: - return isinstance(thing, PDBxFile) + return isinstance(thing, (app.PDBFile, app.Modeller, + app.PDBxFile)) def _read_first_frame(self): self.n_atoms = self.filename.topology.getNumAtoms() - self.ts = _mda_timestep_from_omm_modeller_pdbfile( - self.filename, self._Timestep, **self._ts_kwargs - ) + self.ts = self._mda_timestep_from_omm_app() if self.convert_units: self.convert_pos_from_native(self.ts._pos) @@ -162,84 +141,20 @@ def _read_first_frame(self): self.ts.triclinic_dimensions, inplace=False ) + def _mda_timestep_from_omm_app(self): + """ Construct Timestep object from Openmm Application object """ -class OpenMMModellerReader(base.SingleFrameReaderBase): - """Reader for the OpenMM Modeller objects - - """ - - format = "OPENMMMODELLER" - units = {"time": "ps", "length": "nm"} + omm_object = self.filename + n_atoms = omm_object.topology.getNumAtoms() - @staticmethod - def _format_hint(thing): - """Can this reader read *thing*? - .. versionadded:: 1.0.0 - """ - try: - from simtk.openmm.app import Modeller - except ImportError: - return False - else: - return isinstance(thing, Modeller) - - def _read_first_frame(self): - self.n_atoms = self.filename.topology.getNumAtoms() - - self.ts = _mda_timestep_from_omm_modeller_pdbfile( - self.filename, self._Timestep, **self._ts_kwargs - ) - - if self.convert_units: - self.convert_pos_from_native(self.ts._pos) - self.ts.triclinic_dimensions = self.convert_pos_from_native( - self.ts.triclinic_dimensions, inplace=False + ts = self._Timestep(n_atoms, **self._ts_kwargs) + ts.frame = 0 + if omm_object.topology.getPeriodicBoxVectors() is not None: + ts.triclinic_dimensions = np.array( + omm_object.topology.getPeriodicBoxVectors()._value ) + ts.positions = np.array(omm_object.getPositions()._value) + return ts -def _mda_timestep_from_omm_context(omm_context, timestep_module, **ts_kwargs): - """ Construct Timestep object from Openmm context - - Parameters - ---------- - omm_context: simtk.openmm.context - timestep_module: MDAnalysis.coordinates.base.timestep - This is the module, but the object gets created within this function """ - - state = omm_context.getState(-1, getVelocities=True, getForces=True, getEnergy=True) - - n_atoms = omm_context.getSystem().getNumParticles() - - ts = timestep_module(n_atoms, **ts_kwargs) - ts.frame = 0 - ts.data["time"] = state.getTime()._value - ts.data["potential_energy"] = state.getPotentialEnergy() - ts.data["kinetic_energy"] = state.getKineticEnergy() - ts.triclinic_dimensions = state.getPeriodicBoxVectors(asNumpy=True)._value - ts.positions = state.getPositions(asNumpy=True)._value - ts.velocities = state.getVelocities(asNumpy=True)._value - ts.forces = state.getForces(asNumpy=True)._value - - return ts - - -def _mda_timestep_from_omm_modeller_pdbfile(omm_object, timestep_module, **ts_kwargs): - """ Construct Timestep object from Openmm context - - Parameters - ---------- - omm_object: simtk.openmm.app.PDBFile, simtk.openmm.app.Modeller, or simtk.openmm.app.PDBxFile - timestep_module: MDAnalysis.coordinates.base.timestep - This is the module, but the object gets created within this function """ - - n_atoms = omm_object.topology.getNumAtoms() - - ts = timestep_module(n_atoms, **ts_kwargs) - ts.frame = 0 - if omm_object.topology.getPeriodicBoxVectors() is not None: - ts.triclinic_dimensions = np.array( - omm_object.topology.getPeriodicBoxVectors()._value - ) - ts.positions = np.array(omm_object.getPositions()._value) - return ts diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py index bdcb8ca9fbe..48c318e33ae 100644 --- a/package/MDAnalysis/topology/OpenMMParser.py +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -29,7 +29,7 @@ Converts an `OpenMM `_ :class:`simtk.openmm.app.topology.Topology` into a :class:`MDAnalysis.core.Topology`. -Also converts: +Also converts some objects within the `OpenMM Application layer `_ - `simtk.openmm.app.pdbfile.PDBFile `_ - `simtk.openmm.app.simulation.Simulation `_ @@ -49,25 +49,10 @@ :members: :inherited-members: -.. autoclass:: OpenMMSimulationParser +.. autoclass:: OpenMMAppTopologyParser :members: :inherited-members: -.. autoclass:: OpenMMPDBFileParser - :members: - :inherited-members: - -.. autoclass:: OpenMMModellerParser - :members: - :inherited-members: - -.. autoclass:: OpenMMPDBxFileParser - :members: - :inherited-members: - - - - """ import numpy as np @@ -106,64 +91,75 @@ def _format_hint(thing): else: return isinstance(thing, app.Topology) - def parse(self, **kwargs): - omm_topology = self.filename + def _mda_topology_from_omm_topology(self, omm_topology): + """ Construct mda topology from omm topology - top = _mda_topology_from_omm_topology(omm_topology) - - return top + Can be used for any openmm object that contains a topology object + Parameters + ---------- + omm_topology: simtk.openmm.Topology -class OpenMMSimulationParser(TopologyReaderBase): - format = "OPENMMSIMULATION" + Returns + ------- + top : MDAnalysis.core.topology.Topology - @staticmethod - def _format_hint(thing): - """Can this Parser read object *thing*? - - .. versionadded:: 1.0.0 """ - try: - from simtk.openmm import app - except ImportError: - return False - else: - return isinstance(thing, app.Simulation) - - def parse(self, **kwargs): - omm_topology = self.filename.topology - top = _mda_topology_from_omm_topology(omm_topology) + atom_resindex = [a.residue.index for a in omm_topology.atoms()] + residue_segindex = [r.chain.index for r in omm_topology.residues()] + atomids = [a.id for a in omm_topology.atoms()] + atomnames = [a.name for a in omm_topology.atoms()] + atomtypes = guess_types(atomnames) + chainids = [a.residue.chain.id for a in omm_topology.atoms()] + elements = [a.element.symbol for a in omm_topology.atoms()] + masses = [a.element.mass._value for a in omm_topology.atoms()] + resnames = [r.name for r in omm_topology.residues()] + resids = [r.index + 1 for r in omm_topology.residues()] + resnums = resids.copy() + segids = [c.index for c in omm_topology.chains()] + bonds = [(b.atom1.index, b.atom2.index) for b in omm_topology.bonds()] + bond_orders = [b.order for b in omm_topology.bonds()] + bond_types = [b.type for b in omm_topology.bonds()] + + n_atoms = len(atomids) + n_residues = len(resids) + n_segments = len(segids) + + attrs = [ + Atomids(np.array(atomids, dtype=np.int32)), + Atomnames(np.array(atomnames, dtype=object)), + Atomtypes(np.array(atomtypes, dtype=object)), + Bonds(bonds, types=bond_types, order=bond_orders, guessed=False), + ChainIDs(np.array(chainids, dtype=object)), + Elements(np.array(elements, dtype=object)), + Masses(np.array(masses, dtype=np.float32)), + Resids(resids), + Resnums(resnums), + Resnames(resnames), + Segids(segids), + ] + + top = Topology( + n_atoms, + n_residues, + n_segments, + attrs=attrs, + atom_resindex=atom_resindex, + residue_segindex=residue_segindex, + ) return top - -class OpenMMPDBFileParser(TopologyReaderBase): - format = "OPENMMPDBFILE" - - @staticmethod - def _format_hint(thing): - """Can this Parser read object *thing*? - - .. versionadded:: 1.0.0 - """ - try: - from simtk.openmm import app - except ImportError: - return False - else: - return isinstance(thing, app.PDBFile) - def parse(self, **kwargs): - omm_pdbfile = self.filename + omm_topology = self.filename - top = _mda_topology_from_omm_topology(omm_pdbfile.topology) + top = self._mda_topology_from_omm_topology(omm_topology) return top - -class OpenMMModellerParser(TopologyReaderBase): - format = "OPENMMMODELLER" +class OpenMMAppTopologyParser(OpenMMTopologyParser): + format = "OPENMMAPP" @staticmethod def _format_hint(thing): @@ -176,85 +172,17 @@ def _format_hint(thing): except ImportError: return False else: - return isinstance(thing, app.Modeller) + return isinstance(thing, (app.PDBFile, app.Modeller, + app.Simulation, app.PDBxFile)) def parse(self, **kwargs): - omm_modeller = self.filename - - top = _mda_topology_from_omm_topology(omm_modeller.topology) - - return top - - -class OpenMMPDBxFileParser(TopologyReaderBase): - format = "OPENMMPDBXFILE" - - @staticmethod - def _format_hint(thing): - """Can this Parser read object *thing*? - - .. versionadded:: 1.0.0 - """ try: - from simtk.openmm import app - except ImportError: - return False - else: - return isinstance(thing, app.PDBxFile) + omm_topology = self.filename.getTopology() + except AttributeError: + omm_topology = self.filename.topology - def parse(self, **kwargs): - omm_pdbxfile = self.filename - top = _mda_topology_from_omm_topology(omm_pdbxfile.topology) + top = self._mda_topology_from_omm_topology(omm_topology) return top - -def _mda_topology_from_omm_topology(omm_topology): - """ Construct mda topology from omm topology - - Can be used for any openmm object that contains a topology object""" - atom_resindex = [a.residue.index for a in omm_topology.atoms()] - residue_segindex = [r.chain.index for r in omm_topology.residues()] - atomids = [a.id for a in omm_topology.atoms()] - atomnames = [a.name for a in omm_topology.atoms()] - atomtypes = guess_types(atomnames) - chainids = [a.residue.chain.id for a in omm_topology.atoms()] - elements = [a.element.symbol for a in omm_topology.atoms()] - masses = [a.element.mass._value for a in omm_topology.atoms()] - resnames = [r.name for r in omm_topology.residues()] - resids = [r.index + 1 for r in omm_topology.residues()] - resnums = resids.copy() - segids = [c.index for c in omm_topology.chains()] - bonds = [(b.atom1.index, b.atom2.index) for b in omm_topology.bonds()] - bond_orders = [b.order for b in omm_topology.bonds()] - bond_types = [b.type for b in omm_topology.bonds()] - - n_atoms = len(atomids) - n_residues = len(resids) - n_segments = len(segids) - - attrs = [ - Atomids(np.array(atomids, dtype=np.int32)), - Atomnames(np.array(atomnames, dtype=object)), - Atomtypes(np.array(atomtypes, dtype=object)), - Bonds(bonds, types=bond_types, order=bond_orders, guessed=False), - ChainIDs(np.array(chainids, dtype=object)), - Elements(np.array(elements, dtype=object)), - Masses(np.array(masses, dtype=np.float32)), - Resids(resids), - Resnums(resnums), - Resnames(resnames), - Segids(segids), - ] - - top = Topology( - n_atoms, - n_residues, - n_segments, - attrs=attrs, - atom_resindex=atom_resindex, - residue_segindex=residue_segindex, - ) - - return top diff --git a/testsuite/MDAnalysisTests/topology/test_openmm.py b/testsuite/MDAnalysisTests/topology/test_openmm.py index ca6a40c6d41..aa0502326cc 100644 --- a/testsuite/MDAnalysisTests/topology/test_openmm.py +++ b/testsuite/MDAnalysisTests/topology/test_openmm.py @@ -93,6 +93,25 @@ def test_segids(self, top): else: assert top.segids.values == [] +class OpenMMAppTopologyBase(OpenMMTopologyBase): + parser = mda.topology.OpenMMParser.OpenMMAppTopologyParser + expected_attrs = [ + "ids", + "names", + "resids", + "resnames", + "masses", + "bonds", + "chainIDs", + "elements", + ] + expected_n_bonds = 0 + + def test_creates_universe(self, filename): + """Check that Universe works with this Parser""" + u = mda.Universe(filename, topology_format="OPENMMAPP") + assert isinstance(u, mda.Universe) + class TestOpenMMTopologyParser(OpenMMTopologyBase): ref_filename = app.PDBFile(CONECT).topology @@ -102,8 +121,16 @@ class TestOpenMMTopologyParser(OpenMMTopologyBase): expected_n_bonds = 1922 -class TestOpenMMPDBxFileParser(OpenMMTopologyBase): - ref_filename = app.PDBxFile(PDBX).topology +class TestOpenMMPDBFileParser(OpenMMAppTopologyBase): + ref_filename = app.PDBFile(CONECT) + expected_n_atoms = 1890 + expected_n_residues = 199 + expected_n_segments = 3 + expected_n_bonds = 1922 + + +class TestOpenMMPDBxFileParser(OpenMMAppTopologyBase): + ref_filename = app.PDBxFile(PDBX) expected_n_atoms = 60 expected_n_residues = 7 expected_n_segments = 1 From 24994c65828ac0cb295a7f4e5eeecbf5ef06c939 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Tue, 25 Aug 2020 20:27:29 -0400 Subject: [PATCH 23/47] Adjust line length --- package/MDAnalysis/coordinates/OpenMM.py | 7 +++++-- package/MDAnalysis/topology/OpenMMParser.py | 7 +++++-- testsuite/MDAnalysisTests/coordinates/test_openmm.py | 9 ++++++--- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index e39a959d570..53ef572494a 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -24,10 +24,13 @@ """OpenMM structure I/O --- :mod:`MDAnalysis.coordinates.OpenMM` ================================================================ -Read coordinates data from a `OpenMM `_ :class:`simtk.openmm.app.simulation.Simulation` with :class:`OpenMMReader` +Read coordinates data from a +`OpenMM `_ +:class:`simtk.openmm.app.simulation.Simulation` with :class:`OpenMMReader` into a MDAnalysis Universe. -Also converts other objects within the `OpenMM Application Layer `_: +Also converts other objects within the +`OpenMM Application Layer `_: - `simtk.openmm.app.pdbfile.PDBFile `_ - `simtk.openmm.app.modeller.Modeller `_ diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py index 48c318e33ae..3eb3f3f7228 100644 --- a/package/MDAnalysis/topology/OpenMMParser.py +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -27,9 +27,12 @@ .. versionadded:: 0.17.0 -Converts an `OpenMM `_ :class:`simtk.openmm.app.topology.Topology` into a :class:`MDAnalysis.core.Topology`. +Converts an +`OpenMM `_ +:class:`simtk.openmm.app.topology.Topology` into a :class:`MDAnalysis.core.Topology`. -Also converts some objects within the `OpenMM Application layer `_ +Also converts some objects within the +`OpenMM Application layer `_ - `simtk.openmm.app.pdbfile.PDBFile `_ - `simtk.openmm.app.simulation.Simulation `_ diff --git a/testsuite/MDAnalysisTests/coordinates/test_openmm.py b/testsuite/MDAnalysisTests/coordinates/test_openmm.py index bc74128bfd6..8c124e58c9c 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_openmm.py +++ b/testsuite/MDAnalysisTests/coordinates/test_openmm.py @@ -51,7 +51,8 @@ def test_dimensions(self): self.universe.trajectory.ts.dimensions[0:3], self.ref.trajectory.ts.dimensions[0:3], self.prec, - "OpenMMPDBFileReader failed to get unitcell dimensions from OpenMMPDBFile", + "OpenMMPDBFileReader failed to get unitcell dimensions " + + "from OpenMMPDBFile", ) def test_coordinates(self): @@ -76,7 +77,8 @@ def test_dimensions(self): self.universe.trajectory.ts.dimensions[0:3], self.ref.trajectory.ts.dimensions[0:3], self.prec, - "OpenMMModellerReader failed to get unitcell dimensions from OpenMMModeller", + "OpenMMModellerReader failed to get unitcell dimensions " + + "from OpenMMModeller", ) def test_coordinates(self): @@ -109,7 +111,8 @@ def test_dimensions(self): self.universe.trajectory.ts.dimensions[0:3], self.ref.trajectory.ts.dimensions[0:3], self.prec, - "OpenMMSimulationReader failed to get unitcell dimensions from OpenMMSimulation", + "OpenMMSimulationReader failed to get unitcell dimensions " + + "from OpenMMSimulation", ) def test_coordinates(self): From 23a8c8420ee3b833ae70c86a5b34f0b0ae09745d Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Tue, 1 Sep 2020 20:50:56 -0400 Subject: [PATCH 24/47] Revert datafiles without black formatting --- testsuite/MDAnalysisTests/datafiles.py | 822 +++++++++++-------------- 1 file changed, 343 insertions(+), 479 deletions(-) diff --git a/testsuite/MDAnalysisTests/datafiles.py b/testsuite/MDAnalysisTests/datafiles.py index 3c2ef594d36..898bd05b1ce 100644 --- a/testsuite/MDAnalysisTests/datafiles.py +++ b/testsuite/MDAnalysisTests/datafiles.py @@ -37,21 +37,14 @@ """ __all__ = [ - "PSF", - "DCD", - "CRD", # CHARMM (AdK example, DIMS trajectory from JMB 2009 paper) - "DCD2", # CHARMM (AdK example, DIMS trajectory from PLOS Comput Biol paper) - "PSF_notop", - "PSF_BAD", # Same as PSF but no bonds etc, malformed version of previous + "PSF", "DCD", "CRD", # CHARMM (AdK example, DIMS trajectory from JMB 2009 paper) + "DCD2", # CHARMM (AdK example, DIMS trajectory from PLOS Comput Biol paper) + "PSF_notop", "PSF_BAD", # Same as PSF but no bonds etc, malformed version of previous "DCD_empty", - "PSF_TRICLINIC", - "DCD_TRICLINIC", # CHARMM c36 new unitcell, NPT 125 TIP3P (box vectors, see Issue 187 for details) - "PSF_NAMD", - "PDB_NAMD", # NAMD - "PSF_NAMD_TRICLINIC", - "DCD_NAMD_TRICLINIC", # NAMD, triclinic unitcell (Issue 187) - "PSF_NAMD_GBIS", - "DCD_NAMD_GBIS", # NAMD, implicit solvent, 100 steps, #1819 + "PSF_TRICLINIC", "DCD_TRICLINIC", # CHARMM c36 new unitcell, NPT 125 TIP3P (box vectors, see Issue 187 for details) + "PSF_NAMD", "PDB_NAMD", # NAMD + "PSF_NAMD_TRICLINIC", "DCD_NAMD_TRICLINIC", # NAMD, triclinic unitcell (Issue 187) + "PSF_NAMD_GBIS", "DCD_NAMD_GBIS", # NAMD, implicit solvent, 100 steps, #1819 "PSF_nosegid", # psf without a segid, Issue 121 "PSF_cmap", # ala3 PSF from ParmEd test files with cmap "PDB_small", # PDB @@ -63,178 +56,94 @@ "PDB_singleconect", # Conect record with one entry (Issue 937) "PDB_icodes", # stripped down version of 1osm, has icodes! "XPDB_small", - "PDB_full", # PDB 4E43 (full HEADER, TITLE, COMPND, REMARK, altloc) + "PDB_full", # PDB 4E43 (full HEADER, TITLE, COMPND, REMARK, altloc) "ALIGN", # Various way to align atom names in PDB files - "RNA_PSF", - "RNA_PDB", # nucleic acid (PDB 1K5I in CHARMM36m) + "RNA_PSF", "RNA_PDB", # nucleic acid (PDB 1K5I in CHARMM36m) "INC_PDB", # incomplete PDB file (Issue #396) # for testing cryst before/after model headers - "PDB_cm", - "PDB_cm_bz2", - "PDB_cm_gz", - "PDB_mc", - "PDB_mc_bz2", - "PDB_mc_gz", + "PDB_cm", "PDB_cm_bz2", "PDB_cm_gz", + "PDB_mc", "PDB_mc_bz2", "PDB_mc_gz", "PDB_chainidnewres", # Issue 1110 - "PDB_sameresid_diffresname", # Case where two residues share the same resid + "PDB_sameresid_diffresname", #Case where two residues share the same resid "PDB_chainidrepeat", # Issue #1107 - "PDB", - "GRO", - "XTC", - "TRR", - "TPR", - "GRO_velocity", # Gromacs (AdK) + "PDB", "GRO", "XTC", "TRR", "TPR", "GRO_velocity", # Gromacs (AdK) "GRO_incomplete_vels", "COORDINATES_GRO_BZ2", - "GRO_large", # atom number truncation at > 100,000 particles, Issue 550 + "GRO_large", #atom number truncation at > 100,000 particles, Issue 550 "GRO_residwrap", # resids wrapping because of 5 digit field (Issue #728) "GRO_residwrap_0base", # corner case of #728 with resid=0 for first atom - "GRO_sameresid_diffresname", # Case where two residues share the same resid - "PDB_xvf", - "TPR_xvf", - "TRR_xvf", # Gromacs coords/veloc/forces (cobrotoxin, OPLS-AA, Gromacs 4.5.5 tpr) + "GRO_sameresid_diffresname", # Case where two residues share the same resid + "PDB_xvf", "TPR_xvf", "TRR_xvf", # Gromacs coords/veloc/forces (cobrotoxin, OPLS-AA, Gromacs 4.5.5 tpr) "H5MD_xvf", # TPR_xvf + TRR_xvf converted to h5md format "XVG_BZ2", # Compressed xvg file about cobrotoxin "PDB_xlserial", - "TPR400", - "TPR402", - "TPR403", - "TPR404", - "TPR405", - "TPR406", - "TPR407", - "TPR450", - "TPR451", - "TPR452", - "TPR453", - "TPR454", - "TPR455", - "TPR455Double", - "TPR460", - "TPR461", - "TPR502", - "TPR504", - "TPR505", - "TPR510", - "TPR2016", - "TPR2018", - "TPR2019B3", - "TPR2020B2", - "TPR2020", - "TPR2020Double", - "TPR510_bonded", - "TPR2016_bonded", - "TPR2018_bonded", - "TPR2019B3_bonded", - "TPR2020B2_bonded", - "TPR2020_bonded", - "TPR2020_double_bonded", + "TPR400", "TPR402", "TPR403", "TPR404", "TPR405", "TPR406", "TPR407", + "TPR450", "TPR451", "TPR452", "TPR453", "TPR454", "TPR455", "TPR455Double", + "TPR460", "TPR461", "TPR502", "TPR504", "TPR505", "TPR510", "TPR2016", + "TPR2018", "TPR2019B3", "TPR2020B2", "TPR2020", "TPR2020Double", + "TPR510_bonded", "TPR2016_bonded", "TPR2018_bonded", "TPR2019B3_bonded", + "TPR2020B2_bonded", "TPR2020_bonded", "TPR2020_double_bonded", "TPR334_bonded", - "TPR_EXTRA_2020", - "TPR_EXTRA_2018", - "TPR_EXTRA_2016", - "TPR_EXTRA_407", - "PDB_sub_sol", - "PDB_sub_dry", # TRRReader sub selection + "TPR_EXTRA_2020", "TPR_EXTRA_2018", "TPR_EXTRA_2016", "TPR_EXTRA_407", + "PDB_sub_sol", "PDB_sub_dry", # TRRReader sub selection "TRR_sub_sol", "XTC_sub_sol", - "XYZ", - "XYZ_psf", - "XYZ_bz2", - "XYZ_mini", - "XYZ_five", # 3 and 5 atoms xyzs for an easy topology - "TXYZ", - "ARC", - "ARC_PBC", # Tinker files - "PRM", - "TRJ", - "TRJ_bz2", # Amber (no periodic box) + "XYZ", "XYZ_psf", "XYZ_bz2", + "XYZ_mini", "XYZ_five", # 3 and 5 atoms xyzs for an easy topology + "TXYZ", "ARC", "ARC_PBC", # Tinker files + "PRM", "TRJ", "TRJ_bz2", # Amber (no periodic box) "INPCRD", - "PRMpbc", - "TRJpbc_bz2", # Amber (periodic box) - "PRM7", - "NCDFtruncoct", # Amber (cpptrj test trajectory, see Issue 488) - "PRM12", - "TRJ12_bz2", # Amber (v12 format, Issue 100) - "PRMncdf", - "TRJncdf", - "NCDF", # Amber (netcdf) - "PFncdf_Top", - "PFncdf_Trj", # Amber ncdf with Positions and Forces - "PRMcs", # Amber (format, Issue 1331) - "PRMNCRST", # Amber ncrst with positions/forces/velocities - "PRM_NCBOX", - "TRJ_NCBOX", # Amber parm7 + nc w/ pos/forces/vels/box - "PRMNEGATIVE", # Amber negative ATOMIC_NUMBER (Issue 2306) - "PRMErr1", - "PRMErr2", - "PRMErr3", # Amber TOP files to check raised errors - "PRM_UreyBradley", # prmtop from ParmEd test files with Urey-Bradley angles - "PRM7_ala2", - "RST7_ala2", # prmtop and rst files from ParmEd example files - "PRM19SBOPC", # prmtop w/ ff19SB CMAP terms and OPC water (Issue #2449) + "PRMpbc", "TRJpbc_bz2", # Amber (periodic box) + "PRM7", "NCDFtruncoct", # Amber (cpptrj test trajectory, see Issue 488) + "PRM12", "TRJ12_bz2", # Amber (v12 format, Issue 100) + "PRMncdf", "TRJncdf", "NCDF", # Amber (netcdf) + "PFncdf_Top", "PFncdf_Trj", # Amber ncdf with Positions and Forces + "PRMcs", # Amber (format, Issue 1331) + "PRMNCRST", # Amber ncrst with positions/forces/velocities + "PRM_NCBOX", "TRJ_NCBOX", # Amber parm7 + nc w/ pos/forces/vels/box + "PRMNEGATIVE", # Amber negative ATOMIC_NUMBER (Issue 2306) + "PRMErr1", "PRMErr2", "PRMErr3", # Amber TOP files to check raised errors + "PRM_UreyBradley", # prmtop from ParmEd test files with Urey-Bradley angles + "PRM7_ala2", "RST7_ala2", # prmtop and rst files from ParmEd example files + "PRM19SBOPC", # prmtop w/ ff19SB CMAP terms and OPC water (Issue #2449) "PQR", # PQR v1 "PQR_icodes", # PQR v2 with icodes "PDBQT_input", # PDBQT "PDBQT_querypdb", "FASTA", # sequence alignment, Issue 112 + 113 "HELANAL_BENDING_MATRIX", # HELANAL test (from PSF+DCD (AdK) helix 8) - "HELANAL_BENDING_MATRIX_SUBSET", # As above, slice of frames 10 to 79 + "HELANAL_BENDING_MATRIX_SUBSET", # As above, slice of frames 10 to 79 "PDB_HOLE", # gramicidin A - "MULTIPDB_HOLE", # gramicidin A, normal mode 7 from ElNemo + "MULTIPDB_HOLE", # gramicidin A, normal mode 7 from ElNemo "DMS", "DMS_DOMAINS", # ADK closed with multiple segids "DMS_NO_SEGID", # ADK closed with no segids or chains "CONECT", # HIV Reverse Transcriptase with inhibitor - "TRZ", - "TRZ_psf", + "TRZ", "TRZ_psf", "TRIC", "XTC_multi_frame", "TRR_multi_frame", - "merge_protein", - "merge_ligand", - "merge_water", - "mol2_molecules", - "mol2_molecule", - "mol2_broken_molecule", - "mol2_zinc", - "mol2_comments_header", - "mol2_ligand", - "capping_input", - "capping_output", - "capping_ace", - "capping_nma", - "contacts_villin_folded", - "contacts_villin_unfolded", - "contacts_file", - "LAMMPSdata", - "trz4data", - "LAMMPSdata_mini", - "LAMMPSdata2", - "LAMMPSdcd2", - "LAMMPScnt", - "LAMMPScnt2", # triclinic box - "LAMMPShyd", - "LAMMPShyd2", + "merge_protein", "merge_ligand", "merge_water", + "mol2_molecules", "mol2_molecule", "mol2_broken_molecule", + "mol2_zinc", "mol2_comments_header", "mol2_ligand", + "capping_input", "capping_output", "capping_ace", "capping_nma", + "contacts_villin_folded", "contacts_villin_unfolded", "contacts_file", + "LAMMPSdata", "trz4data", "LAMMPSdata_mini", + "LAMMPSdata2", "LAMMPSdcd2", + "LAMMPScnt", "LAMMPScnt2", # triclinic box + "LAMMPShyd", "LAMMPShyd2", "LAMMPSdata_deletedatoms", # with deleted atoms "LAMMPSDUMP", "unordered_res", # pdb file with resids non sequential "GMS_ASYMOPT", # GAMESS C1 optimization - "GMS_SYMOPT", # GAMESS D4h optimization - "GMS_ASYMSURF", # GAMESS C1 surface - "two_water_gro", - "two_water_gro_nonames", # for bond guessing, 2 water molecules, one with weird names + "GMS_SYMOPT", # GAMESS D4h optimization + "GMS_ASYMSURF", # GAMESS C1 surface + "two_water_gro", "two_water_gro_nonames", # for bond guessing, 2 water molecules, one with weird names "two_water_gro_multiframe", "two_water_gro_widebox", # Issue #548 - "DLP_CONFIG", - "DLP_CONFIG_order", - "DLP_CONFIG_minimal", # dl_poly 4 config file - "DLP_HISTORY", - "DLP_HISTORY_order", - "DLP_HISTORY_minimal", # dl_poly 4 history file - "waterPSF", - "waterDCD", - "rmsfArray", + "DLP_CONFIG", "DLP_CONFIG_order", "DLP_CONFIG_minimal", # dl_poly 4 config file + "DLP_HISTORY", "DLP_HISTORY_order", "DLP_HISTORY_minimal", # dl_poly 4 history file + "waterPSF","waterDCD","rmsfArray", "HoomdXMLdata", "Make_Whole", # for testing the function lib.mdamath.make_whole, has 9 atoms "fullerene", # for make_whole, a nice friendly C60 with bonds @@ -243,322 +152,288 @@ "COORDINATES_XYZ_BZ2", "COORDINATES_GRO", "COORDINATES_GRO_INCOMPLETE_VELOCITY", - "Martini_membrane_gro", # for testing the leaflet finder + "Martini_membrane_gro", # for testing the leaflet finder "COORDINATES_XTC", "COORDINATES_TRR", "COORDINATES_H5MD", "COORDINATES_DCD", "COORDINATES_TOPOLOGY", "NUCLsel", - "GRO_empty_atom", - "GRO_missing_atomname", # for testing GROParser exception raise - "ENT", # for testing ENT file extension + "GRO_empty_atom", "GRO_missing_atomname", # for testing GROParser exception raise + "ENT", #for testing ENT file extension "RANDOM_WALK", - "RANDOM_WALK_TOPO", # garbage topology to go along with XTC positions above - "AUX_XVG", - "XVG_BAD_NCOL", # for testing .xvg auxiliary reader - "AUX_XVG_LOWF", - "AUX_XVG_HIGHF", - "MMTF", - "MMTF_gz", - "MMTF_skinny", # skinny - some optional fields stripped out + "RANDOM_WALK_TOPO", # garbage topology to go along with XTC positions above + "AUX_XVG", "XVG_BAD_NCOL", #for testing .xvg auxiliary reader + "AUX_XVG_LOWF", "AUX_XVG_HIGHF", + "MMTF", "MMTF_gz", 'MMTF_skinny', # skinny - some optional fields stripped out "MMTF_skinny2", "ALIGN_BOUND", # two component bound system - "ALIGN_UNBOUND", # two component unbound system - "legacy_DCD_ADK_coords", # frames 5 and 29 read in for adk_dims.dcd using legacy DCD reader - "legacy_DCD_NAMD_coords", # frame 0 read in for SiN_tric_namd.dcd using legacy DCD reader - "legacy_DCD_c36_coords", # frames 1 and 4 read in for tip125_tric_C36.dcd using legacy DCD reader - "GSD", - "GSD_bonds", - "GSD_long", - "GRO_MEMPROT", - "XTC_MEMPROT", # YiiP transporter in POPE:POPG lipids with Na+, Cl-, Zn2+ dummy model without water - "DihedralArray", - "DihedralsArray", # time series of single dihedral - "RamaArray", - "GLYRamaArray", # time series of phi/psi angles - "JaninArray", - "LYSJaninArray", # time series of chi1/chi2 angles - "PDB_rama", - "PDB_janin", # for testing failures of Ramachandran and Janin classes - "PDB_metal", # PDB with metal atoms - "BATArray", # time series of bond-angle-torsion coordinates array from Molecule_comments_header.mol2 + "ALIGN_UNBOUND", # two component unbound system + "legacy_DCD_ADK_coords", # frames 5 and 29 read in for adk_dims.dcd using legacy DCD reader + "legacy_DCD_NAMD_coords", # frame 0 read in for SiN_tric_namd.dcd using legacy DCD reader + "legacy_DCD_c36_coords", # frames 1 and 4 read in for tip125_tric_C36.dcd using legacy DCD reader + "GSD", "GSD_bonds", "GSD_long", + "GRO_MEMPROT", "XTC_MEMPROT", # YiiP transporter in POPE:POPG lipids with Na+, Cl-, Zn2+ dummy model without water + "DihedralArray", "DihedralsArray", # time series of single dihedral + "RamaArray", "GLYRamaArray", # time series of phi/psi angles + "JaninArray", "LYSJaninArray", # time series of chi1/chi2 angles + "PDB_rama", "PDB_janin", # for testing failures of Ramachandran and Janin classes + "PDB_metal", # PDB with metal atoms + "BATArray", # time series of bond-angle-torsion coordinates array from Molecule_comments_header.mol2 # DOS line endings - "WIN_PDB_multiframe", - "WIN_DLP_HISTORY", - "WIN_TRJ", - "WIN_LAMMPSDUMP", - "WIN_ARC", - "GRO_huge_box", # for testing gro parser with hige box sizes - "ITP", # for GROMACS generated itps - "ITP_nomass", # for ATB generated itps - "NAMDBIN", # for NAMD generated binary file - "ITP_edited", # to check different directives are read properly - "ITP_tip5p", # tip5p water from opls-aa, edited with additional keywords - "ITP_spce", # spce water from gromos54a7, edited with additional keywords, - "GMX_TOP", # 2 ala10 chains + 3 spc water - "GMX_DIR", # GROMACS directory - "GMX_TOP_BAD", # file with an #include that doesn't exist - "ITP_no_endif", # file missing an #endif - "PDB_CRYOEM_BOX", # Issue 2599, Issue #2679, PR #2685 - "PDB_CHECK_RIGHTHAND_PA", # for testing right handedness of principal_axes - "MMTF_NOCRYST", # File with meaningless CRYST1 record (Issue #2679, PR #2685) - "FHIAIMS", # to test FHIAIMS coordinate files - "SDF_molecule", # MDL SDFile for rdkit - "PDBX", # PDBxfile + "WIN_PDB_multiframe", "WIN_DLP_HISTORY", "WIN_TRJ", "WIN_LAMMPSDUMP", "WIN_ARC", + "GRO_huge_box", # for testing gro parser with hige box sizes + "ITP", # for GROMACS generated itps + "ITP_nomass", # for ATB generated itps + "NAMDBIN", # for NAMD generated binary file + "ITP_edited", # to check different directives are read properly + "ITP_tip5p", # tip5p water from opls-aa, edited with additional keywords + "ITP_spce", # spce water from gromos54a7, edited with additional keywords, + "GMX_TOP", # 2 ala10 chains + 3 spc water + "GMX_DIR", # GROMACS directory + "GMX_TOP_BAD", # file with an #include that doesn't exist + "ITP_no_endif", # file missing an #endif + "PDB_CRYOEM_BOX", # Issue 2599, Issue #2679, PR #2685 + "PDB_CHECK_RIGHTHAND_PA", # for testing right handedness of principal_axes + "MMTF_NOCRYST", # File with meaningless CRYST1 record (Issue #2679, PR #2685) + "FHIAIMS", # to test FHIAIMS coordinate files + "SDF_molecule" # MDL SDFile for rdkit ] from pkg_resources import resource_filename -WIN_PDB_multiframe = resource_filename( - __name__, "data/windows/WIN_nmr_neopetrosiamide.pdb" -) -WIN_DLP_HISTORY = resource_filename(__name__, "data/windows/WIN_HISTORY") -WIN_TRJ = resource_filename(__name__, "data/windows/WIN_ache.mdcrd") -WIN_ARC = resource_filename(__name__, "data/windows/WIN_test.arc") -WIN_LAMMPSDUMP = resource_filename(__name__, "data/windows/WIN_wat.lammpstrj") - -legacy_DCD_NAMD_coords = resource_filename(__name__, "data/legacy_DCD_NAMD_coords.npy") -legacy_DCD_ADK_coords = resource_filename(__name__, "data/legacy_DCD_adk_coords.npy") -legacy_DCD_c36_coords = resource_filename(__name__, "data/legacy_DCD_c36_coords.npy") -AUX_XVG_LOWF = resource_filename(__name__, "data/test_lowf.xvg") -AUX_XVG_HIGHF = resource_filename(__name__, "data/test_highf.xvg") -XVG_BAD_NCOL = resource_filename(__name__, "data/bad_num_col.xvg") -AUX_XVG = resource_filename(__name__, "data/test.xvg") -ENT = resource_filename(__name__, "data/testENT.ent") -GRO_missing_atomname = resource_filename(__name__, "data/missing_atomname.gro") -GRO_empty_atom = resource_filename(__name__, "data/empty_atom.gro") -GRO_huge_box = resource_filename(__name__, "data/huge_box.gro") - -COORDINATES_GRO = resource_filename(__name__, "data/coordinates/test.gro") -COORDINATES_GRO_INCOMPLETE_VELOCITY = resource_filename( - __name__, "data/coordinates/test_incomplete_vel.gro" -) -COORDINATES_GRO_BZ2 = resource_filename(__name__, "data/coordinates/test.gro.bz2") -COORDINATES_XYZ = resource_filename(__name__, "data/coordinates/test.xyz") -COORDINATES_XYZ_BZ2 = resource_filename(__name__, "data/coordinates/test.xyz.bz2") -COORDINATES_XTC = resource_filename(__name__, "data/coordinates/test.xtc") -COORDINATES_TRR = resource_filename(__name__, "data/coordinates/test.trr") -COORDINATES_H5MD = resource_filename(__name__, "data/coordinates/test.h5md") -COORDINATES_DCD = resource_filename(__name__, "data/coordinates/test.dcd") -COORDINATES_TOPOLOGY = resource_filename(__name__, "data/coordinates/test_topology.pdb") - -PSF = resource_filename(__name__, "data/adk.psf") -PSF_notop = resource_filename(__name__, "data/adk_notop.psf") -PSF_BAD = resource_filename(__name__, "data/adk_notop_BAD.psf") -DCD = resource_filename(__name__, "data/adk_dims.dcd") -DCD_empty = resource_filename(__name__, "data/empty.dcd") -CRD = resource_filename(__name__, "data/adk_open.crd") -PSF_TRICLINIC = resource_filename(__name__, "data/tip125_tric_C36.psf") -DCD_TRICLINIC = resource_filename(__name__, "data/tip125_tric_C36.dcd") -DCD2 = resource_filename(__name__, "data/adk_dims2.dcd") - -PSF_NAMD = resource_filename(__name__, "data/namd_cgenff.psf") -PDB_NAMD = resource_filename(__name__, "data/namd_cgenff.pdb") -PSF_NAMD_TRICLINIC = resource_filename(__name__, "data/SiN_tric_namd.psf") -DCD_NAMD_TRICLINIC = resource_filename(__name__, "data/SiN_tric_namd.dcd") -PSF_NAMD_GBIS = resource_filename(__name__, "data/adk_closed_NAMD.psf") -DCD_NAMD_GBIS = resource_filename(__name__, "data/adk_gbis_tmd-fast1_NAMD.dcd") - -PSF_nosegid = resource_filename(__name__, "data/nosegid.psf") - -PSF_cmap = resource_filename(__name__, "data/parmed_ala3.psf") - -PDB_small = resource_filename(__name__, "data/adk_open.pdb") -PDB_closed = resource_filename(__name__, "data/adk_closed.pdb") -PDB_metal = resource_filename(__name__, "data/metals.pdb") - -ALIGN = resource_filename(__name__, "data/align.pdb") -RNA_PSF = resource_filename(__name__, "data/analysis/1k5i_c36.psf.gz") -RNA_PDB = resource_filename(__name__, "data/analysis/1k5i_c36.pdb.gz") -INC_PDB = resource_filename(__name__, "data/incomplete.pdb") -PDB_cm = resource_filename(__name__, "data/cryst_then_model.pdb") -PDB_cm_gz = resource_filename(__name__, "data/cryst_then_model.pdb.gz") -PDB_cm_bz2 = resource_filename(__name__, "data/cryst_then_model.pdb.bz2") -PDB_mc = resource_filename(__name__, "data/model_then_cryst.pdb") -PDB_mc_gz = resource_filename(__name__, "data/model_then_cryst.pdb.gz") -PDB_mc_bz2 = resource_filename(__name__, "data/model_then_cryst.pdb.bz2") -PDB_chainidnewres = resource_filename(__name__, "data/chainIDnewres.pdb.gz") -PDB_sameresid_diffresname = resource_filename( - __name__, "data/sameresid_diffresname.pdb" -) -PDB_chainidrepeat = resource_filename(__name__, "data/chainIDrepeat.pdb.gz") -PDB_multiframe = resource_filename(__name__, "data/nmr_neopetrosiamide.pdb") -PDB_helix = resource_filename(__name__, "data/A6PA6_alpha.pdb") -PDB_conect = resource_filename(__name__, "data/conect_parsing.pdb") -PDB_conect2TER = resource_filename(__name__, "data/CONECT2TER.pdb") -PDB_singleconect = resource_filename(__name__, "data/SINGLECONECT.pdb") -PDB_icodes = resource_filename(__name__, "data/1osm.pdb.gz") -PDB_CRYOEM_BOX = resource_filename(__name__, "data/5a7u.pdb") -PDB_CHECK_RIGHTHAND_PA = resource_filename(__name__, "data/6msm.pdb.bz2") -FHIAIMS = resource_filename(__name__, "data/fhiaims.in") - -GRO = resource_filename(__name__, "data/adk_oplsaa.gro") -GRO_velocity = resource_filename(__name__, "data/sample_velocity_file.gro") -GRO_incomplete_vels = resource_filename(__name__, "data/grovels.gro") -GRO_large = resource_filename(__name__, "data/bigbox.gro.bz2") -GRO_residwrap = resource_filename(__name__, "data/residwrap.gro") -GRO_residwrap_0base = resource_filename(__name__, "data/residwrap_0base.gro") -GRO_sameresid_diffresname = resource_filename( - __name__, "data/sameresid_diffresname.gro" -) -PDB = resource_filename(__name__, "data/adk_oplsaa.pdb") -XTC = resource_filename(__name__, "data/adk_oplsaa.xtc") -TRR = resource_filename(__name__, "data/adk_oplsaa.trr") -TPR = resource_filename(__name__, "data/adk_oplsaa.tpr") -PDB_sub_dry = resource_filename(__name__, "data/cobrotoxin_dry_neutral_0.pdb") -TRR_sub_sol = resource_filename(__name__, "data/cobrotoxin.trr") -XTC_sub_sol = resource_filename(__name__, "data/cobrotoxin.xtc") -PDB_sub_sol = resource_filename(__name__, "data/cobrotoxin.pdb") -PDB_xlserial = resource_filename(__name__, "data/xl_serial.pdb") -GRO_MEMPROT = resource_filename(__name__, "data/analysis/YiiP_lipids.gro.gz") -XTC_MEMPROT = resource_filename(__name__, "data/analysis/YiiP_lipids.xtc") +WIN_PDB_multiframe = resource_filename(__name__, + 'data/windows/WIN_nmr_neopetrosiamide.pdb') +WIN_DLP_HISTORY = resource_filename(__name__, + 'data/windows/WIN_HISTORY') +WIN_TRJ = resource_filename(__name__, + 'data/windows/WIN_ache.mdcrd') +WIN_ARC = resource_filename(__name__, + 'data/windows/WIN_test.arc') +WIN_LAMMPSDUMP = resource_filename(__name__, + 'data/windows/WIN_wat.lammpstrj') + +legacy_DCD_NAMD_coords = resource_filename(__name__, +'data/legacy_DCD_NAMD_coords.npy') +legacy_DCD_ADK_coords = resource_filename(__name__, +'data/legacy_DCD_adk_coords.npy') +legacy_DCD_c36_coords = resource_filename(__name__, +'data/legacy_DCD_c36_coords.npy') +AUX_XVG_LOWF = resource_filename(__name__, 'data/test_lowf.xvg') +AUX_XVG_HIGHF = resource_filename(__name__, 'data/test_highf.xvg') +XVG_BAD_NCOL = resource_filename(__name__, 'data/bad_num_col.xvg') +AUX_XVG = resource_filename(__name__, 'data/test.xvg') +ENT = resource_filename(__name__, 'data/testENT.ent') +GRO_missing_atomname = resource_filename(__name__, 'data/missing_atomname.gro') +GRO_empty_atom = resource_filename(__name__, 'data/empty_atom.gro') +GRO_huge_box = resource_filename(__name__, 'data/huge_box.gro') + +COORDINATES_GRO = resource_filename(__name__, 'data/coordinates/test.gro') +COORDINATES_GRO_INCOMPLETE_VELOCITY = resource_filename(__name__, 'data/coordinates/test_incomplete_vel.gro') +COORDINATES_GRO_BZ2 = resource_filename(__name__, 'data/coordinates/test.gro.bz2') +COORDINATES_XYZ = resource_filename(__name__, 'data/coordinates/test.xyz') +COORDINATES_XYZ_BZ2 = resource_filename( + __name__, 'data/coordinates/test.xyz.bz2') +COORDINATES_XTC = resource_filename(__name__, 'data/coordinates/test.xtc') +COORDINATES_TRR = resource_filename(__name__, 'data/coordinates/test.trr') +COORDINATES_H5MD = resource_filename(__name__, 'data/coordinates/test.h5md') +COORDINATES_DCD = resource_filename(__name__, 'data/coordinates/test.dcd') +COORDINATES_TOPOLOGY = resource_filename(__name__, 'data/coordinates/test_topology.pdb') + +PSF = resource_filename(__name__, 'data/adk.psf') +PSF_notop = resource_filename(__name__, 'data/adk_notop.psf') +PSF_BAD = resource_filename(__name__, 'data/adk_notop_BAD.psf') +DCD = resource_filename(__name__, 'data/adk_dims.dcd') +DCD_empty = resource_filename(__name__, 'data/empty.dcd') +CRD = resource_filename(__name__, 'data/adk_open.crd') +PSF_TRICLINIC = resource_filename(__name__, 'data/tip125_tric_C36.psf') +DCD_TRICLINIC = resource_filename(__name__, 'data/tip125_tric_C36.dcd') +DCD2 = resource_filename(__name__, 'data/adk_dims2.dcd') + +PSF_NAMD = resource_filename(__name__, 'data/namd_cgenff.psf') +PDB_NAMD = resource_filename(__name__, 'data/namd_cgenff.pdb') +PSF_NAMD_TRICLINIC = resource_filename(__name__, 'data/SiN_tric_namd.psf') +DCD_NAMD_TRICLINIC = resource_filename(__name__, 'data/SiN_tric_namd.dcd') +PSF_NAMD_GBIS = resource_filename(__name__, 'data/adk_closed_NAMD.psf') +DCD_NAMD_GBIS = resource_filename(__name__, 'data/adk_gbis_tmd-fast1_NAMD.dcd') + +PSF_nosegid = resource_filename(__name__, 'data/nosegid.psf') + +PSF_cmap = resource_filename(__name__, 'data/parmed_ala3.psf') + +PDB_small = resource_filename(__name__, 'data/adk_open.pdb') +PDB_closed = resource_filename(__name__, 'data/adk_closed.pdb') +PDB_metal = resource_filename(__name__, 'data/metals.pdb') + +ALIGN = resource_filename(__name__, 'data/align.pdb') +RNA_PSF = resource_filename(__name__, 'data/analysis/1k5i_c36.psf.gz') +RNA_PDB = resource_filename(__name__, 'data/analysis/1k5i_c36.pdb.gz') +INC_PDB = resource_filename(__name__, 'data/incomplete.pdb') +PDB_cm = resource_filename(__name__, 'data/cryst_then_model.pdb') +PDB_cm_gz = resource_filename(__name__, 'data/cryst_then_model.pdb.gz') +PDB_cm_bz2 = resource_filename(__name__, 'data/cryst_then_model.pdb.bz2') +PDB_mc = resource_filename(__name__, 'data/model_then_cryst.pdb') +PDB_mc_gz = resource_filename(__name__, 'data/model_then_cryst.pdb.gz') +PDB_mc_bz2 = resource_filename(__name__, 'data/model_then_cryst.pdb.bz2') +PDB_chainidnewres = resource_filename(__name__, 'data/chainIDnewres.pdb.gz') +PDB_sameresid_diffresname = resource_filename(__name__, 'data/sameresid_diffresname.pdb') +PDB_chainidrepeat = resource_filename(__name__, 'data/chainIDrepeat.pdb.gz') +PDB_multiframe = resource_filename(__name__, 'data/nmr_neopetrosiamide.pdb') +PDB_helix = resource_filename(__name__, 'data/A6PA6_alpha.pdb') +PDB_conect = resource_filename(__name__, 'data/conect_parsing.pdb') +PDB_conect2TER = resource_filename(__name__, 'data/CONECT2TER.pdb') +PDB_singleconect = resource_filename(__name__, 'data/SINGLECONECT.pdb') +PDB_icodes = resource_filename(__name__, 'data/1osm.pdb.gz') +PDB_CRYOEM_BOX = resource_filename(__name__, 'data/5a7u.pdb') +PDB_CHECK_RIGHTHAND_PA = resource_filename(__name__, 'data/6msm.pdb.bz2') +FHIAIMS = resource_filename(__name__, 'data/fhiaims.in') + +GRO = resource_filename(__name__, 'data/adk_oplsaa.gro') +GRO_velocity = resource_filename(__name__, 'data/sample_velocity_file.gro') +GRO_incomplete_vels = resource_filename(__name__, 'data/grovels.gro') +GRO_large = resource_filename(__name__, 'data/bigbox.gro.bz2') +GRO_residwrap = resource_filename(__name__, 'data/residwrap.gro') +GRO_residwrap_0base = resource_filename(__name__, 'data/residwrap_0base.gro') +GRO_sameresid_diffresname = resource_filename(__name__, 'data/sameresid_diffresname.gro') +PDB = resource_filename(__name__, 'data/adk_oplsaa.pdb') +XTC = resource_filename(__name__, 'data/adk_oplsaa.xtc') +TRR = resource_filename(__name__, 'data/adk_oplsaa.trr') +TPR = resource_filename(__name__, 'data/adk_oplsaa.tpr') +PDB_sub_dry = resource_filename(__name__, 'data/cobrotoxin_dry_neutral_0.pdb') +TRR_sub_sol = resource_filename(__name__, 'data/cobrotoxin.trr') +XTC_sub_sol = resource_filename(__name__, 'data/cobrotoxin.xtc') +PDB_sub_sol = resource_filename(__name__, 'data/cobrotoxin.pdb') +PDB_xlserial = resource_filename(__name__, 'data/xl_serial.pdb') +GRO_MEMPROT = resource_filename(__name__, 'data/analysis/YiiP_lipids.gro.gz') +XTC_MEMPROT = resource_filename(__name__, 'data/analysis/YiiP_lipids.xtc') XTC_multi_frame = resource_filename( - __name__, "data/xtc_test_only_10_frame_10_atoms.xtc" + __name__, 'data/xtc_test_only_10_frame_10_atoms.xtc' ) TRR_multi_frame = resource_filename( - __name__, "data/trr_test_only_10_frame_10_atoms.trr" + __name__, 'data/trr_test_only_10_frame_10_atoms.trr' ) -PDB_xvf = resource_filename(__name__, "data/cobrotoxin.pdb") -TPR_xvf = resource_filename(__name__, "data/cobrotoxin.tpr") -TRR_xvf = resource_filename(__name__, "data/cobrotoxin.trr") -H5MD_xvf = resource_filename(__name__, "data/cobrotoxin.h5md") -XVG_BZ2 = resource_filename(__name__, "data/cobrotoxin_protein_forces.xvg.bz2") +PDB_xvf = resource_filename(__name__, 'data/cobrotoxin.pdb') +TPR_xvf = resource_filename(__name__, 'data/cobrotoxin.tpr') +TRR_xvf = resource_filename(__name__, 'data/cobrotoxin.trr') +H5MD_xvf = resource_filename(__name__, 'data/cobrotoxin.h5md') +XVG_BZ2 = resource_filename(__name__, 'data/cobrotoxin_protein_forces.xvg.bz2') -XPDB_small = resource_filename(__name__, "data/5digitResid.pdb") +XPDB_small = resource_filename(__name__, 'data/5digitResid.pdb') # number is the gromacs version -TPR400 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.0.tpr") -TPR402 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.0.2.tpr") -TPR403 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.0.3.tpr") -TPR404 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.0.4.tpr") -TPR405 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.0.5.tpr") -TPR406 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.0.6.tpr") -TPR407 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.0.7.tpr") -TPR450 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.5.tpr") -TPR451 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.5.1.tpr") -TPR452 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.5.2.tpr") -TPR453 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.5.3.tpr") -TPR454 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.5.4.tpr") -TPR455 = resource_filename(__name__, "data/tprs/2lyz_gmx_4.5.5.tpr") -TPR502 = resource_filename(__name__, "data/tprs/2lyz_gmx_5.0.2.tpr") -TPR504 = resource_filename(__name__, "data/tprs/2lyz_gmx_5.0.4.tpr") -TPR505 = resource_filename(__name__, "data/tprs/2lyz_gmx_5.0.5.tpr") -TPR510 = resource_filename(__name__, "data/tprs/2lyz_gmx_5.1.tpr") -TPR2016 = resource_filename(__name__, "data/tprs/2lyz_gmx_2016.tpr") -TPR2018 = resource_filename(__name__, "data/tprs/2lyz_gmx_2018.tpr") -TPR2019B3 = resource_filename(__name__, "data/tprs/2lyz_gmx_2019-beta3.tpr") -TPR2020B2 = resource_filename(__name__, "data/tprs/2lyz_gmx_2020-beta2.tpr") -TPR2020 = resource_filename(__name__, "data/tprs/2lyz_gmx_2020.tpr") +TPR400 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.0.tpr') +TPR402 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.0.2.tpr') +TPR403 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.0.3.tpr') +TPR404 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.0.4.tpr') +TPR405 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.0.5.tpr') +TPR406 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.0.6.tpr') +TPR407 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.0.7.tpr') +TPR450 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.5.tpr') +TPR451 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.5.1.tpr') +TPR452 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.5.2.tpr') +TPR453 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.5.3.tpr') +TPR454 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.5.4.tpr') +TPR455 = resource_filename(__name__, 'data/tprs/2lyz_gmx_4.5.5.tpr') +TPR502 = resource_filename(__name__, 'data/tprs/2lyz_gmx_5.0.2.tpr') +TPR504 = resource_filename(__name__, 'data/tprs/2lyz_gmx_5.0.4.tpr') +TPR505 = resource_filename(__name__, 'data/tprs/2lyz_gmx_5.0.5.tpr') +TPR510 = resource_filename(__name__, 'data/tprs/2lyz_gmx_5.1.tpr') +TPR2016 = resource_filename(__name__, 'data/tprs/2lyz_gmx_2016.tpr') +TPR2018 = resource_filename(__name__, 'data/tprs/2lyz_gmx_2018.tpr') +TPR2019B3 = resource_filename(__name__, 'data/tprs/2lyz_gmx_2019-beta3.tpr') +TPR2020B2 = resource_filename(__name__, 'data/tprs/2lyz_gmx_2020-beta2.tpr') +TPR2020 = resource_filename(__name__, 'data/tprs/2lyz_gmx_2020.tpr') # double precision -TPR455Double = resource_filename(__name__, "data/tprs/drew_gmx_4.5.5.double.tpr") -TPR460 = resource_filename(__name__, "data/tprs/ab42_gmx_4.6.tpr") -TPR461 = resource_filename(__name__, "data/tprs/ab42_gmx_4.6.1.tpr") -TPR2020Double = resource_filename(__name__, "data/tprs/2lyz_gmx_2020_double.tpr") +TPR455Double = resource_filename(__name__, 'data/tprs/drew_gmx_4.5.5.double.tpr') +TPR460 = resource_filename(__name__, 'data/tprs/ab42_gmx_4.6.tpr') +TPR461 = resource_filename(__name__, 'data/tprs/ab42_gmx_4.6.1.tpr') +TPR2020Double = resource_filename(__name__, 'data/tprs/2lyz_gmx_2020_double.tpr') # all bonded interactions -TPR334_bonded = resource_filename(__name__, "data/tprs/all_bonded/dummy_3.3.4.tpr") -TPR510_bonded = resource_filename(__name__, "data/tprs/all_bonded/dummy_5.1.tpr") -TPR2016_bonded = resource_filename(__name__, "data/tprs/all_bonded/dummy_2016.tpr") -TPR2018_bonded = resource_filename(__name__, "data/tprs/all_bonded/dummy_2018.tpr") -TPR2019B3_bonded = resource_filename( - __name__, "data/tprs/all_bonded/dummy_2019-beta3.tpr" -) -TPR2020B2_bonded = resource_filename( - __name__, "data/tprs/all_bonded/dummy_2020-beta2.tpr" -) -TPR2020_bonded = resource_filename(__name__, "data/tprs/all_bonded/dummy_2020.tpr") -TPR2020_double_bonded = resource_filename( - __name__, "data/tprs/all_bonded/dummy_2020_double.tpr" -) +TPR334_bonded = resource_filename(__name__, 'data/tprs/all_bonded/dummy_3.3.4.tpr') +TPR510_bonded = resource_filename(__name__, 'data/tprs/all_bonded/dummy_5.1.tpr') +TPR2016_bonded = resource_filename(__name__, 'data/tprs/all_bonded/dummy_2016.tpr') +TPR2018_bonded = resource_filename(__name__, 'data/tprs/all_bonded/dummy_2018.tpr') +TPR2019B3_bonded = resource_filename(__name__, 'data/tprs/all_bonded/dummy_2019-beta3.tpr') +TPR2020B2_bonded = resource_filename(__name__, 'data/tprs/all_bonded/dummy_2020-beta2.tpr') +TPR2020_bonded = resource_filename(__name__, 'data/tprs/all_bonded/dummy_2020.tpr') +TPR2020_double_bonded = resource_filename(__name__, 'data/tprs/all_bonded/dummy_2020_double.tpr') # all interactions -TPR_EXTRA_2020 = resource_filename( - __name__, "data/tprs/virtual_sites/extra-interactions-2020.tpr" -) -TPR_EXTRA_2018 = resource_filename( - __name__, "data/tprs/virtual_sites/extra-interactions-2018.tpr" -) -TPR_EXTRA_2016 = resource_filename( - __name__, "data/tprs/virtual_sites/extra-interactions-2016.3.tpr" -) -TPR_EXTRA_407 = resource_filename( - __name__, "data/tprs/virtual_sites/extra-interactions-4.0.7.tpr" -) +TPR_EXTRA_2020 = resource_filename(__name__, 'data/tprs/virtual_sites/extra-interactions-2020.tpr') +TPR_EXTRA_2018 = resource_filename(__name__, 'data/tprs/virtual_sites/extra-interactions-2018.tpr') +TPR_EXTRA_2016 = resource_filename(__name__, 'data/tprs/virtual_sites/extra-interactions-2016.3.tpr') +TPR_EXTRA_407 = resource_filename(__name__, 'data/tprs/virtual_sites/extra-interactions-4.0.7.tpr') -XYZ_psf = resource_filename(__name__, "data/2r9r-1b.psf") -XYZ_bz2 = resource_filename(__name__, "data/2r9r-1b.xyz.bz2") -XYZ = resource_filename(__name__, "data/2r9r-1b.xyz") -XYZ_mini = resource_filename(__name__, "data/mini.xyz") -XYZ_five = resource_filename(__name__, "data/five.xyz") -TXYZ = resource_filename(__name__, "data/coordinates/test.txyz") -ARC = resource_filename(__name__, "data/coordinates/test.arc") -ARC_PBC = resource_filename(__name__, "data/coordinates/new_hexane.arc") +XYZ_psf = resource_filename(__name__, 'data/2r9r-1b.psf') +XYZ_bz2 = resource_filename(__name__, 'data/2r9r-1b.xyz.bz2') +XYZ = resource_filename(__name__, 'data/2r9r-1b.xyz') +XYZ_mini = resource_filename(__name__, 'data/mini.xyz') +XYZ_five = resource_filename(__name__, 'data/five.xyz') +TXYZ = resource_filename(__name__, 'data/coordinates/test.txyz') +ARC = resource_filename(__name__, 'data/coordinates/test.arc') +ARC_PBC = resource_filename(__name__, 'data/coordinates/new_hexane.arc') -PRM = resource_filename(__name__, "data/Amber/ache.prmtop") -TRJ = resource_filename(__name__, "data/Amber/ache.mdcrd") -INPCRD = resource_filename(__name__, "data/Amber/test.inpcrd") -TRJ_bz2 = resource_filename(__name__, "data/Amber/ache.mdcrd.bz2") -PFncdf_Top = resource_filename(__name__, "data/Amber/posfor.top") -PFncdf_Trj = resource_filename(__name__, "data/Amber/posfor.ncdf") +PRM = resource_filename(__name__, 'data/Amber/ache.prmtop') +TRJ = resource_filename(__name__, 'data/Amber/ache.mdcrd') +INPCRD = resource_filename(__name__, 'data/Amber/test.inpcrd') +TRJ_bz2 = resource_filename(__name__, 'data/Amber/ache.mdcrd.bz2') +PFncdf_Top = resource_filename(__name__, 'data/Amber/posfor.top') +PFncdf_Trj = resource_filename(__name__, 'data/Amber/posfor.ncdf') -PRMpbc = resource_filename(__name__, "data/Amber/capped-ala.prmtop") -TRJpbc_bz2 = resource_filename(__name__, "data/Amber/capped-ala.mdcrd.bz2") +PRMpbc = resource_filename(__name__, 'data/Amber/capped-ala.prmtop') +TRJpbc_bz2 = resource_filename(__name__, 'data/Amber/capped-ala.mdcrd.bz2') -PRMncdf = resource_filename(__name__, "data/Amber/bala.prmtop") -TRJncdf = resource_filename(__name__, "data/Amber/bala.trj") -NCDF = resource_filename(__name__, "data/Amber/bala.ncdf") +PRMncdf = resource_filename(__name__, 'data/Amber/bala.prmtop') +TRJncdf = resource_filename(__name__, 'data/Amber/bala.trj') +NCDF = resource_filename(__name__, 'data/Amber/bala.ncdf') -PRM12 = resource_filename(__name__, "data/Amber/anti.top") -TRJ12_bz2 = resource_filename(__name__, "data/Amber/anti_md1.mdcrd.bz2") +PRM12 = resource_filename(__name__, 'data/Amber/anti.top') +TRJ12_bz2 = resource_filename(__name__, 'data/Amber/anti_md1.mdcrd.bz2') -PRM7 = resource_filename(__name__, "data/Amber/tz2.truncoct.parm7.bz2") -NCDFtruncoct = resource_filename(__name__, "data/Amber/tz2.truncoct.nc") +PRM7 = resource_filename(__name__, 'data/Amber/tz2.truncoct.parm7.bz2') +NCDFtruncoct = resource_filename(__name__, 'data/Amber/tz2.truncoct.nc') -PRMcs = resource_filename(__name__, "data/Amber/chitosan.prmtop") +PRMcs = resource_filename(__name__, 'data/Amber/chitosan.prmtop') -PRMNCRST = resource_filename(__name__, "data/Amber/ace_mbondi3.parm7") +PRMNCRST = resource_filename(__name__, 'data/Amber/ace_mbondi3.parm7') -PRM_NCBOX = resource_filename(__name__, "data/Amber/ace_tip3p.parm7") -TRJ_NCBOX = resource_filename(__name__, "data/Amber/ace_tip3p.nc") +PRM_NCBOX = resource_filename(__name__, 'data/Amber/ace_tip3p.parm7') +TRJ_NCBOX = resource_filename(__name__, 'data/Amber/ace_tip3p.nc') -PRMNEGATIVE = resource_filename(__name__, "data/Amber/ace_mbondi3.negative.parm7") +PRMNEGATIVE = resource_filename(__name__, 'data/Amber/ace_mbondi3.negative.parm7') -PRMErr1 = resource_filename(__name__, "data/Amber/ace_mbondi3.error1.parm7") -PRMErr2 = resource_filename(__name__, "data/Amber/ace_mbondi3.error2.parm7") -PRMErr3 = resource_filename(__name__, "data/Amber/ace_mbondi3.error3.parm7") +PRMErr1 = resource_filename(__name__, 'data/Amber/ace_mbondi3.error1.parm7') +PRMErr2 = resource_filename(__name__, 'data/Amber/ace_mbondi3.error2.parm7') +PRMErr3 = resource_filename(__name__, 'data/Amber/ace_mbondi3.error3.parm7') -PRM_UreyBradley = resource_filename(__name__, "data/Amber/parmed_fad.prmtop") -PRM7_ala2 = resource_filename(__name__, "data/Amber/parmed_ala2_solv.parm7") -RST7_ala2 = resource_filename(__name__, "data/Amber/parmed_ala2_solv.rst7") +PRM_UreyBradley = resource_filename(__name__, 'data/Amber/parmed_fad.prmtop') +PRM7_ala2 = resource_filename(__name__, 'data/Amber/parmed_ala2_solv.parm7') +RST7_ala2 = resource_filename(__name__, 'data/Amber/parmed_ala2_solv.rst7') -PRM19SBOPC = resource_filename(__name__, "data/Amber/ala.ff19SB.OPC.parm7.bz2") +PRM19SBOPC = resource_filename(__name__, 'data/Amber/ala.ff19SB.OPC.parm7.bz2') -PQR = resource_filename(__name__, "data/adk_open.pqr") -PQR_icodes = resource_filename(__name__, "data/1A2C.pqr") +PQR = resource_filename(__name__, 'data/adk_open.pqr') +PQR_icodes = resource_filename(__name__, 'data/1A2C.pqr') -PDBQT_input = resource_filename(__name__, "data/pdbqt_inputpdbqt.pdbqt") -PDBQT_querypdb = resource_filename(__name__, "data/pdbqt_querypdb.pdb") +PDBQT_input = resource_filename(__name__, 'data/pdbqt_inputpdbqt.pdbqt') +PDBQT_querypdb = resource_filename(__name__, 'data/pdbqt_querypdb.pdb') -FASTA = resource_filename(__name__, "data/test.fasta") -HELANAL_BENDING_MATRIX = resource_filename( - __name__, "data/helanal_bending_matrix_AdK_DIMS_H8.dat" -) -HELANAL_BENDING_MATRIX_SUBSET = resource_filename( - __name__, "data/helanal_bending_matrix_AdK_DIMS_H8_frames10to79.dat" -) +FASTA = resource_filename(__name__, 'data/test.fasta') +HELANAL_BENDING_MATRIX = resource_filename(__name__, 'data/helanal_bending_matrix_AdK_DIMS_H8.dat') +HELANAL_BENDING_MATRIX_SUBSET = resource_filename(__name__, 'data/helanal_bending_matrix_AdK_DIMS_H8_frames10to79.dat') -PDB_HOLE = resource_filename(__name__, "data/1grm_single.pdb") -MULTIPDB_HOLE = resource_filename(__name__, "data/1grm_elNemo_mode7.pdb.bz2") +PDB_HOLE = resource_filename(__name__, 'data/1grm_single.pdb') +MULTIPDB_HOLE = resource_filename(__name__, 'data/1grm_elNemo_mode7.pdb.bz2') -DMS = resource_filename(__name__, "data/adk_closed.dms") -DMS_DOMAINS = resource_filename(__name__, "data/adk_closed_domains.dms") -DMS_NO_SEGID = resource_filename(__name__, "data/adk_closed_no_segid.dms") +DMS = resource_filename(__name__, 'data/adk_closed.dms') +DMS_DOMAINS = resource_filename(__name__, 'data/adk_closed_domains.dms') +DMS_NO_SEGID = resource_filename(__name__, 'data/adk_closed_no_segid.dms') -CONECT = resource_filename(__name__, "data/1hvr.pdb") +CONECT = resource_filename(__name__, 'data/1hvr.pdb') -TRZ = resource_filename(__name__, "data/trzfile.trz") -TRZ_psf = resource_filename(__name__, "data/trz_psf.psf") +TRZ = resource_filename(__name__, 'data/trzfile.trz') +TRZ_psf = resource_filename(__name__, 'data/trz_psf.psf') -TRIC = resource_filename(__name__, "data/dppc_vesicle_hg.gro") +TRIC = resource_filename(__name__, 'data/dppc_vesicle_hg.gro') PDB_full = resource_filename(__name__, "data/4E43.pdb") @@ -570,9 +445,7 @@ mol2_molecule = resource_filename(__name__, "data/mol2/Molecule.mol2") mol2_ligand = resource_filename(__name__, "data/mol2/Ligand.mol2") mol2_broken_molecule = resource_filename(__name__, "data/mol2/BrokenMolecule.mol2") -mol2_comments_header = resource_filename( - __name__, "data/mol2/Molecule_comments_header.mol2" -) +mol2_comments_header = resource_filename(__name__, "data/mol2/Molecule_comments_header.mol2") # MOL2 file without substructure field mol2_zinc = resource_filename(__name__, "data/mol2/zinc_856218.mol2") @@ -581,12 +454,8 @@ capping_ace = resource_filename(__name__, "data/capping/ace.pdb") capping_nma = resource_filename(__name__, "data/capping/nma.pdb") -contacts_villin_folded = resource_filename( - __name__, "data/contacts/villin_folded.gro.bz2" -) -contacts_villin_unfolded = resource_filename( - __name__, "data/contacts/villin_unfolded.gro.bz2" -) +contacts_villin_folded = resource_filename(__name__, "data/contacts/villin_folded.gro.bz2") +contacts_villin_unfolded = resource_filename(__name__, "data/contacts/villin_unfolded.gro.bz2") contacts_file = resource_filename(__name__, "data/contacts/2F4K_qlist5_remap.dat") trz4data = resource_filename(__name__, "data/lammps/datatest.trz") @@ -598,19 +467,17 @@ LAMMPScnt2 = resource_filename(__name__, "data/lammps/cnt-hexagonal-class1.data2") LAMMPShyd = resource_filename(__name__, "data/lammps/hydrogen-class1.data") LAMMPShyd2 = resource_filename(__name__, "data/lammps/hydrogen-class1.data2") -LAMMPSdata_deletedatoms = resource_filename(__name__, "data/lammps/deletedatoms.data") +LAMMPSdata_deletedatoms = resource_filename(__name__, 'data/lammps/deletedatoms.data') LAMMPSDUMP = resource_filename(__name__, "data/lammps/wat.lammpstrj.bz2") unordered_res = resource_filename(__name__, "data/unordered_res.pdb") -GMS_ASYMOPT = resource_filename(__name__, "data/gms/c1opt.gms.gz") -GMS_SYMOPT = resource_filename(__name__, "data/gms/symopt.gms") -GMS_ASYMSURF = resource_filename(__name__, "data/gms/surf2wat.gms") +GMS_ASYMOPT = resource_filename(__name__, "data/gms/c1opt.gms.gz") +GMS_SYMOPT = resource_filename(__name__, "data/gms/symopt.gms") +GMS_ASYMSURF = resource_filename(__name__, "data/gms/surf2wat.gms") two_water_gro = resource_filename(__name__, "data/two_water_gro.gro") -two_water_gro_multiframe = resource_filename( - __name__, "data/two_water_gro_multiframe.gro" -) +two_water_gro_multiframe = resource_filename(__name__, "data/two_water_gro_multiframe.gro") two_water_gro_nonames = resource_filename(__name__, "data/two_water_gro_nonames.gro") two_water_gro_widebox = resource_filename(__name__, "data/two_water_gro_widebox.gro") @@ -621,65 +488,62 @@ DLP_HISTORY_order = resource_filename(__name__, "data/dlpoly/HISTORY_order") DLP_HISTORY_minimal = resource_filename(__name__, "data/dlpoly/HISTORY_minimal") -waterPSF = resource_filename(__name__, "data/watdyn.psf") -waterDCD = resource_filename(__name__, "data/watdyn.dcd") +waterPSF = resource_filename(__name__, 'data/watdyn.psf') +waterDCD = resource_filename(__name__, 'data/watdyn.dcd') -rmsfArray = resource_filename(__name__, "data/adk_oplsaa_CA_rmsf.npy") +rmsfArray = resource_filename(__name__, 'data/adk_oplsaa_CA_rmsf.npy') -HoomdXMLdata = resource_filename(__name__, "data/C12x64.xml.bz2") +HoomdXMLdata = resource_filename(__name__, 'data/C12x64.xml.bz2') -Make_Whole = resource_filename(__name__, "data/make_whole.gro") -fullerene = resource_filename(__name__, "data/fullerene.pdb.gz") +Make_Whole = resource_filename(__name__, 'data/make_whole.gro') +fullerene = resource_filename(__name__, 'data/fullerene.pdb.gz') -Plength = resource_filename(__name__, "data/plength.gro") -Martini_membrane_gro = resource_filename(__name__, "data/martini_dppc_chol_bilayer.gro") +Plength = resource_filename(__name__, 'data/plength.gro') +Martini_membrane_gro = resource_filename(__name__, 'data/martini_dppc_chol_bilayer.gro') # Contains one of each residue in 'nucleic' selections -NUCLsel = resource_filename(__name__, "data/nucl_res.pdb") +NUCLsel = resource_filename(__name__, 'data/nucl_res.pdb') -RANDOM_WALK = resource_filename(__name__, "data/xyz_random_walk.xtc") -RANDOM_WALK_TOPO = resource_filename(__name__, "data/RANDOM_WALK_TOPO.pdb") +RANDOM_WALK = resource_filename(__name__, 'data/xyz_random_walk.xtc') +RANDOM_WALK_TOPO = resource_filename(__name__, 'data/RANDOM_WALK_TOPO.pdb') -MMTF = resource_filename(__name__, "data/173D.mmtf") -MMTF_gz = resource_filename(__name__, "data/5KIH.mmtf.gz") -MMTF_skinny = resource_filename(__name__, "data/1ubq-less-optional.mmtf") -MMTF_skinny2 = resource_filename(__name__, "data/3NJW-onlyrequired.mmtf") +MMTF = resource_filename(__name__, 'data/173D.mmtf') +MMTF_gz = resource_filename(__name__, 'data/5KIH.mmtf.gz') +MMTF_skinny = resource_filename(__name__, 'data/1ubq-less-optional.mmtf') +MMTF_skinny2 = resource_filename(__name__, 'data/3NJW-onlyrequired.mmtf') MMTF_NOCRYST = resource_filename(__name__, "data/6QYR.mmtf.gz") -ALIGN_BOUND = resource_filename(__name__, "data/analysis/align_bound.pdb.gz") -ALIGN_UNBOUND = resource_filename(__name__, "data/analysis/align_unbound.pdb.gz") +ALIGN_BOUND = resource_filename(__name__, 'data/analysis/align_bound.pdb.gz') +ALIGN_UNBOUND = resource_filename(__name__, 'data/analysis/align_unbound.pdb.gz') -GSD = resource_filename(__name__, "data/example.gsd") -GSD_bonds = resource_filename(__name__, "data/example_bonds.gsd") -GSD_long = resource_filename(__name__, "data/example_longer.gsd") +GSD = resource_filename(__name__, 'data/example.gsd') +GSD_bonds = resource_filename(__name__, 'data/example_bonds.gsd') +GSD_long = resource_filename(__name__, 'data/example_longer.gsd') -DihedralArray = resource_filename(__name__, "data/adk_oplsaa_dihedral.npy") -DihedralsArray = resource_filename(__name__, "data/adk_oplsaa_dihedral_list.npy") -RamaArray = resource_filename(__name__, "data/adk_oplsaa_rama.npy") -GLYRamaArray = resource_filename(__name__, "data/adk_oplsaa_GLY_rama.npy") -JaninArray = resource_filename(__name__, "data/adk_oplsaa_janin.npy") -LYSJaninArray = resource_filename(__name__, "data/adk_oplsaa_LYS_janin.npy") -PDB_rama = resource_filename(__name__, "data/19hc.pdb.gz") -PDB_janin = resource_filename(__name__, "data/1a28.pdb.gz") +DihedralArray = resource_filename(__name__, 'data/adk_oplsaa_dihedral.npy') +DihedralsArray = resource_filename(__name__, 'data/adk_oplsaa_dihedral_list.npy') +RamaArray = resource_filename(__name__, 'data/adk_oplsaa_rama.npy') +GLYRamaArray = resource_filename(__name__, 'data/adk_oplsaa_GLY_rama.npy') +JaninArray = resource_filename(__name__, 'data/adk_oplsaa_janin.npy') +LYSJaninArray = resource_filename(__name__, 'data/adk_oplsaa_LYS_janin.npy') +PDB_rama = resource_filename(__name__, 'data/19hc.pdb.gz') +PDB_janin = resource_filename(__name__, 'data/1a28.pdb.gz') -BATArray = resource_filename(__name__, "data/mol2_comments_header_bat.npy") +BATArray = resource_filename(__name__, 'data/mol2_comments_header_bat.npy') -ITP = resource_filename(__name__, "data/gromacs_ala10.itp") -ITP_nomass = resource_filename(__name__, "data/itp_nomass.itp") -ITP_edited = resource_filename(__name__, "data/edited_itp.itp") +ITP = resource_filename(__name__, 'data/gromacs_ala10.itp') +ITP_nomass = resource_filename(__name__, 'data/itp_nomass.itp') +ITP_edited = resource_filename(__name__, 'data/edited_itp.itp') ITP_tip5p = resource_filename(__name__, "data/tip5p.itp") -ITP_spce = resource_filename(__name__, "data/spce.itp") -GMX_TOP = resource_filename(__name__, "data/gromacs_ala10.top") -GMX_DIR = resource_filename(__name__, "data/gromacs/") -GMX_TOP_BAD = resource_filename(__name__, "data/bad_top.top") -ITP_no_endif = resource_filename(__name__, "data/no_endif_spc.itp") - -NAMDBIN = resource_filename(__name__, "data/adk_open.coor") - -SDF_molecule = resource_filename(__name__, "data/molecule.sdf") +ITP_spce = resource_filename(__name__, 'data/spce.itp') +GMX_TOP = resource_filename(__name__, 'data/gromacs_ala10.top') +GMX_DIR = resource_filename(__name__, 'data/gromacs/') +GMX_TOP_BAD = resource_filename(__name__, 'data/bad_top.top') +ITP_no_endif = resource_filename(__name__, 'data/no_endif_spc.itp') -PDBX = resource_filename(__name__, "data/4x8u.pdbx") +NAMDBIN = resource_filename(__name__, 'data/adk_open.coor') +SDF_molecule = resource_filename(__name__, 'data/molecule.sdf') # This should be the last line: clean up namespace del resource_filename From 906da5e12552ecdd005185d667fc3c150220da8b Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Tue, 1 Sep 2020 20:51:25 -0400 Subject: [PATCH 25/47] Add pdbx file to datafiles, update changelog --- package/CHANGELOG | 3 ++- testsuite/MDAnalysisTests/datafiles.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/package/CHANGELOG b/package/CHANGELOG index 3cf95e0f949..7a81dea1b72 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -15,7 +15,7 @@ The rules for this file: ------------------------------------------------------------------------------ ??/??/?? tylerjereddy, richardjgowers, IAlibay, hmacdope, orbeckst, cbouy, lilyminium, daveminh, jbarnoud, yuxuanzhuang, VOD555, ianmkenney, - calcraven,xiki-tempula, mieczyslaw + calcraven,xiki-tempula, mieczyslaw, ahy3nz * 2.0.0 @@ -112,6 +112,7 @@ Changes * Removes deprecated waterdynamics.HydrogenBondLifetimes (PR #2842) * Make NeighborSearch return empty atomgroup, residue, segments instead of list (Issue #2892, PR #2907) * Updated Universe creation function signatures to named arguments (Issue #2921) + * Added OpenMM coordinate and topology converters (Issue #2863, PR #2917) Deprecations diff --git a/testsuite/MDAnalysisTests/datafiles.py b/testsuite/MDAnalysisTests/datafiles.py index 898bd05b1ce..e887aff7dc7 100644 --- a/testsuite/MDAnalysisTests/datafiles.py +++ b/testsuite/MDAnalysisTests/datafiles.py @@ -198,6 +198,7 @@ "MMTF_NOCRYST", # File with meaningless CRYST1 record (Issue #2679, PR #2685) "FHIAIMS", # to test FHIAIMS coordinate files "SDF_molecule" # MDL SDFile for rdkit + "PDBX", # PDBxfile ] from pkg_resources import resource_filename @@ -545,5 +546,7 @@ SDF_molecule = resource_filename(__name__, 'data/molecule.sdf') +PDBX = resource_filename(__name__, "data/4x8u.pdbx") + # This should be the last line: clean up namespace del resource_filename From 1bbf543ee3c6e8ec62cab36bf7832b21b7aee578 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Tue, 1 Sep 2020 20:51:44 -0400 Subject: [PATCH 26/47] Update docstring with proper versionadded tag --- package/MDAnalysis/coordinates/OpenMM.py | 6 ++++-- package/MDAnalysis/topology/OpenMMParser.py | 4 +--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index 53ef572494a..df0f7644d5b 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -24,6 +24,7 @@ """OpenMM structure I/O --- :mod:`MDAnalysis.coordinates.OpenMM` ================================================================ + Read coordinates data from a `OpenMM `_ :class:`simtk.openmm.app.simulation.Simulation` with :class:`OpenMMReader` @@ -58,6 +59,8 @@ class OpenMMSimulationReader(base.SingleFrameReaderBase): """Reader for OpenMM Simulation objects + + .. versionadded:: 2.0.0 """ format = "OPENMMSIMULATION" @@ -67,7 +70,6 @@ class OpenMMSimulationReader(base.SingleFrameReaderBase): @staticmethod def _format_hint(thing): """Can this reader read *thing*? - .. versionadded:: 1.0.0 """ try: from simtk.openmm.app import Simulation @@ -115,6 +117,7 @@ def _mda_timestep_from_omm_context(self): class OpenMMAppReader(base.SingleFrameReaderBase): """Reader for OpenMM App objects + .. versionadded:: 2.0.0 """ format = "OPENMMAPP" @@ -123,7 +126,6 @@ class OpenMMAppReader(base.SingleFrameReaderBase): @staticmethod def _format_hint(thing): """Can this reader read *thing*? - .. versionadded:: 1.0.0 """ try: from simtk.openmm import app diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py index 3eb3f3f7228..deb96d1d72a 100644 --- a/package/MDAnalysis/topology/OpenMMParser.py +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -24,7 +24,7 @@ """OpenMM topology parser ========================= -.. versionadded:: 0.17.0 +.. versionadded:: 2.0.0 Converts an @@ -85,7 +85,6 @@ class OpenMMTopologyParser(TopologyReaderBase): def _format_hint(thing): """Can this Parser read object *thing*? - .. versionadded:: 1.0.0 """ try: from simtk.openmm import app @@ -168,7 +167,6 @@ class OpenMMAppTopologyParser(OpenMMTopologyParser): def _format_hint(thing): """Can this Parser read object *thing*? - .. versionadded:: 1.0.0 """ try: from simtk.openmm import app From 6c7756fa65be22447392d1bc1e8f64b5b3f3e213 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Wed, 2 Sep 2020 08:07:12 -0400 Subject: [PATCH 27/47] Missing comma in list --- testsuite/MDAnalysisTests/datafiles.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/MDAnalysisTests/datafiles.py b/testsuite/MDAnalysisTests/datafiles.py index e887aff7dc7..d42179453f8 100644 --- a/testsuite/MDAnalysisTests/datafiles.py +++ b/testsuite/MDAnalysisTests/datafiles.py @@ -197,7 +197,7 @@ "PDB_CHECK_RIGHTHAND_PA", # for testing right handedness of principal_axes "MMTF_NOCRYST", # File with meaningless CRYST1 record (Issue #2679, PR #2685) "FHIAIMS", # to test FHIAIMS coordinate files - "SDF_molecule" # MDL SDFile for rdkit + "SDF_molecule", # MDL SDFile for rdkit "PDBX", # PDBxfile ] From 170304d8eca319e7affeb7c45eabe579b1f7f864 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Wed, 2 Sep 2020 17:49:28 -0400 Subject: [PATCH 28/47] Add pytest importorskip for testing openmm topology c onversion --- testsuite/MDAnalysisTests/topology/test_openmm.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/testsuite/MDAnalysisTests/topology/test_openmm.py b/testsuite/MDAnalysisTests/topology/test_openmm.py index aa0502326cc..0bea9f55112 100644 --- a/testsuite/MDAnalysisTests/topology/test_openmm.py +++ b/testsuite/MDAnalysisTests/topology/test_openmm.py @@ -22,7 +22,6 @@ # import pytest import numpy as np -from simtk.openmm import app import MDAnalysis as mda @@ -30,6 +29,8 @@ from MDAnalysisTests.datafiles import CONECT, PDBX +app = pytest.importorskip('simtk.openmm.app') + class OpenMMTopologyBase(ParserBase): parser = mda.topology.OpenMMParser.OpenMMTopologyParser expected_attrs = [ From 7d117d0ffda9993c289fab6591b19c65ede5d584 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Sat, 19 Sep 2020 14:24:08 -0400 Subject: [PATCH 29/47] Merge conflict --- package/CHANGELOG | 1 - 1 file changed, 1 deletion(-) diff --git a/package/CHANGELOG b/package/CHANGELOG index 3ec96bc127f..1b6bb516a96 100644 --- a/package/CHANGELOG +++ b/package/CHANGELOG @@ -111,7 +111,6 @@ Changes * Sets the minimal RDKit version for CI to 2020.03.1 (Issue #2827, PR #2831) * Removes deprecated waterdynamics.HydrogenBondLifetimes (PR #2842) * Make NeighborSearch return empty atomgroup, residue, segments instead of list (Issue #2892, PR #2907) - * Updated Universe creation function signatures to named arguments (Issue #2921) * Updated Universe creation function signatures to named arguments (Issue #2921) * The transformation was changed from a function/closure to a class with `__call__` (Issue #2860, PR #2859) From 6a4229cc31b515666ffc283eba09324bfcf8ba6d Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Tue, 6 Oct 2020 20:49:46 -0400 Subject: [PATCH 30/47] Remove unnecessary imports, more documentation for openmm application layer objects, additional openmm test from a basic openmm simulation made from scratch --- package/MDAnalysis/coordinates/OpenMM.py | 4 +- package/MDAnalysis/topology/OpenMMParser.py | 9 ++-- .../coordinates/test_openmm.py | 45 ++++++++++++++++++- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index df0f7644d5b..264d80d2be8 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -115,7 +115,9 @@ def _mda_timestep_from_omm_context(self): class OpenMMAppReader(base.SingleFrameReaderBase): - """Reader for OpenMM App objects + """Reader for OpenMM Application layer objects + + See also `OpenMM Application layer `_ .. versionadded:: 2.0.0 """ diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py index deb96d1d72a..4bd5033993e 100644 --- a/package/MDAnalysis/topology/OpenMMParser.py +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -39,7 +39,7 @@ - `simtk.openmm.app.modeller.Modeller `_ - `simtk.openmm.app.pdbxfile.PDBxFile `_ -The :class:`OpenMMTopologyParser` generates a topology from an OpenMM Topology object files. +The :class:`OpenMMTopologyParser` generates a topology from an OpenMM Topology object. .. _OpenMM: http://docs.openmm.org/latest/api-python/app.html @@ -112,7 +112,7 @@ def _mda_topology_from_omm_topology(self, omm_topology): residue_segindex = [r.chain.index for r in omm_topology.residues()] atomids = [a.id for a in omm_topology.atoms()] atomnames = [a.name for a in omm_topology.atoms()] - atomtypes = guess_types(atomnames) + #atomtypes = guess_types(atomnames) chainids = [a.residue.chain.id for a in omm_topology.atoms()] elements = [a.element.symbol for a in omm_topology.atoms()] masses = [a.element.mass._value for a in omm_topology.atoms()] @@ -131,7 +131,7 @@ def _mda_topology_from_omm_topology(self, omm_topology): attrs = [ Atomids(np.array(atomids, dtype=np.int32)), Atomnames(np.array(atomnames, dtype=object)), - Atomtypes(np.array(atomtypes, dtype=object)), + #Atomtypes(np.array(atomtypes, dtype=object)), Bonds(bonds, types=bond_types, order=bond_orders, guessed=False), ChainIDs(np.array(chainids, dtype=object)), Elements(np.array(elements, dtype=object)), @@ -155,7 +155,6 @@ def _mda_topology_from_omm_topology(self, omm_topology): def parse(self, **kwargs): omm_topology = self.filename - top = self._mda_topology_from_omm_topology(omm_topology) return top @@ -181,8 +180,6 @@ def parse(self, **kwargs): omm_topology = self.filename.getTopology() except AttributeError: omm_topology = self.filename.topology - - top = self._mda_topology_from_omm_topology(omm_topology) return top diff --git a/testsuite/MDAnalysisTests/coordinates/test_openmm.py b/testsuite/MDAnalysisTests/coordinates/test_openmm.py index 8c124e58c9c..d218883fc37 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_openmm.py +++ b/testsuite/MDAnalysisTests/coordinates/test_openmm.py @@ -34,7 +34,50 @@ mm = pytest.importorskip("simtk.openmm") unit = pytest.importorskip("simtk.unit") app = pytest.importorskip("simtk.openmm.app") -pmd = pytest.importorskip("parmed") + +class TestOpenMMBasicSimulationReader(): + @pytest.fixture + def omm_sim_uni(self): + system = mm.System() + topology = app.Topology() + chain = topology.addChain("CHAIN") + hydrogen = app.element.Element.getByAtomicNumber(1) + residue = topology.addResidue("RES", chain) + for i in range(5): + system.addParticle(1.0) + topology.addAtom(i, hydrogen, residue) + positions = np.ones((5,3)) * unit.angstrom + integrator = mm.LangevinIntegrator(273 * unit.kelvin, + 1.0 / unit.picoseconds, 2.0 * unit.femtoseconds) + simulation = app.Simulation(topology, system, integrator) + simulation.context.setPositions(positions) + + return mda.Universe(simulation) + + + def test_dimensions(self, omm_sim_uni): + assert_almost_equal( + omm_sim_uni.trajectory.ts.dimensions, + np.array([20., 20., 20., 90., 90., 90.]), + 3, + "OpenMMBasicSimulationReader failed to get unitcell dimensions " + + "from OpenMM Simulation Object", + ) + + def test_coordinates(self, omm_sim_uni): + up = omm_sim_uni.atoms.positions + reference = np.ones((5,3)) + assert_almost_equal(up, reference, decimal=3) + + def test_basic_topology(self, omm_sim_uni): + assert omm_sim_uni.atoms.n_atoms == 5 + assert omm_sim_uni.residues.n_residues == 1 + assert omm_sim_uni.residues.resnames[0] == "RES" + assert omm_sim_uni.segments.n_segments == 1 + assert omm_sim_uni.segments.segids[0] == 0 + assert len(omm_sim_uni.bonds.indices) == 0 + + class TestOpenMMPDBFileReader(_SingleFrameReader): From 1b4d0c2d2cd6e32d9f4ec7d0c2f16a177ab4a283 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Tue, 6 Oct 2020 21:05:41 -0400 Subject: [PATCH 31/47] Example usage in documentation --- package/MDAnalysis/coordinates/OpenMM.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index 264d80d2be8..acd32edcbc7 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -37,6 +37,19 @@ - `simtk.openmm.app.modeller.Modeller `_ - `simtk.openmm.app.pdbxfile.PDBxFile `_ +Example +------- +OpenMM can read various file formats into OpenMM objects. +MDAnalysis can then convert some of these OpenMM objects into MDAnalysis Universe objects. + + >>> import simtk.openmm.app as app + >>> import MDAnalysis as mda + >>> from MDAnalysis.tests.datafiles import PDBX + >>> pdbxfile = app.PDBxFile(PDBX) + >>> mda.Universe(pdbxfile) + + + Classes ------- From 1d085a82e1babc950100f86d182f61ec8063b6ae Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Tue, 6 Oct 2020 21:24:41 -0400 Subject: [PATCH 32/47] Convert simtk quanitties into default internal units --- package/MDAnalysis/coordinates/OpenMM.py | 35 ++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index acd32edcbc7..e1b6cb34878 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -67,6 +67,7 @@ import numpy as np from . import base +from .. import units class OpenMMSimulationReader(base.SingleFrameReaderBase): @@ -78,7 +79,7 @@ class OpenMMSimulationReader(base.SingleFrameReaderBase): format = "OPENMMSIMULATION" units = {"time": "ps", "length": "nm", "velocity": "nm/ps", - "force": "kJ/(mol*nm)"} + "force": "kJ/(mol*nm)", "energy": "kJ/mol"} @staticmethod def _format_hint(thing): @@ -116,8 +117,10 @@ def _mda_timestep_from_omm_context(self): ts = self._Timestep(n_atoms, **self._ts_kwargs) ts.frame = 0 ts.data["time"] = state.getTime()._value - ts.data["potential_energy"] = state.getPotentialEnergy() - ts.data["kinetic_energy"] = state.getKineticEnergy() + ts.data["potential_energy"] = self.convert_energies_from_native( + state.getPotentialEnergy()._value) + ts.data["kinetic_energy"] = self.convert_energies_from_native( + state.getKineticEnergy()._value) ts.triclinic_dimensions = state.getPeriodicBoxVectors( asNumpy=True)._value ts.positions = state.getPositions(asNumpy=True)._value @@ -126,6 +129,32 @@ def _mda_timestep_from_omm_context(self): return ts + def convert_energies_from_native(self, energy, inplace=True): + """Conversion of energies array *energy* from native to base units + + Parameters + ---------- + energy: array_like + energies to transform + inplace : bool (optional) + Whether to modify the array inplace, overwriting previous data + + Note + ---- + By default, the input *energy* is modified in place and also returned. + In-place operations improve performance because allocating new arrays + is avoided. + + """ + f = units.get_conversion_factor( + 'energy', self.units['energy'], 'kJ/mol') + if f == 1.: + return energy + if not inplace: + return f * energy + energy *= f + return energy + class OpenMMAppReader(base.SingleFrameReaderBase): """Reader for OpenMM Application layer objects From 3349ab53a63a06fb4a58abfa36a63b8626624ba5 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Tue, 3 Nov 2020 21:33:15 -0500 Subject: [PATCH 33/47] Update travis with extra variables for openmm, installing only on py37 tests --- .travis.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8bc71d05333..4e377ab8fb3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,8 @@ env: - SETUP_CMD="${PYTEST_FLAGS}" - BUILD_CMD="pip install -e package/ && (cd testsuite/ && python setup.py build)" - CONDA_MIN_DEPENDENCIES="mmtf-python biopython networkx cython matplotlib scipy griddataformats hypothesis gsd codecov" - - CONDA_DEPENDENCIES="${CONDA_MIN_DEPENDENCIES} seaborn>=0.7.0 clustalw=2.1 netcdf4 scikit-learn joblib>=0.12 chemfiles tqdm>=4.43.0 tidynamics>=1.0.0 rdkit>=2020.03.1 h5py openmm" + - CONDA_OPENMM="" + - CONDA_DEPENDENCIES="${CONDA_MIN_DEPENDENCIES} ${CONDA_OPENMM} seaborn>=0.7.0 clustalw=2.1 netcdf4 scikit-learn joblib>=0.12 chemfiles tqdm>=4.43.0 tidynamics>=1.0.0 rdkit>=2020.03.1 h5py" - CONDA_CHANNELS='biobuilds conda-forge omnia' - CONDA_CHANNEL_PRIORITY=True - PIP_DEPENDENCIES="duecredit parmed" @@ -43,8 +44,8 @@ env: matrix: # Run a coverage test for most versions - CODECOV="true" SETUP_CMD="${PYTEST_FLAGS} --cov=MDAnalysis" - - PYTHON_VERSION=3.8 CODECOV="true" SETUP_CMD="${PYTEST_FLAGS} --cov=MDAnalysis" - - PYTHON_VERSION=3.7 CODECOV="true" SETUP_CMD="${PYTEST_FLAGS} --cov=MDAnalysis" + - PYTHON_VERSION=3.8 CODECOV="true" SETUP_CMD="${PYTEST_FLAGS} --cov=MDAnalysis" CONDA_OPENMM="" + - PYTHON_VERSION=3.7 CODECOV="true" SETUP_CMD="${PYTEST_FLAGS} --cov=MDAnalysis" CONDA_OPENMM="openmm" - NUMPY_VERSION=1.16.0 - NUMPY_VERSION=dev EVENT_TYPE="cron" From eec5d9ddf725bfebf14f6cccb60309b781888475 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Tue, 3 Nov 2020 22:28:48 -0500 Subject: [PATCH 34/47] Revert back to atomtype guessing --- package/MDAnalysis/topology/OpenMMParser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py index 4bd5033993e..a41711a3905 100644 --- a/package/MDAnalysis/topology/OpenMMParser.py +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -112,7 +112,7 @@ def _mda_topology_from_omm_topology(self, omm_topology): residue_segindex = [r.chain.index for r in omm_topology.residues()] atomids = [a.id for a in omm_topology.atoms()] atomnames = [a.name for a in omm_topology.atoms()] - #atomtypes = guess_types(atomnames) + atomtypes = guess_types(atomnames) chainids = [a.residue.chain.id for a in omm_topology.atoms()] elements = [a.element.symbol for a in omm_topology.atoms()] masses = [a.element.mass._value for a in omm_topology.atoms()] @@ -131,7 +131,7 @@ def _mda_topology_from_omm_topology(self, omm_topology): attrs = [ Atomids(np.array(atomids, dtype=np.int32)), Atomnames(np.array(atomnames, dtype=object)), - #Atomtypes(np.array(atomtypes, dtype=object)), + Atomtypes(np.array(atomtypes, dtype=object)), Bonds(bonds, types=bond_types, order=bond_orders, guessed=False), ChainIDs(np.array(chainids, dtype=object)), Elements(np.array(elements, dtype=object)), From 76c905396e261854204ffcc79bd790c744d3ab4d Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Wed, 4 Nov 2020 18:14:23 -0500 Subject: [PATCH 35/47] Use proper openmm atom naming conventions for unit test --- testsuite/MDAnalysisTests/coordinates/test_openmm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testsuite/MDAnalysisTests/coordinates/test_openmm.py b/testsuite/MDAnalysisTests/coordinates/test_openmm.py index d218883fc37..36a86eba2d4 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_openmm.py +++ b/testsuite/MDAnalysisTests/coordinates/test_openmm.py @@ -45,7 +45,7 @@ def omm_sim_uni(self): residue = topology.addResidue("RES", chain) for i in range(5): system.addParticle(1.0) - topology.addAtom(i, hydrogen, residue) + topology.addAtom(hydrogen.symbol, hydrogen, residue) positions = np.ones((5,3)) * unit.angstrom integrator = mm.LangevinIntegrator(273 * unit.kelvin, 1.0 / unit.picoseconds, 2.0 * unit.femtoseconds) From a255dc0f94f1345cc780aa3965bb988d4b113883 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Wed, 4 Nov 2020 20:52:44 -0500 Subject: [PATCH 36/47] Modify appveyor config to specify openmm on py36 vs py38 --- .appveyor.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index c751ca1dcbc..499a83f615c 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -10,7 +10,8 @@ cache: environment: global: CONDA_CHANNELS: conda-forge omnia - CONDA_DEPENDENCIES: pip setuptools wheel cython biopython networkx joblib matplotlib scipy vs2015_runtime pytest mmtf-python GridDataFormats hypothesis pytest-cov codecov chemfiles tqdm tidynamics>=1.0.0 rdkit>=2020.03.1 h5py openmm + CONDA_DEPENDENCIES: pip setuptools wheel cython biopython networkx joblib matplotlib scipy vs2015_runtime pytest mmtf-python GridDataFormats hypothesis pytest-cov codecov chemfiles tqdm tidynamics>=1.0.0 rdkit>=2020.03.1 h5py ${env:CONDA_OPENMM} + CONDA_OPENMM: "" PIP_DEPENDENCIES: gsd==1.9.3 duecredit parmed DEBUG: "False" MINGW_64: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin @@ -27,10 +28,12 @@ environment: - PYTHON_VERSION: 3.6 PYTHON_ARCH: 64 MSVC_VERSION: "Visual Studio 10 Win64" + CONDA_OPENMM: "openmm" - PYTHON_VERSION: 3.8 PYTHON_ARCH: 64 MSVC_VERSION: "Visual Studio 10 Win64" + CONDA_OPENMM: "" init: - ps: Write-Host ${env:PYTHON} ${env:PYTHON_VERSION} ${env:PYTHON_ARCH} From cd637db3156d82f69692097c1857bfc4f9901cb4 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Wed, 4 Nov 2020 21:02:03 -0500 Subject: [PATCH 37/47] Correct syntax for appveyor env vars --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 499a83f615c..033a7f88aa1 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -10,7 +10,7 @@ cache: environment: global: CONDA_CHANNELS: conda-forge omnia - CONDA_DEPENDENCIES: pip setuptools wheel cython biopython networkx joblib matplotlib scipy vs2015_runtime pytest mmtf-python GridDataFormats hypothesis pytest-cov codecov chemfiles tqdm tidynamics>=1.0.0 rdkit>=2020.03.1 h5py ${env:CONDA_OPENMM} + CONDA_DEPENDENCIES: pip setuptools wheel cython biopython networkx joblib matplotlib scipy vs2015_runtime pytest mmtf-python GridDataFormats hypothesis pytest-cov codecov chemfiles tqdm tidynamics>=1.0.0 rdkit>=2020.03.1 h5py $env:CONDA_OPENMM CONDA_OPENMM: "" PIP_DEPENDENCIES: gsd==1.9.3 duecredit parmed DEBUG: "False" From 292a52ec3c7cd1f5a2b242a4cde3b54865e66bb5 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Wed, 4 Nov 2020 21:27:00 -0500 Subject: [PATCH 38/47] Change appveyor var syntax --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 033a7f88aa1..1ed19876ba0 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -10,7 +10,7 @@ cache: environment: global: CONDA_CHANNELS: conda-forge omnia - CONDA_DEPENDENCIES: pip setuptools wheel cython biopython networkx joblib matplotlib scipy vs2015_runtime pytest mmtf-python GridDataFormats hypothesis pytest-cov codecov chemfiles tqdm tidynamics>=1.0.0 rdkit>=2020.03.1 h5py $env:CONDA_OPENMM + CONDA_DEPENDENCIES: pip setuptools wheel cython biopython networkx joblib matplotlib scipy vs2015_runtime pytest mmtf-python GridDataFormats hypothesis pytest-cov codecov chemfiles tqdm tidynamics>=1.0.0 rdkit>=2020.03.1 h5py $(CONDA_OPENMM) CONDA_OPENMM: "" PIP_DEPENDENCIES: gsd==1.9.3 duecredit parmed DEBUG: "False" From 3c2322d8fb0d0fa86f10b1a1d680e4615605e1b1 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Wed, 4 Nov 2020 22:00:33 -0500 Subject: [PATCH 39/47] Empty string for conda openmm var --- .appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.appveyor.yml b/.appveyor.yml index 1ed19876ba0..d5942493e72 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -33,7 +33,7 @@ environment: - PYTHON_VERSION: 3.8 PYTHON_ARCH: 64 MSVC_VERSION: "Visual Studio 10 Win64" - CONDA_OPENMM: "" + CONDA_OPENMM: " " init: - ps: Write-Host ${env:PYTHON} ${env:PYTHON_VERSION} ${env:PYTHON_ARCH} From a48b7ba27a20febe6646d7cb66f476cca50fc48d Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Fri, 11 Dec 2020 17:50:32 -0500 Subject: [PATCH 40/47] Merge conflict --- testsuite/MDAnalysisTests/datafiles.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/testsuite/MDAnalysisTests/datafiles.py b/testsuite/MDAnalysisTests/datafiles.py index 0fc9ee60b49..e3f7d91ecb7 100644 --- a/testsuite/MDAnalysisTests/datafiles.py +++ b/testsuite/MDAnalysisTests/datafiles.py @@ -197,13 +197,9 @@ "PDB_CHECK_RIGHTHAND_PA", # for testing right handedness of principal_axes "MMTF_NOCRYST", # File with meaningless CRYST1 record (Issue #2679, PR #2685) "FHIAIMS", # to test FHIAIMS coordinate files -<<<<<<< HEAD "SDF_molecule", # MDL SDFile for rdkit "PDBX", # PDBxfile -======= - "SDF_molecule", # MDL SDFile for rdkit "PDB_elements", # PDB file with elements ->>>>>>> origin/develop ] from pkg_resources import resource_filename From 85d1352e146f86a7f551853fe2d95b0903553302 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Fri, 11 Dec 2020 17:52:36 -0500 Subject: [PATCH 41/47] Update GHA conda min dependencies for openmm on conda-forge --- .github/workflows/gh-ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/gh-ci.yaml b/.github/workflows/gh-ci.yaml index 679dd97ec5f..88f1712341a 100644 --- a/.github/workflows/gh-ci.yaml +++ b/.github/workflows/gh-ci.yaml @@ -14,7 +14,7 @@ defaults: shell: bash -l {0} env: - MDA_CONDA_MIN_DEPS: "pip pytest mmtf-python biopython networkx cython matplotlib scipy griddataformats hypothesis gsd codecov" + MDA_CONDA_MIN_DEPS: "pip pytest mmtf-python biopython networkx cython matplotlib scipy griddataformats hypothesis gsd codecov openmm" MDA_CONDA_EXTRA_DEPS: "seaborn>=0.7.0 clustalw=2.1 netcdf4 scikit-learn joblib>=0.12 chemfiles tqdm>=4.43.0 tidynamics>=1.0.0 rdkit>=2020.03.1 h5py==2.10.0" MDA_PIP_MIN_DEPS: 'coveralls coverage<5 pytest-cov pytest-xdist' MDA_PIP_EXTRA_DEPS: 'duecredit parmed' From c682a07e7b279903045363834c84a1bfa8bc253f Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Fri, 11 Dec 2020 21:07:34 -0500 Subject: [PATCH 42/47] Remove inplace flag for converting energies, not used anywhere in openmm conversions --- package/MDAnalysis/coordinates/OpenMM.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index e1b6cb34878..b2fee4f9a7b 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -129,29 +129,19 @@ def _mda_timestep_from_omm_context(self): return ts - def convert_energies_from_native(self, energy, inplace=True): + def convert_energies_from_native(self, energy): """Conversion of energies array *energy* from native to base units Parameters ---------- energy: array_like energies to transform - inplace : bool (optional) - Whether to modify the array inplace, overwriting previous data - - Note - ---- - By default, the input *energy* is modified in place and also returned. - In-place operations improve performance because allocating new arrays - is avoided. """ f = units.get_conversion_factor( 'energy', self.units['energy'], 'kJ/mol') if f == 1.: return energy - if not inplace: - return f * energy energy *= f return energy From e1bc710e27bfd40490212ec55dbb1a48e4879d16 Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Fri, 11 Dec 2020 22:03:45 -0500 Subject: [PATCH 43/47] Update appveyor to pull openmm from conda-forge --- .appveyor.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 44890b506b3..ab425e2a427 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -9,9 +9,8 @@ cache: environment: global: - CONDA_CHANNELS: conda-forge omnia - CONDA_DEPENDENCIES: pip setuptools wheel cython biopython networkx joblib matplotlib scipy vs2015_runtime pytest mmtf-python GridDataFormats hypothesis pytest-cov codecov chemfiles tqdm tidynamics>=1.0.0 rdkit>=2020.03.1 h5py==2.10.0 $(CONDA_OPENMM) - CONDA_OPENMM: "" + CONDA_CHANNELS: conda-forge + CONDA_DEPENDENCIES: pip setuptools wheel cython biopython networkx joblib matplotlib scipy vs2015_runtime pytest mmtf-python GridDataFormats hypothesis pytest-cov codecov chemfiles tqdm tidynamics>=1.0.0 rdkit>=2020.03.1 h5py==2.10.0 openmm PIP_DEPENDENCIES: gsd==1.9.3 duecredit parmed DEBUG: "False" MINGW_64: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin @@ -28,12 +27,10 @@ environment: - PYTHON_VERSION: 3.6 PYTHON_ARCH: 64 MSVC_VERSION: "Visual Studio 10 Win64" - CONDA_OPENMM: "openmm" - PYTHON_VERSION: 3.8 PYTHON_ARCH: 64 MSVC_VERSION: "Visual Studio 10 Win64" - CONDA_OPENMM: " " init: - ps: Write-Host ${env:PYTHON} ${env:PYTHON_VERSION} ${env:PYTHON_ARCH} From 37f1a565080c02287097364e53e9ec0e309ddaaf Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Fri, 23 Apr 2021 22:15:32 -0400 Subject: [PATCH 44/47] Use simtk syntax for unit conversions --- package/MDAnalysis/coordinates/OpenMM.py | 31 +++++++----------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index b2fee4f9a7b..481d47bb461 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -107,7 +107,8 @@ def _read_first_frame(self): self.convert_time_from_native(self.ts.dt) def _mda_timestep_from_omm_context(self): - """ Construct Timestep object from Openmm context """ + """ Construct Timestep object from OpenMM context """ + import simtk.unit as u state = self.filename.context.getState(-1, getVelocities=True, getForces=True, getEnergy=True) @@ -117,10 +118,12 @@ def _mda_timestep_from_omm_context(self): ts = self._Timestep(n_atoms, **self._ts_kwargs) ts.frame = 0 ts.data["time"] = state.getTime()._value - ts.data["potential_energy"] = self.convert_energies_from_native( - state.getPotentialEnergy()._value) - ts.data["kinetic_energy"] = self.convert_energies_from_native( - state.getKineticEnergy()._value) + ts.data["potential_energy"] = ( + state.getPotentialEnergy().in_units_of(u.kilojoule/u.mole) + ) + ts.data["kinetic_energy"] = ( + state.getKineticEnergy().in_units_of(u.kilojoule/u.mole) + ) ts.triclinic_dimensions = state.getPeriodicBoxVectors( asNumpy=True)._value ts.positions = state.getPositions(asNumpy=True)._value @@ -129,22 +132,6 @@ def _mda_timestep_from_omm_context(self): return ts - def convert_energies_from_native(self, energy): - """Conversion of energies array *energy* from native to base units - - Parameters - ---------- - energy: array_like - energies to transform - - """ - f = units.get_conversion_factor( - 'energy', self.units['energy'], 'kJ/mol') - if f == 1.: - return energy - energy *= f - return energy - class OpenMMAppReader(base.SingleFrameReaderBase): """Reader for OpenMM Application layer objects @@ -181,7 +168,7 @@ def _read_first_frame(self): ) def _mda_timestep_from_omm_app(self): - """ Construct Timestep object from Openmm Application object """ + """ Construct Timestep object from OpenMM Application object """ omm_object = self.filename n_atoms = omm_object.topology.getNumAtoms() From a8c40afe0e13aff1c7c3630f5a34af47b09c456d Mon Sep 17 00:00:00 2001 From: Alex Yang Date: Mon, 26 Apr 2021 22:42:25 -0400 Subject: [PATCH 45/47] - Sanitize box angles when converting from OpenMM unitcell to MDA unitcell - Add xfail to pickle single frame reader for openmm tests - Use elements to specify atomtypes from OpenMM topology --- package/MDAnalysis/coordinates/OpenMM.py | 11 ++++++++++ package/MDAnalysis/topology/OpenMMParser.py | 2 +- .../coordinates/test_openmm.py | 21 ++++++++++--------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index 481d47bb461..95bdc35778a 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -102,6 +102,7 @@ def _read_first_frame(self): self.ts.triclinic_dimensions = self.convert_pos_from_native( self.ts.triclinic_dimensions, inplace=False ) + self.ts.dimensions[3:] = _sanitize_box_angles(self.ts.dimensions[3:]) self.convert_velocities_from_native(self.ts._velocities) self.convert_forces_from_native(self.ts._forces) self.convert_time_from_native(self.ts.dt) @@ -126,6 +127,7 @@ def _mda_timestep_from_omm_context(self): ) ts.triclinic_dimensions = state.getPeriodicBoxVectors( asNumpy=True)._value + ts.dimensions[3:] = _sanitize_box_angles(ts.dimensions[3:]) ts.positions = state.getPositions(asNumpy=True)._value ts.velocities = state.getVelocities(asNumpy=True)._value ts.forces = state.getForces(asNumpy=True)._value @@ -166,6 +168,7 @@ def _read_first_frame(self): self.ts.triclinic_dimensions = self.convert_pos_from_native( self.ts.triclinic_dimensions, inplace=False ) + self.ts.dimensions[3:] = _sanitize_box_angles(self.ts.dimensions[3:]) def _mda_timestep_from_omm_app(self): """ Construct Timestep object from OpenMM Application object """ @@ -179,8 +182,16 @@ def _mda_timestep_from_omm_app(self): ts.triclinic_dimensions = np.array( omm_object.topology.getPeriodicBoxVectors()._value ) + ts.dimensions[3:] = _sanitize_box_angles(ts.dimensions[3:]) ts.positions = np.array(omm_object.getPositions()._value) return ts +def _sanitize_box_angles(angles): + """ Ensure box angles correspond to first quadrant + See `discussion on unitcell angles `_ + """ + inverted = 180 - angles + + return np.min(np.array([angles, inverted]), axis=0) diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py index a41711a3905..f7719bee452 100644 --- a/package/MDAnalysis/topology/OpenMMParser.py +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -112,9 +112,9 @@ def _mda_topology_from_omm_topology(self, omm_topology): residue_segindex = [r.chain.index for r in omm_topology.residues()] atomids = [a.id for a in omm_topology.atoms()] atomnames = [a.name for a in omm_topology.atoms()] - atomtypes = guess_types(atomnames) chainids = [a.residue.chain.id for a in omm_topology.atoms()] elements = [a.element.symbol for a in omm_topology.atoms()] + atomtypes = [a.element.symbol for a in omm_topology.atoms()] masses = [a.element.mass._value for a in omm_topology.atoms()] resnames = [r.name for r in omm_topology.residues()] resids = [r.index + 1 for r in omm_topology.residues()] diff --git a/testsuite/MDAnalysisTests/coordinates/test_openmm.py b/testsuite/MDAnalysisTests/coordinates/test_openmm.py index 36a86eba2d4..adcf6d93336 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_openmm.py +++ b/testsuite/MDAnalysisTests/coordinates/test_openmm.py @@ -90,9 +90,8 @@ def setUp(self): def test_dimensions(self): assert_almost_equal( - # Angles seem to parse differently when openmm reads the pdb file - self.universe.trajectory.ts.dimensions[0:3], - self.ref.trajectory.ts.dimensions[0:3], + self.universe.trajectory.ts.dimensions, + self.ref.trajectory.ts.dimensions, self.prec, "OpenMMPDBFileReader failed to get unitcell dimensions " + "from OpenMMPDBFile", @@ -116,9 +115,8 @@ def setUp(self): def test_dimensions(self): assert_almost_equal( - # Angles seem to parse differently when openmm reads the pdb file - self.universe.trajectory.ts.dimensions[0:3], - self.ref.trajectory.ts.dimensions[0:3], + self.universe.trajectory.ts.dimensions, + self.ref.trajectory.ts.dimensions, self.prec, "OpenMMModellerReader failed to get unitcell dimensions " + "from OpenMMModeller", @@ -150,9 +148,8 @@ def setUp(self): def test_dimensions(self): assert_almost_equal( - # Angles seem to parse differently when openmm reads the pdb file - self.universe.trajectory.ts.dimensions[0:3], - self.ref.trajectory.ts.dimensions[0:3], + self.universe.trajectory.ts.dimensions, + self.ref.trajectory.ts.dimensions, self.prec, "OpenMMSimulationReader failed to get unitcell dimensions " + "from OpenMMSimulation", @@ -163,8 +160,12 @@ def test_coordinates(self): rp = self.ref.atoms.positions assert_almost_equal(up, rp, decimal=3) + @pytest.mark.xfail(reason='OpenMM pickling not supported yet') def test_pickle_singleframe_reader(self): - pass + """ + See `OpenMM SwigPyObject serialisation discussion `_ + """ + super().test_pickle_singleframe_reader() @pytest.fixture From 28ab3924096e4f37f38764c2b73c0d9454dd8b55 Mon Sep 17 00:00:00 2001 From: Jonathan Barnoud Date: Wed, 5 May 2021 11:58:53 +0100 Subject: [PATCH 46/47] Make sure OpenMM appears in the documentation * Add the stubs to trigger the build and link to the documentation of the new modules * Fix issues with references in the docstrings --- package/MDAnalysis/coordinates/OpenMM.py | 2 +- package/MDAnalysis/topology/OpenMMParser.py | 3 --- .../sphinx/source/documentation_pages/coordinates/OpenMM.rst | 1 + .../sphinx/source/documentation_pages/coordinates_modules.rst | 1 + .../doc/sphinx/source/documentation_pages/topology/OpenMM.rst | 1 + .../doc/sphinx/source/documentation_pages/topology_modules.rst | 1 + 6 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 package/doc/sphinx/source/documentation_pages/coordinates/OpenMM.rst create mode 100644 package/doc/sphinx/source/documentation_pages/topology/OpenMM.rst diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index 95bdc35778a..ebe9d1d528d 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -138,7 +138,7 @@ def _mda_timestep_from_omm_context(self): class OpenMMAppReader(base.SingleFrameReaderBase): """Reader for OpenMM Application layer objects - See also `OpenMM Application layer `_ + See also `the object definition in the OpenMM Application layer `_ .. versionadded:: 2.0.0 """ diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py index f7719bee452..070144c1d3b 100644 --- a/package/MDAnalysis/topology/OpenMMParser.py +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -41,9 +41,6 @@ The :class:`OpenMMTopologyParser` generates a topology from an OpenMM Topology object. -.. _OpenMM: http://docs.openmm.org/latest/api-python/app.html - - Classes ------- diff --git a/package/doc/sphinx/source/documentation_pages/coordinates/OpenMM.rst b/package/doc/sphinx/source/documentation_pages/coordinates/OpenMM.rst new file mode 100644 index 00000000000..ece8b877519 --- /dev/null +++ b/package/doc/sphinx/source/documentation_pages/coordinates/OpenMM.rst @@ -0,0 +1 @@ +.. automodule:: MDAnalysis.coordinates.OpenMM diff --git a/package/doc/sphinx/source/documentation_pages/coordinates_modules.rst b/package/doc/sphinx/source/documentation_pages/coordinates_modules.rst index 3666d4928b3..d9fa0362666 100644 --- a/package/doc/sphinx/source/documentation_pages/coordinates_modules.rst +++ b/package/doc/sphinx/source/documentation_pages/coordinates_modules.rst @@ -32,6 +32,7 @@ provide the format in the keyword argument *format* to coordinates/MMTF coordinates/MOL2 coordinates/NAMDBIN + coordinates/OpenMM coordinates/PDB coordinates/PDBQT coordinates/PQR diff --git a/package/doc/sphinx/source/documentation_pages/topology/OpenMM.rst b/package/doc/sphinx/source/documentation_pages/topology/OpenMM.rst new file mode 100644 index 00000000000..5c312eaea86 --- /dev/null +++ b/package/doc/sphinx/source/documentation_pages/topology/OpenMM.rst @@ -0,0 +1 @@ +.. automodule:: MDAnalysis.topology.OpenMMParser diff --git a/package/doc/sphinx/source/documentation_pages/topology_modules.rst b/package/doc/sphinx/source/documentation_pages/topology_modules.rst index ed8caba8ce6..9b62fbf938a 100644 --- a/package/doc/sphinx/source/documentation_pages/topology_modules.rst +++ b/package/doc/sphinx/source/documentation_pages/topology_modules.rst @@ -38,6 +38,7 @@ topology file format in the *topology_format* keyword argument to topology/MinimalParser topology/MMTFParser topology/MOL2Parser + topology/OpenMM topology/PDBParser topology/ExtendedPDBParser topology/PDBQTParser From a86a5283ba0b83e51b3e25d8cc1a5fbfd6848864 Mon Sep 17 00:00:00 2001 From: Jonathan Barnoud Date: Wed, 5 May 2021 15:09:03 +0100 Subject: [PATCH 47/47] PEP8 fixes for OpenMM reader and parser --- package/MDAnalysis/coordinates/OpenMM.py | 25 ++++++++++--------- package/MDAnalysis/topology/OpenMMParser.py | 22 ++++++++++------ .../coordinates/test_openmm.py | 14 +++++------ testsuite/MDAnalysisTests/datafiles.py | 2 +- .../MDAnalysisTests/topology/test_openmm.py | 2 ++ 5 files changed, 37 insertions(+), 28 deletions(-) diff --git a/package/MDAnalysis/coordinates/OpenMM.py b/package/MDAnalysis/coordinates/OpenMM.py index ebe9d1d528d..389576a7084 100644 --- a/package/MDAnalysis/coordinates/OpenMM.py +++ b/package/MDAnalysis/coordinates/OpenMM.py @@ -25,15 +25,15 @@ ================================================================ -Read coordinates data from a -`OpenMM `_ -:class:`simtk.openmm.app.simulation.Simulation` with :class:`OpenMMReader` -into a MDAnalysis Universe. +Read coordinates data from a +`OpenMM `_ +:class:`simtk.openmm.app.simulation.Simulation` with :class:`OpenMMReader` +into a MDAnalysis Universe. -Also converts other objects within the +Also converts other objects within the `OpenMM Application Layer `_: - - `simtk.openmm.app.pdbfile.PDBFile `_ + - `simtk.openmm.app.pdbfile.PDBFile `_ - `simtk.openmm.app.modeller.Modeller `_ - `simtk.openmm.app.pdbxfile.PDBxFile `_ @@ -78,8 +78,8 @@ class OpenMMSimulationReader(base.SingleFrameReaderBase): """ format = "OPENMMSIMULATION" - units = {"time": "ps", "length": "nm", "velocity": "nm/ps", - "force": "kJ/(mol*nm)", "energy": "kJ/mol"} + units = {"time": "ps", "length": "nm", "velocity": "nm/ps", + "force": "kJ/(mol*nm)", "energy": "kJ/mol"} @staticmethod def _format_hint(thing): @@ -111,7 +111,7 @@ def _mda_timestep_from_omm_context(self): """ Construct Timestep object from OpenMM context """ import simtk.unit as u - state = self.filename.context.getState(-1, getVelocities=True, + state = self.filename.context.getState(-1, getVelocities=True, getForces=True, getEnergy=True) n_atoms = self.filename.context.getSystem().getNumParticles() @@ -136,9 +136,9 @@ def _mda_timestep_from_omm_context(self): class OpenMMAppReader(base.SingleFrameReaderBase): - """Reader for OpenMM Application layer objects + """Reader for OpenMM Application layer objects - See also `the object definition in the OpenMM Application layer `_ + See also `the object definition in the OpenMM Application layer `_ .. versionadded:: 2.0.0 """ @@ -187,8 +187,9 @@ def _mda_timestep_from_omm_app(self): return ts + def _sanitize_box_angles(angles): - """ Ensure box angles correspond to first quadrant + """ Ensure box angles correspond to first quadrant See `discussion on unitcell angles `_ """ diff --git a/package/MDAnalysis/topology/OpenMMParser.py b/package/MDAnalysis/topology/OpenMMParser.py index 070144c1d3b..01a6eb50183 100644 --- a/package/MDAnalysis/topology/OpenMMParser.py +++ b/package/MDAnalysis/topology/OpenMMParser.py @@ -27,19 +27,19 @@ .. versionadded:: 2.0.0 -Converts an -`OpenMM `_ +Converts an +`OpenMM `_ :class:`simtk.openmm.app.topology.Topology` into a :class:`MDAnalysis.core.Topology`. -Also converts some objects within the +Also converts some objects within the `OpenMM Application layer `_ - - `simtk.openmm.app.pdbfile.PDBFile `_ + - `simtk.openmm.app.pdbfile.PDBFile `_ - `simtk.openmm.app.simulation.Simulation `_ - `simtk.openmm.app.modeller.Modeller `_ - `simtk.openmm.app.pdbxfile.PDBxFile `_ -The :class:`OpenMMTopologyParser` generates a topology from an OpenMM Topology object. +The :class:`OpenMMTopologyParser` generates a topology from an OpenMM Topology object. Classes @@ -91,7 +91,7 @@ def _format_hint(thing): return isinstance(thing, app.Topology) def _mda_topology_from_omm_topology(self, omm_topology): - """ Construct mda topology from omm topology + """ Construct mda topology from omm topology Can be used for any openmm object that contains a topology object @@ -156,6 +156,7 @@ def parse(self, **kwargs): return top + class OpenMMAppTopologyParser(OpenMMTopologyParser): format = "OPENMMAPP" @@ -169,8 +170,13 @@ def _format_hint(thing): except ImportError: return False else: - return isinstance(thing, (app.PDBFile, app.Modeller, - app.Simulation, app.PDBxFile)) + return isinstance( + thing, + ( + app.PDBFile, app.Modeller, + app.Simulation, app.PDBxFile + ) + ) def parse(self, **kwargs): try: diff --git a/testsuite/MDAnalysisTests/coordinates/test_openmm.py b/testsuite/MDAnalysisTests/coordinates/test_openmm.py index adcf6d93336..7025658dc3c 100644 --- a/testsuite/MDAnalysisTests/coordinates/test_openmm.py +++ b/testsuite/MDAnalysisTests/coordinates/test_openmm.py @@ -35,6 +35,7 @@ unit = pytest.importorskip("simtk.unit") app = pytest.importorskip("simtk.openmm.app") + class TestOpenMMBasicSimulationReader(): @pytest.fixture def omm_sim_uni(self): @@ -46,15 +47,16 @@ def omm_sim_uni(self): for i in range(5): system.addParticle(1.0) topology.addAtom(hydrogen.symbol, hydrogen, residue) - positions = np.ones((5,3)) * unit.angstrom - integrator = mm.LangevinIntegrator(273 * unit.kelvin, - 1.0 / unit.picoseconds, 2.0 * unit.femtoseconds) + positions = np.ones((5, 3)) * unit.angstrom + integrator = mm.LangevinIntegrator( + 273 * unit.kelvin, + 1.0 / unit.picoseconds, 2.0 * unit.femtoseconds, + ) simulation = app.Simulation(topology, system, integrator) simulation.context.setPositions(positions) return mda.Universe(simulation) - def test_dimensions(self, omm_sim_uni): assert_almost_equal( omm_sim_uni.trajectory.ts.dimensions, @@ -66,7 +68,7 @@ def test_dimensions(self, omm_sim_uni): def test_coordinates(self, omm_sim_uni): up = omm_sim_uni.atoms.positions - reference = np.ones((5,3)) + reference = np.ones((5, 3)) assert_almost_equal(up, reference, decimal=3) def test_basic_topology(self, omm_sim_uni): @@ -78,8 +80,6 @@ def test_basic_topology(self, omm_sim_uni): assert len(omm_sim_uni.bonds.indices) == 0 - - class TestOpenMMPDBFileReader(_SingleFrameReader): __test__ = True diff --git a/testsuite/MDAnalysisTests/datafiles.py b/testsuite/MDAnalysisTests/datafiles.py index 52f1f0f800a..879c9ee664d 100644 --- a/testsuite/MDAnalysisTests/datafiles.py +++ b/testsuite/MDAnalysisTests/datafiles.py @@ -200,7 +200,7 @@ "PDB_CHECK_RIGHTHAND_PA", # for testing right handedness of principal_axes "MMTF_NOCRYST", # File with meaningless CRYST1 record (Issue #2679, PR #2685) "FHIAIMS", # to test FHIAIMS coordinate files - "SDF_molecule", # MDL SDFile for rdkit + "SDF_molecule", # MDL SDFile for rdkit "PDBX", # PDBxfile "PDB_elements", # PDB file with elements ] diff --git a/testsuite/MDAnalysisTests/topology/test_openmm.py b/testsuite/MDAnalysisTests/topology/test_openmm.py index 0bea9f55112..d4208a0c4d4 100644 --- a/testsuite/MDAnalysisTests/topology/test_openmm.py +++ b/testsuite/MDAnalysisTests/topology/test_openmm.py @@ -31,6 +31,7 @@ app = pytest.importorskip('simtk.openmm.app') + class OpenMMTopologyBase(ParserBase): parser = mda.topology.OpenMMParser.OpenMMTopologyParser expected_attrs = [ @@ -94,6 +95,7 @@ def test_segids(self, top): else: assert top.segids.values == [] + class OpenMMAppTopologyBase(OpenMMTopologyBase): parser = mda.topology.OpenMMParser.OpenMMAppTopologyParser expected_attrs = [