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
57f3be7e
Commit
57f3be7e
authored
Sep 25, 2017
by
peastman
Committed by
GitHub
Sep 25, 2017
Browse files
Merge pull request #1908 from JoaoRodrigues/asym_chain_fix
Fixed chain labeling in mmCIF files IO.
parents
f3e727df
8d59a6be
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
87 additions
and
13 deletions
+87
-13
wrappers/python/CMakeLists.txt
wrappers/python/CMakeLists.txt
+1
-0
wrappers/python/simtk/openmm/app/pdbxfile.py
wrappers/python/simtk/openmm/app/pdbxfile.py
+8
-13
wrappers/python/tests/TestPdbxFile.py
wrappers/python/tests/TestPdbxFile.py
+16
-0
wrappers/python/tests/systems/multichain.pdbx
wrappers/python/tests/systems/multichain.pdbx
+62
-0
No files found.
wrappers/python/CMakeLists.txt
View file @
57f3be7e
...
...
@@ -55,6 +55,7 @@ foreach(SUBDIR ${SUBDIRS})
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SUBDIR
}
/*.xml"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SUBDIR
}
/*.pdb"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SUBDIR
}
/*.pdbx"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SUBDIR
}
/*.cif"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SUBDIR
}
/*.prmtop"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SUBDIR
}
/*.prm"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
SUBDIR
}
/*.inpcrd"
...
...
wrappers/python/simtk/openmm/app/pdbxfile.py
View file @
57f3be7e
...
...
@@ -80,13 +80,11 @@ class PDBxFile(object):
# Build the topology.
atomData
=
block
.
getObj
(
'atom_site'
)
atomNameCol
=
atomData
.
getAttributeIndex
(
'
label
_atom_id'
)
atomNameCol
=
atomData
.
getAttributeIndex
(
'
auth
_atom_id'
)
atomIdCol
=
atomData
.
getAttributeIndex
(
'id'
)
resNameCol
=
atomData
.
getAttributeIndex
(
'label_comp_id'
)
resIdCol
=
atomData
.
getAttributeIndex
(
'label_seq_id'
)
resNameCol
=
atomData
.
getAttributeIndex
(
'auth_comp_id'
)
resNumCol
=
atomData
.
getAttributeIndex
(
'auth_seq_id'
)
asymIdCol
=
atomData
.
getAttributeIndex
(
'label_asym_id'
)
chainIdCol
=
atomData
.
getAttributeIndex
(
'label_entity_id'
)
chainIdCol
=
atomData
.
getAttributeIndex
(
'auth_asym_id'
)
elementCol
=
atomData
.
getAttributeIndex
(
'type_symbol'
)
altIdCol
=
atomData
.
getAttributeIndex
(
'label_alt_id'
)
modelCol
=
atomData
.
getAttributeIndex
(
'pdbx_PDB_model_num'
)
...
...
@@ -95,12 +93,11 @@ class PDBxFile(object):
zCol
=
atomData
.
getAttributeIndex
(
'Cartn_z'
)
lastChainId
=
None
lastResId
=
None
lastAsymId
=
None
atomTable
=
{}
atomsInResidue
=
set
()
models
=
[]
for
row
in
atomData
.
getRowList
():
atomKey
=
((
row
[
res
Id
Col
],
row
[
asym
IdCol
],
row
[
atomNameCol
]))
atomKey
=
((
row
[
res
Num
Col
],
row
[
chain
IdCol
],
row
[
atomNameCol
]))
model
=
(
'1'
if
modelCol
==
-
1
else
row
[
modelCol
])
if
model
not
in
models
:
models
.
append
(
model
)
...
...
@@ -115,15 +112,13 @@ class PDBxFile(object):
if
lastChainId
!=
row
[
chainIdCol
]:
# The start of a new chain.
chain
=
top
.
addChain
(
row
[
asym
IdCol
])
chain
=
top
.
addChain
(
row
[
chain
IdCol
])
lastChainId
=
row
[
chainIdCol
]
lastResId
=
None
lastAsymId
=
None
if
lastResId
!=
row
[
resIdCol
]
or
lastAsymId
!=
row
[
asymIdCol
]
or
(
lastResId
==
'.'
and
row
[
atomNameCol
]
in
atomsInResidue
):
if
lastResId
!=
row
[
resNumCol
]
or
lastChainId
!=
row
[
chainIdCol
]
or
(
lastResId
==
'.'
and
row
[
atomNameCol
]
in
atomsInResidue
):
# The start of a new residue.
res
=
top
.
addResidue
(
row
[
resNameCol
],
chain
,
None
if
resNumCol
==
-
1
else
row
[
resNumCol
])
lastResId
=
row
[
resIdCol
]
lastAsymId
=
row
[
asymIdCol
]
lastResId
=
row
[
resNumCol
]
atomsInResidue
.
clear
()
element
=
None
try
:
...
...
@@ -139,7 +134,7 @@ class PDBxFile(object):
try
:
atom
=
atomTable
[
atomKey
]
except
KeyError
:
raise
ValueError
(
'Unknown atom %s in residue %s %s for model %s'
%
(
row
[
atomNameCol
],
row
[
resNameCol
],
row
[
res
Id
Col
],
model
))
raise
ValueError
(
'Unknown atom %s in residue %s %s for model %s'
%
(
row
[
atomNameCol
],
row
[
resNameCol
],
row
[
res
Num
Col
],
model
))
if
atom
.
index
!=
len
(
self
.
_positions
[
modelIndex
]):
raise
ValueError
(
'Atom %s for model %s does not match the order of atoms for model %s'
%
(
row
[
atomIdCol
],
model
,
models
[
0
]))
self
.
_positions
[
modelIndex
].
append
(
Vec3
(
float
(
row
[
xCol
]),
float
(
row
[
yCol
]),
float
(
row
[
zCol
]))
*
0.1
)
...
...
wrappers/python/tests/TestPdbxFile.py
View file @
57f3be7e
...
...
@@ -133,5 +133,21 @@ class TestPdbxFile(unittest.TestCase):
self
.
assertEqual
(
bond1
[
0
].
name
,
bond2
[
0
].
name
)
self
.
assertEqual
(
bond1
[
1
].
name
,
bond2
[
1
].
name
)
def
testMultiChain
(
self
):
"""Test reading and writing a file that includes multiple chains"""
cif_ori
=
PDBxFile
(
'systems/multichain.pdbx'
)
output
=
StringIO
()
PDBxFile
.
writeFile
(
cif_ori
.
topology
,
cif_ori
.
positions
,
output
,
keepIds
=
True
)
input
=
StringIO
(
output
.
getvalue
())
cif_new
=
PDBxFile
(
input
)
output
.
close
()
input
.
close
()
self
.
assertEqual
(
cif_ori
.
topology
.
getNumChains
(),
cif_new
.
topology
.
getNumChains
())
for
chain1
,
chain2
in
zip
(
cif_ori
.
topology
.
chains
(),
cif_new
.
topology
.
chains
()):
self
.
assertEqual
(
chain1
.
id
,
chain2
.
id
)
if
__name__
==
'__main__'
:
unittest
.
main
()
wrappers/python/tests/systems/multichain.pdbx
0 → 100644
View file @
57f3be7e
# dummy file with multiple chains
# fragment of 1brs
#
data_1brs_AD
_entry.id 1brs_AD
#
loop_
_atom_site.group_PDB
_atom_site.id
_atom_site.type_symbol
_atom_site.label_atom_id
_atom_site.label_alt_id
_atom_site.label_comp_id
_atom_site.label_asym_id
_atom_site.label_entity_id
_atom_site.label_seq_id
_atom_site.pdbx_PDB_ins_code
_atom_site.Cartn_x
_atom_site.Cartn_y
_atom_site.Cartn_z
_atom_site.occupancy
_atom_site.B_iso_or_equiv
_atom_site.pdbx_formal_charge
_atom_site.auth_asym_id
_atom_site.pdbx_PDB_model_num
ATOM 1 N N . VAL A 1 3 ? 16.783 48.812 26.447 1.00 30.15 0 A 1
ATOM 2 C CA . VAL A 1 3 ? 17.591 48.101 25.416 1.00 27.93 0 A 1
ATOM 3 C C . VAL A 1 3 ? 16.643 47.160 24.676 1.00 25.52 0 A 1
ATOM 4 O O . VAL A 1 3 ? 16.213 46.129 25.220 1.00 26.86 0 A 1
ATOM 5 C CB . VAL A 1 3 ? 18.813 47.329 25.940 1.00 28.10 0 A 1
ATOM 6 C CG1 . VAL A 1 3 ? 19.512 46.623 24.799 1.00 29.27 0 A 1
ATOM 7 C CG2 . VAL A 1 3 ? 19.838 48.188 26.670 1.00 28.76 0 A 1
ATOM 8 N N . ILE A 1 4 ? 16.327 47.509 23.466 1.00 23.19 0 A 1
ATOM 9 C CA . ILE A 1 4 ? 15.435 46.625 22.666 1.00 21.26 0 A 1
ATOM 10 C C . ILE A 1 4 ? 16.364 45.902 21.716 1.00 19.99 0 A 1
ATOM 11 O O . ILE A 1 4 ? 16.847 46.590 20.823 1.00 18.74 0 A 1
ATOM 12 C CB . ILE A 1 4 ? 14.415 47.516 21.981 1.00 22.04 0 A 1
ATOM 13 C CG1 . ILE A 1 4 ? 13.710 48.294 23.129 1.00 22.39 0 A 1
ATOM 14 C CG2 . ILE A 1 4 ? 13.485 46.762 21.052 1.00 19.05 0 A 1
ATOM 15 C CD1 . ILE A 1 4 ? 12.870 49.416 22.486 1.00 23.20 0 A 1
ATOM 16 N N . LYS D 2 1 ? 48.330 40.393 9.798 1.00 29.18 0 D 1
ATOM 17 C CA . LYS D 2 1 ? 47.401 39.287 9.370 1.00 29.51 0 D 1
ATOM 18 C C . LYS D 2 1 ? 47.507 38.911 7.890 1.00 28.30 0 D 1
ATOM 19 O O . LYS D 2 1 ? 47.126 39.582 6.905 1.00 28.68 0 D 1
ATOM 20 C CB . LYS D 2 1 ? 45.995 39.632 9.817 1.00 31.06 0 D 1
ATOM 21 C CG . LYS D 2 1 ? 44.801 38.778 9.587 1.00 34.24 0 D 1
ATOM 22 C CD . LYS D 2 1 ? 44.946 37.289 9.712 1.00 37.99 0 D 1
ATOM 23 C CE . LYS D 2 1 ? 44.733 36.789 11.137 1.00 39.74 0 D 1
ATOM 24 N NZ . LYS D 2 1 ? 44.858 35.301 11.250 1.00 39.95 1 D 1
ATOM 25 N N . LYS D 2 2 ? 48.047 37.742 7.642 1.00 26.22 0 D 1
ATOM 26 C CA . LYS D 2 2 ? 48.270 37.151 6.331 1.00 25.12 0 D 1
ATOM 27 C C . LYS D 2 2 ? 47.509 35.851 6.169 1.00 24.31 0 D 1
ATOM 28 O O . LYS D 2 2 ? 47.675 35.055 7.114 1.00 25.51 0 D 1
ATOM 29 C CB . LYS D 2 2 ? 49.764 36.810 6.325 1.00 25.77 0 D 1
ATOM 30 C CG . LYS D 2 2 ? 50.121 35.923 5.159 1.00 27.71 0 D 1
ATOM 31 C CD . LYS D 2 2 ? 50.197 36.783 3.916 1.00 28.44 0 D 1
ATOM 32 C CE . LYS D 2 2 ? 50.902 36.036 2.805 1.00 30.19 0 D 1
ATOM 33 N NZ . LYS D 2 2 ? 52.379 36.102 2.952 1.00 31.01 1 D 1
HETATM 34 O O . HOH G 3 111 ? 25.978 40.412 17.662 1.00 16.91 0 A 1
HETATM 35 O O . HOH G 3 112 ? 24.196 43.521 11.471 1.00 13.10 0 A 1
HETATM 36 O O . HOH J 3 91 ? 25.995 40.067 5.614 1.00 11.53 0 D 1
HETATM 37 O O . HOH J 3 92 ? 36.372 43.366 10.462 1.00 17.15 0 D 1
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