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
b98273c7
"docs-source/usersguide/vscode:/vscode.git/clone" did not exist on "ccb83f1db93e6329cdcbb72f2210875b856fdbcd"
Commit
b98273c7
authored
Jan 01, 2016
by
John Chodera (MSKCC)
Browse files
Clean up interface for adding bonds to residue templates.
parent
24d1a213
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
5 deletions
+27
-5
wrappers/python/simtk/openmm/app/forcefield.py
wrappers/python/simtk/openmm/app/forcefield.py
+27
-5
No files found.
wrappers/python/simtk/openmm/app/forcefield.py
View file @
b98273c7
...
@@ -169,16 +169,14 @@ class ForceField(object):
...
@@ -169,16 +169,14 @@ class ForceField(object):
template
.
virtualSites
.
append
(
ForceField
.
_VirtualSiteData
(
site
,
atomIndices
))
template
.
virtualSites
.
append
(
ForceField
.
_VirtualSiteData
(
site
,
atomIndices
))
for
bond
in
residue
.
findall
(
'Bond'
):
for
bond
in
residue
.
findall
(
'Bond'
):
if
'atomName1'
in
bond
.
attrib
:
if
'atomName1'
in
bond
.
attrib
:
template
.
addBond
(
atomIndices
[
bond
.
attrib
[
'atomName1'
]
]
,
atomIndices
[
bond
.
attrib
[
'atomName2'
]
]
)
template
.
addBond
ByName
(
bond
.
attrib
[
'atomName1'
],
bond
.
attrib
[
'atomName2'
])
else
:
else
:
template
.
addBond
(
int
(
bond
.
attrib
[
'from'
]),
int
(
bond
.
attrib
[
'to'
]))
template
.
addBond
(
int
(
bond
.
attrib
[
'from'
]),
int
(
bond
.
attrib
[
'to'
]))
for
bond
in
residue
.
findall
(
'ExternalBond'
):
for
bond
in
residue
.
findall
(
'ExternalBond'
):
if
'atomName'
in
bond
.
attrib
:
if
'atomName'
in
bond
.
attrib
:
b
=
atomIndices
[
bond
.
attrib
[
'atomName'
]
]
template
.
addExternalBondByName
(
bond
.
attrib
[
'atomName'
]
)
else
:
else
:
b
=
int
(
bond
.
attrib
[
'from'
])
template
.
addExternalBond
(
int
(
bond
.
attrib
[
'from'
]))
template
.
externalBonds
.
append
(
b
)
template
.
atoms
[
b
].
externalBonds
+=
1
self
.
registerResidueTemplate
(
template
)
self
.
registerResidueTemplate
(
template
)
# Load force definitions
# Load force definitions
...
@@ -335,11 +333,35 @@ class ForceField(object):
...
@@ -335,11 +333,35 @@ class ForceField(object):
self
.
bonds
=
[]
self
.
bonds
=
[]
self
.
externalBonds
=
[]
self
.
externalBonds
=
[]
def
getAtomIndexByName
(
self
,
atom_name
):
"""Look up an atom index by atom name, providing a helpful error message if not found."""
for
(
index
,
atom
)
in
enumerate
(
self
.
atoms
):
if
atom
.
name
==
atom_name
:
return
index
# Provide a helpful error message if atom name not found.
msg
=
"Atom '%s' not found in residue template '%s'."
%
(
atom_name
,
self
.
name
)
msg
+=
"Possible names are: %s"
%
str
(
atomIndices
.
keys
())
raise
ValueError
(
msg
)
def
addBond
(
self
,
atom1
,
atom2
):
def
addBond
(
self
,
atom1
,
atom2
):
self
.
bonds
.
append
((
atom1
,
atom2
))
self
.
bonds
.
append
((
atom1
,
atom2
))
self
.
atoms
[
atom1
].
bondedTo
.
append
(
atom2
)
self
.
atoms
[
atom1
].
bondedTo
.
append
(
atom2
)
self
.
atoms
[
atom2
].
bondedTo
.
append
(
atom1
)
self
.
atoms
[
atom2
].
bondedTo
.
append
(
atom1
)
def
addBondByName
(
self
,
atom1_name
,
atom2_name
):
atom1
=
self
.
getAtomIndexByName
(
atom1_name
)
atom2
=
self
.
getAtomIndexByName
(
atom2_name
)
self
.
addBond
(
atom1
,
atom2
)
def
addExternalBond
(
self
,
atom_index
):
self
.
externalBonds
.
append
(
atom_index
)
self
.
atoms
[
atom_index
].
externalBonds
+=
1
def
addExternalBondByName
(
self
,
atom_name
):
atom
=
self
.
getAtomIndexByName
(
atom_name
)
self
.
addExternalBond
(
atom
)
class
_TemplateAtomData
:
class
_TemplateAtomData
:
"""Inner class used to encapsulate data about an atom in a residue template definition."""
"""Inner class used to encapsulate data about an atom in a residue template definition."""
def
__init__
(
self
,
name
,
type
,
element
,
parameters
=
{}):
def
__init__
(
self
,
name
,
type
,
element
,
parameters
=
{}):
...
...
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