Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
aab77399
Commit
aab77399
authored
Mar 30, 2012
by
Peter Eastman
Browse files
Lots of improvements to Python API documentation
parent
cf4c2287
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
59 additions
and
15 deletions
+59
-15
wrappers/python/simtk/openmm/app/__init__.py
wrappers/python/simtk/openmm/app/__init__.py
+1
-0
wrappers/python/simtk/openmm/app/amberinpcrdfile.py
wrappers/python/simtk/openmm/app/amberinpcrdfile.py
+3
-0
wrappers/python/simtk/openmm/app/amberprmtopfile.py
wrappers/python/simtk/openmm/app/amberprmtopfile.py
+4
-3
wrappers/python/simtk/openmm/app/dcdreporter.py
wrappers/python/simtk/openmm/app/dcdreporter.py
+1
-1
wrappers/python/simtk/openmm/app/element.py
wrappers/python/simtk/openmm/app/element.py
+20
-4
wrappers/python/simtk/openmm/app/forcefield.py
wrappers/python/simtk/openmm/app/forcefield.py
+2
-2
wrappers/python/simtk/openmm/app/modeller.py
wrappers/python/simtk/openmm/app/modeller.py
+2
-0
wrappers/python/simtk/openmm/app/pdbfile.py
wrappers/python/simtk/openmm/app/pdbfile.py
+2
-0
wrappers/python/simtk/openmm/app/pdbreporter.py
wrappers/python/simtk/openmm/app/pdbreporter.py
+1
-1
wrappers/python/simtk/openmm/app/simulation.py
wrappers/python/simtk/openmm/app/simulation.py
+7
-1
wrappers/python/simtk/openmm/app/statedatareporter.py
wrappers/python/simtk/openmm/app/statedatareporter.py
+3
-3
wrappers/python/simtk/openmm/app/topology.py
wrappers/python/simtk/openmm/app/topology.py
+13
-0
No files found.
wrappers/python/simtk/openmm/app/__init__.py
View file @
aab77399
...
@@ -21,6 +21,7 @@ from dcdfile import DCDFile
...
@@ -21,6 +21,7 @@ from dcdfile import DCDFile
from
dcdreporter
import
DCDReporter
from
dcdreporter
import
DCDReporter
from
modeller
import
Modeller
from
modeller
import
Modeller
from
statedatareporter
import
StateDataReporter
from
statedatareporter
import
StateDataReporter
from
element
import
Element
# Enumerated values
# Enumerated values
...
...
wrappers/python/simtk/openmm/app/amberinpcrdfile.py
View file @
aab77399
...
@@ -56,9 +56,12 @@ class AmberInpcrdFile(object):
...
@@ -56,9 +56,12 @@ class AmberInpcrdFile(object):
"""
"""
results
=
amber_file_parser
.
readAmberCoordinates
(
file
,
read_velocities
=
loadVelocities
,
read_box
=
loadBoxVectors
)
results
=
amber_file_parser
.
readAmberCoordinates
(
file
,
read_velocities
=
loadVelocities
,
read_box
=
loadBoxVectors
)
if
loadVelocities
:
if
loadVelocities
:
## The atom positions read from the inpcrd file
self
.
positions
=
results
[
0
]
self
.
positions
=
results
[
0
]
if
loadBoxVectors
:
if
loadBoxVectors
:
## The periodic box vectors read from the inpcrd file
self
.
boxVectors
=
results
[
1
]
self
.
boxVectors
=
results
[
1
]
## The atom velocities read from the inpcrd file
self
.
velocities
=
results
[
2
]
self
.
velocities
=
results
[
2
]
else
:
else
:
self
.
velocities
=
results
[
1
]
self
.
velocities
=
results
[
1
]
...
...
wrappers/python/simtk/openmm/app/amberprmtopfile.py
View file @
aab77399
...
@@ -52,12 +52,13 @@ class AmberPrmtopFile(object):
...
@@ -52,12 +52,13 @@ class AmberPrmtopFile(object):
def
__init__
(
self
,
file
):
def
__init__
(
self
,
file
):
"""Load a prmtop file."""
"""Load a prmtop file."""
top
=
Topology
()
top
=
Topology
()
## The Topology read from the prmtop file
self
.
topology
=
top
self
.
topology
=
top
# Load the prmtop file
# Load the prmtop file
prmtop
=
amber_file_parser
.
PrmtopLoader
(
file
)
prmtop
=
amber_file_parser
.
PrmtopLoader
(
file
)
self
.
prmtop
=
prmtop
self
.
_
prmtop
=
prmtop
# Add atoms to the topology
# Add atoms to the topology
...
@@ -132,7 +133,7 @@ class AmberPrmtopFile(object):
...
@@ -132,7 +133,7 @@ class AmberPrmtopFile(object):
ff
.
PME
:
'PME'
}
ff
.
PME
:
'PME'
}
if
nonbondedMethod
not
in
methodMap
:
if
nonbondedMethod
not
in
methodMap
:
raise
ValueError
(
'Illegal value for nonbonded method'
)
raise
ValueError
(
'Illegal value for nonbonded method'
)
if
not
self
.
prmtop
.
getIfBox
()
and
nonbondedMethod
in
(
ff
.
CutoffPeriodic
,
ff
.
Ewald
,
ff
.
PME
):
if
not
self
.
_
prmtop
.
getIfBox
()
and
nonbondedMethod
in
(
ff
.
CutoffPeriodic
,
ff
.
Ewald
,
ff
.
PME
):
raise
ValueError
(
'Illegal nonbonded method for a non-periodic system'
)
raise
ValueError
(
'Illegal nonbonded method for a non-periodic system'
)
if
nonbondedMethod
==
ff
.
NoCutoff
:
if
nonbondedMethod
==
ff
.
NoCutoff
:
nonbondedCutoff
=
None
nonbondedCutoff
=
None
...
@@ -158,7 +159,7 @@ class AmberPrmtopFile(object):
...
@@ -158,7 +159,7 @@ class AmberPrmtopFile(object):
implicitString
=
'GBn'
implicitString
=
'GBn'
else
:
else
:
raise
ValueError
(
'Illegal value for implicit solvent model'
)
raise
ValueError
(
'Illegal value for implicit solvent model'
)
sys
=
amber_file_parser
.
readAmberSystem
(
prmtop_loader
=
self
.
prmtop
,
shake
=
constraintString
,
nonbondedCutoff
=
nonbondedCutoff
,
sys
=
amber_file_parser
.
readAmberSystem
(
prmtop_loader
=
self
.
_
prmtop
,
shake
=
constraintString
,
nonbondedCutoff
=
nonbondedCutoff
,
nonbondedMethod
=
methodMap
[
nonbondedMethod
],
flexibleConstraints
=
False
,
gbmodel
=
implicitString
,
nonbondedMethod
=
methodMap
[
nonbondedMethod
],
flexibleConstraints
=
False
,
gbmodel
=
implicitString
,
soluteDielectric
=
soluteDielectric
,
solventDielectric
=
solventDielectric
,
rigidWater
=
rigidWater
)
soluteDielectric
=
soluteDielectric
,
solventDielectric
=
solventDielectric
,
rigidWater
=
rigidWater
)
if
removeCMMotion
:
if
removeCMMotion
:
...
...
wrappers/python/simtk/openmm/app/dcdreporter.py
View file @
aab77399
...
@@ -38,7 +38,7 @@ from simtk.unit import nanometer
...
@@ -38,7 +38,7 @@ from simtk.unit import nanometer
class
DCDReporter
(
object
):
class
DCDReporter
(
object
):
"""DCDReporter outputs a series of frames from a Simulation to a DCD file.
"""DCDReporter outputs a series of frames from a Simulation to a DCD file.
To use it, create a DCDReporter, th
a
n add it to the Simulation's list of reporters.
To use it, create a DCDReporter, th
e
n add it to the Simulation's list of reporters.
"""
"""
def
__init__
(
self
,
file
,
reportInterval
):
def
__init__
(
self
,
file
,
reportInterval
):
...
...
wrappers/python/simtk/openmm/app/element.py
View file @
aab77399
...
@@ -37,22 +37,38 @@ __version__ = "1.0"
...
@@ -37,22 +37,38 @@ __version__ = "1.0"
from
simtk.unit
import
daltons
from
simtk.unit
import
daltons
class
Element
:
class
Element
:
elements_by_symbol
=
{}
"""An Element represents a chemical element.
The simtk.openmm.app.element module contains objects for all the standard chemical elements,
such as element.hydrogen or element.carbon. You can also call the static method Element.getBySymbol() to
look up the Element with a particular chemical symbol."""
_elements_by_symbol
=
{}
def
__init__
(
self
,
number
,
name
,
symbol
,
mass
):
def
__init__
(
self
,
number
,
name
,
symbol
,
mass
):
## The atomic number of the element
self
.
atomic_number
=
number
self
.
atomic_number
=
number
## The name of the element
self
.
name
=
name
self
.
name
=
name
## The chemical symbol of the element
self
.
symbol
=
symbol
self
.
symbol
=
symbol
## The atomic mass of the element
self
.
mass
=
mass
self
.
mass
=
mass
# Index this element in a global table
# Index this element in a global table
s
=
symbol
.
strip
().
upper
()
s
=
symbol
.
strip
().
upper
()
assert
s
not
in
Element
.
elements_by_symbol
assert
s
not
in
Element
.
_
elements_by_symbol
Element
.
elements_by_symbol
[
s
]
=
self
Element
.
_
elements_by_symbol
[
s
]
=
self
@
staticmethod
def
getBySymbol
(
symbol
):
"""Get the Element with a particular chemical symbol."""
s
=
symbol
.
strip
().
upper
()
return
Element
.
_elements_by_symbol
[
s
]
# This is for backward compatibility.
def
get_by_symbol
(
symbol
):
def
get_by_symbol
(
symbol
):
s
=
symbol
.
strip
().
upper
()
s
=
symbol
.
strip
().
upper
()
return
Element
.
elements_by_symbol
[
s
]
return
Element
.
_
elements_by_symbol
[
s
]
hydrogen
=
Element
(
1
,
"hydrogen"
,
"H"
,
1.007947
*
daltons
)
hydrogen
=
Element
(
1
,
"hydrogen"
,
"H"
,
1.007947
*
daltons
)
...
...
wrappers/python/simtk/openmm/app/forcefield.py
View file @
aab77399
...
@@ -65,7 +65,7 @@ class ForceField(object):
...
@@ -65,7 +65,7 @@ class ForceField(object):
"""Load one or more XML files and create a ForceField object based on them.
"""Load one or more XML files and create a ForceField object based on them.
Parameters:
Parameters:
- A list of XML files defining the force field. Each entry may be an absolute file path, a path relative to the
-
files
A list of XML files defining the force field. Each entry may be an absolute file path, a path relative to the
current working directory, or a path relative to this module's data subdirectory (for built in force fields).
current working directory, or a path relative to this module's data subdirectory (for built in force fields).
"""
"""
self
.
_atomTypes
=
{}
self
.
_atomTypes
=
{}
...
@@ -251,7 +251,7 @@ class ForceField(object):
...
@@ -251,7 +251,7 @@ class ForceField(object):
Allowed values are None, HBonds, AllBonds, or HAngles.
Allowed values are None, HBonds, AllBonds, or HAngles.
- rigidWater (boolean=True) If true, water molecules will be fully rigid regardless of the value passed for the constraints argument
- rigidWater (boolean=True) If true, water molecules will be fully rigid regardless of the value passed for the constraints argument
- removeCMMotion (boolean=True) If true, a CMMotionRemover will be added to the System
- removeCMMotion (boolean=True) If true, a CMMotionRemover will be added to the System
-
-
Arbitrary additional keyword arguments may also be specified. This allows extra parameters to be specified that are specific to
-
args
Arbitrary additional keyword arguments may also be specified. This allows extra parameters to be specified that are specific to
particular force fields.
particular force fields.
Returns: the newly created System
Returns: the newly created System
"""
"""
...
...
wrappers/python/simtk/openmm/app/modeller.py
View file @
aab77399
...
@@ -63,9 +63,11 @@ class Modeller(object):
...
@@ -63,9 +63,11 @@ class Modeller(object):
- topology (Topology) the initial Topology of the model
- topology (Topology) the initial Topology of the model
- positions (list) the initial atomic positions
- positions (list) the initial atomic positions
"""
"""
## The Topology describing the structure of the system
self
.
topology
=
topology
self
.
topology
=
topology
if
not
is_quantity
(
positions
):
if
not
is_quantity
(
positions
):
positions
=
positions
*
nanometers
positions
=
positions
*
nanometers
## The list of atom positions
self
.
positions
=
positions
self
.
positions
=
positions
def
getTopology
(
self
):
def
getTopology
(
self
):
...
...
wrappers/python/simtk/openmm/app/pdbfile.py
View file @
aab77399
...
@@ -65,6 +65,7 @@ class PDBFile(object):
...
@@ -65,6 +65,7 @@ class PDBFile(object):
"""
"""
top
=
Topology
()
top
=
Topology
()
coords
=
[];
coords
=
[];
## The Topology read from the PDB file
self
.
topology
=
top
self
.
topology
=
top
# Load the PDB file
# Load the PDB file
...
@@ -119,6 +120,7 @@ class PDBFile(object):
...
@@ -119,6 +120,7 @@ class PDBFile(object):
atomByNumber
[
atom
.
serial_number
]
=
newAtom
atomByNumber
[
atom
.
serial_number
]
=
newAtom
pos
=
atom
.
get_position
().
value_in_unit
(
nanometers
)
pos
=
atom
.
get_position
().
value_in_unit
(
nanometers
)
coords
.
append
(
Vec3
(
pos
[
0
],
pos
[
1
],
pos
[
2
]))
coords
.
append
(
Vec3
(
pos
[
0
],
pos
[
1
],
pos
[
2
]))
## The atom positions read from the PDB file
self
.
positions
=
coords
*
nanometers
self
.
positions
=
coords
*
nanometers
self
.
topology
.
setUnitCellDimensions
(
pdb
.
get_unit_cell_dimensions
())
self
.
topology
.
setUnitCellDimensions
(
pdb
.
get_unit_cell_dimensions
())
self
.
topology
.
createStandardBonds
()
self
.
topology
.
createStandardBonds
()
...
...
wrappers/python/simtk/openmm/app/pdbreporter.py
View file @
aab77399
...
@@ -37,7 +37,7 @@ from simtk.openmm.app import PDBFile
...
@@ -37,7 +37,7 @@ from simtk.openmm.app import PDBFile
class
PDBReporter
(
object
):
class
PDBReporter
(
object
):
"""PDBReporter outputs a series of frames from a Simulation to a PDB file.
"""PDBReporter outputs a series of frames from a Simulation to a PDB file.
To use it, create a PDBReporter, th
a
n add it to the Simulation's list of reporters.
To use it, create a PDBReporter, th
e
n add it to the Simulation's list of reporters.
"""
"""
def
__init__
(
self
,
file
,
reportInterval
):
def
__init__
(
self
,
file
,
reportInterval
):
...
...
wrappers/python/simtk/openmm/app/simulation.py
View file @
aab77399
...
@@ -53,19 +53,25 @@ class Simulation(object):
...
@@ -53,19 +53,25 @@ class Simulation(object):
"""Create a Simulation.
"""Create a Simulation.
Parameters:
Parameters:
- topology (Topology) A Topology describing the the system to simulat
ion
- topology (Topology) A Topology describing the the system to simulat
e
- system (System) The OpenMM System object to simulate
- system (System) The OpenMM System object to simulate
- integrator (Integrator) The OpenMM Integrator to use for simulating the System
- integrator (Integrator) The OpenMM Integrator to use for simulating the System
- platform (Platform=None) If not None, the OpenMM Platform to use
- platform (Platform=None) If not None, the OpenMM Platform to use
- platformProperties (map=None) If not None, a set of platform-specific properties to pass
- platformProperties (map=None) If not None, a set of platform-specific properties to pass
to the Context's constructor
to the Context's constructor
"""
"""
## The Topology describing the system being simulated
self
.
topology
=
topology
self
.
topology
=
topology
## The System being simulated
self
.
system
=
system
self
.
system
=
system
## The Integrator used to advance the simulation
self
.
integrator
=
integrator
self
.
integrator
=
integrator
## The index of the current time step
self
.
currentStep
=
0
self
.
currentStep
=
0
## A list of reporters to invoke during the simulation
self
.
reporters
=
[]
self
.
reporters
=
[]
if
platform
is
None
:
if
platform
is
None
:
## The Context containing the current state of the simulation
self
.
context
=
mm
.
Context
(
system
,
integrator
)
self
.
context
=
mm
.
Context
(
system
,
integrator
)
elif
platformProperties
is
None
:
elif
platformProperties
is
None
:
self
.
context
=
mm
.
Context
(
system
,
integrator
,
platform
)
self
.
context
=
mm
.
Context
(
system
,
integrator
,
platform
)
...
...
wrappers/python/simtk/openmm/app/statedatareporter.py
View file @
aab77399
...
@@ -49,12 +49,12 @@ class StateDataReporter(object):
...
@@ -49,12 +49,12 @@ class StateDataReporter(object):
Parameters:
Parameters:
- file (string or file) The file to write to, specified as a file name or file object
- file (string or file) The file to write to, specified as a file name or file object
- reportInterval (int) The interval (in time steps) at which to write frames
- reportInterval (int) The interval (in time steps) at which to write frames
- step (boolean=
Tru
e) Whether to write the current step index to the file
- step (boolean=
Fals
e) Whether to write the current step index to the file
- time (boolean=
Tru
e) Whether to write the current time to the file
- time (boolean=
Fals
e) Whether to write the current time to the file
- potentialEnergy (boolean=False) Whether to write the potential energy to the file
- potentialEnergy (boolean=False) Whether to write the potential energy to the file
- kineticEnergy (boolean=False) Whether to write the kinetic energy to the file
- kineticEnergy (boolean=False) Whether to write the kinetic energy to the file
- totalEnergy (boolean=False) Whether to write the total energy to the file
- totalEnergy (boolean=False) Whether to write the total energy to the file
- temperature(boolean=False) Whether to write the instantaneous temperature to the file
- temperature
(boolean=False) Whether to write the instantaneous temperature to the file
- volume (boolean=False) Whether to write the periodic box volume to the file
- volume (boolean=False) Whether to write the periodic box volume to the file
- density (boolean=False) Whether to write the system density to the file
- density (boolean=False) Whether to write the system density to the file
- separator (string=',') The separator to use between columns in the file
- separator (string=',') The separator to use between columns in the file
...
...
wrappers/python/simtk/openmm/app/topology.py
View file @
aab77399
...
@@ -205,9 +205,12 @@ class Topology(object):
...
@@ -205,9 +205,12 @@ class Topology(object):
self
.
addBond
(
sg1
,
sg2
)
self
.
addBond
(
sg1
,
sg2
)
class
Chain
(
object
):
class
Chain
(
object
):
"""A Chain object represents a chain within a Topology."""
def
__init__
(
self
,
index
,
topology
):
def
__init__
(
self
,
index
,
topology
):
"""Construct a new Chain. You should call addChain() on the Topology instead of calling this directly."""
"""Construct a new Chain. You should call addChain() on the Topology instead of calling this directly."""
## The index of the Chain within its Topology
self
.
index
=
index
self
.
index
=
index
## The Topology this Chain belongs to
self
.
topology
=
topology
self
.
topology
=
topology
self
.
_residues
=
[]
self
.
_residues
=
[]
...
@@ -222,10 +225,14 @@ class Chain(object):
...
@@ -222,10 +225,14 @@ class Chain(object):
yield
atom
yield
atom
class
Residue
(
object
):
class
Residue
(
object
):
"""A Residue object represents a residue within a Topology."""
def
__init__
(
self
,
name
,
index
,
chain
):
def
__init__
(
self
,
name
,
index
,
chain
):
"""Construct a new Residue. You should call addResidue() on the Topology instead of calling this directly."""
"""Construct a new Residue. You should call addResidue() on the Topology instead of calling this directly."""
## The name of the Residue
self
.
name
=
name
self
.
name
=
name
## The index of the Residue within its Topology
self
.
index
=
index
self
.
index
=
index
## The Chain this Residue belongs to
self
.
chain
=
chain
self
.
chain
=
chain
self
.
_atoms
=
[]
self
.
_atoms
=
[]
...
@@ -234,10 +241,16 @@ class Residue(object):
...
@@ -234,10 +241,16 @@ class Residue(object):
return
iter
(
self
.
_atoms
)
return
iter
(
self
.
_atoms
)
class
Atom
(
object
):
class
Atom
(
object
):
"""An Atom object represents a residue within a Topology."""
def
__init__
(
self
,
name
,
element
,
index
,
residue
):
def
__init__
(
self
,
name
,
element
,
index
,
residue
):
"""Construct a new Atom. You should call addAtom() on the Topology instead of calling this directly."""
"""Construct a new Atom. You should call addAtom() on the Topology instead of calling this directly."""
## The name of the Atom
self
.
name
=
name
self
.
name
=
name
## That Atom's element
self
.
element
=
element
self
.
element
=
element
## The index of the Atom within its Topology
self
.
index
=
index
self
.
index
=
index
## The Residue this Atom belongs to
self
.
residue
=
residue
self
.
residue
=
residue
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment