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
f9aae0bc
Unverified
Commit
f9aae0bc
authored
Jul 17, 2024
by
Peter Eastman
Committed by
GitHub
Jul 17, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed bug in added bonds to heterogens (#298)
parent
92044f3c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
3 deletions
+31
-3
pdbfixer/pdbfixer.py
+22
-3
pdbfixer/tests/test_mutate.py
+9
-0
No files found.
pdbfixer/pdbfixer.py
View file @
f9aae0bc
...
@@ -472,7 +472,7 @@ class PDBFixer(object):
...
@@ -472,7 +472,7 @@ class PDBFixer(object):
newAtoms
=
[]
newAtoms
=
[]
existingAtomMap
=
{}
existingAtomMap
=
{}
addedAtomMap
=
{}
addedAtomMap
=
{}
added
OXT
=
[]
added
HeterogenBonds
=
[]
residueCenters
=
[
self
.
_computeResidueCenter
(
res
)
.
value_in_unit
(
unit
.
nanometers
)
for
res
in
self
.
topology
.
residues
()]
*
unit
.
nanometers
residueCenters
=
[
self
.
_computeResidueCenter
(
res
)
.
value_in_unit
(
unit
.
nanometers
)
for
res
in
self
.
topology
.
residues
()]
*
unit
.
nanometers
for
chain
in
self
.
topology
.
chains
():
for
chain
in
self
.
topology
.
chains
():
if
omitUnknownMolecules
and
all
(
self
.
_getTemplate
(
residue
.
name
)
is
None
for
residue
in
chain
.
residues
()):
if
omitUnknownMolecules
and
all
(
self
.
_getTemplate
(
residue
.
name
)
is
None
for
residue
in
chain
.
residues
()):
...
@@ -535,6 +535,18 @@ class PDBFixer(object):
...
@@ -535,6 +535,18 @@ class PDBFixer(object):
addedAtomMap
[
residue
][
atom
]
=
newAtom
addedAtomMap
[
residue
][
atom
]
=
newAtom
templatePosition
=
template
.
positions
[
atom
.
index
]
.
value_in_unit
(
unit
.
nanometer
)
templatePosition
=
template
.
positions
[
atom
.
index
]
.
value_in_unit
(
unit
.
nanometer
)
newPositions
.
append
((
mm
.
Vec3
(
*
np
.
dot
(
rotate
,
templatePosition
+
translate2
))
+
translate1
)
*
unit
.
nanometer
)
newPositions
.
append
((
mm
.
Vec3
(
*
np
.
dot
(
rotate
,
templatePosition
+
translate2
))
+
translate1
)
*
unit
.
nanometer
)
if
residue
.
name
not
in
app
.
Topology
.
_standardBonds
:
# This is a heterogen. Make sure bonds will get added for any new atoms.
addedAtomNames
=
set
(
atom
.
name
for
atom
in
addedAtomMap
[
residue
])
newResidueAtoms
=
{
atom
.
name
:
atom
for
atom
in
newResidue
.
atoms
()}
for
atom1
,
atom2
in
template
.
topology
.
bonds
():
if
atom1
.
name
in
addedAtomNames
or
atom2
.
name
in
addedAtomNames
:
if
atom1
.
name
in
newResidueAtoms
and
atom2
.
name
in
newResidueAtoms
:
addedHeterogenBonds
.
append
((
newResidueAtoms
[
atom1
.
name
],
newResidueAtoms
[
atom2
.
name
]))
if
residue
in
self
.
missingTerminals
:
if
residue
in
self
.
missingTerminals
:
terminalsToAdd
=
self
.
missingTerminals
[
residue
]
terminalsToAdd
=
self
.
missingTerminals
[
residue
]
else
:
else
:
...
@@ -566,7 +578,6 @@ class PDBFixer(object):
...
@@ -566,7 +578,6 @@ class PDBFixer(object):
if
'OXT'
in
terminalsToAdd
:
if
'OXT'
in
terminalsToAdd
:
newAtom
=
newTopology
.
addAtom
(
'OXT'
,
oxygen
,
newResidue
)
newAtom
=
newTopology
.
addAtom
(
'OXT'
,
oxygen
,
newResidue
)
newAtoms
.
append
(
newAtom
)
newAtoms
.
append
(
newAtom
)
addedOXT
.
append
(
newAtom
)
d_ca_o
=
atomPositions
[
'O'
]
-
atomPositions
[
'CA'
]
d_ca_o
=
atomPositions
[
'O'
]
-
atomPositions
[
'CA'
]
d_ca_c
=
atomPositions
[
'C'
]
-
atomPositions
[
'CA'
]
d_ca_c
=
atomPositions
[
'C'
]
-
atomPositions
[
'CA'
]
d_ca_c
/=
unit
.
sqrt
(
unit
.
dot
(
d_ca_c
,
d_ca_c
))
d_ca_c
/=
unit
.
sqrt
(
unit
.
dot
(
d_ca_c
,
d_ca_c
))
...
@@ -576,12 +587,20 @@ class PDBFixer(object):
...
@@ -576,12 +587,20 @@ class PDBFixer(object):
newTopology
.
createStandardBonds
()
newTopology
.
createStandardBonds
()
newTopology
.
createDisulfideBonds
(
newPositions
)
newTopology
.
createDisulfideBonds
(
newPositions
)
# Add the bonds between atoms in heterogens.
# Add the
existing
bonds between atoms in heterogens.
for
a1
,
a2
in
self
.
topology
.
bonds
():
for
a1
,
a2
in
self
.
topology
.
bonds
():
if
a1
in
existingAtomMap
and
a2
in
existingAtomMap
and
(
a1
.
residue
.
name
not
in
app
.
Topology
.
_standardBonds
or
a2
.
residue
.
name
not
in
app
.
Topology
.
_standardBonds
):
if
a1
in
existingAtomMap
and
a2
in
existingAtomMap
and
(
a1
.
residue
.
name
not
in
app
.
Topology
.
_standardBonds
or
a2
.
residue
.
name
not
in
app
.
Topology
.
_standardBonds
):
newTopology
.
addBond
(
existingAtomMap
[
a1
],
existingAtomMap
[
a2
])
newTopology
.
addBond
(
existingAtomMap
[
a1
],
existingAtomMap
[
a2
])
# Add any new bonds within heterogens.
bonds
=
set
((
atom1
.
index
,
atom2
.
index
)
for
atom1
,
atom2
in
newTopology
.
bonds
())
for
atom1
,
atom2
in
addedHeterogenBonds
:
if
(
atom1
.
index
,
atom2
.
index
)
not
in
bonds
and
(
atom2
.
index
,
atom1
.
index
)
not
in
bonds
:
newTopology
.
addBond
(
atom1
,
atom2
)
bonds
.
add
((
atom1
.
index
,
atom2
.
index
))
# Return the results.
# Return the results.
return
(
newTopology
,
newPositions
,
newAtoms
,
existingAtomMap
)
return
(
newTopology
,
newPositions
,
newAtoms
,
existingAtomMap
)
...
...
pdbfixer/tests/test_mutate.py
View file @
f9aae0bc
...
@@ -90,3 +90,11 @@ def test_download_template():
...
@@ -90,3 +90,11 @@ def test_download_template():
atoms
=
list
(
residues
[
i
]
.
atoms
())
atoms
=
list
(
residues
[
i
]
.
atoms
())
assert
sum
(
1
for
a
in
atoms
if
a
.
element
==
app
.
element
.
phosphorus
)
==
1
assert
sum
(
1
for
a
in
atoms
if
a
.
element
==
app
.
element
.
phosphorus
)
==
1
assert
sum
(
1
for
a
in
atoms
if
a
.
name
==
'OXT'
)
==
(
1
if
i
==
134
else
0
)
assert
sum
(
1
for
a
in
atoms
if
a
.
name
==
'OXT'
)
==
(
1
if
i
==
134
else
0
)
# Check a few bonds to make sure the mutated residue has the ones it's supposed to.
bonds
=
list
(
residues
[
3
]
.
bonds
())
assert
sum
(
1
for
a1
,
a2
in
bonds
if
{
a1
.
name
,
a2
.
name
}
==
{
'N'
,
'CA'
})
==
1
assert
sum
(
1
for
a1
,
a2
in
bonds
if
{
a1
.
name
,
a2
.
name
}
==
{
'CB'
,
'OG'
})
==
1
assert
sum
(
1
for
a1
,
a2
in
bonds
if
{
a1
.
name
,
a2
.
name
}
==
{
'P'
,
'OG'
})
==
1
assert
sum
(
1
for
a1
,
a2
in
bonds
if
{
a1
.
name
,
a2
.
name
}
==
{
'P'
,
'O2P'
})
==
1
\ No newline at end of file
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