Skip to content

Commit

Permalink
DAOTHER-9899: (1) Fix indent mistake in case one-letter code is used …
Browse files Browse the repository at this point in the history
…in CYANA restraint file, (2) and Further fix of misinterpretation of distance restraints as RDCs in CYANA restraint file
  • Loading branch information
yokochi47 committed Feb 13, 2025
1 parent 08a9260 commit ceb1f7c
Showing 1 changed file with 46 additions and 22 deletions.
68 changes: 46 additions & 22 deletions wwpdb/utils/nmr/mr/CyanaMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -1061,7 +1061,7 @@ def exitDistance_restraint(self, ctx: CyanaMRParser.Distance_restraintContext):
break
if not one_letter_na:
self.exitDistance_wo_comp_restraint(compId1, seqId1, atomId1, compId2, seqId2, atomId2)
return
return

target_value = None
lower_limit = None
Expand Down Expand Up @@ -1299,8 +1299,7 @@ def exitDistance_restraint(self, ctx: CyanaMRParser.Distance_restraintContext):
comp_id_2 = self.atomSelectionSet[1][0]['comp_id']
atom_id_2 = self.atomSelectionSet[1][0]['atom_id']

if (atom_id_1[0] not in ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS)\
or (atom_id_2[0] not in ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS)\
if atom_id_1[0] not in ('H', 'C', 'N') or atom_id_2[0] not in ('H', 'C', 'N')\
or atom_id_1[0] == atom_id_2[0] == 'H':
isRdc = False

Expand All @@ -1316,7 +1315,6 @@ def exitDistance_restraint(self, ctx: CyanaMRParser.Distance_restraintContext):
((seq_id_1 < seq_id_2 and atom_id_1 == 'C' and atom_id_2 in rdcBbPairCode)
or (seq_id_1 > seq_id_2 and atom_id_1 in rdcBbPairCode and atom_id_2 == 'C')):
pass

else:
isRdc = False

Expand All @@ -1325,15 +1323,25 @@ def exitDistance_restraint(self, ctx: CyanaMRParser.Distance_restraintContext):

elif self.__ccU.updateChemCompDict(comp_id_1): # matches with comp_id in CCD

if not self.__ccU.hasBond(comp_id_1, atom_id_1, atom_id_2):
bbAtoms = self.__csStat.getBackBoneAtoms(comp_id_1, excl_minor_atom=True)
if atom_id_1 not in bbAtoms or atom_id_2 not in bbAtoms:
isRdc = False

elif not self.__ccU.hasBond(comp_id_1, atom_id_1, atom_id_2):

if comp_id_1 in monDict3\
and self.__nefT.validate_comp_atom(comp_id_1, atom_id_1)\
and self.__nefT.validate_comp_atom(comp_id_2, atom_id_2):
if (atom_id_1[0] == 'H' and atom_id_2[0] != 'H')\
or (atom_id_1[0] != 'H' and atom_id_2[0] == 'H'):
isRdc = False
elif comp_id_1 in monDict3\
and self.__nefT.validate_comp_atom(comp_id_1, atom_id_1)\
and self.__nefT.validate_comp_atom(comp_id_2, atom_id_2):
pass
else:
isRdc = False

else:
isRdc = False

if not isRdc:
self.__cur_subtype_altered = False

