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
27471dd2
Commit
27471dd2
authored
Oct 15, 2013
by
peastman
Browse files
Write CONECT records to PDB files
parent
79e2fb0e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
1 deletion
+52
-1
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/pdbfile.py
View file @
27471dd2
...
...
@@ -313,6 +313,56 @@ class PDBFile(object):
- topology (Topology) The Topology defining the molecular system being written
- 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"
...
...
wrappers/python/simtk/openmm/app/pdbreporter.py
View file @
27471dd2
...
...
@@ -79,5 +79,6 @@ class PDBReporter(object):
self
.
_nextModel
+=
1
def
__del__
(
self
):
PDBFile
.
writeFooter
(
self
.
_topology
,
self
.
_out
)
if
self
.
_topology
is
not
None
:
PDBFile
.
writeFooter
(
self
.
_topology
,
self
.
_out
)
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