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
925fc9d9
"wrappers/python/src/vscode:/vscode.git/clone" did not exist on "1589d42511a82fa759bf30c6e1e75c49e0065e71"
Commit
925fc9d9
authored
Oct 17, 2013
by
Peter Eastman
Browse files
Merge branch 'master' of
https://github.com/SimTk/openmm
parents
8f168506
7b133c70
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
90 additions
and
18 deletions
+90
-18
wrappers/python/simtk/openmm/app/internal/amber_file_parser.py
...ers/python/simtk/openmm/app/internal/amber_file_parser.py
+38
-17
wrappers/python/simtk/openmm/app/pdbfile.py
wrappers/python/simtk/openmm/app/pdbfile.py
+50
-0
wrappers/python/simtk/openmm/app/pdbreporter.py
wrappers/python/simtk/openmm/app/pdbreporter.py
+2
-1
No files found.
wrappers/python/simtk/openmm/app/internal/amber_file_parser.py
View file @
925fc9d9
...
@@ -41,9 +41,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
...
@@ -41,9 +41,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
import
os
import
os
import
os.path
import
os.path
import
copy
import
re
import
re
import
math
import
math
import
warnings
try
:
try
:
import
numpy
import
numpy
...
@@ -428,15 +428,25 @@ class PrmtopLoader(object):
...
@@ -428,15 +428,25 @@ class PrmtopLoader(object):
charges
=
self
.
getCharges
()
charges
=
self
.
getCharges
()
nonbondTerms
=
self
.
getNonbondTerms
()
nonbondTerms
=
self
.
getNonbondTerms
()
for
ii
in
range
(
0
,
len
(
dihedralPointers
),
5
):
for
ii
in
range
(
0
,
len
(
dihedralPointers
),
5
):
if
int
(
dihedralPointers
[
ii
+
2
])
>
0
and
int
(
dihedralPointers
[
ii
+
3
])
>
0
:
if
int
(
dihedralPointers
[
ii
+
2
])
>
0
and
int
(
dihedralPointers
[
ii
+
3
])
>
0
:
iAtom
=
int
(
dihedralPointers
[
ii
])
//
3
iAtom
=
int
(
dihedralPointers
[
ii
])
//
3
lAtom
=
int
(
dihedralPointers
[
ii
+
3
])
//
3
lAtom
=
int
(
dihedralPointers
[
ii
+
3
])
//
3
chargeProd
=
charges
[
iAtom
]
*
charges
[
lAtom
]
iidx
=
int
(
dihedralPointers
[
ii
+
4
])
-
1
(
rVdwI
,
epsilonI
)
=
nonbondTerms
[
iAtom
]
chargeProd
=
charges
[
iAtom
]
*
charges
[
lAtom
]
(
rVdwL
,
epsilonL
)
=
nonbondTerms
[
lAtom
]
(
rVdwI
,
epsilonI
)
=
nonbondTerms
[
iAtom
]
rMin
=
(
rVdwI
+
rVdwL
)
(
rVdwL
,
epsilonL
)
=
nonbondTerms
[
lAtom
]
epsilon
=
math
.
sqrt
(
epsilonI
*
epsilonL
)
rMin
=
(
rVdwI
+
rVdwL
)
returnList
.
append
((
iAtom
,
lAtom
,
chargeProd
,
rMin
,
epsilon
))
epsilon
=
math
.
sqrt
(
epsilonI
*
epsilonL
)
try
:
iScee
=
float
(
self
.
_raw_data
[
"SCEE_SCALE_FACTOR"
][
iidx
])
except
KeyError
:
iScee
=
1.2
try
:
iScnb
=
float
(
self
.
_raw_data
[
"SCNB_SCALE_FACTOR"
][
iidx
])
except
KeyError
:
iScnb
=
2.0
returnList
.
append
((
iAtom
,
lAtom
,
chargeProd
,
rMin
,
epsilon
,
iScee
,
iScnb
))
return
returnList
return
returnList
def
getExcludedAtoms
(
self
):
def
getExcludedAtoms
(
self
):
...
@@ -502,11 +512,15 @@ class PrmtopLoader(object):
...
@@ -502,11 +512,15 @@ class PrmtopLoader(object):
units
.
Quantity
(
y
,
units
.
angstrom
),
units
.
Quantity
(
y
,
units
.
angstrom
),
units
.
Quantity
(
z
,
units
.
angstrom
))
units
.
Quantity
(
z
,
units
.
angstrom
))
@
property
def
has_scee_scnb
(
self
):
return
(
"SCEE_SCALE_FACTOR"
in
self
.
_raw_data
and
"SCNB_SCALE_FACTOR"
in
self
.
_raw_data
)
#=============================================================================================
#=============================================================================================
# AMBER System builder (based on, but not identical to, systemManager from 'zander')
# AMBER System builder (based on, but not identical to, systemManager from 'zander')
#=============================================================================================
#=============================================================================================
def
readAmberSystem
(
prmtop_filename
=
None
,
prmtop_loader
=
None
,
shake
=
None
,
gbmodel
=
None
,
soluteDielectric
=
1.0
,
solventDielectric
=
78.5
,
nonbondedCutoff
=
None
,
nonbondedMethod
=
'NoCutoff'
,
scee
=
1.2
,
scnb
=
2.0
,
mm
=
None
,
verbose
=
False
,
EwaldErrorTolerance
=
None
,
flexibleConstraints
=
True
,
rigidWater
=
True
):
def
readAmberSystem
(
prmtop_filename
=
None
,
prmtop_loader
=
None
,
shake
=
None
,
gbmodel
=
None
,
soluteDielectric
=
1.0
,
solventDielectric
=
78.5
,
nonbondedCutoff
=
None
,
nonbondedMethod
=
'NoCutoff'
,
scee
=
None
,
scnb
=
None
,
mm
=
None
,
verbose
=
False
,
EwaldErrorTolerance
=
None
,
flexibleConstraints
=
True
,
rigidWater
=
True
):
"""
"""
Create an OpenMM System from an Amber prmtop file.
Create an OpenMM System from an Amber prmtop file.
...
@@ -520,8 +534,8 @@ def readAmberSystem(prmtop_filename=None, prmtop_loader=None, shake=None, gbmode
...
@@ -520,8 +534,8 @@ def readAmberSystem(prmtop_filename=None, prmtop_loader=None, shake=None, gbmode
soluteDielectric (float) - The solute dielectric constant to use in the implicit solvent model (default: 1.0)
soluteDielectric (float) - The solute dielectric constant to use in the implicit solvent model (default: 1.0)
solventDielectric (float) - The solvent dielectric constant to use in the implicit solvent model (default: 78.5)
solventDielectric (float) - The solvent dielectric constant to use in the implicit solvent model (default: 78.5)
nonbondedCutoff (float) - if specified, will set nonbondedCutoff (default: None)
nonbondedCutoff (float) - if specified, will set nonbondedCutoff (default: None)
scnb (float) - 1-4 Lennard-Jones scaling factor (default:
1.2
)
scnb (float) - 1-4 Lennard-Jones scaling factor (default:
taken from prmtop or 1.2 if not present there
)
scee (float) - 1-4 electrostatics scaling factor (default:
2.0
)
scee (float) - 1-4 electrostatics scaling factor (default:
taken from prmtop or 2.0 if not present there
)
mm - if specified, this module will be used in place of pyopenmm (default: None)
mm - if specified, this module will be used in place of pyopenmm (default: None)
verbose (boolean) - if True, print out information on progress (default: False)
verbose (boolean) - if True, print out information on progress (default: False)
flexibleConstraints (boolean) - if True, flexible bonds will be added in addition ot constrained bonds
flexibleConstraints (boolean) - if True, flexible bonds will be added in addition ot constrained bonds
...
@@ -571,6 +585,10 @@ def readAmberSystem(prmtop_filename=None, prmtop_loader=None, shake=None, gbmode
...
@@ -571,6 +585,10 @@ def readAmberSystem(prmtop_filename=None, prmtop_loader=None, shake=None, gbmode
if
prmtop
.
getIfBox
()
>
1
:
if
prmtop
.
getIfBox
()
>
1
:
raise
Exception
(
"only standard periodic boxes are currently supported"
)
raise
Exception
(
"only standard periodic boxes are currently supported"
)
if
prmtop
.
has_scee_scnb
and
(
scee
is
not
None
or
scnb
is
not
None
):
warnings
.
warn
(
"1-4 scaling parameters in topology file are being ignored. "
"This is not recommended unless you know what you are doing."
)
# Use pyopenmm implementation of OpenMM by default.
# Use pyopenmm implementation of OpenMM by default.
if
mm
is
None
:
if
mm
is
None
:
mm
=
simtk
.
openmm
mm
=
simtk
.
openmm
...
@@ -615,7 +633,7 @@ def readAmberSystem(prmtop_filename=None, prmtop_loader=None, shake=None, gbmode
...
@@ -615,7 +633,7 @@ def readAmberSystem(prmtop_filename=None, prmtop_loader=None, shake=None, gbmode
if
shake
==
'h-angles'
:
if
shake
==
'h-angles'
:
numConstrainedBonds
=
system
.
getNumConstraints
()
numConstrainedBonds
=
system
.
getNumConstraints
()
atomConstraints
=
[[]]
*
system
.
getNumParticles
()
atomConstraints
=
[[]]
*
system
.
getNumParticles
()
for
i
in
range
(
system
.
getN
umConstrain
ts
()
):
for
i
in
range
(
n
umConstrain
edBonds
):
c
=
system
.
getConstraintParameters
(
i
)
c
=
system
.
getConstraintParameters
(
i
)
distance
=
c
[
2
].
value_in_unit
(
units
.
nanometer
)
distance
=
c
[
2
].
value_in_unit
(
units
.
nanometer
)
atomConstraints
[
c
[
0
]].
append
((
c
[
1
],
distance
))
atomConstraints
[
c
[
0
]].
append
((
c
[
1
],
distance
))
...
@@ -712,9 +730,12 @@ def readAmberSystem(prmtop_filename=None, prmtop_loader=None, shake=None, gbmode
...
@@ -712,9 +730,12 @@ def readAmberSystem(prmtop_filename=None, prmtop_loader=None, shake=None, gbmode
# Add 1-4 Interactions
# Add 1-4 Interactions
excludedAtomPairs
=
set
()
excludedAtomPairs
=
set
()
sigmaScale
=
2
**
(
-
1.
/
6.
)
sigmaScale
=
2
**
(
-
1.
/
6.
)
for
(
iAtom
,
lAtom
,
chargeProd
,
rMin
,
epsilon
)
in
prmtop
.
get14Interactions
():
_scee
,
_scnb
=
scee
,
scnb
chargeProd
/=
scee
for
(
iAtom
,
lAtom
,
chargeProd
,
rMin
,
epsilon
,
iScee
,
iScnb
)
in
prmtop
.
get14Interactions
():
epsilon
/=
scnb
if
scee
is
None
:
_scee
=
iScee
if
scnb
is
None
:
_scnb
=
iScnb
chargeProd
/=
_scee
epsilon
/=
_scnb
sigma
=
rMin
*
sigmaScale
sigma
=
rMin
*
sigmaScale
force
.
addException
(
iAtom
,
lAtom
,
chargeProd
,
sigma
,
epsilon
)
force
.
addException
(
iAtom
,
lAtom
,
chargeProd
,
sigma
,
epsilon
)
excludedAtomPairs
.
add
(
min
((
iAtom
,
lAtom
),
(
lAtom
,
iAtom
)))
excludedAtomPairs
.
add
(
min
((
iAtom
,
lAtom
),
(
lAtom
,
iAtom
)))
...
...
wrappers/python/simtk/openmm/app/pdbfile.py
View file @
925fc9d9
...
@@ -313,6 +313,56 @@ class PDBFile(object):
...
@@ -313,6 +313,56 @@ class PDBFile(object):
- topology (Topology) The Topology defining the molecular system being written
- topology (Topology) The Topology defining the molecular system being written
- file (file=stdout) A file to write the file to
- file (file=stdout) A file to write the file to
"""
"""
# Identify bonds that should be listed as CONECT records.
standardResidues
=
[
'ALA'
,
'ASN'
,
'CYS'
,
'GLU'
,
'HIS'
,
'LEU'
,
'MET'
,
'PRO'
,
'THR'
,
'TYR'
,
'ARG'
,
'ASP'
,
'GLN'
,
'GLY'
,
'ILE'
,
'LYS'
,
'PHE'
,
'SER'
,
'TRP'
,
'VAL'
,
'A'
,
'G'
,
'C'
,
'U'
,
'I'
,
'DA'
,
'DG'
,
'DC'
,
'DT'
,
'DI'
,
'HOH'
]
conectBonds
=
[]
for
atom1
,
atom2
in
topology
.
bonds
():
if
atom1
.
residue
.
name
not
in
standardResidues
or
atom2
.
residue
.
name
not
in
standardResidues
:
conectBonds
.
append
((
atom1
,
atom2
))
elif
atom1
.
name
==
'SG'
and
atom2
.
name
==
'SG'
and
atom1
.
residue
.
name
==
'CYS'
and
atom2
.
residue
.
name
==
'CYS'
:
conectBonds
.
append
((
atom1
,
atom2
))
if
len
(
conectBonds
)
>
0
:
# Work out the index used in the PDB file for each atom.
atomIndex
=
{}
nextAtomIndex
=
0
prevChain
=
None
for
chain
in
topology
.
chains
():
for
atom
in
chain
.
atoms
():
if
atom
.
residue
.
chain
!=
prevChain
:
nextAtomIndex
+=
1
prevChain
=
atom
.
residue
.
chain
atomIndex
[
atom
]
=
nextAtomIndex
nextAtomIndex
+=
1
# Record which other atoms each atom is bonded to.
atomBonds
=
{}
for
atom1
,
atom2
in
conectBonds
:
index1
=
atomIndex
[
atom1
]
index2
=
atomIndex
[
atom2
]
if
index1
not
in
atomBonds
:
atomBonds
[
index1
]
=
[]
if
index2
not
in
atomBonds
:
atomBonds
[
index2
]
=
[]
atomBonds
[
index1
].
append
(
index2
)
atomBonds
[
index2
].
append
(
index1
)
# Write the CONECT records.
for
index1
in
sorted
(
atomBonds
):
bonded
=
atomBonds
[
index1
]
while
len
(
bonded
)
>
4
:
print
>>
file
,
"CONECT%5d%5d%5d%5d"
%
(
index1
,
bonded
[
0
],
bonded
[
1
],
bonded
[
2
])
del
bonded
[:
4
]
line
=
"CONECT%5d"
%
index1
for
index2
in
bonded
:
line
=
"%s%5d"
%
(
line
,
index2
)
print
>>
file
,
line
print
>>
file
,
"END"
print
>>
file
,
"END"
...
...
wrappers/python/simtk/openmm/app/pdbreporter.py
View file @
925fc9d9
...
@@ -79,5 +79,6 @@ class PDBReporter(object):
...
@@ -79,5 +79,6 @@ class PDBReporter(object):
self
.
_nextModel
+=
1
self
.
_nextModel
+=
1
def
__del__
(
self
):
def
__del__
(
self
):
PDBFile
.
writeFooter
(
self
.
_topology
,
self
.
_out
)
if
self
.
_topology
is
not
None
:
PDBFile
.
writeFooter
(
self
.
_topology
,
self
.
_out
)
self
.
_out
.
close
()
self
.
_out
.
close
()
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