Skip to content

Commit

Permalink
Extract auth_mon_id as alt_cmop_id for reliable ligand assignment (6r14)
Browse files Browse the repository at this point in the history
  • Loading branch information
yokochi47 committed Mar 14, 2024
1 parent 7ac82f3 commit 0e941fe
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 20 deletions.
11 changes: 10 additions & 1 deletion wwpdb/utils/nmr/mr/AmberMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -4893,15 +4893,24 @@ def updateSanderAtomNumberDict(self, factor, cifCheck=True, useDefault=True):
if self.__hasNonPoly and self.__cur_subtype == 'dist':
for np in self.__nonPoly:
ligands += np['comp_id'].count(authCompId)
if ligands == 0:
for np in self.__nonPoly:
if 'alt_comp_id' in np:
ligands += np['alt_comp_id'].count(authCompId)

for np in self.__nonPolySeq:
chainId = np['auth_chain_id']

if factor['auth_seq_id'] in np['auth_seq_id'] or (ligands == 1 and authCompId in np['comp_id']):
if factor['auth_seq_id'] in np['auth_seq_id']\
or (ligands == 1 and (authCompId in np['comp_id'] or ('alt_comp_id' in np and authCompId in np['alt_comp_id']))):
if ligands == 1 and authCompId in np['comp_id']:
idx = np['comp_id'].index(authCompId)
seqId = np['seq_id'][idx]
compId = authCompId
elif ligands == 1 and 'alt_comp_id' in np and authCompId in np['alt_comp_id']:
idx = np['alt_comp_id'].index(authCompId)
seqId = np['seq_id'][idx]
compId = authCompId
else:
idx = np['auth_seq_id'].index(factor['auth_seq_id'])
seqId = np['seq_id'][idx]
Expand Down
25 changes: 25 additions & 0 deletions wwpdb/utils/nmr/mr/AmberPTParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,20 @@ def is_segment(prev_comp_id, prev_atom_name, comp_id, atom_name):
and (is_prev_3_prime_comp
or self.__csStat.peptideLike(translateToStdResName(prev_comp_id, ccU=self.__ccU)))

def is_ligand(prev_comp_id, comp_id):
if prev_comp_id is None or not self.__hasNonPolyModel:
return False
if not prev_comp_id.endswith('3'):
return False
for np in self.__nonPolyModel:
if comp_id in np['comp_id']:
return True
for np in self.__nonPolyModel:
if 'alt_comp_id' in np:
if comp_id in np['alt_comp_id']:
return True
return False

def is_metal_ion(comp_id, atom_name):
if comp_id is None:
return False
Expand Down Expand Up @@ -320,6 +334,7 @@ def is_metal_elem(prev_atom_name, prev_seq_id, seq_id):

if (terminus[atomNum - 1] and ancAtomName.endswith('T'))\
or is_segment(prevCompId, prevAtomName, compId, atomName)\
or is_ligand(prevCompId, compId)\
or is_metal_ion(compId, atomName)\
or is_metal_ion(prevCompId, prevAtomName)\
or is_metal_elem(prevAtomName, prevSeqId, _seqId):
Expand Down Expand Up @@ -410,6 +425,16 @@ def is_metal_elem(prev_atom_name, prev_seq_id, seq_id):
for atomNum in self.__atomNumberDict.values()
if atomNum['chain_id'] == chainId
and atomNum['seq_id'] == seqId])

if self.__hasNonPolyModel and compId != authCompId:
for np in self.__nonPolyModel:
if authCompId in np['comp_id']:
compId = authCompId
break
if 'alt_comp_id' in np and authCompId in np['alt_comp_id']:
compId = np['comp_id'][0]
break