Expand Down Expand Up @@ -1908,8 +1916,7 @@ def exitDistance_wo_comp_restraint(self, chainId1: str, seqId1: int, atomId1: st
comp_id_2 = self.atomSelectionSet[1][0]['comp_id']
atom_id_2 = self.atomSelectionSet[1][0]['atom_id']

if (atom_id_1[0] not in ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS)\
or (atom_id_2[0] not in ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS)\
if atom_id_1[0] not in ('H', 'C', 'N') or atom_id_2[0] not in ('H', 'C', 'N')\
or atom_id_1[0] == atom_id_2[0] == 'H':
isRdc = False

Expand All @@ -1925,7 +1932,6 @@ def exitDistance_wo_comp_restraint(self, chainId1: str, seqId1: int, atomId1: st
((seq_id_1 < seq_id_2 and atom_id_1 == 'C' and atom_id_2 in rdcBbPairCode)
or (seq_id_1 > seq_id_2 and atom_id_1 in rdcBbPairCode and atom_id_2 == 'C')):
pass

else:
isRdc = False

Expand All @@ -1934,15 +1940,25 @@ def exitDistance_wo_comp_restraint(self, chainId1: str, seqId1: int, atomId1: st

elif self.__ccU.updateChemCompDict(comp_id_1): # matches with comp_id in CCD

if not self.__ccU.hasBond(comp_id_1, atom_id_1, atom_id_2):
bbAtoms = self.__csStat.getBackBoneAtoms(comp_id_1, excl_minor_atom=True)
if atom_id_1 not in bbAtoms or atom_id_2 not in bbAtoms:
isRdc = False

elif not self.__ccU.hasBond(comp_id_1, atom_id_1, atom_id_2):

if comp_id_1 in monDict3\
and self.__nefT.validate_comp_atom(comp_id_1, atom_id_1)\
and self.__nefT.validate_comp_atom(comp_id_2, atom_id_2):
if (atom_id_1[0] == 'H' and atom_id_2[0] != 'H')\
or (atom_id_1[0] != 'H' and atom_id_2[0] == 'H'):
isRdc = False
elif comp_id_1 in monDict3\
and self.__nefT.validate_comp_atom(comp_id_1, atom_id_1)\
and self.__nefT.validate_comp_atom(comp_id_2, atom_id_2):
pass
else:
isRdc = False

else:
isRdc = False

if not isRdc:
self.__cur_subtype_altered = False

Expand Down Expand Up @@ -8648,8 +8664,7 @@ def exitDistance_w_chain_restraint(self, ctx: CyanaMRParser.Distance_w_chain_res
comp_id_2 = self.atomSelectionSet[1][0]['comp_id']
atom_id_2 = self.atomSelectionSet[1][0]['atom_id']

if (atom_id_1[0] not in ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS)\
or (atom_id_2[0] not in ISOTOPE_NUMBERS_OF_NMR_OBS_NUCS)\
if atom_id_1[0] not in ('H', 'C', 'N') or atom_id_2[0] not in ('H', 'C', 'N')\
or atom_id_1[0] == atom_id_2[0] == 'H':
isRdc = False

Expand All @@ -8665,7 +8680,6 @@ def exitDistance_w_chain_restraint(self, ctx: CyanaMRParser.Distance_w_chain_res
((seq_id_1 < seq_id_2 and atom_id_1 == 'C' and atom_id_2 in rdcBbPairCode)
or (seq_id_1 > seq_id_2 and atom_id_1 in rdcBbPairCode and atom_id_2 == 'C')):
pass

else:
isRdc = False

Expand All @@ -8674,15 +8688,25 @@ def exitDistance_w_chain_restraint(self, ctx: CyanaMRParser.Distance_w_chain_res

elif self.__ccU.updateChemCompDict(comp_id_1): # matches with comp_id in CCD

if not self.__ccU.hasBond(comp_id_1, atom_id_1, atom_id_2):
bbAtoms = self.__csStat.getBackBoneAtoms(comp_id_1, excl_minor_atom=True)
if atom_id_1 not in bbAtoms or atom_id_2 not in bbAtoms:
isRdc = False

if comp_id_1 in monDict3\
and self.__nefT.validate_comp_atom(comp_id_1, atom_id_1)\
and self.__nefT.validate_comp_atom(comp_id_2, atom_id_2):
elif not self.__ccU.hasBond(comp_id_1, atom_id_1, atom_id_2):

if (atom_id_1[0] == 'H' and atom_id_2[0] != 'H')\
or (atom_id_1[0] != 'H' and atom_id_2[0] == 'H'):
isRdc = False
elif comp_id_1 in monDict3\
and self.__nefT.validate_comp_atom(comp_id_1, atom_id_1)\
and self.__nefT.validate_comp_atom(comp_id_2, atom_id_2):
pass
else:
isRdc = False

else:
isRdc = False

if not isRdc:
self.__cur_subtype_altered = False

Expand Down

0 comments on commit ceb1f7c

Please sign in to comment.