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
b8bf8fbd
"...ssh:/git@developer.sourcefind.cn:2222/tsoc/openmm.git" did not exist on "4e1e1b1162036a617d6ecadd5e218a799e0ecc6b"
Commit
b8bf8fbd
authored
Mar 28, 2012
by
Peter Eastman
Browse files
Lots of optimizations to creating systems from prmtop files
parent
689fd4d4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
20 deletions
+19
-20
wrappers/python/simtk/openmm/app/internal/amber_file_parser.py
...ers/python/simtk/openmm/app/internal/amber_file_parser.py
+19
-20
No files found.
wrappers/python/simtk/openmm/app/internal/amber_file_parser.py
View file @
b8bf8fbd
...
@@ -122,7 +122,9 @@ class PrmtopLoader(object):
...
@@ -122,7 +122,9 @@ class PrmtopLoader(object):
format
=
line
.
rstrip
()
format
=
line
.
rstrip
()
index0
=
format
.
index
(
'('
)
index0
=
format
.
index
(
'('
)
index1
=
format
.
index
(
')'
)
index1
=
format
.
index
(
')'
)
self
.
_raw_format
[
self
.
_flags
[
-
1
]]
=
format
[
index0
+
1
:
index1
]
format
=
format
[
index0
+
1
:
index1
]
m
=
FORMAT_RE_PATTERN
.
search
(
format
)
self
.
_raw_format
[
self
.
_flags
[
-
1
]]
=
(
format
,
m
.
group
(
1
),
m
.
group
(
2
),
m
.
group
(
3
),
m
.
group
(
4
))
elif
self
.
_flags
\
elif
self
.
_flags
\
and
'TITLE'
==
self
.
_flags
[
-
1
]
\
and
'TITLE'
==
self
.
_flags
[
-
1
]
\
and
not
self
.
_raw_data
[
'TITLE'
]:
and
not
self
.
_raw_data
[
'TITLE'
]:
...
@@ -132,8 +134,9 @@ class PrmtopLoader(object):
...
@@ -132,8 +134,9 @@ class PrmtopLoader(object):
(
format
,
numItems
,
itemType
,
(
format
,
numItems
,
itemType
,
itemLength
,
itemPrecision
)
=
self
.
_getFormat
(
flag
)
itemLength
,
itemPrecision
)
=
self
.
_getFormat
(
flag
)
iLength
=
int
(
itemLength
)
iLength
=
int
(
itemLength
)
line
=
line
.
rstrip
()
for
index
in
range
(
0
,
len
(
line
),
iLength
):
for
index
in
range
(
0
,
len
(
line
),
iLength
):
item
=
line
.
rstrip
()
[
index
:
index
+
iLength
]
item
=
line
[
index
:
index
+
iLength
]
if
item
:
if
item
:
self
.
_raw_data
[
flag
].
append
(
item
.
strip
())
self
.
_raw_data
[
flag
].
append
(
item
.
strip
())
fIn
.
close
()
fIn
.
close
()
...
@@ -141,10 +144,7 @@ class PrmtopLoader(object):
...
@@ -141,10 +144,7 @@ class PrmtopLoader(object):
def
_getFormat
(
self
,
flag
=
None
):
def
_getFormat
(
self
,
flag
=
None
):
if
not
flag
:
if
not
flag
:
flag
=
self
.
_flags
[
-
1
]
flag
=
self
.
_flags
[
-
1
]
format
=
self
.
_raw_format
[
flag
]
return
self
.
_raw_format
[
flag
]
m
=
FORMAT_RE_PATTERN
.
search
(
format
)
return
(
format
,
m
.
group
(
1
),
m
.
group
(
2
),
m
.
group
(
3
),
m
.
group
(
4
))
def
_getPointerValue
(
self
,
pointerLabel
):
def
_getPointerValue
(
self
,
pointerLabel
):
"""Return pointer value given pointer label
"""Return pointer value given pointer label
...
@@ -282,17 +282,14 @@ class PrmtopLoader(object):
...
@@ -282,17 +282,14 @@ class PrmtopLoader(object):
return
self
.
residuePointerDict
[
iAtom
]
return
self
.
residuePointerDict
[
iAtom
]
except
:
except
:
pass
pass
self
.
residuePointerDict
=
{}
resPointers
=
self
.
_raw_data
[
'RESIDUE_POINTER'
]
resPointers
=
self
.
_raw_data
[
'RESIDUE_POINTER'
]
iRes
=
len
(
resPointers
)
firstAtom
=
[
int
(
p
)
-
1
for
p
in
resPointers
]
for
ii
in
range
(
1
,
len
(
resPointers
)):
res
=
0
firstAtom
=
int
(
resPointers
[
ii
])
-
1
for
i
in
range
(
self
.
getNumAtoms
()):
if
firstAtom
>
iAtom
:
while
i
<
firstAtom
[
res
]:
iRes
=
ii
res
+=
1
break
self
.
residuePointerDict
[
i
]
=
res
try
:
self
.
residuePointerDict
[
iAtom
]
=
iRes
-
1
except
AttributeError
:
self
.
residuePointerDict
=
{
iAtom
:
iRes
-
1
}
return
self
.
residuePointerDict
[
iAtom
]
return
self
.
residuePointerDict
[
iAtom
]
def
getNonbondTerms
(
self
):
def
getNonbondTerms
(
self
):
...
@@ -699,30 +696,32 @@ def readAmberSystem(prmtop_filename=None, prmtop_loader=None, shake=None, gbmode
...
@@ -699,30 +696,32 @@ def readAmberSystem(prmtop_filename=None, prmtop_loader=None, shake=None, gbmode
force
.
setEwaldErrorTolerance
(
EwaldErrorTolerance
)
force
.
setEwaldErrorTolerance
(
EwaldErrorTolerance
)
# Add per-particle nonbonded parameters.
# Add per-particle nonbonded parameters.
sigmaScale
=
2
**
(
-
1.
/
6.
)
*
2.0
for
(
charge
,
(
rVdw
,
epsilon
))
in
zip
(
prmtop
.
getCharges
(),
prmtop
.
getNonbondTerms
()):
for
(
charge
,
(
rVdw
,
epsilon
))
in
zip
(
prmtop
.
getCharges
(),
prmtop
.
getNonbondTerms
()):
sigma
=
rVdw
*
2
**
(
-
1.
/
6.
)
*
2.0
sigma
=
rVdw
*
sigmaScale
force
.
addParticle
(
charge
,
sigma
,
epsilon
)
force
.
addParticle
(
charge
,
sigma
,
epsilon
)
# Add 1-4 Interactions
# Add 1-4 Interactions
excludedAtomPairs
=
set
()
excludedAtomPairs
=
set
()
sigmaScale
=
2
**
(
-
1.
/
6.
)
for
(
iAtom
,
lAtom
,
chargeProd
,
rMin
,
epsilon
)
in
prmtop
.
get14Interactions
():
for
(
iAtom
,
lAtom
,
chargeProd
,
rMin
,
epsilon
)
in
prmtop
.
get14Interactions
():
chargeProd
/=
scee
chargeProd
/=
scee
epsilon
/=
scnb
epsilon
/=
scnb
sigma
=
rMin
*
2
**
(
-
1.
/
6.
)
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
)))
# Add Excluded Atoms
# Add Excluded Atoms
excludedAtoms
=
prmtop
.
getExcludedAtoms
()
excludedAtoms
=
prmtop
.
getExcludedAtoms
()
excludeParams
=
(
0.0
*
units
.
elementary_charge
**
2
,
1.0
*
units
.
angstroms
,
0.0
*
units
.
kilocalories_per_mole
)
for
iAtom
in
range
(
prmtop
.
getNumAtoms
()):
for
iAtom
in
range
(
prmtop
.
getNumAtoms
()):
for
jAtom
in
excludedAtoms
[
iAtom
]:
for
jAtom
in
excludedAtoms
[
iAtom
]:
if
min
((
iAtom
,
jAtom
),
(
jAtom
,
iAtom
))
in
excludedAtomPairs
:
continue
if
min
((
iAtom
,
jAtom
),
(
jAtom
,
iAtom
))
in
excludedAtomPairs
:
continue
force
.
addException
(
iAtom
,
jAtom
,
0.0
*
units
.
elementary_charge
**
2
,
1.0
*
units
.
angstroms
,
0.0
*
units
.
kilocalories_per_mole
)
force
.
addException
(
iAtom
,
jAtom
,
excludeParams
[
0
],
excludeParams
[
1
],
excludeParams
[
2
]
)
system
.
addForce
(
force
)
system
.
addForce
(
force
)
# Add virtual sites for water.
# Add virtual sites for water.
epNames
=
[
'EP'
,
'LP'
]
epNames
=
[
'EP'
,
'LP'
]
ep
=
[
i
for
i
in
range
(
prmtop
.
getNumAtoms
())
if
isWater
[
i
]
and
prmtop
.
getAtomName
(
i
)[:
2
]
in
epNames
]
ep
=
[
i
for
i
in
range
(
prmtop
.
getNumAtoms
())
if
isWater
[
i
]
and
prmtop
.
getAtomName
(
i
)[:
2
]
in
epNames
]
if
len
(
ep
)
>
0
:
if
len
(
ep
)
>
0
:
...
...
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