Skip to content

Commit

Permalink
Reconciled fix of 6bvy and 5nwu
Browse files Browse the repository at this point in the history
  • Loading branch information
yokochi47 committed Mar 13, 2024
1 parent 4f1e734 commit 1efa488
Show file tree
Hide file tree
Showing 13 changed files with 811 additions and 190 deletions.
16 changes: 13 additions & 3 deletions wwpdb/utils/nmr/NEFTranslator/NEFTranslator.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@

try:
from wwpdb.utils.nmr.AlignUtil import (emptyValue, trueValue, monDict3,
protonBeginCode, pseProBeginCode,
protonBeginCode, pseProBeginCode, aminoProtonCode,
letterToDigit, indexToLetter)
from wwpdb.utils.nmr.ChemCompUtil import ChemCompUtil
from wwpdb.utils.nmr.BMRBChemShiftStat import BMRBChemShiftStat
Expand All @@ -123,7 +123,7 @@
ALLOWED_AMBIGUITY_CODES)
except ImportError:
from nmr.AlignUtil import (emptyValue, trueValue, monDict3,
protonBeginCode, pseProBeginCode,
protonBeginCode, pseProBeginCode, aminoProtonCode,
letterToDigit, indexToLetter)
from nmr.ChemCompUtil import ChemCompUtil
from nmr.BMRBChemShiftStat import BMRBChemShiftStat
Expand Down Expand Up @@ -4856,7 +4856,7 @@ def get_star_atom(self, comp_id, nef_atom, details=None, leave_unmatched=True, m
return copy.deepcopy(self.__cachedDictForStarAtom[key])

comp_id = comp_id.upper()
is_std_comp_id = comp_id in monDict3 or self.__csStat.peptideLike(comp_id) # ACA:H21, H22, H2 (5nwu)
is_std_comp_id = comp_id in monDict3

atom_list = []
ambiguity_code = 1
Expand Down Expand Up @@ -5016,6 +5016,10 @@ def guess_ambiguity_code(atom_list):

atom_list = [a for a in atoms if re.search(pattern, a) and nef_atom[0] in ('H', '1', '2', '3', a[0])]

if not is_std_comp_id and self.__csStat.peptideLike(comp_id) and any(a in aminoProtonCode for a in atom_list)\
and any(a not in aminoProtonCode for a in atom_list):
atom_list = [a for a in atom_list if a not in aminoProtonCode] # ACA:H21, H22, H2 (5nwu)

if atom_type != _atom_type and self.chemCompBond is not None and comp_id in self.chemCompBond:
_atom_list = []
for a in atom_list:
Expand Down Expand Up @@ -5073,6 +5077,10 @@ def guess_ambiguity_code(atom_list):

atom_list = [a for a in atoms if re.search(pattern, a)]

if not is_std_comp_id and self.__csStat.peptideLike(comp_id) and any(a in aminoProtonCode for a in atom_list)\
and any(a not in aminoProtonCode for a in atom_list):
atom_list = [a for a in atom_list if a not in aminoProtonCode] # ACA:H21, H22, H2 (5nwu)

ambiguity_code = 1 if atom_list[0] in methyl_atoms else self.__csStat.getMaxAmbigCodeWoSetId(comp_id, atom_list[0])

# DAOTHER-8817: guess ambiguity code from pseudo CCD
Expand Down Expand Up @@ -5133,6 +5141,8 @@ def guess_ambiguity_code(atom_list):
if leave_unmatched and details is None:
details = f"{nef_atom} is invalid atom_id in comp_id {comp_id}."

atom_list = sorted(atom_list)

return (atom_list, ambiguity_code, details)

finally:
Expand Down
205 changes: 205 additions & 0 deletions wwpdb/utils/nmr/mr/AmberMRParserListener.py

Large diffs are not rendered by default.

65 changes: 58 additions & 7 deletions wwpdb/utils/nmr/mr/AriaMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -1749,20 +1749,26 @@ def selectCoordAtoms(self, chainAssign, seqId, compId, atomId, allowAmbig=True,
atomSelection.append({'chain_id': chainId, 'seq_id': cifSeqId, 'comp_id': cifCompId,
'atom_id': cifAtomId, 'auth_atom_id': authAtomId})

self.testCoordAtomIdConsistency(chainId, cifSeqId, cifCompId, cifAtomId, seqKey, coordAtomSite)
_cifAtomId = self.testCoordAtomIdConsistency(chainId, cifSeqId, cifCompId, cifAtomId, seqKey, coordAtomSite)
if cifAtomId != _cifAtomId:
atomSelection[-1]['atom_id'] = _cifAtomId

if len(atomSelection) > 0:
self.atomSelectionSet.append(atomSelection)

def testCoordAtomIdConsistency(self, chainId, seqId, compId, atomId, seqKey, coordAtomSite):
if not self.__hasCoord:
return
return atomId

found = False

if coordAtomSite is not None:
if atomId in coordAtomSite['atom_id']:
found = True
elif atomId in ('HN1', 'HN2', 'HN3') and ((atomId[-1] + 'HN') in coordAtomSite['atom_id']
or ('H' + atomId[-1]) in coordAtomSite['atom_id']):
atomId = atomId[-1] + 'HN' if atomId[-1] + 'HN' in coordAtomSite['atom_id'] else 'H' + atomId[-1]
found = True
elif 'alt_atom_id' in coordAtomSite and atomId in coordAtomSite['alt_atom_id']:
found = True
# self.__authAtomId = 'auth_atom_id'
Expand All @@ -1776,6 +1782,14 @@ def testCoordAtomIdConsistency(self, chainId, seqId, compId, atomId, seqKey, coo
self.__authSeqId = 'label_seq_id'
seqKey = _seqKey
self.__setLocalSeqScheme()
elif atomId in ('HN1', 'HN2', 'HN3') and ((atomId[-1] + 'HN') in _coordAtomSite['atom_id']
or ('H' + atomId[-1]) in _coordAtomSite['atom_id']):
atomId = atomId[-1] + 'HN' if atomId[-1] + 'HN' in _coordAtomSite['atom_id'] else 'H' + atomId[-1]
found = True
self.__preferAuthSeq = False
self.__authSeqId = 'label_seq_id'
seqKey = _seqKey
self.__setLocalSeqScheme()
elif 'alt_atom_id' in _coordAtomSite and atomId in _coordAtomSite['alt_atom_id']:
found = True
self.__preferAuthSeq = False
Expand All @@ -1793,6 +1807,13 @@ def testCoordAtomIdConsistency(self, chainId, seqId, compId, atomId, seqKey, coo
self.__authSeqId = 'auth_seq_id'
seqKey = _seqKey
self.__setLocalSeqScheme()
elif atomId in ('HN1', 'HN2', 'HN3') and ((atomId[-1] + 'HN') in _coordAtomSite['atom_id']
or ('H' + atomId[-1]) in _coordAtomSite['atom_id']):
atomId = atomId[-1] + 'HN' if atomId[-1] + 'HN' in _coordAtomSite['atom_id'] else 'H' + atomId[-1]
found = True
self.__authSeqId = 'auth_seq_id'
seqKey = _seqKey
self.__setLocalSeqScheme()
elif 'alt_atom_id' in _coordAtomSite and atomId in _coordAtomSite['alt_atom_id']:
found = True
self.__authSeqId = 'auth_seq_id'
Expand All @@ -1813,6 +1834,14 @@ def testCoordAtomIdConsistency(self, chainId, seqId, compId, atomId, seqKey, coo
self.__authSeqId = 'label_seq_id'
seqKey = _seqKey
self.__setLocalSeqScheme()
elif atomId in ('HN1', 'HN2', 'HN3') and ((atomId[-1] + 'HN') in _coordAtomSite['atom_id']
or ('H' + atomId[-1]) in _coordAtomSite['atom_id']):
atomId = atomId[-1] + 'HN' if atomId[-1] + 'HN' in _coordAtomSite['atom_id'] else 'H' + atomId[-1]
found = True
self.__preferAuthSeq = False
self.__authSeqId = 'label_seq_id'
seqKey = _seqKey
self.__setLocalSeqScheme()
elif 'alt_atom_id' in _coordAtomSite and atomId in _coordAtomSite['alt_atom_id']:
found = True
self.__preferAuthSeq = False
Expand All @@ -1830,6 +1859,13 @@ def testCoordAtomIdConsistency(self, chainId, seqId, compId, atomId, seqKey, coo
self.__authSeqId = 'auth_seq_id'
seqKey = _seqKey
self.__setLocalSeqScheme()
elif atomId in ('HN1', 'HN2', 'HN3') and ((atomId[-1] + 'HN') in _coordAtomSite['atom_id']
or ('H' + atomId[-1]) in _coordAtomSite['atom_id']):
atomId = atomId[-1] + 'HN' if atomId[-1] + 'HN' in _coordAtomSite['atom_id'] else 'H' + atomId[-1]
found = True
self.__authSeqId = 'auth_seq_id'
seqKey = _seqKey
self.__setLocalSeqScheme()
elif 'alt_atom_id' in _coordAtomSite and atomId in _coordAtomSite['alt_atom_id']:
found = True
self.__authSeqId = 'auth_seq_id'
Expand All @@ -1842,7 +1878,7 @@ def testCoordAtomIdConsistency(self, chainId, seqId, compId, atomId, seqKey, coo
self.__preferAuthSeq = False

if found:
return
return atomId

if chainId in self.__chainNumberDict.values():

Expand All @@ -1855,6 +1891,14 @@ def testCoordAtomIdConsistency(self, chainId, seqId, compId, atomId, seqKey, coo
self.__authSeqId = 'label_seq_id'
seqKey = _seqKey
self.__setLocalSeqScheme()
elif atomId in ('HN1', 'HN2', 'HN3') and ((atomId[-1] + 'HN') in _coordAtomSite['atom_id']
or ('H' + atomId[-1]) in _coordAtomSite['atom_id']):
atomId = atomId[-1] + 'HN' if atomId[-1] + 'HN' in _coordAtomSite['atom_id'] else 'H' + atomId[-1]
found = True
self.__preferAuthSeq = False
self.__authSeqId = 'label_seq_id'
seqKey = _seqKey
self.__setLocalSeqScheme()
elif 'alt_atom_id' in _coordAtomSite and atomId in _coordAtomSite['alt_atom_id']:
found = True
self.__preferAuthSeq = False
Expand All @@ -1871,6 +1915,13 @@ def testCoordAtomIdConsistency(self, chainId, seqId, compId, atomId, seqKey, coo
self.__authSeqId = 'auth_seq_id'
seqKey = _seqKey
self.__setLocalSeqScheme()
elif atomId in ('HN1', 'HN2', 'HN3') and ((atomId[-1] + 'HN') in _coordAtomSite['atom_id']
or ('H' + atomId[-1]) in _coordAtomSite['atom_id']):
atomId = atomId[-1] + 'HN' if atomId[-1] + 'HN' in _coordAtomSite['atom_id'] else 'H' + atomId[-1]
found = True
self.__authSeqId = 'auth_seq_id'
seqKey = _seqKey
self.__setLocalSeqScheme()
elif 'alt_atom_id' in _coordAtomSite and atomId in _coordAtomSite['alt_atom_id']:
found = True
self.__authSeqId = 'auth_seq_id'
Expand All @@ -1883,7 +1934,7 @@ def testCoordAtomIdConsistency(self, chainId, seqId, compId, atomId, seqKey, coo
self.__preferAuthSeq = False

if found:
return
return atomId

if self.__ccU.updateChemCompDict(compId):
cca = next((cca for cca in self.__ccU.lastAtomList if cca[self.__ccU.ccaAtomId] == atomId), None)
Expand All @@ -1894,8 +1945,7 @@ def testCoordAtomIdConsistency(self, chainId, seqId, compId, atomId, seqKey, coo
auth_seq_id_list = list(filter(None, ps['auth_seq_id']))
if seqId == 1 or (chainId, seqId - 1) in self.__coordUnobsRes or (ps is not None and min(auth_seq_id_list) == seqId):
if atomId in aminoProtonCode and atomId != 'H1':
self.testCoordAtomIdConsistency(chainId, seqId, compId, 'H1', seqKey, coordAtomSite)
return
return self.testCoordAtomIdConsistency(chainId, seqId, compId, 'H1', seqKey, coordAtomSite)
if atomId in aminoProtonCode or atomId == 'P' or atomId.startswith('HOP'):
checked = True
if not checked:
Expand All @@ -1910,10 +1960,11 @@ def testCoordAtomIdConsistency(self, chainId, seqId, compId, atomId, seqKey, coo
self.__f.append(f"[Hydrogen not instantiated] {self.__getCurrentRestraint()}"
f"{chainId}:{seqId}:{compId}:{atomId} is not properly instantiated in the coordinates. "
"Please re-upload the model file.")
return
return atomId
if chainId in LARGE_ASYM_ID:
self.__f.append(f"[Atom not found] {self.__getCurrentRestraint()}"
f"{chainId}:{seqId}:{compId}:{atomId} is not present in the coordinates.")
return atomId

def selectRealisticBondConstraint(self, atom1, atom2, alt_atom_id1, alt_atom_id2, dst_func):
""" Return realistic bond constraint taking into account the current coordinates.
Expand Down
Loading

0 comments on commit 1efa488

Please sign in to comment.