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
9d054482
Commit
9d054482
authored
Sep 01, 2015
by
Chodera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Major mutation code cleanup
parent
2436468b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
17 deletions
+16
-17
pdbfixer/pdbfixer.py
+16
-17
No files found.
pdbfixer/pdbfixer.py
View file @
9d054482
...
@@ -742,41 +742,40 @@ class PDBFixer(object):
...
@@ -742,41 +742,40 @@ class PDBFixer(object):
index_to_old_name
=
dict
((
r
.
index
,
r
.
name
)
for
r
in
self
.
topology
.
residues
())
index_to_old_name
=
dict
((
r
.
index
,
r
.
name
)
for
r
in
self
.
topology
.
residues
())
index_to_new_residues
=
{}
index_to_new_residues
=
{}
chain_numbers
=
list
()
# NOTE: Multiple chains may have the same chainid, but must have unique resSeq entries.
resSeq_to_
index
=
dict
()
resSeq_to_
residue
=
dict
()
# resSeq_to_residue[resid] is the residue in the requested chain corresponding to residue identifier 'resid'
for
(
chain_number
,
chain
)
in
enumerate
(
self
.
topology
.
chains
()):
for
(
chain_number
,
chain
)
in
enumerate
(
self
.
topology
.
chains
()):
if
chain
.
id
==
chain_id
:
if
chain
.
id
==
chain_id
:
chain_numbers
.
append
(
chain_id
)
for
(
residue_number
,
residue
)
in
enumerate
(
chain
.
residues
()):
for
(
residue_number
,
residue
)
in
enumerate
(
chain
.
residues
()):
resSeq_to_
index
[
int
(
residue
.
id
)]
=
residue_number
resSeq_to_
residue
[
int
(
residue
.
id
)]
=
residue
residue_map
=
dict
()
# residue_map[residue] is the name of the new residue to mutate to, if a mutation is desired
for
mut_str
in
mutations
:
for
mut_str
in
mutations
:
old_name
,
resSeq
,
new_name
=
mut_str
.
split
(
"-"
)
old_name
,
resSeq
,
new_name
=
mut_str
.
split
(
"-"
)
resSeq
=
int
(
resSeq
)
resSeq
=
int
(
resSeq
)
index
=
resSeq_to_index
[
resSeq
]
if
index
not
in
index_to_old_nam
e
:
if
resSeq
not
in
resSeq_to_residu
e
:
raise
(
KeyError
(
"Cannot find
index
%
d in system!"
%
index
))
raise
(
KeyError
(
"Cannot find
chain
%
s residue
%
d in system!"
%
(
chain_id
,
resSeq
)
))
if
index_to_old_name
[
index
]
!=
old_name
:
residue
=
resSeq_to_residue
[
resSeq
]
# retrieve the requested residue
raise
(
ValueError
(
"You asked to mutate
%
s
%
d, but that residue is actually
%
s!"
%
(
old_name
,
index
,
index_to_old_name
[
index
])))
if
residue
.
name
!=
old_name
:
raise
(
ValueError
(
"You asked to mutate chain
%
s residue
%
d name
%
s, but that residue is actually
%
s!"
%
(
chain_id
,
resSeq
,
old_name
,
residue
.
name
)))
try
:
try
:
template
=
self
.
templates
[
new_name
]
template
=
self
.
templates
[
new_name
]
except
KeyError
:
except
KeyError
:
raise
(
KeyError
(
"Cannot find residue
%
s in template library!"
%
new_name
))
raise
(
KeyError
(
"Cannot find residue
%
s in template library!"
%
new_name
))
index_to_new_residues
[
index
]
=
new_name
# Store mutation
residue_map
[
residue
]
=
new_name
residue_map
=
[(
r
,
index_to_new_residues
[
r
.
index
])
for
r
in
self
.
topology
.
residues
()
if
r
.
index
in
index_to_new_residues
]
# If there are mutations to be made, make them.
if
len
(
residue_map
)
>
0
:
if
len
(
residue_map
)
>
0
:
deleteAtoms
=
[]
deleteAtoms
=
[]
# list of atoms to delete
# Find atoms that should be deleted.
# Find atoms that should be deleted.
for
residue
,
replaceWith
in
residue_map
.
iteritems
():
for
residue
,
replaceWith
in
residue_map
:
if
residue
.
chain
.
index
!=
chain_number
:
if
residue
.
chain
.
index
!=
chain_number
:
continue
# Only modify specified chain
continue
# Only modify specified chain
residue
.
name
=
replaceWith
residue
.
name
=
replaceWith
...
@@ -786,7 +785,7 @@ class PDBFixer(object):
...
@@ -786,7 +785,7 @@ class PDBFixer(object):
if
atom
.
element
in
(
None
,
hydrogen
)
or
atom
.
name
not
in
standardAtoms
:
if
atom
.
element
in
(
None
,
hydrogen
)
or
atom
.
name
not
in
standardAtoms
:
deleteAtoms
.
append
(
atom
)
deleteAtoms
.
append
(
atom
)
# Delete
them
.
# Delete
atoms queued to be deleted
.
modeller
=
app
.
Modeller
(
self
.
topology
,
self
.
positions
)
modeller
=
app
.
Modeller
(
self
.
topology
,
self
.
positions
)
modeller
.
delete
(
deleteAtoms
)
modeller
.
delete
(
deleteAtoms
)
self
.
topology
=
modeller
.
topology
self
.
topology
=
modeller
.
topology
...
...
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