Skip to content

Commit

Permalink
Avoid converting incorrect residue name by simple string comparison (…
Browse files Browse the repository at this point in the history
…e.g. DA2 -> DA) (2lto)
  • Loading branch information
yokochi47 committed Mar 5, 2024
1 parent dc0c210 commit 06dfa63
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 19 deletions.
42 changes: 36 additions & 6 deletions wwpdb/utils/nmr/mr/AmberMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -4177,6 +4177,7 @@ def updateSanderAtomNumberDict(self, factor, cifCheck=True, useDefault=True):

hasAuthSeqScheme = self.__reasons is not None and 'auth_seq_scheme' in self.__reasons

_useDefault = useDefault
if self.__concatHetero and not hasAuthSeqScheme:
useDefault = False

Expand Down Expand Up @@ -4238,8 +4239,13 @@ def updateSanderAtomNumberDict(self, factor, cifCheck=True, useDefault=True):
seqId = factor['auth_seq_id'] + __offset
enforceAuthSeq = True

asis = False
_compId = translateToStdResName(authCompId, ccU=self.__ccU)
if authCompId in ps['comp_id'] and _compId != authCompId:
_compId = authCompId
asis = True

if self.__reasons is not None and 'chain_seq_id_remap' in self.__reasons:
_compId = translateToStdResName(authCompId, ccU=self.__ccU)
__chainId, __seqId = retrieveRemappedSeqId(self.__reasons['chain_seq_id_remap'], chainId, seqId,
_compId if _compId in monDict3 else None)
if __chainId is not None and __chainId != chainId:
Expand All @@ -4251,7 +4257,6 @@ def updateSanderAtomNumberDict(self, factor, cifCheck=True, useDefault=True):
enforceAuthSeq |= hasAuthSeqScheme\
and chainId in self.__reasons['auth_seq_scheme'] and self.__reasons['auth_seq_scheme'][chainId]

_compId = translateToStdResName(authCompId, ccU=self.__ccU)
if _compId in monDict3 and _compId not in ps['comp_id']:
continue

Expand All @@ -4265,7 +4270,7 @@ def updateSanderAtomNumberDict(self, factor, cifCheck=True, useDefault=True):
_, _, authAtomId = retrieveAtomIdentFromMRMap(self.__mrAtomNameMapping, seqId, origCompId, authAtomId, compId)

if (((authCompId in (compId, origCompId, 'None') or compId not in monDict3) and useDefault) or not useDefault)\
or compId == translateToStdResName(authCompId, compId, self.__ccU):
or compId == translateToStdResName(authCompId, compId, self.__ccU) or asis:
seqKey, coordAtomSite = self.getCoordAtomSiteOf(chainId, seqId if cifSeqId is None else cifSeqId, cifCheck=cifCheck,
asis=(not hasAuthSeqScheme or enforceAuthSeq or not self.__preferAuthSeq))
if coordAtomSite is not None and _authAtomId in coordAtomSite['atom_id']:
Expand Down Expand Up @@ -4495,6 +4500,16 @@ def updateSanderAtomNumberDict(self, factor, cifCheck=True, useDefault=True):
if found:
return True

elif not useDefault and _useDefault:
_ps = next((_ps for _ps in self.__polySeq if _ps['chain_id'] == chainId), None)
if _ps is not None and seqId in _ps['auth_seq_id']:
idx = _ps['auth_seq_id'].index(seqId)
compId = _ps['comp_id'][idx]
if compId == authCompId:
if 'auth_seq_scheme' not in self.reasonsForReParsing:
self.reasonsForReParsing['auth_seq_scheme'] = {}
self.reasonsForReParsing['auth_seq_scheme'][chainId] = True

if self.__hasNonPolySeq and (useDefault or (self.__concatHetero and not hasAuthSeqScheme)):

