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
65a1f936
Unverified
Commit
65a1f936
authored
May 22, 2018
by
peastman
Committed by
GitHub
May 22, 2018
Browse files
Merge pull request #2079 from peastman/altloc
Handle PDB files with altlocs correctly
parents
553a96bf
d11c2f67
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
2 deletions
+66
-2
wrappers/python/simtk/openmm/app/pdbfile.py
wrappers/python/simtk/openmm/app/pdbfile.py
+2
-2
wrappers/python/tests/TestPdbFile.py
wrappers/python/tests/TestPdbFile.py
+7
-0
wrappers/python/tests/systems/altlocs.pdb
wrappers/python/tests/systems/altlocs.pdb
+57
-0
No files found.
wrappers/python/simtk/openmm/app/pdbfile.py
View file @
65a1f936
...
@@ -111,7 +111,7 @@ class PDBFile(object):
...
@@ -111,7 +111,7 @@ class PDBFile(object):
atomReplacements
=
PDBFile
.
_atomNameReplacements
[
resName
]
atomReplacements
=
PDBFile
.
_atomNameReplacements
[
resName
]
else
:
else
:
atomReplacements
=
{}
atomReplacements
=
{}
for
atom
in
residue
.
atoms
:
for
atom
in
residue
.
iter_
atoms
()
:
atomName
=
atom
.
get_name
()
atomName
=
atom
.
get_name
()
if
atomName
in
atomReplacements
:
if
atomName
in
atomReplacements
:
atomName
=
atomReplacements
[
atomName
]
atomName
=
atomReplacements
[
atomName
]
...
@@ -153,7 +153,7 @@ class PDBFile(object):
...
@@ -153,7 +153,7 @@ class PDBFile(object):
coords
=
[]
coords
=
[]
for
chain
in
model
.
iter_chains
():
for
chain
in
model
.
iter_chains
():
for
residue
in
chain
.
iter_residues
():
for
residue
in
chain
.
iter_residues
():
for
atom
in
residue
.
atoms
:
for
atom
in
residue
.
iter_
atoms
()
:
pos
=
atom
.
get_position
().
value_in_unit
(
nanometers
)
pos
=
atom
.
get_position
().
value_in_unit
(
nanometers
)
coords
.
append
(
Vec3
(
pos
[
0
],
pos
[
1
],
pos
[
2
]))
coords
.
append
(
Vec3
(
pos
[
0
],
pos
[
1
],
pos
[
2
]))
self
.
_positions
.
append
(
coords
*
nanometers
)
self
.
_positions
.
append
(
coords
*
nanometers
)
...
...
wrappers/python/tests/TestPdbFile.py
View file @
65a1f936
...
@@ -84,6 +84,13 @@ class TestPdbFile(unittest.TestCase):
...
@@ -84,6 +84,13 @@ class TestPdbFile(unittest.TestCase):
if
atom
.
index
>
2
:
if
atom
.
index
>
2
:
self
.
assertEqual
(
None
,
atom
.
element
)
self
.
assertEqual
(
None
,
atom
.
element
)
def
test_AltLocs
(
self
):
"""Test reading a file that includes AltLocs"""
pdb
=
PDBFile
(
'systems/altlocs.pdb'
)
self
.
assertEqual
(
1
,
pdb
.
topology
.
getNumResidues
())
self
.
assertEqual
(
19
,
pdb
.
topology
.
getNumAtoms
())
self
.
assertEqual
(
19
,
len
(
pdb
.
positions
))
self
.
assertEqual
(
'ILE'
,
list
(
pdb
.
topology
.
residues
())[
0
].
name
)
def
assertVecAlmostEqual
(
self
,
p1
,
p2
,
tol
=
1e-7
):
def
assertVecAlmostEqual
(
self
,
p1
,
p2
,
tol
=
1e-7
):
unit
=
p1
.
unit
unit
=
p1
.
unit
...
...
wrappers/python/tests/systems/altlocs.pdb
0 → 100644
View file @
65a1f936
ATOM 415 N AILE A 25 4.377 15.265 1.447 0.20 2.82 N
ATOM 416 N BILE A 25 4.377 15.265 1.447 0.20 2.82 N
ATOM 417 CA AILE A 25 3.033 14.786 1.800 0.20 2.71 C
ATOM 418 CA BILE A 25 3.033 14.786 1.800 0.20 2.71 C
ATOM 419 C AILE A 25 3.077 13.514 2.641 0.20 2.38 C
ATOM 420 C BILE A 25 3.077 13.514 2.641 0.20 2.38 C
ATOM 421 O AILE A 25 2.310 13.367 3.581 0.20 2.92 O
ATOM 422 O BILE A 25 2.310 13.367 3.581 0.20 2.92 O
ATOM 423 CB AILE A 25 2.186 14.577 0.518 0.20 2.90 C
ATOM 424 CB BILE A 25 2.186 14.577 0.518 0.20 2.90 C
ATOM 425 CG1AILE A 25 1.658 15.855 -0.086 0.20 2.48 C
ATOM 426 CG1BILE A 25 1.658 15.855 -0.086 0.20 2.48 C
ATOM 427 CG2AILE A 25 0.962 13.694 0.784 0.20 4.13 C
ATOM 428 CG2BILE A 25 0.962 13.694 0.784 0.20 4.13 C
ATOM 429 CD1AILE A 25 0.623 16.572 0.761 0.20 4.11 C
ATOM 430 CD1BILE A 25 1.222 15.717 -1.500 0.20 5.09 C
ATOM 431 H AILE A 25 4.728 15.070 0.644 0.20 1.70 H
ATOM 432 H BILE A 25 4.728 15.070 0.644 0.20 1.70 H
ATOM 433 HA AILE A 25 2.573 15.480 2.312 0.20 2.56 H
ATOM 434 HA BILE A 25 2.573 15.480 2.312 0.20 2.56 H
ATOM 435 HB AILE A 25 2.769 14.106 -0.118 0.20 3.37 H
ATOM 436 HB BILE A 25 2.769 14.106 -0.118 0.20 3.37 H
ATOM 437 HG12AILE A 25 2.432 16.460 -0.225 0.20 2.73 H
ATOM 438 HG12BILE A 25 1.075 16.325 0.437 0.20 3.30 H
ATOM 439 HG13AILE A 25 1.243 15.658 -0.968 0.20 2.96 H
ATOM 440 HG13BILE A 25 2.432 16.460 -0.225 0.20 2.73 H
ATOM 441 HG21AILE A 25 0.423 14.095 1.506 0.20 3.33 H
ATOM 442 HG21BILE A 25 0.423 14.095 1.506 0.20 3.33 H
ATOM 443 HG22AILE A 25 0.451 13.622 -0.059 0.20 3.57 H
ATOM 444 HG22BILE A 25 0.451 13.622 -0.059 0.20 3.57 H
ATOM 445 HG23AILE A 25 1.278 12.796 1.059 0.20 3.60 H
ATOM 446 HG23BILE A 25 1.278 12.796 1.059 0.20 3.60 H
ATOM 447 HD11AILE A 25 0.989 16.789 1.668 0.20 3.14 H
ATOM 448 HD11BILE A 25 0.515 15.030 -1.466 0.20 4.69 H
ATOM 449 HD12AILE A 25 0.344 17.402 0.282 0.20 3.79 H
ATOM 450 HD12BILE A 25 0.829 16.587 -1.836 0.20 4.59 H
ATOM 451 HD13AILE A 25 -0.170 15.974 0.843 0.20 2.83 H
ATOM 452 HD13BILE A 25 1.946 15.436 -2.128 0.20 4.44 H
ATOM 453 N CLEU A 25 4.377 15.265 1.447 0.60 2.82 N
ATOM 454 CA CLEU A 25 3.033 14.786 1.800 0.60 2.71 C
ATOM 455 C CLEU A 25 3.077 13.514 2.641 0.60 2.38 C
ATOM 456 O CLEU A 25 2.310 13.367 3.581 0.60 2.92 O
ATOM 457 CB CLEU A 25 2.186 14.577 0.518 0.60 2.90 C
ATOM 458 CG CLEU A 25 1.814 15.965 -0.117 0.60 4.43 C
ATOM 459 CD1CLEU A 25 1.222 15.717 -1.500 0.60 5.09 C
ATOM 460 CD2CLEU A 25 0.623 16.572 0.761 0.60 4.11 C
ATOM 461 H CLEU A 25 4.728 15.070 0.644 0.60 1.70 H
ATOM 462 HA CLEU A 25 2.573 15.480 2.312 0.60 2.56 H
ATOM 463 HB2CLEU A 25 2.832 14.186 -0.175 0.60 3.74 H
ATOM 464 HB3CLEU A 25 1.312 14.093 0.720 0.60 3.27 H
ATOM 465 HG CLEU A 25 2.617 16.584 -0.248 0.60 2.73 H
ATOM 466 HD11CLEU A 25 0.515 15.030 -1.466 0.60 4.69 H
ATOM 467 HD12CLEU A 25 0.829 16.587 -1.836 0.60 4.59 H
ATOM 468 HD13CLEU A 25 1.946 15.436 -2.128 0.60 4.44 H
ATOM 469 HD21CLEU A 25 -0.170 15.974 0.843 0.60 2.83 H
ATOM 470 HD22CLEU A 25 0.989 16.789 1.668 0.60 3.14 H
ATOM 471 HD23CLEU A 25 0.344 17.402 0.282 0.60 3.79 H
\ 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