From 3c4e1d50b28fbbda029ee41124edfabd0df45990 Mon Sep 17 00:00:00 2001 From: yokochi47 Date: Tue, 30 Jan 2024 09:02:57 +0900 Subject: [PATCH] Fix IndexError of the previous commit --- wwpdb/utils/nmr/mr/BiosymMRParserListener.py | 26 +++++---- wwpdb/utils/nmr/mr/CharmmMRParserListener.py | 17 +++--- wwpdb/utils/nmr/mr/CnsMRParserListener.py | 17 +++--- wwpdb/utils/nmr/mr/CyanaMRParserListener.py | 36 ++++++++---- wwpdb/utils/nmr/mr/DynamoMRParserListener.py | 57 +++++++++++-------- wwpdb/utils/nmr/mr/RosettaMRParserListener.py | 13 +++-- wwpdb/utils/nmr/mr/XplorMRParserListener.py | 17 +++--- 7 files changed, 105 insertions(+), 78 deletions(-) diff --git a/wwpdb/utils/nmr/mr/BiosymMRParserListener.py b/wwpdb/utils/nmr/mr/BiosymMRParserListener.py index ca2574786..dbc01f5fd 100644 --- a/wwpdb/utils/nmr/mr/BiosymMRParserListener.py +++ b/wwpdb/utils/nmr/mr/BiosymMRParserListener.py @@ -2046,10 +2046,14 @@ def exitDihedral_angle_restraint(self, ctx: BiosymMRParser.Dihedral_angle_restra if len(self.atomSelectionSet) < 4: return - """ - if not self.areUniqueCoordAtoms('a dihedral angle'): + + try: + compId = self.atomSelectionSet[0][0]['comp_id'] + peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) + except IndexError: + self.areUniqueCoordAtoms('a dihedral angle') return - """ + len_f = len(self.__f) self.areUniqueCoordAtoms('a dihedral angle', allow_ambig=True, allow_ambig_warn_title='Ambiguous dihedral angle') @@ -2058,9 +2062,6 @@ def exitDihedral_angle_restraint(self, ctx: BiosymMRParser.Dihedral_angle_restra if self.__createSfDict: sf = self.__getSf(potentialType=getPotentialType(self.__file_type, self.__cur_subtype, dstFunc)) - compId = self.atomSelectionSet[0][0]['comp_id'] - peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) - first_item = True for atom1, atom2, atom3, atom4 in itertools.product(self.atomSelectionSet[0], @@ -2205,10 +2206,14 @@ def exitDihedral_angle_constraint(self, ctx: BiosymMRParser.Dihedral_angle_const if len(self.atomSelectionSet) < 4: return - """ - if not self.areUniqueCoordAtoms('a dihedral angle'): + + try: + compId = self.atomSelectionSet[0][0]['comp_id'] + peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) + except IndexError: + self.areUniqueCoordAtoms('a dihedral angle') return - """ + len_f = len(self.__f) self.areUniqueCoordAtoms('a dihedral angle', allow_ambig=True, allow_ambig_warn_title='Ambiguous dihedral angle') @@ -2217,9 +2222,6 @@ def exitDihedral_angle_constraint(self, ctx: BiosymMRParser.Dihedral_angle_const if self.__createSfDict: sf = self.__getSf(potentialType=getPotentialType(self.__file_type, self.__cur_subtype, dstFunc)) - compId = self.atomSelectionSet[0][0]['comp_id'] - peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) - first_item = True for atom1, atom2, atom3, atom4 in itertools.product(self.atomSelectionSet[0], diff --git a/wwpdb/utils/nmr/mr/CharmmMRParserListener.py b/wwpdb/utils/nmr/mr/CharmmMRParserListener.py index c40861583..4776b1e80 100644 --- a/wwpdb/utils/nmr/mr/CharmmMRParserListener.py +++ b/wwpdb/utils/nmr/mr/CharmmMRParserListener.py @@ -941,12 +941,16 @@ def exitDihedral_angle_restraint(self, ctx: CharmmMRParser.Dihedral_angle_restra if len(self.atomSelectionSet) != 4: return - """ - if not self.areUniqueCoordAtoms('a dihedral angle (DIHE)'): - if len(self.__g) > 0: - self.__f.extend(self.__g) + + try: + compId = self.atomSelectionSet[0][0]['comp_id'] + peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) + except IndexError: + if not self.areUniqueCoordAtoms('a dihedral angle (DIHE)'): + if len(self.__g) > 0: + self.__f.extend(self.__g) return - """ + len_f = len(self.__f) self.areUniqueCoordAtoms('a dihedral angle (DIHE)', allow_ambig=True, allow_ambig_warn_title='Ambiguous dihedral angle') @@ -955,9 +959,6 @@ def exitDihedral_angle_restraint(self, ctx: CharmmMRParser.Dihedral_angle_restra if self.__createSfDict: sf = self.__getSf(potentialType=getPotentialType(self.__file_type, self.__cur_subtype, dstFunc)) - compId = self.atomSelectionSet[0][0]['comp_id'] - peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) - first_item = True for atom1, atom2, atom3, atom4 in itertools.product(self.atomSelectionSet[0], diff --git a/wwpdb/utils/nmr/mr/CnsMRParserListener.py b/wwpdb/utils/nmr/mr/CnsMRParserListener.py index bb9475cb2..0eb13e052 100644 --- a/wwpdb/utils/nmr/mr/CnsMRParserListener.py +++ b/wwpdb/utils/nmr/mr/CnsMRParserListener.py @@ -1885,12 +1885,16 @@ def exitDihedral_assign(self, ctx: CnsMRParser.Dihedral_assignContext): if not self.__hasPolySeq and not self.__hasNonPolySeq: return - """ - if not self.areUniqueCoordAtoms('a dihedral angle (DIHE)'): - if len(self.__g) > 0: - self.__f.extend(self.__g) + + try: + compId = self.atomSelectionSet[0][0]['comp_id'] + peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) + except IndexError: + if not self.areUniqueCoordAtoms('a dihedral angle (DIHE)'): + if len(self.__g) > 0: + self.__f.extend(self.__g) return - """ + len_f = len(self.__f) self.areUniqueCoordAtoms('a dihedral angle (DIHE)', allow_ambig=True, allow_ambig_warn_title='Ambiguous dihedral angle') @@ -1899,9 +1903,6 @@ def exitDihedral_assign(self, ctx: CnsMRParser.Dihedral_assignContext): if self.__createSfDict: sf = self.__getSf(potentialType=getPotentialType(self.__file_type, self.__cur_subtype, dstFunc)) - compId = self.atomSelectionSet[0][0]['comp_id'] - peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) - first_item = True for atom1, atom2, atom3, atom4 in itertools.product(self.atomSelectionSet[0], diff --git a/wwpdb/utils/nmr/mr/CyanaMRParserListener.py b/wwpdb/utils/nmr/mr/CyanaMRParserListener.py index 325c1f8d8..1b8e14004 100644 --- a/wwpdb/utils/nmr/mr/CyanaMRParserListener.py +++ b/wwpdb/utils/nmr/mr/CyanaMRParserListener.py @@ -4059,10 +4059,13 @@ def exitTorsion_angle_restraint(self, ctx: CyanaMRParser.Torsion_angle_restraint if len(self.atomSelectionSet) < 4: return - """ - if not self.areUniqueCoordAtoms('a torsion angle'): + + try: + self.atomSelectionSet[0][0]['comp_id'] + except IndexError: + self.areUniqueCoordAtoms('a torsion angle') return - """ + len_f = len(self.__f) self.areUniqueCoordAtoms('a torsion angle', allow_ambig=True, allow_ambig_warn_title='Ambiguous dihedral angle') @@ -4171,10 +4174,13 @@ def exitTorsion_angle_restraint(self, ctx: CyanaMRParser.Torsion_angle_restraint if len(self.atomSelectionSet) < 5: return - """ - if not self.areUniqueCoordAtoms('a torsion angle'): + + try: + self.atomSelectionSet[0][0]['comp_id'] + except IndexError: + self.areUniqueCoordAtoms('a torsion angle') return - """ + len_f = len(self.__f) self.areUniqueCoordAtoms('a torsion angle', allow_ambig=True, allow_ambig_warn_title='Ambiguous dihedral angle') @@ -7544,10 +7550,13 @@ def exitTorsion_angle_w_chain_restraint(self, ctx: CyanaMRParser.Torsion_angle_w if len(self.atomSelectionSet) < 4: return - """ - if not self.areUniqueCoordAtoms('a torsion angle'): + + try: + self.atomSelectionSet[0][0]['comp_id'] + except IndexError: + self.areUniqueCoordAtoms('a torsion angle') return - """ + len_f = len(self.__f) self.areUniqueCoordAtoms('a torsion angle', allow_ambig=True, allow_ambig_warn_title='Ambiguous dihedral angle') @@ -7656,10 +7665,13 @@ def exitTorsion_angle_w_chain_restraint(self, ctx: CyanaMRParser.Torsion_angle_w if len(self.atomSelectionSet) < 5: return - """ - if not self.areUniqueCoordAtoms('a torsion angle'): + + try: + self.atomSelectionSet[0][0]['comp_id'] + except IndexError: + self.areUniqueCoordAtoms('a torsion angle') return - """ + len_f = len(self.__f) self.areUniqueCoordAtoms('a torsion angle', allow_ambig=True, allow_ambig_warn_title='Ambiguous dihedral angle') diff --git a/wwpdb/utils/nmr/mr/DynamoMRParserListener.py b/wwpdb/utils/nmr/mr/DynamoMRParserListener.py index bab1967c1..da2ff416f 100644 --- a/wwpdb/utils/nmr/mr/DynamoMRParserListener.py +++ b/wwpdb/utils/nmr/mr/DynamoMRParserListener.py @@ -2405,10 +2405,14 @@ def exitTorsion_angle_restraint(self, ctx: DynamoMRParser.Torsion_angle_restrain if len(self.atomSelectionSet) < 4: return - """ - if not self.areUniqueCoordAtoms('a torsion angle'): + + try: + compId = self.atomSelectionSet[0][0]['comp_id'] + peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) + except IndexError: + self.areUniqueCoordAtoms('a torsion angle') return - """ + len_f = len(self.__f) self.areUniqueCoordAtoms('a torsion angle', allow_ambig=True, allow_ambig_warn_title='Ambiguous dihedral angle') @@ -2419,9 +2423,6 @@ def exitTorsion_angle_restraint(self, ctx: DynamoMRParser.Torsion_angle_restrain potentialType=getPotentialType(self.__file_type, self.__cur_subtype, dstFunc), softwareName='DYNAMO/TALOS') - compId = self.atomSelectionSet[0][0]['comp_id'] - peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) - first_item = True for atom1, atom2, atom3, atom4 in itertools.product(self.atomSelectionSet[0], @@ -2534,10 +2535,14 @@ def exitTorsion_angle_restraint_sw_segid(self, ctx: DynamoMRParser.Torsion_angle if len(self.atomSelectionSet) < 4: return - """ - if not self.areUniqueCoordAtoms('a torsion angle'): + + try: + compId = self.atomSelectionSet[0][0]['comp_id'] + peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) + except IndexError: + self.areUniqueCoordAtoms('a torsion angle') return - """ + len_f = len(self.__f) self.areUniqueCoordAtoms('a torsion angle', allow_ambig=True, allow_ambig_warn_title='Ambiguous dihedral angle') @@ -2548,9 +2553,6 @@ def exitTorsion_angle_restraint_sw_segid(self, ctx: DynamoMRParser.Torsion_angle potentialType=getPotentialType(self.__file_type, self.__cur_subtype, dstFunc), softwareName='DYNAMO/TALOS') - compId = self.atomSelectionSet[0][0]['comp_id'] - peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) - first_item = True for atom1, atom2, atom3, atom4 in itertools.product(self.atomSelectionSet[0], @@ -2663,10 +2665,14 @@ def exitTorsion_angle_restraint_ew_segid(self, ctx: DynamoMRParser.Torsion_angle if len(self.atomSelectionSet) < 4: return - """ - if not self.areUniqueCoordAtoms('a torsion angle'): + + try: + compId = self.atomSelectionSet[0][0]['comp_id'] + peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) + except IndexError: + self.areUniqueCoordAtoms('a torsion angle') return - """ + len_f = len(self.__f) self.areUniqueCoordAtoms('a torsion angle', allow_ambig=True, allow_ambig_warn_title='Ambiguous dihedral angle') @@ -2677,9 +2683,6 @@ def exitTorsion_angle_restraint_ew_segid(self, ctx: DynamoMRParser.Torsion_angle potentialType=getPotentialType(self.__file_type, self.__cur_subtype, dstFunc), softwareName='DYNAMO/TALOS') - compId = self.atomSelectionSet[0][0]['comp_id'] - peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) - first_item = True for atom1, atom2, atom3, atom4 in itertools.product(self.atomSelectionSet[0], @@ -4291,10 +4294,13 @@ def exitTalos_restraint(self, ctx: DynamoMRParser.Talos_restraintContext): if len(self.atomSelectionSet) < 4: return - """ - if not self.areUniqueCoordAtoms('a torsion angle (TALOS)'): + + try: + self.atomSelectionSet[0][0]['comp_id'] + except IndexError: + self.areUniqueCoordAtoms('a torsion angle (TALOS)') return - """ + len_f = len(self.__f) self.areUniqueCoordAtoms('a torsion angle (TALOS)', allow_ambig=True, allow_ambig_warn_title='Ambiguous dihedral angle') @@ -4483,10 +4489,13 @@ def exitTalos_restraint_wo_s2(self, ctx: DynamoMRParser.Talos_restraint_wo_s2Con if len(self.atomSelectionSet) < 4: return - """ - if not self.areUniqueCoordAtoms('a torsion angle (TALOS)'): + + try: + self.atomSelectionSet[0][0]['comp_id'] + except IndexError: + self.areUniqueCoordAtoms('a torsion angle (TALOS)') return - """ + len_f = len(self.__f) self.areUniqueCoordAtoms('a torsion angle (TALOS)', allow_ambig=True, allow_ambig_warn_title='Ambiguous dihedral angle') diff --git a/wwpdb/utils/nmr/mr/RosettaMRParserListener.py b/wwpdb/utils/nmr/mr/RosettaMRParserListener.py index 51f611986..cdb9f4840 100644 --- a/wwpdb/utils/nmr/mr/RosettaMRParserListener.py +++ b/wwpdb/utils/nmr/mr/RosettaMRParserListener.py @@ -2236,10 +2236,14 @@ def exitDihedral_restraint(self, ctx: RosettaMRParser.Dihedral_restraintContext) if len(self.atomSelectionSet) < 4: return - """ - if not self.areUniqueCoordAtoms('a dihedral angle'): + + try: + compId = self.atomSelectionSet[0][0]['comp_id'] + peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) + except IndexError: + self.areUniqueCoordAtoms('a dihedral angle') return - """ + len_f = len(self.__f) self.areUniqueCoordAtoms('a torsion angle', allow_ambig=True, allow_ambig_warn_title='Ambiguous dihedral angle') @@ -2248,9 +2252,6 @@ def exitDihedral_restraint(self, ctx: RosettaMRParser.Dihedral_restraintContext) if self.__createSfDict: sf = self.__getSf(potentialType=getPotentialType(self.__file_type, self.__cur_subtype, dstFunc)) - compId = self.atomSelectionSet[0][0]['comp_id'] - peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) - isNested = len(self.stackNest) > 0 if isNested: diff --git a/wwpdb/utils/nmr/mr/XplorMRParserListener.py b/wwpdb/utils/nmr/mr/XplorMRParserListener.py index b8c88b541..81fadae8b 100644 --- a/wwpdb/utils/nmr/mr/XplorMRParserListener.py +++ b/wwpdb/utils/nmr/mr/XplorMRParserListener.py @@ -2350,12 +2350,16 @@ def exitDihedral_assign(self, ctx: XplorMRParser.Dihedral_assignContext): if not self.__hasPolySeq and not self.__hasNonPolySeq: return - """ - if not self.areUniqueCoordAtoms('a dihedral angle (DIHE)'): - if len(self.__g) > 0: - self.__f.extend(self.__g) + + try: + compId = self.atomSelectionSet[0][0]['comp_id'] + peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) + except IndexError: + if not self.areUniqueCoordAtoms('a dihedral angle (DIHE)'): + if len(self.__g) > 0: + self.__f.extend(self.__g) return - """ + len_f = len(self.__f) self.areUniqueCoordAtoms('a dihedral angle (DIHE)', allow_ambig=True, allow_ambig_warn_title='Ambiguous dihedral angle') @@ -2364,9 +2368,6 @@ def exitDihedral_assign(self, ctx: XplorMRParser.Dihedral_assignContext): if self.__createSfDict: sf = self.__getSf(potentialType=getPotentialType(self.__file_type, self.__cur_subtype, dstFunc)) - compId = self.atomSelectionSet[0][0]['comp_id'] - peptide, nucleotide, carbohydrate = self.__csStat.getTypeOfCompId(compId) - first_item = True for atom1, atom2, atom3, atom4 in itertools.product(self.atomSelectionSet[0],