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
a700032d
Commit
a700032d
authored
Apr 03, 2013
by
Peter Eastman
Browse files
Added Topology.loadBondDefinitions()
parent
cd68d924
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
10 deletions
+26
-10
wrappers/python/simtk/openmm/app/topology.py
wrappers/python/simtk/openmm/app/topology.py
+26
-10
No files found.
wrappers/python/simtk/openmm/app/topology.py
View file @
a700032d
...
@@ -6,7 +6,7 @@ Simbios, the NIH National Center for Physics-Based Simulation of
...
@@ -6,7 +6,7 @@ Simbios, the NIH National Center for Physics-Based Simulation of
Biological Structures at Stanford, funded under the NIH Roadmap for
Biological Structures at Stanford, funded under the NIH Roadmap for
Medical Research, grant U54 GM072970. See https://simtk.org.
Medical Research, grant U54 GM072970. See https://simtk.org.
Portions copyright (c) 2012 Stanford University and the Authors.
Portions copyright (c) 2012
-2013
Stanford University and the Authors.
Authors: Peter Eastman
Authors: Peter Eastman
Contributors:
Contributors:
...
@@ -47,6 +47,7 @@ class Topology(object):
...
@@ -47,6 +47,7 @@ class Topology(object):
"""
"""
_standardBonds
=
{}
_standardBonds
=
{}
_hasLoadedStandardBonds
=
False
def
__init__
(
self
):
def
__init__
(
self
):
"""Create a new Topology object"""
"""Create a new Topology object"""
...
@@ -133,17 +134,32 @@ class Topology(object):
...
@@ -133,17 +134,32 @@ class Topology(object):
"""Set the dimensions of the crystallographic unit cell."""
"""Set the dimensions of the crystallographic unit cell."""
self
.
_unitCellDimensions
=
dimensions
self
.
_unitCellDimensions
=
dimensions
@
staticmethod
def
loadBondDefinitions
(
file
):
"""Load an XML file containing definitions of bonds that should be used by createStandardBonds().
The built in residues.xml file containing definitions for standard amino acids and nucleotides is loaded automatically.
This method can be used to load additional definitions for other residue types. They will then be used in subsequent
calls to createStandardBonds().
"""
tree
=
etree
.
parse
(
file
)
for
residue
in
tree
.
getroot
().
findall
(
'Residue'
):
bonds
=
[]
Topology
.
_standardBonds
[
residue
.
attrib
[
'name'
]]
=
bonds
for
bond
in
residue
.
findall
(
'Bond'
):
bonds
.
append
((
bond
.
attrib
[
'from'
],
bond
.
attrib
[
'to'
]))
def
createStandardBonds
(
self
):
def
createStandardBonds
(
self
):
"""Create bonds based on the atom and residue names for all standard residue types."""
"""Create bonds based on the atom and residue names for all standard residue types.
if
len
(
Topology
.
_standardBonds
)
==
0
:
# Load the standard bond defitions.
Definitions for standard amino acids and nucleotides are built in. You can call loadBondDefinitions() to load
additional definitions for other residue types.
"""
if
not
Topology
.
_hasLoadedStandardBonds
:
# Load the standard bond definitions.
tree
=
etree
.
parse
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'data'
,
'residues.xml'
))
Topology
.
loadBondDefinitions
(
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'data'
,
'residues.xml'
))
for
residue
in
tree
.
getroot
().
findall
(
'Residue'
):
Topology
.
_hasLoadedStandardBonds
=
True
bonds
=
[]
Topology
.
_standardBonds
[
residue
.
attrib
[
'name'
]]
=
bonds
for
bond
in
residue
.
findall
(
'Bond'
):
bonds
.
append
((
bond
.
attrib
[
'from'
],
bond
.
attrib
[
'to'
]))
for
chain
in
self
.
_chains
:
for
chain
in
self
.
_chains
:
# First build a map of atom names to atoms.
# First build a map of atom names to atoms.
...
...
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