if compId is not None:
compIdList.append(compId + '?') # decide when coordinate is available
chemCompAtomIds = None
Expand Down
8 changes: 6 additions & 2 deletions wwpdb/utils/nmr/mr/AriaMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,10 @@ def getRealChainSeqId(self, ps, seqId, compId, isPolySeq=True):
return _chainId, _seqId, ps['comp_id'][ps['seq_id'].index(seqId)]
if seqId in ps['auth_seq_id']:
for idx in [_idx for _idx, _seqId in enumerate(ps['auth_seq_id']) if _seqId == seqId]:
if compId in (ps['comp_id'][idx], ps['auth_comp_id'][idx], 'MTS', 'ORI'):
if 'alt_comp_id' in ps:
if compId in (ps['comp_id'][idx], ps['auth_comp_id'][idx], ps['alt_comp_id'][idx], 'MTS', 'ORI'):
return ps['auth_chain_id'], seqId, ps['comp_id'][idx]
elif compId in (ps['comp_id'][idx], ps['auth_comp_id'][idx], 'MTS', 'ORI'):
return ps['auth_chain_id'], seqId, ps['comp_id'][idx]
# if seqId in ps['seq_id']:
# idx = ps['seq_id'].index(seqId)
Expand Down Expand Up @@ -1600,7 +1603,8 @@ def selectCoordAtoms(self, chainAssign, seqId, compId, atomId, allowAmbig=True,

seqKey, coordAtomSite = self.getCoordAtomSiteOf(chainId, cifSeqId, cifCompId, asis=self.__preferAuthSeq)

if self.__cur_subtype == 'dist' and _compId is not None and (_compId.startswith('MTS') or _compId.startswith('ORI')) and cifCompId != _compId:
if self.__cur_subtype == 'dist' and _compId is not None\
and (_compId.startswith('MTS') or _compId.startswith('ORI')) and cifCompId != _compId:
if _atomId[0] in ('O', 'N'):

if cifCompId == 'CYS':
Expand Down
8 changes: 6 additions & 2 deletions wwpdb/utils/nmr/mr/BiosymMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,7 +1011,10 @@ def getRealChainSeqId(self, ps, seqId, compId, isPolySeq=True):
return _chainId, _seqId, ps['comp_id'][ps['seq_id'].index(seqId)]
if seqId in ps['auth_seq_id']:
for idx in [_idx for _idx, _seqId in enumerate(ps['auth_seq_id']) if _seqId == seqId]:
if compId in (ps['comp_id'][idx], ps['auth_comp_id'][idx], 'MTS', 'ORI'):
if 'alt_comp_id' in ps:
if compId in (ps['comp_id'][idx], ps['auth_comp_id'][idx], ps['alt_comp_id'][idx], 'MTS', 'ORI'):
return ps['auth_chain_id'], seqId, ps['comp_id'][idx]
elif compId in (ps['comp_id'][idx], ps['auth_comp_id'][idx], 'MTS', 'ORI'):
return ps['auth_chain_id'], seqId, ps['comp_id'][idx]
# if seqId in ps['seq_id']:
# idx = ps['seq_id'].index(seqId)
Expand Down Expand Up @@ -1424,7 +1427,8 @@ def selectCoordAtoms(self, chainAssign, seqId, compId, atomId, allowAmbig=True,

seqKey, coordAtomSite = self.getCoordAtomSiteOf(chainId, cifSeqId, cifCompId, asis=self.__preferAuthSeq)

if self.__cur_subtype == 'dist' and _compId is not None and (_compId.startswith('MTS') or _compId.startswith('ORI')) and cifCompId != _compId:
if self.__cur_subtype == 'dist' and _compId is not None\
and (_compId.startswith('MTS') or _compId.startswith('ORI')) and cifCompId != _compId:
if _atomId[0] in ('O', 'N'):

if cifCompId == 'CYS':
Expand Down
9 changes: 7 additions & 2 deletions wwpdb/utils/nmr/mr/CharmmMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -3536,13 +3536,18 @@ def __consumeFactor_expressions__(self, _factor, cifCheck, _atomSelection,
for np in self.__nonPoly:
if np['auth_chain_id'] == chainId and _factor['atom_id'][0].upper() == np['comp_id'][0]:
ligands += len(np['seq_id'])
if ligands == 0:
for np in self.__nonPoly:
if 'alt_comp_id' in np and np['auth_chain_id'] == chainId and _factor['atom_id'][0].upper() == np['alt_comp_id'][0]:
ligands += len(np['seq_id'])
if ligands == 1:
checked = False
if 'np_seq_id_remap' not in self.reasonsForReParsing:
self.reasonsForReParsing['np_seq_id_remap'] = {}
srcSeqId = _factor['seq_id'][0]
for np in self.__nonPoly:
if _factor['atom_id'][0].upper() == np['comp_id'][0]:
if _factor['atom_id'][0].upper() == np['comp_id'][0]\
or ('alt_comp_id' in np and _factor['atom_id'][0].upper() == np['alt_comp_id'][0]):
dstSeqId = np['auth_seq_id'][0]
if chainId not in self.reasonsForReParsing['np_seq_id_remap']:
self.reasonsForReParsing['np_seq_id_remap'][chainId] = {}
Expand Down Expand Up @@ -3655,7 +3660,7 @@ def getRealSeqId(self, ps, seqId, isPolySeq=True):
if _seqId in ps['auth_seq_id']:
return _seqId, ps['comp_id'][ps['seq_id'].index(seqId + offset)
if seqId + offset in ps['seq_id']
else ps['auth_seq_id'].index(seqId + offset)]
else ps['auth_seq_id'].index(_seqId)]
else:
if isPolySeq and self.__reasons is not None and 'global_auth_sequence_offset' in self.__reasons\
and ps['auth_chain_id'] in self.__reasons['global_auth_sequence_offset']:
Expand Down
9 changes: 7 additions & 2 deletions wwpdb/utils/nmr/mr/CnsMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -5778,13 +5778,18 @@ def __consumeFactor_expressions__(self, _factor, cifCheck, _atomSelection,
for np in self.__nonPoly:
if np['auth_chain_id'] == chainId and _factor['atom_id'][0].upper() == np['comp_id'][0]:
ligands += len(np['seq_id'])
if ligands == 0:
for np in self.__nonPoly:
if 'alt_comp_id' in np and np['auth_chain_id'] == chainId and _factor['atom_id'][0].upper() == np['alt_comp_id'][0]:
ligands += len(np['seq_id'])
if ligands == 1:
checked = False
if 'np_seq_id_remap' not in self.reasonsForReParsing:
self.reasonsForReParsing['np_seq_id_remap'] = {}
srcSeqId = _factor['seq_id'][0]
for np in self.__nonPoly:
if _factor['atom_id'][0].upper() == np['comp_id'][0]:
if _factor['atom_id'][0].upper() == np['comp_id'][0]\
or ('alt_comp_id' in np and _factor['atom_id'][0].upper() == np['alt_comp_id'][0]):
dstSeqId = np['auth_seq_id'][0]
if chainId not in self.reasonsForReParsing['np_seq_id_remap']:
self.reasonsForReParsing['np_seq_id_remap'][chainId] = {}
Expand Down Expand Up @@ -5897,7 +5902,7 @@ def getRealSeqId(self, ps, seqId, isPolySeq=True):
if _seqId in ps['auth_seq_id']:
return _seqId, ps['comp_id'][ps['seq_id'].index(seqId + offset)
if seqId + offset in ps['seq_id']
else ps['auth_seq_id'].index(seqId + offset)]
else ps['auth_seq_id'].index(_seqId)]
else:
if isPolySeq and self.__reasons is not None and 'global_auth_sequence_offset' in self.__reasons\
and ps['auth_chain_id'] in self.__reasons['global_auth_sequence_offset']:
Expand Down
8 changes: 6 additions & 2 deletions wwpdb/utils/nmr/mr/CyanaMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -2081,7 +2081,10 @@ def getRealChainSeqId(self, ps, seqId, compId=None, isPolySeq=True):
if compId is None:
return ps['auth_chain_id'], seqId, ps['auth_seq_id'][ps['auth_seq_id'].index(seqId)]
for idx in [_idx for _idx, _seqId in enumerate(ps['auth_seq_id']) if _seqId == seqId]:
if compId in (ps['comp_id'][idx], ps['auth_comp_id'][idx]):
if 'alt_comp_id' in ps:
if compId in (ps['comp_id'][idx], ps['auth_comp_id'][idx], ps['alt_comp_id'][idx]):
return ps['auth_chain_id'], seqId, ps['comp_id'][idx]
elif compId in (ps['comp_id'][idx], ps['auth_comp_id'][idx]):
return ps['auth_chain_id'], seqId, ps['comp_id'][idx]
# if seqId in ps['seq_id']:
# idx = ps['seq_id'].index(seqId)
Expand Down Expand Up @@ -3296,7 +3299,8 @@ def selectCoordAtoms(self, chainAssign, seqId, compId, atomId, allowAmbig=True,

seqKey, coordAtomSite = self.getCoordAtomSiteOf(chainId, cifSeqId, cifCompId, asis=self.__preferAuthSeq)

if self.__cur_subtype == 'dist' and _compId is not None and (_compId.startswith('MTS') or _compId.startswith('ORI')) and cifCompId != _compId:
if self.__cur_subtype == 'dist' and _compId is not None\
and (_compId.startswith('MTS') or _compId.startswith('ORI')) and cifCompId != _compId:
if _atomId[0] in ('O', 'N'):

if cifCompId == 'CYS':
Expand Down
8 changes: 6 additions & 2 deletions wwpdb/utils/nmr/mr/DynamoMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,10 @@ def getRealChainSeqId(self, ps, seqId, compId, isPolySeq=True):
return _chainId, _seqId, ps['comp_id'][ps['seq_id'].index(seqId)]
if seqId in ps['auth_seq_id']:
for idx in [_idx for _idx, _seqId in enumerate(ps['auth_seq_id']) if _seqId == seqId]:
if compId in (ps['comp_id'][idx], ps['auth_comp_id'][idx], 'MTS', 'ORI'):
if 'alt_comp_id' in ps:
if compId in (ps['comp_id'][idx], ps['auth_comp_id'][idx], ps['alt_comp_id'][idx], 'MTS', 'ORI'):
return ps['auth_chain_id'], seqId, ps['comp_id'][idx]
elif compId in (ps['comp_id'][idx], ps['auth_comp_id'][idx], 'MTS', 'ORI'):
return ps['auth_chain_id'], seqId, ps['comp_id'][idx]
# if seqId in ps['seq_id']:
# idx = ps['seq_id'].index(seqId)
Expand Down Expand Up @@ -1742,7 +1745,8 @@ def selectCoordAtoms(self, chainAssign, seqId, compId, atomId, allowAmbig=True,

seqKey, coordAtomSite = self.getCoordAtomSiteOf(chainId, cifSeqId, cifCompId, asis=self.__preferAuthSeq)

if self.__cur_subtype == 'dist' and _compId is not None and (_compId.startswith('MTS') or _compId.startswith('ORI')) and cifCompId != _compId:
if self.__cur_subtype == 'dist' and _compId is not None\
and (_compId.startswith('MTS') or _compId.startswith('ORI')) and cifCompId != _compId:
if _atomId[0] in ('O', 'N'):

if cifCompId == 'CYS':
Expand Down
25 changes: 25 additions & 0 deletions wwpdb/utils/nmr/mr/GromacsPTParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,20 @@ def is_segment(prev_comp_id, prev_atom_name, comp_id, atom_name):
and (is_prev_3_prime_comp
or self.__csStat.peptideLike(translateToStdResName(prev_comp_id, ccU=self.__ccU)))

def is_ligand(prev_comp_id, comp_id):
if prev_comp_id is None or not self.__hasNonPolyModel:
return False
if not prev_comp_id.endswith('3'):
return False
for np in self.__nonPolyModel:
if comp_id in np['comp_id']:
return True
for np in self.__nonPolyModel:
if 'alt_comp_id' in np:
if comp_id in np['alt_comp_id']:
return True
return False

def is_metal_ion(comp_id, atom_name):
if comp_id is None:
return False
Expand Down Expand Up @@ -266,6 +280,7 @@ def is_metal_elem(prev_atom_name, prev_seq_id, seq_id):

if (terminus[atomNum - 1] and ancAtomName.endswith('T'))\
or is_segment(prevCompId, prevAtomName, compId, atomName)\
or is_ligand(prevCompId, compId)\
or is_metal_ion(compId, atomName)\
or is_metal_ion(prevCompId, prevAtomName)\
or is_metal_elem(prevAtomName, prevSeqId, _seqId):
Expand Down Expand Up @@ -356,6 +371,16 @@ def is_metal_elem(prev_atom_name, prev_seq_id, seq_id):
for atomNum in self.__atomNumberDict.values()
if atomNum['chain_id'] == chainId
and atomNum['seq_id'] == seqId])

if self.__hasNonPolyModel and compId != authCompId:
for np in self.__nonPolyModel:
if authCompId in np['comp_id']:
compId = authCompId
break
if 'alt_comp_id' in np and authCompId in np['alt_comp_id']:
compId = np['comp_id'][0]
break

if compId is not None:
compIdList.append(compId + '?') # decide when coordinate is available
chemCompAtomIds = None
Expand Down
8 changes: 6 additions & 2 deletions wwpdb/utils/nmr/mr/IsdMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,10 @@ def getRealChainSeqId(self, ps, seqId, compId, isPolySeq=True):
return _chainId, _seqId, ps['comp_id'][ps['seq_id'].index(seqId)]
if seqId in ps['auth_seq_id']:
for idx in [_idx for _idx, _seqId in enumerate(ps['auth_seq_id']) if _seqId == seqId]:
if compId in (ps['comp_id'][idx], ps['auth_comp_id'][idx], 'MTS', 'ORI'):
if 'alt_comp_id' in ps:
if compId in (ps['comp_id'][idx], ps['auth_comp_id'][idx], ps['alt_comp_id'][idx], 'MTS', 'ORI'):
return ps['auth_chain_id'], seqId, ps['comp_id'][idx]
elif compId in (ps['comp_id'][idx], ps['auth_comp_id'][idx], 'MTS', 'ORI'):
return ps['auth_chain_id'], seqId, ps['comp_id'][idx]
# if seqId in ps['seq_id']:
# idx = ps['seq_id'].index(seqId)
Expand Down Expand Up @@ -1188,7 +1191,8 @@ def selectCoordAtoms(self, chainAssign, seqId, compId, atomId, allowAmbig=True,

seqKey, coordAtomSite = self.getCoordAtomSiteOf(chainId, cifSeqId, cifCompId, asis=self.__preferAuthSeq)

if self.__cur_subtype == 'dist' and _compId is not None and (_compId.startswith('MTS') or _compId.startswith('ORI')) and cifCompId != _compId:
if self.__cur_subtype == 'dist' and _compId is not None\
and (_compId.startswith('MTS') or _compId.startswith('ORI')) and cifCompId != _compId:
if _atomId[0] in ('O', 'N'):

if cifCompId == 'CYS':
Expand Down
Loading

0 comments on commit 0e941fe

Please sign in to comment.