Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
openstructure
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
schwede
openstructure
Commits
88fd1fd1
Commit
88fd1fd1
authored
12 years ago
by
Bienchen
Browse files
Options
Downloads
Patches
Plain Diff
Fixing PDBize
parent
103cf37e
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/io/pymod/__init__.py
+94
-89
94 additions, 89 deletions
modules/io/pymod/__init__.py
modules/io/tests/test_io_mmcif.py
+1
-1
1 addition, 1 deletion
modules/io/tests/test_io_mmcif.py
with
95 additions
and
90 deletions
modules/io/pymod/__init__.py
+
94
−
89
View file @
88fd1fd1
...
@@ -357,105 +357,110 @@ def _PDBize(biounit, asu, seqres=None, min_polymer_size=10,
...
@@ -357,105 +357,110 @@ def _PDBize(biounit, asu, seqres=None, min_polymer_size=10,
return
atom_pos_wrong
return
atom_pos_wrong
chain_names
=
'
ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz
'
chain_names
=
'
ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz
'
cur_chain_name
=
0
water_chain
=
mol
.
ChainHandle
()
ligand_chain
=
mol
.
ChainHandle
()
a_pos_wrong
=
False
pdb_bu
=
mol
.
CreateEntity
()
edi
=
pdb_bu
.
EditXCS
(
mol
.
BUFFERED_EDIT
)
chains
=
biounit
.
GetChainList
()
c_intvls
=
biounit
.
GetChainIntervalList
()
o_intvls
=
biounit
.
GetOperationsIntervalList
()
# create list of operations
# create list of operations
# for cartesian products, operations are stored in a list, multiplied with
# for cartesian products, operations are stored in a list, multiplied with
# the next list of operations and re-stored... until all lists of operations
# the next list of operations and re-stored... until all lists of operations
# are multiplied in an all-against-all manner.
# are multiplied in an all-against-all manner.
operations
=
biounit
.
GetOperations
()
operations
=
biounit
.
GetOperations
()
trans_matrices
=
list
()
for
i
in
range
(
0
,
len
(
c_intvls
)):
if
len
(
operations
)
>
0
:
trans_matrices
=
list
()
for
op
in
operations
[
0
]:
l_operations
=
operations
[
o_intvls
[
i
][
0
]:
o_intvls
[
i
][
1
]]
rot
=
geom
.
Mat4
()
if
len
(
l_operations
)
>
0
:
rot
.
PasteRotation
(
op
.
rotation
)
for
op
in
l_operations
[
0
]:
trans
=
geom
.
Mat4
()
trans
.
PasteTranslation
(
op
.
translation
)
tr
=
geom
.
Mat4
()
tr
=
trans
*
rot
trans_matrices
.
append
(
tr
)
for
op_n
in
range
(
1
,
len
(
operations
)):
tmp_ops
=
list
()
for
o
in
operations
[
op_n
]:
rot
=
geom
.
Mat4
()
rot
=
geom
.
Mat4
()
rot
.
PasteRotation
(
o
.
rotation
)
rot
.
PasteRotation
(
o
p
.
rotation
)
trans
=
geom
.
Mat4
()
trans
=
geom
.
Mat4
()
trans
.
PasteTranslation
(
o
.
translation
)
trans
.
PasteTranslation
(
o
p
.
translation
)
tr
=
geom
.
Mat4
()
tr
=
geom
.
Mat4
()
tr
=
trans
*
rot
tr
=
trans
*
rot
for
t_o
in
trans_matrices
:
trans_matrices
.
append
(
tr
)
tp
=
t_o
*
tr
for
op_n
in
range
(
1
,
len
(
l_operations
)):
tmp_ops
.
append
(
tp
)
tmp_ops
=
list
()
trans_matrices
=
tmp_ops
for
o
in
l_operations
[
op_n
]:
# select chains into a view as basis for each transformation
rot
=
geom
.
Mat4
()
assu
=
asu
.
Select
(
'
cname=
'
+
'
,
'
.
join
(
biounit
.
GetChainList
()))
rot
.
PasteRotation
(
o
.
rotation
)
# use each transformation on the view, store as entity and transform, PDBize
trans
=
geom
.
Mat4
()
# the result while adding everything to one large entity
trans
.
PasteTranslation
(
o
.
translation
)
pdb_bu
=
mol
.
CreateEntity
()
tr
=
geom
.
Mat4
()
edi
=
pdb_bu
.
EditXCS
(
mol
.
BUFFERED_EDIT
)
tr
=
trans
*
rot
cur_chain_name
=
0
for
t_o
in
trans_matrices
:
water_chain
=
mol
.
ChainHandle
()
tp
=
t_o
*
tr
ligand_chain
=
mol
.
ChainHandle
()
tmp_ops
.
append
(
tp
)
a_pos_wrong
=
False
trans_matrices
=
tmp_ops
for
tr
in
trans_matrices
:
# select chains into a view as basis for each transformation
# do a PDBize, add each new entity to the end product
assu
=
asu
.
Select
(
'
cname=
'
+
'
,
'
.
join
(
chains
[
c_intvls
[
i
][
0
]:
c_intvls
[
i
][
1
]]))
for
chain
in
assu
.
chains
:
# use each transformation on the view, store as entity and transform, PDBize
residue_count
=
len
(
chain
.
residues
)
# the result while adding everything to one large entity
if
seqres
:
for
tr
in
trans_matrices
:
seqres_chain
=
seqres
.
FindSequence
(
chain
.
name
)
# do a PDBize, add each new entity to the end product
if
seqres_chain
.
IsValid
():
for
chain
in
assu
.
chains
:
residue_count
=
len
(
seqres_chain
)
residue_count
=
len
(
chain
.
residues
)
if
chain
.
is_polymer
and
residue_count
>=
min_polymer_size
:
if
seqres
:
if
len
(
chain_names
)
==
cur_chain_name
:
seqres_chain
=
seqres
.
FindSequence
(
chain
.
name
)
raise
RuntimeError
(
'
Running out of chain names
'
)
if
seqres_chain
.
IsValid
():
new_chain
=
edi
.
InsertChain
(
chain_names
[
cur_chain_name
])
residue_count
=
len
(
seqres_chain
)
cur_chain_name
+=
1
if
chain
.
is_polymer
and
residue_count
>=
min_polymer_size
:
edi
.
SetChainDescription
(
new_chain
,
chain
.
description
)
if
len
(
chain_names
)
==
cur_chain_name
:
edi
.
SetChainType
(
new_chain
,
chain
.
type
)
raise
RuntimeError
(
'
Running out of chain names
'
)
new_chain
.
SetStringProp
(
'
original_name
'
,
chain
.
name
)
new_chain
=
edi
.
InsertChain
(
chain_names
[
cur_chain_name
])
if
chain
.
HasProp
(
"
pdb_auth_chain_name
"
):
cur_chain_name
+=
1
new_chain
.
SetStringProp
(
"
pdb_auth_chain_name
"
,
edi
.
SetChainDescription
(
new_chain
,
chain
.
description
)
chain
.
GetStringProp
(
"
pdb_auth_chain_name
"
))
edi
.
SetChainType
(
new_chain
,
chain
.
type
)
for
res
in
chain
.
residues
:
new_chain
.
SetStringProp
(
'
original_name
'
,
chain
.
name
)
new_res
=
edi
.
AppendResidue
(
new_chain
,
res
.
name
,
res
.
number
)
a_b
=
_CopyAtoms
(
res
,
new_res
,
edi
,
tr
)
if
not
a_pos_wrong
:
a_pos_wrong
=
a_b
elif
chain
.
type
==
mol
.
CHAINTYPE_WATER
:
if
not
water_chain
.
IsValid
():
# water gets '-' as name
water_chain
=
edi
.
InsertChain
(
'
-
'
)
edi
.
SetChainDescription
(
water_chain
,
chain
.
description
)
edi
.
SetChainType
(
water_chain
,
chain
.
type
)
for
res
in
chain
.
residues
:
new_res
=
edi
.
AppendResidue
(
water_chain
,
res
.
name
)
new_res
.
SetStringProp
(
'
type
'
,
mol
.
StringFromChainType
(
chain
.
type
))
new_res
.
SetStringProp
(
'
description
'
,
chain
.
description
)
a_b
=
_CopyAtoms
(
res
,
new_res
,
edi
,
tr
)
if
not
a_pos_wrong
:
a_pos_wrong
=
a_b
else
:
if
not
ligand_chain
.
IsValid
():
# all ligands, put in one chain, are named '_'
ligand_chain
=
edi
.
InsertChain
(
'
_
'
)
last_rnum
=
0
else
:
last_rnum
=
ligand_chain
.
residues
[
-
1
].
number
.
num
residues
=
chain
.
residues
ins_code
=
'
\0
'
if
len
(
residues
)
>
1
:
ins_code
=
'
A
'
for
res
in
chain
.
residues
:
new_res
=
edi
.
AppendResidue
(
ligand_chain
,
res
.
name
,
mol
.
ResNum
(
last_rnum
+
1
,
ins_code
))
new_res
.
SetStringProp
(
'
description
'
,
chain
.
description
)
new_res
.
SetStringProp
(
'
type
'
,
mol
.
StringFromChainType
(
chain
.
type
))
new_res
.
SetStringProp
(
"
original_name
"
,
chain
.
name
)
if
chain
.
HasProp
(
"
pdb_auth_chain_name
"
):
if
chain
.
HasProp
(
"
pdb_auth_chain_name
"
):
new_res
.
SetStringProp
(
"
pdb_auth_chain_name
"
,
new_chain
.
SetStringProp
(
"
pdb_auth_chain_name
"
,
chain
.
GetStringProp
(
"
pdb_auth_chain_name
"
))
chain
.
GetStringProp
(
"
pdb_auth_chain_name
"
))
ins_code
=
chr
(
ord
(
ins_code
)
+
1
)
for
res
in
chain
.
residues
:
a_b
=
_CopyAtoms
(
res
,
new_res
,
edi
,
tr
)
new_res
=
edi
.
AppendResidue
(
new_chain
,
res
.
name
,
res
.
number
)
if
not
a_pos_wrong
:
a_b
=
_CopyAtoms
(
res
,
new_res
,
edi
,
tr
)
a_pos_wrong
=
a_b
if
not
a_pos_wrong
:
a_pos_wrong
=
a_b
elif
chain
.
type
==
mol
.
CHAINTYPE_WATER
:
if
not
water_chain
.
IsValid
():
# water gets '-' as name
water_chain
=
edi
.
InsertChain
(
'
-
'
)
edi
.
SetChainDescription
(
water_chain
,
chain
.
description
)
edi
.
SetChainType
(
water_chain
,
chain
.
type
)
for
res
in
chain
.
residues
:
new_res
=
edi
.
AppendResidue
(
water_chain
,
res
.
name
)
new_res
.
SetStringProp
(
'
type
'
,
mol
.
StringFromChainType
(
chain
.
type
))
new_res
.
SetStringProp
(
'
description
'
,
chain
.
description
)
a_b
=
_CopyAtoms
(
res
,
new_res
,
edi
,
tr
)
if
not
a_pos_wrong
:
a_pos_wrong
=
a_b
else
:
if
not
ligand_chain
.
IsValid
():
# all ligands, put in one chain, are named '_'
ligand_chain
=
edi
.
InsertChain
(
'
_
'
)
last_rnum
=
0
else
:
last_rnum
=
ligand_chain
.
residues
[
-
1
].
number
.
num
residues
=
chain
.
residues
ins_code
=
'
\0
'
if
len
(
residues
)
>
1
:
ins_code
=
'
A
'
for
res
in
chain
.
residues
:
new_res
=
edi
.
AppendResidue
(
ligand_chain
,
res
.
name
,
mol
.
ResNum
(
last_rnum
+
1
,
ins_code
))
new_res
.
SetStringProp
(
'
description
'
,
chain
.
description
)
new_res
.
SetStringProp
(
'
type
'
,
mol
.
StringFromChainType
(
chain
.
type
))
new_res
.
SetStringProp
(
"
original_name
"
,
chain
.
name
)
if
chain
.
HasProp
(
"
pdb_auth_chain_name
"
):
new_res
.
SetStringProp
(
"
pdb_auth_chain_name
"
,
chain
.
GetStringProp
(
"
pdb_auth_chain_name
"
))
ins_code
=
chr
(
ord
(
ins_code
)
+
1
)
a_b
=
_CopyAtoms
(
res
,
new_res
,
edi
,
tr
)
if
not
a_pos_wrong
:
a_pos_wrong
=
a_b
move_to_origin
=
None
move_to_origin
=
None
if
a_pos_wrong
:
if
a_pos_wrong
:
start
=
pdb_bu
.
bounds
.
min
start
=
pdb_bu
.
bounds
.
min
...
...
This diff is collapsed.
Click to expand it.
modules/io/tests/test_io_mmcif.py
+
1
−
1
View file @
88fd1fd1
...
@@ -201,7 +201,7 @@ class TestMMCifInfo(unittest.TestCase):
...
@@ -201,7 +201,7 @@ class TestMMCifInfo(unittest.TestCase):
pdb_ent
,
t
=
info
.
GetBioUnits
()[
0
].
PDBize
(
ent
,
transformation
=
True
)
pdb_ent
,
t
=
info
.
GetBioUnits
()[
0
].
PDBize
(
ent
,
transformation
=
True
)
self
.
assertAlmostEquals
(
pdb_ent
.
GetCenterOfAtoms
()[
0
],
-
915.8
,
1
)
self
.
assertAlmostEquals
(
pdb_ent
.
GetCenterOfAtoms
()[
0
],
-
915.8
,
1
)
self
.
assertAlmostEquals
(
pdb_ent
.
GetCenterOfAtoms
()[
1
],
-
952.345
,
2
)
self
.
assertAlmostEquals
(
pdb_ent
.
GetCenterOfAtoms
()[
1
],
-
952.345
,
2
)
self
.
assertAlmostEquals
(
pdb_ent
.
GetCenterOfAtoms
()[
2
],
3221.7
4
,
2
)
self
.
assertAlmostEquals
(
pdb_ent
.
GetCenterOfAtoms
()[
2
],
3221.7
5
,
2
)
self
.
assertEquals
(
geom
.
Equal
(
t
,
self
.
assertEquals
(
geom
.
Equal
(
t
,
geom
.
Mat4
(
1
,
0
,
0
,
-
920.462
,
geom
.
Mat4
(
1
,
0
,
0
,
-
920.462
,
0
,
1
,
0
,
-
966.654
,
0
,
1
,
0
,
-
966.654
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment