Skip to content

Commit

Permalink
DAOTHER-9644: Minor code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
yokochi47 committed Aug 22, 2024
1 parent 597d73d commit d0374c7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
46 changes: 23 additions & 23 deletions wwpdb/utils/nmr/io/CifReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,27 +697,26 @@ def getPolymerSequence(self, catName, keyItems, withStructConf=False, withRmsd=F
repModelId = effModelIds[0] if effModelIds is not None else 1

# DAOTHER-9644: support for truncated loop in the model
if withRmsd: # avoid interference of ParserListenerUtils.coordAssemblyChecker()
if withRmsd and catName == 'pdbx_poly_seq_scheme': # avoid interference of ParserListenerUtils.coordAssemblyChecker()
misPolyLink = []
if catName == 'pdbx_poly_seq_scheme':

_catName = 'pdbx_validate_polymer_linkage'

if self.hasCategory(_catName):
_keyItems = [{'name': 'auth_asym_id_1', 'type': 'str', 'alt_name': 'auth_chain_id'},
{'name': 'auth_seq_id_1', 'type': 'int'},
{'name': 'auth_asym_id_2', 'type': 'str', 'alt_name': 'test_auth_chain_id'},
{'name': 'auth_seq_id_2', 'type': 'int'}
]
_filterItems = [{'name': 'PDB_model_num', 'type': 'int', 'value': repModelId},
{'name': 'label_alt_id_1', 'type': 'enum', 'enum': (repAltId,)},
{'name': 'label_alt_id_2', 'type': 'enum', 'enum': (repAltId,)}
]

for mis in self.getDictListWithFilter(_catName, _keyItems, _filterItems):
if mis['auth_chain_id'] == mis['test_auth_chain_id']:
del mis['test_auth_chain_id']
misPolyLink.append(mis)

_catName = 'pdbx_validate_polymer_linkage'

if self.hasCategory(_catName):
_keyItems = [{'name': 'auth_asym_id_1', 'type': 'str', 'alt_name': 'auth_chain_id'},
{'name': 'auth_seq_id_1', 'type': 'int'},
{'name': 'auth_asym_id_2', 'type': 'str', 'alt_name': 'test_auth_chain_id'},
{'name': 'auth_seq_id_2', 'type': 'int'}
]
_filterItems = [{'name': 'PDB_model_num', 'type': 'int', 'value': repModelId},
{'name': 'label_alt_id_1', 'type': 'enum', 'enum': (repAltId,)},
{'name': 'label_alt_id_2', 'type': 'enum', 'enum': (repAltId,)}
]

for mis in self.getDictListWithFilter(_catName, _keyItems, _filterItems):
if mis['auth_chain_id'] == mis['test_auth_chain_id']:
del mis['test_auth_chain_id']
misPolyLink.append(mis)

# get category object
catObj = self.__dBlock.getObj(catName)
Expand Down Expand Up @@ -880,8 +879,9 @@ def getPolymerSequence(self, catName, keyItems, withStructConf=False, withRmsd=F
etype = next((e['type'] for e in entity_poly if 'pdbx_strand_id' in e and c in e['pdbx_strand_id'].split(',')), None)

# DAOTHER-9644: support for truncated loop in the model
if withRmsd: # avoid interference of ParserListenerUtils.coordAssemblyChecker()
if len(misPolyLink) > 0 and len(authSeqDict) > 0:
if withRmsd and catName == 'pdbx_poly_seq_scheme' and len(authSeqDict) > 0: # avoid interference of ParserListenerUtils.coordAssemblyChecker()

if len(misPolyLink) > 0:

for mis in misPolyLink:

Expand Down Expand Up @@ -918,7 +918,7 @@ def getPolymerSequence(self, catName, keyItems, withStructConf=False, withRmsd=F
seqDict[c] = labelSeqDict[c] = list(range(1, len(authSeqDict[c]) + 1))

# DAOTHER-9644: simulate pdbx_poly_seq_scheme category
elif catName == 'pdbx_poly_seq_scheme' and len(authSeqDict) > 0 and etype is not None:
elif etype is not None:

if 'polypeptide' in etype:
BEG_ATOM = "C"
Expand Down
2 changes: 1 addition & 1 deletion wwpdb/utils/nmr/mr/ParserListenerUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -3564,7 +3564,7 @@ def to_np_array(a):
ps['seq_id'] = list(range(1, len(ps['auth_seq_id']) + 1))

# DAOTHER-9644: simulate pdbx_poly_seq_scheme category
elif not cR.hasCategory('pdbx_validate_polymer_linkage'):
else:

entity_poly = cR.getDictList('entity_poly')

Expand Down

0 comments on commit d0374c7

Please sign in to comment.