Skip to content

Commit

Permalink
Split implict ins_code of atom_site and allow safe retrieval from bot…
Browse files Browse the repository at this point in the history
…h auth and label sequence schemes (2kny)
  • Loading branch information
yokochi47 committed Mar 1, 2024
1 parent f9aa80f commit 62a2de7
Show file tree
Hide file tree
Showing 14 changed files with 692 additions and 393 deletions.
106 changes: 105 additions & 1 deletion wwpdb/utils/nmr/NmrDpUtility.py
Original file line number Diff line number Diff line change
Expand Up @@ -24959,7 +24959,111 @@ def fill_cs_row(lp, index, _row, prefer_auth_atom_name, coord_atom_site, _seq_ke
else:
resolved = False

if not resolved:
if not resolved and has_auth_seq and row[auth_asym_id_col] == 'UNMAPPED': # 2kny: leave data as is

is_valid, cc_name, _ = self.__getChemCompNameAndStatusOf(comp_id)
comp_id_bmrb_only = not is_valid and cc_name is not None and 'processing site' in cc_name

chain_id = row[chain_id_col]
if chain_id in emptyValue:
chain_id = 'A'

if chain_id in copied_chain_ids:
continue

entity_id = None
if (self.__combined_mode or (self.__bmrb_only and self.__internal_mode)) and entity_id_col != -1:
try:
entity_id = int(row[entity_id_col])
except (ValueError, TypeError):
entity_id = None

seq_id = auth_seq_id

_row[1], _row[2], _row[3], _row[4], _row[5] = chain_id, entity_id, seq_id, seq_id, comp_id

# DAOTHER-9065
if details_col != -1 and row[details_col] == 'UNMAPPED':
if isinstance(_row[1], int) and str(_row[1]) in seq_id_offset_for_unmapped:
offset = None
if isinstance(_row[17], int):
offset = _row[3] - _row[17]
elif isinstance(_row[17], str) and _row[17].isdigit():
offset = _row[3] - int(_row[17])
if offset is not None and offset != seq_id_offset_for_unmapped[str(_row[1])]:
if isinstance(_row[17], int):
_row[3] = _row[17] + seq_id_offset_for_unmapped[str(_row[1])]
_row[4] = _row[3]
else:
_row[3] = int(_row[17]) + seq_id_offset_for_unmapped[str(_row[1])]
_row[4] = _row[3]
elif isinstance(_row[1], str) and _row[1] in seq_id_offset_for_unmapped:
offset = None
if isinstance(_row[17], int):
offset = _row[3] - _row[17]
elif isinstance(_row[17], str) and _row[17].isdigit():
offset = _row[3] - int(_row[17])
if offset is not None and offset != seq_id_offset_for_unmapped[_row[1]]:
if isinstance(_row[17], int):
_row[3] = _row[17] + seq_id_offset_for_unmapped[_row[1]]
_row[4] = _row[3]
else:
_row[3] = int(_row[17]) + seq_id_offset_for_unmapped[_row[1]]
_row[4] = _row[3]
elif trial == 0:
regenerate_request = True

atom_ids = self.__getAtomIdListInXplor(comp_id, atom_id)
if len(atom_ids) == 0 or atom_ids[0] not in self.__csStat.getAllAtoms(comp_id):
atom_ids = self.__getAtomIdListInXplor(comp_id, translateToStdAtomName(atom_id, comp_id, ccU=self.__ccU))
len_atom_ids = len(atom_ids)
if len_atom_ids == 0 or comp_id_bmrb_only:
_row[6] = atom_id
_row[7] = 'H' if atom_id[0] in pseProBeginCode else atom_id[0]
if _row[7] in ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS:
_row[8] = ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS[_row[7]][0]
else:
_row[6] = atom_ids[0]
_row[19] = None
fill_auth_atom_id = _row[18] not in emptyValue
if self.__ccU.updateChemCompDict(comp_id):
cca = next((cca for cca in self.__ccU.lastAtomList if cca[self.__ccU.ccaAtomId] == _row[6]), None)
if cca is not None:
_row[7] = cca[self.__ccU.ccaTypeSymbol]
if _row[7] in ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS:
_row[8] = ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS[_row[7]][0]
else:
_row[7] = 'H' if _row[6][0] in protonBeginCode else atom_id[0]
if _row[7] in ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS:
_row[8] = ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS[_row[7]][0]
else:
_row[7] = 'H' if atom_id[0] in pseProBeginCode else atom_id[0]
if _row[7] in ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS:
_row[8] = ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS[_row[7]][0]

if len_atom_ids > 1:
__row = copy.copy(_row)
lp.add_data(__row)

for _atom_id in atom_ids[1:-1]:
__row = copy.copy(_row)

index += 1

__row[0] = index
__row[6] = _atom_id

lp.add_data(__row)

index += 1

_row[0] = index
_row[6] = atom_ids[-1]

if fill_auth_atom_id:
_row[19] = _row[6]

elif not resolved:

chain_id = row[chain_id_col]
if chain_id in emptyValue:
Expand Down
Loading

0 comments on commit 62a2de7

Please sign in to comment.