Skip to content

Commit

Permalink
Get dictionary connecting label_asym_id with auth_asym_id
Browse files Browse the repository at this point in the history
  • Loading branch information
olegsobolev committed Dec 5, 2024
1 parent c0c7fa9 commit 082a702
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
5 changes: 5 additions & 0 deletions iotbx/pdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,11 @@ def input(

class pdb_input_mixin(object):

def label_to_auth_asym_id_dictionary(self):
""" Only avaliable for cif_input
"""
return None

def deposition_date(self, us_style=True):
"""
Placeholder to match mmCIF functionality. Probably could parse
Expand Down
7 changes: 6 additions & 1 deletion iotbx/pdb/mmcif.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,14 @@ def construct_hierarchy(self, set_atom_i_seq=True, sort_atoms=True):
if (set_atom_i_seq):
self.hierarchy.reset_atom_i_seqs()
self.hierarchy.atoms_reset_serial()

return self.hierarchy

def label_to_auth_asym_id_dictionary(self):
auth_asym = self.cif_block.get('_atom_site.auth_asym_id')
label_asym = self.cif_block.get('_atom_site.label_asym_id')
assert len(label_asym) == len(auth_asym)
return dict(zip(label_asym, auth_asym))

def source_info(self):
return self._source_info

Expand Down
11 changes: 9 additions & 2 deletions iotbx/regression/tst_mmcif_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
_atom_site.pdbx_PDB_model_num
ATOM 1 N N . GLY A 1 1 ? -9.009 4.612 6.102 1.00 16.77 ? 1 GLY A N 1
ATOM 2 C CA . GLY A 1 1 ? -9.052 4.207 4.651 1.00 16.57 ? 1 GLY A CA 1
ATOM 3 C C . GLY A 1 1 ? -8.015 3.140 4.419 1.00 16.16 ? 1 GLY A C 1
ATOM 4 O O . GLY A 1 1 ? -7.523 2.521 5.381 1.00 16.78 ? 1 GLY A O 1
ATOM 3 C C . GLY C 1 1 ? -8.015 3.140 4.419 1.00 16.16 ? 1 GLY CC C 1
ATOM 4 O O . GLY D 1 1 ? -7.523 2.521 5.381 1.00 16.78 ? 1 GLY DDDD O 1
"""


Expand All @@ -58,5 +58,12 @@ def exercise_extract_header_year(prefix="iotbx_tst_mmcif_segids"):
assert cif_inp_2.deposition_date() == '?'
assert cif_inp_2.extract_header_year() == None

def exercise_label_to_auth_asym_id_dictionary():
cif_inp = iotbx.pdb.input(lines=cif_str, source_info=None)
res = cif_inp.label_to_auth_asym_id_dictionary()
# print(res)
assert res == {'A': 'A', 'C': 'CC', 'D': 'DDDD'}, res

if __name__ == "__main__":
exercise_extract_header_year()
exercise_label_to_auth_asym_id_dictionary()

0 comments on commit 082a702

Please sign in to comment.