Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pdbfixer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pdbfixer
Commits
e41a190b
Commit
e41a190b
authored
Feb 17, 2015
by
peastman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eliminated most dependence on PdbStructure
parent
ffa808a3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
40 deletions
+31
-40
pdbfixer/pdbfixer.py
+18
-20
pdbfixer/ui.py
+11
-18
tests/test_removechains.py
+2
-2
No files found.
pdbfixer/pdbfixer.py
View file @
e41a190b
...
...
@@ -6,7 +6,7 @@ Simbios, the NIH National Center for Physics-Based Simulation of
Biological Structures at Stanford, funded under the NIH Roadmap for
Medical Research, grant U54 GM072970. See https://simtk.org.
Portions copyright (c) 2013-201
4
Stanford University and the Authors.
Portions copyright (c) 2013-201
5
Stanford University and the Authors.
Authors: Peter Eastman
Contributors:
...
...
@@ -221,7 +221,6 @@ class PDBFixer(object):
self
.
pdb
=
app
.
PDBFile
(
structure
)
self
.
topology
=
self
.
pdb
.
topology
self
.
positions
=
self
.
pdb
.
positions
self
.
structureChains
=
list
(
self
.
structure
.
iter_chains
())
# Load the templates.
...
...
@@ -462,7 +461,6 @@ class PDBFixer(object):
modeller
.
delete
(
allChains
[
i
]
for
i
in
chainIndices
)
self
.
topology
=
modeller
.
topology
self
.
positions
=
modeller
.
positions
self
.
structureChains
=
[
self
.
structureChains
[
i
]
for
i
in
range
(
len
(
self
.
structureChains
))
if
i
not
in
chainIndices
]
return
...
...
@@ -481,17 +479,17 @@ class PDBFixer(object):
>>> missing_residues = fixer.missingResidues
"""
chains
=
[
c
for
c
in
self
.
structureChains
if
any
(
atom
.
record_name
==
'ATOM'
for
atom
in
c
.
iter_atoms
())
]
chains
=
[
c
for
c
in
self
.
topology
.
chains
()
if
len
(
list
(
c
.
residues
()))
>
0
]
chainWithGaps
=
{}
# Find the sequence of each chain, with gaps for missing residues.
for
chain
in
chains
:
minResidue
=
min
(
r
.
number
for
r
in
chain
.
iter_
residues
())
maxResidue
=
max
(
r
.
number
for
r
in
chain
.
iter_
residues
())
minResidue
=
min
(
int
(
r
.
id
)
for
r
in
chain
.
residues
())
maxResidue
=
max
(
int
(
r
.
id
)
for
r
in
chain
.
residues
())
residues
=
[
None
]
*
(
maxResidue
-
minResidue
+
1
)
for
r
in
chain
.
iter_
residues
():
residues
[
r
.
number
-
minResidue
]
=
r
.
get_name
()
for
r
in
chain
.
residues
():
residues
[
int
(
r
.
id
)
-
minResidue
]
=
r
.
name
chainWithGaps
[
chain
]
=
residues
# Try to find the chain that matches each sequence.
...
...
@@ -500,7 +498,7 @@ class PDBFixer(object):
chainOffset
=
{}
for
sequence
in
self
.
structure
.
sequences
:
for
chain
in
chains
:
if
chain
.
chain_
id
!=
sequence
.
chain_id
:
if
chain
.
id
!=
sequence
.
chain_id
:
continue
if
chain
in
chainSequence
:
continue
...
...
@@ -515,15 +513,15 @@ class PDBFixer(object):
# Now build the list of residues to add.
self
.
missingResidues
=
{}
for
structChain
,
topChain
in
zip
(
self
.
structureChains
,
self
.
topology
.
chains
()
):
if
structC
hain
in
chainSequence
:
offset
=
chainOffset
[
structC
hain
]
sequence
=
chainSequence
[
structC
hain
]
.
residues
gappedSequence
=
chainWithGaps
[
structC
hain
]
for
chain
in
self
.
topology
.
chains
(
):
if
c
hain
in
chainSequence
:
offset
=
chainOffset
[
c
hain
]
sequence
=
chainSequence
[
c
hain
]
.
residues
gappedSequence
=
chainWithGaps
[
c
hain
]
index
=
0
for
i
in
range
(
len
(
sequence
)):
if
i
<
offset
or
i
>=
len
(
gappedSequence
)
+
offset
or
gappedSequence
[
i
-
offset
]
is
None
:
key
=
(
topC
hain
.
index
,
index
)
key
=
(
c
hain
.
index
,
index
)
if
key
not
in
self
.
missingResidues
:
self
.
missingResidues
[
key
]
=
[]
residueName
=
sequence
[
i
]
...
...
@@ -556,16 +554,16 @@ class PDBFixer(object):
# Now add ones based on MODRES records.
modres
=
dict
(((
m
.
chain_id
,
m
.
number
,
m
.
residue_name
),
m
.
standard_name
)
for
m
in
self
.
structure
.
modified_residues
)
for
structChain
,
topChain
in
zip
(
self
.
structureChains
,
self
.
topology
.
chains
()
):
for
structResidue
,
topResidue
in
zip
(
structChain
.
iter_residues
(),
topChain
.
residues
()
):
key
=
(
structChain
.
chain_id
,
structResidue
.
number
,
structR
esidue
.
name
)
modres
=
dict
(((
m
.
chain_id
,
str
(
m
.
number
)
,
m
.
residue_name
),
m
.
standard_name
)
for
m
in
self
.
structure
.
modified_residues
)
for
chain
in
self
.
topology
.
chains
(
):
for
residue
in
chain
.
residues
(
):
key
=
(
chain
.
id
,
residue
.
id
,
r
esidue
.
name
)
if
key
in
modres
:
replacement
=
modres
[
key
]
if
replacement
==
'DU'
:
replacement
=
'DT'
if
replacement
in
self
.
templates
:
nonstandard
[
topR
esidue
]
=
replacement
nonstandard
[
r
esidue
]
=
replacement
self
.
nonstandardResidues
=
[(
r
,
nonstandard
[
r
])
for
r
in
sorted
(
nonstandard
,
key
=
lambda
r
:
r
.
index
)]
def
replaceNonstandardResidues
(
self
):
...
...
pdbfixer/ui.py
View file @
e41a190b
import
simtk.openmm.app
as
app
from
simtk.openmm.app.internal.pdbstructure
import
PdbStructure
import
simtk.unit
as
unit
from
pdbfixer
import
PDBFixer
,
substitutions
,
proteinResidues
,
dnaResidues
,
rnaResidues
import
uiserver
...
...
@@ -74,7 +73,7 @@ def addResiduesPageCallback(parameters, handler):
for
i
,
key
in
enumerate
(
keys
):
if
'add'
+
str
(
i
)
not
in
parameters
:
del
fixer
.
missingResidues
[
key
]
display
MissingAtom
sPage
()
display
ConvertResidue
sPage
()
def
convertResiduesPageCallback
(
parameters
,
handler
):
for
i
in
range
(
len
(
fixer
.
nonstandardResidues
)):
...
...
@@ -135,7 +134,7 @@ def displayDeleteChainsPage():
content
=
"DNA"
else
:
content
=
', '
.
join
(
set
(
residues
))
table
+=
' <tr><td>
%
d</td><td>
%
d</td><td>
%
s</td><td><input type="checkbox" name="include
%
d" checked></td></tr>
\n
'
%
(
chain
.
index
+
1
,
len
(
residues
),
content
,
i
)
table
+=
' <tr><td>
%
s</td><td>
%
d</td><td>
%
s</td><td><input type="checkbox" name="include
%
d" checked></td></tr>
\n
'
%
(
chain
.
id
,
len
(
residues
),
content
,
i
)
uiserver
.
setContent
(
header
+
loadHtmlFile
(
"removeChains.html"
)
%
(
numChains
,
table
))
def
displayAddResiduesPage
():
...
...
@@ -145,14 +144,16 @@ def displayAddResiduesPage():
displayConvertResiduesPage
()
return
table
=
""
chains
=
list
(
fixer
.
topology
.
chains
())
for
i
,
key
in
enumerate
(
sorted
(
fixer
.
missingResidues
)):
residues
=
fixer
.
missingResidues
[
key
]
chain
=
fixer
.
structureChains
[
key
[
0
]]
if
key
[
1
]
<
len
(
chain
.
residues
):
offset
=
chain
.
residues
[
key
[
1
]]
.
number
-
len
(
residues
)
-
1
chain
=
chains
[
key
[
0
]]
chainResidues
=
list
(
chain
.
residues
())
if
key
[
1
]
<
len
(
chainResidues
):
offset
=
int
(
chainResidues
[
key
[
1
]]
.
id
)
-
len
(
residues
)
-
1
else
:
offset
=
chain
.
residues
[
-
1
]
.
number
table
+=
' <tr><td>
%
d</td><td>
%
d to
%
d</td><td>
%
s</td><td><input type="checkbox" name="add
%
d" checked></td></tr>
\n
'
%
(
key
[
0
]
+
1
,
offset
+
1
,
offset
+
len
(
residues
),
', '
.
join
(
residues
),
i
)
offset
=
int
(
chainResidues
[
-
1
]
.
id
)
table
+=
' <tr><td>
%
s</td><td>
%
d to
%
d</td><td>
%
s</td><td><input type="checkbox" name="add
%
d" checked></td></tr>
\n
'
%
(
chain
.
id
,
offset
+
1
,
offset
+
len
(
residues
),
', '
.
join
(
residues
),
i
)
uiserver
.
setContent
(
header
+
loadHtmlFile
(
"addResidues.html"
)
%
table
)
def
displayConvertResiduesPage
():
...
...
@@ -161,10 +162,6 @@ def displayConvertResiduesPage():
if
len
(
fixer
.
nonstandardResidues
)
==
0
:
displayMissingAtomsPage
()
return
indexInChain
=
{}
for
structChain
,
topChain
in
zip
(
fixer
.
structureChains
,
fixer
.
topology
.
chains
()):
for
structResidue
,
topResidue
in
zip
(
structChain
.
iter_residues
(),
topChain
.
residues
()):
indexInChain
[
topResidue
]
=
structResidue
.
number
table
=
''
nucleotides
=
[
'DA'
,
'DC'
,
'DG'
,
'DT'
,
'A'
,
'C'
,
'G'
,
'T'
]
for
i
in
range
(
len
(
fixer
.
nonstandardResidues
)):
...
...
@@ -179,7 +176,7 @@ def displayConvertResiduesPage():
if
res
==
replaceWith
:
selected
=
' selected'
options
+=
'<option value="
%
s"
%
s>
%
s</option>'
%
(
res
,
selected
,
res
)
table
+=
' <tr><td>
%
d</td><td>
%
s
%
d</td><td><select name="residue
%
d">
%
s</select></td><td><input type="checkbox" name="convert
%
d" checked></td></tr>
\n
'
%
(
residue
.
chain
.
index
+
1
,
residue
.
name
,
indexInChain
[
residue
]
,
i
,
options
,
i
)
table
+=
' <tr><td>
%
s</td><td>
%
s
%
s</td><td><select name="residue
%
d">
%
s</select></td><td><input type="checkbox" name="convert
%
d" checked></td></tr>
\n
'
%
(
residue
.
chain
.
id
,
residue
.
name
,
residue
.
id
,
i
,
options
,
i
)
uiserver
.
setContent
(
header
+
loadHtmlFile
(
"convertResidues.html"
)
%
table
)
def
displayMissingAtomsPage
():
...
...
@@ -191,10 +188,6 @@ def displayMissingAtomsPage():
fixer
.
addMissingAtoms
()
displayAddHydrogensPage
()
return
indexInChain
=
{}
for
structChain
,
topChain
in
zip
(
fixer
.
structureChains
,
fixer
.
topology
.
chains
()):
for
structResidue
,
topResidue
in
zip
(
structChain
.
iter_residues
(),
topChain
.
residues
()):
indexInChain
[
topResidue
]
=
structResidue
.
number
table
=
""
for
residue
in
allResidues
:
atoms
=
[]
...
...
@@ -202,7 +195,7 @@ def displayMissingAtomsPage():
atoms
.
extend
(
atom
.
name
for
atom
in
fixer
.
missingAtoms
[
residue
])
if
residue
in
fixer
.
missingTerminals
:
atoms
.
extend
(
atom
for
atom
in
fixer
.
missingTerminals
[
residue
])
table
+=
' <tr><td>
%
d</td><td>
%
s
%
d</td><td>
%
s</td></tr>
\n
'
%
(
residue
.
chain
.
index
+
1
,
residue
.
name
,
indexInChain
[
residue
]
,
', '
.
join
(
atoms
))
table
+=
' <tr><td>
%
s</td><td>
%
s
%
s</td><td>
%
s</td></tr>
\n
'
%
(
residue
.
chain
.
id
,
residue
.
name
,
residue
.
id
,
', '
.
join
(
atoms
))
uiserver
.
setContent
(
header
+
loadHtmlFile
(
"addHeavyAtoms.html"
)
%
table
)
def
displayAddHydrogensPage
():
...
...
tests/test_removechains.py
View file @
e41a190b
...
...
@@ -9,7 +9,7 @@ def remove_chain_ids_and_verify(pdbid, chain_ids_to_remove, expected_chain_ids_r
# Remove specified chains.
fixer
.
removeChains
(
chainIds
=
chain_ids_to_remove
)
# Check to make sure asserted chains remain.
chain_ids_remaining
=
[
c
.
chain_id
for
c
in
fixer
.
structureChains
]
chain_ids_remaining
=
[
c
.
id
for
c
in
fixer
.
topology
.
chains
()
]
assert_items_equal
(
chain_ids_remaining
,
expected_chain_ids_remaining
)
def
test_removechain_ids
():
...
...
@@ -25,7 +25,7 @@ def remove_chain_indices_and_verify(pdbid, chain_indices_to_remove, expected_cha
# Remove specified chains.
fixer
.
removeChains
(
chainIndices
=
chain_indices_to_remove
)
# Check to make sure asserted chains remain.
chain_ids_remaining
=
[
c
.
chain_id
for
c
in
fixer
.
structureChains
]
chain_ids_remaining
=
[
c
.
id
for
c
in
fixer
.
topology
.
chains
()
]
assert_items_equal
(
chain_ids_remaining
,
expected_chain_ids_remaining
)
def
test_removechain_indices
():
...
...
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