@@ -77,13 +77,17 @@ class OpenMMSimulationReader(base.SingleFrameReaderBase):
77
77
"""
78
78
79
79
format = "OPENMMSIMULATION"
80
- units = {"time" : "ps" , "length" : "nm" , "velocity" : "nm/ps" ,
81
- "force" : "kJ/(mol*nm)" , "energy" : "kJ/mol" }
80
+ units = {
81
+ "time" : "ps" ,
82
+ "length" : "nm" ,
83
+ "velocity" : "nm/ps" ,
84
+ "force" : "kJ/(mol*nm)" ,
85
+ "energy" : "kJ/mol" ,
86
+ }
82
87
83
88
@staticmethod
84
89
def _format_hint (thing ):
85
- """Can this reader read *thing*?
86
- """
90
+ """Can this reader read *thing*?"""
87
91
try :
88
92
from openmm .app import Simulation
89
93
except ImportError :
@@ -104,34 +108,38 @@ def _read_first_frame(self):
104
108
self .ts .triclinic_dimensions = self .convert_pos_from_native (
105
109
self .ts .triclinic_dimensions , inplace = False
106
110
)
107
- self .ts .dimensions [3 :] = _sanitize_box_angles (self .ts .dimensions [3 :])
111
+ self .ts .dimensions [3 :] = _sanitize_box_angles (
112
+ self .ts .dimensions [3 :]
113
+ )
108
114
self .convert_velocities_from_native (self .ts ._velocities )
109
115
self .convert_forces_from_native (self .ts ._forces )
110
116
self .convert_time_from_native (self .ts .dt )
111
117
112
118
def _mda_timestep_from_omm_context (self ):
113
- """ Construct Timestep object from OpenMM context """
119
+ """Construct Timestep object from OpenMM context"""
114
120
try :
115
121
import openmm .unit as u
116
122
except ImportError : # pragma: no cover
117
123
import simtk .unit as u
118
124
119
- state = self .filename .context .getState (- 1 , getVelocities = True ,
120
- getForces = True , getEnergy = True )
125
+ state = self .filename .context .getState (
126
+ - 1 , getVelocities = True , getForces = True , getEnergy = True
127
+ )
121
128
122
129
n_atoms = self .filename .context .getSystem ().getNumParticles ()
123
130
124
131
ts = self ._Timestep (n_atoms , ** self ._ts_kwargs )
125
132
ts .frame = 0
126
133
ts .data ["time" ] = state .getTime ()._value
127
134
ts .data ["potential_energy" ] = (
128
- state .getPotentialEnergy ().in_units_of (u .kilojoule / u .mole )._value
135
+ state .getPotentialEnergy ().in_units_of (u .kilojoule / u .mole )._value
129
136
)
130
137
ts .data ["kinetic_energy" ] = (
131
- state .getKineticEnergy ().in_units_of (u .kilojoule / u .mole )._value
138
+ state .getKineticEnergy ().in_units_of (u .kilojoule / u .mole )._value
132
139
)
133
140
ts .triclinic_dimensions = state .getPeriodicBoxVectors (
134
- asNumpy = True )._value
141
+ asNumpy = True
142
+ )._value
135
143
ts .dimensions [3 :] = _sanitize_box_angles (ts .dimensions [3 :])
136
144
ts .positions = state .getPositions (asNumpy = True )._value
137
145
ts .velocities = state .getVelocities (asNumpy = True )._value
@@ -153,8 +161,7 @@ class OpenMMAppReader(base.SingleFrameReaderBase):
153
161
154
162
@staticmethod
155
163
def _format_hint (thing ):
156
- """Can this reader read *thing*?
157
- """
164
+ """Can this reader read *thing*?"""
158
165
try :
159
166
from openmm import app
160
167
except ImportError :
@@ -163,8 +170,7 @@ def _format_hint(thing):
163
170
except ImportError :
164
171
return False
165
172
else :
166
- return isinstance (thing , (app .PDBFile , app .Modeller ,
167
- app .PDBxFile ))
173
+ return isinstance (thing , (app .PDBFile , app .Modeller , app .PDBxFile ))
168
174
169
175
def _read_first_frame (self ):
170
176
self .n_atoms = self .filename .topology .getNumAtoms ()
@@ -177,10 +183,12 @@ def _read_first_frame(self):
177
183
self .ts .triclinic_dimensions = self .convert_pos_from_native (
178
184
self .ts .triclinic_dimensions , inplace = False
179
185
)
180
- self .ts .dimensions [3 :] = _sanitize_box_angles (self .ts .dimensions [3 :])
186
+ self .ts .dimensions [3 :] = _sanitize_box_angles (
187
+ self .ts .dimensions [3 :]
188
+ )
181
189
182
190
def _mda_timestep_from_omm_app (self ):
183
- """ Construct Timestep object from OpenMM Application object """
191
+ """Construct Timestep object from OpenMM Application object"""
184
192
185
193
omm_object = self .filename
186
194
n_atoms = omm_object .topology .getNumAtoms ()
@@ -198,7 +206,7 @@ def _mda_timestep_from_omm_app(self):
198
206
199
207
200
208
def _sanitize_box_angles (angles ):
201
- """ Ensure box angles correspond to first quadrant
209
+ """Ensure box angles correspond to first quadrant
202
210
203
211
See `discussion on unitcell angles <https://github.com/MDAnalysis/mdanalysis/pull/2917/files#r620558575>`_
204
212
"""
0 commit comments