ligands = 0
Expand Down Expand Up @@ -4779,6 +4794,7 @@ def updateSanderAtomNumberDictWithAmbigCode(self, factor, cifCheck=True, useDefa

hasAuthSeqScheme = self.__reasons is not None and 'auth_seq_scheme' in self.__reasons

_useDefault = useDefault
if self.__concatHetero and not hasAuthSeqScheme:
useDefault = False

Expand Down Expand Up @@ -4849,8 +4865,13 @@ def updateSanderAtomNumberDictWithAmbigCode(self, factor, cifCheck=True, useDefa
seqId = factor['auth_seq_id'] + __offset
enforceAuthSeq = True

asis = False
_compId = translateToStdResName(authCompId, ccU=self.__ccU)
if authCompId in ps['comp_id'] and _compId != authCompId:
_compId = authCompId
asis = True

if self.__reasons is not None and 'chain_seq_id_remap' in self.__reasons:
_compId = translateToStdResName(authCompId, ccU=self.__ccU)
__chainId, __seqId = retrieveRemappedSeqId(self.__reasons['chain_seq_id_remap'], chainId, seqId,
_compId if _compId in monDict3 else None)
if __chainId is not None and __chainId != chainId:
Expand All @@ -4862,7 +4883,6 @@ def updateSanderAtomNumberDictWithAmbigCode(self, factor, cifCheck=True, useDefa
enforceAuthSeq |= hasAuthSeqScheme\
and chainId in self.__reasons['auth_seq_scheme'] and self.__reasons['auth_seq_scheme'][chainId]

_compId = translateToStdResName(authCompId, ccU=self.__ccU)
if _compId in monDict3 and _compId not in ps['comp_id']:
continue

Expand All @@ -4877,7 +4897,7 @@ def updateSanderAtomNumberDictWithAmbigCode(self, factor, cifCheck=True, useDefa
_, _, _authAtomId_ = retrieveAtomIdentFromMRMap(self.__mrAtomNameMapping, seqId, origCompId, authAtomId, compId)

if (((authCompId in (compId, origCompId, 'None') or compId not in monDict3) and useDefault) or not useDefault)\
or compId == translateToStdResName(authCompId, compId, self.__ccU):
or compId == translateToStdResName(authCompId, compId, self.__ccU) or asis:

seqKey, coordAtomSite = self.getCoordAtomSiteOf(chainId, seqId if cifSeqId is None else cifSeqId, cifCheck=cifCheck,
asis=(not hasAuthSeqScheme or enforceAuthSeq or not self.__preferAuthSeq))
Expand Down Expand Up @@ -5081,6 +5101,16 @@ def updateSanderAtomNumberDictWithAmbigCode(self, factor, cifCheck=True, useDefa
self.__f.append(f"[Atom not found] {self.__getCurrentRestraint()}"
f"{chainId}:{seqId}:{compId}:{authAtomId} is not present in the coordinates.")

elif not useDefault and _useDefault:
_ps = next((_ps for _ps in self.__polySeq if _ps['chain_id'] == chainId), None)
if _ps is not None and seqId in _ps['auth_seq_id']:
idx = _ps['auth_seq_id'].index(seqId)
compId = _ps['comp_id'][idx]
if compId == authCompId:
if 'auth_seq_scheme' not in self.reasonsForReParsing:
self.reasonsForReParsing['auth_seq_scheme'] = {}
self.reasonsForReParsing['auth_seq_scheme'][chainId] = True

if not found and self.__hasNonPolySeq and (useDefault or (self.__concatHetero and not hasAuthSeqScheme)):

for np in self.__nonPolySeq:
Expand Down
6 changes: 6 additions & 0 deletions wwpdb/utils/nmr/mr/AmberMRReader.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,12 @@ def parse(self, mrFilePath, cifFilePath=None, ptFilePath=None, isFilePath=True,


if __name__ == "__main__":
reader = AmberMRReader(True)
reader.setDebugMode(True)
reader.parse('../../tests-nmr/mock-data-remediation/2lto/2lto-corrected.mr',
'../../tests-nmr/mock-data-remediation/2lto/2lto.cif',
None)

reader = AmberMRReader(True)
reader.setDebugMode(True)
reader.parse('../../tests-nmr/mock-data-remediation/6e83/ang.rst',
Expand Down
6 changes: 3 additions & 3 deletions wwpdb/utils/nmr/mr/AriaMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ def assignCoordPolymerSequence(self, seqId, compId, atomId):

preferNonPoly = False

if compId in ('CYSZ','CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
if compId in ('CYSZ', 'CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
znCount = 0
znSeqId = None
for np in self.__nonPoly:
Expand Down Expand Up @@ -1184,7 +1184,7 @@ def assignCoordPolymerSequenceWithChainId(self, refChainId, seqId, compId, atomI

preferNonPoly = False

if compId in ('CYSZ','CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
if compId in ('CYSZ', 'CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
znCount = 0
znSeqId = None
for np in self.__nonPoly:
Expand Down Expand Up @@ -1554,7 +1554,7 @@ def selectCoordAtoms(self, chainAssign, seqId, compId, atomId, allowAmbig=True,
_compId = compId
_atomId = atomId

if compId in ('CYSZ','CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
if compId in ('CYSZ', 'CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
znCount = 0
znSeqId = None
for np in self.__nonPoly:
Expand Down
4 changes: 2 additions & 2 deletions wwpdb/utils/nmr/mr/BiosymMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ def assignCoordPolymerSequence(self, refChainId, seqId, compId, atomId):

preferNonPoly = False

if compId in ('CYSZ','CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
if compId in ('CYSZ', 'CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
znCount = 0
znSeqId = None
for np in self.__nonPoly:
Expand Down Expand Up @@ -1378,7 +1378,7 @@ def selectCoordAtoms(self, chainAssign, seqId, compId, atomId, allowAmbig=True,
_compId = compId
_atomId = atomId

if compId in ('CYSZ','CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
if compId in ('CYSZ', 'CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
znCount = 0
znSeqId = None
for np in self.__nonPoly:
Expand Down
4 changes: 2 additions & 2 deletions wwpdb/utils/nmr/mr/CyanaMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -2082,7 +2082,7 @@ def assignCoordPolymerSequence(self, seqId, compId, atomId):

preferNonPoly = False

if compId in ('CYSZ','CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
if compId in ('CYSZ', 'CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
znCount = 0
znSeqId = None
for np in self.__nonPoly:
Expand Down Expand Up @@ -2402,7 +2402,7 @@ def assignCoordPolymerSequenceWithChainId(self, refChainId, seqId, compId, atomI

preferNonPoly = False

if compId in ('CYSZ','CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
if compId in ('CYSZ', 'CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
znCount = 0
znSeqId = None
for np in self.__nonPoly:
Expand Down
4 changes: 2 additions & 2 deletions wwpdb/utils/nmr/mr/DynamoMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ def assignCoordPolymerSequence(self, refChainId, seqId, compId, atomId, index=No

preferNonPoly = False

if compId in ('CYSZ','CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
if compId in ('CYSZ', 'CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
znCount = 0
znSeqId = None
for np in self.__nonPoly:
Expand Down Expand Up @@ -1696,7 +1696,7 @@ def selectCoordAtoms(self, chainAssign, seqId, compId, atomId, allowAmbig=True,
_compId = compId
_atomId = atomId

if compId in ('CYSZ','CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
if compId in ('CYSZ', 'CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
znCount = 0
znSeqId = None
for np in self.__nonPoly:
Expand Down
4 changes: 2 additions & 2 deletions wwpdb/utils/nmr/mr/IsdMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,7 @@ def assignCoordPolymerSequence(self, seqId, compId, atomId):

preferNonPoly = False

if compId in ('CYSZ','CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
if compId in ('CYSZ', 'CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
znCount = 0
znSeqId = None
for np in self.__nonPoly:
Expand Down Expand Up @@ -1142,7 +1142,7 @@ def selectCoordAtoms(self, chainAssign, seqId, compId, atomId, allowAmbig=True,
_compId = compId
_atomId = atomId

if compId in ('CYSZ','CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
if compId in ('CYSZ', 'CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
znCount = 0
znSeqId = None
for np in self.__nonPoly:
Expand Down
4 changes: 2 additions & 2 deletions wwpdb/utils/nmr/mr/SybylMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ def assignCoordPolymerSequence(self, seqId, compId, atomId):

preferNonPoly = False

if compId in ('CYSZ','CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
if compId in ('CYSZ', 'CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
znCount = 0
znSeqId = None
for np in self.__nonPoly:
Expand Down Expand Up @@ -1148,7 +1148,7 @@ def selectCoordAtoms(self, chainAssign, seqId, compId, atomId, allowAmbig=True,
_compId = compId
_atomId = atomId

if compId in ('CYSZ','CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
if compId in ('CYSZ', 'CYZ', 'CYS') and atomId == 'ZN' and self.__hasNonPoly:
znCount = 0
znSeqId = None
for np in self.__nonPoly:
Expand Down

0 comments on commit 06dfa63

Please sign in to comment.