Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
yokochi47 committed Nov 28, 2024
1 parent bdfa21d commit fee3dfa
Show file tree
Hide file tree
Showing 15 changed files with 334 additions and 256 deletions.
3 changes: 1 addition & 2 deletions wwpdb/utils/nmr/NmrDpReport.py
Original file line number Diff line number Diff line change
Expand Up @@ -2475,8 +2475,7 @@ def sortChemicalShiftValidation(self):

d = []

anomalous_cs = False
mixed_status = False
anomalous_cs = mixed_status = False

for item in ['anomalous_data', 'anomalous_chemical_shift', 'unusual_data', 'unusual_chemical_shift']:

Expand Down
37 changes: 21 additions & 16 deletions wwpdb/utils/nmr/mr/AmberMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
isCyclicPolymer,
getAltProtonIdInBondConstraint,
getTypeOfDihedralRestraint,
remediateBackboneDehedralRestraint,
fixBackboneAtomsOfDihedralRestraint,
isLikePheOrTyr,
getRdcCode,
getRestraintName,
Expand Down Expand Up @@ -106,7 +106,7 @@
isCyclicPolymer,
getAltProtonIdInBondConstraint,
getTypeOfDihedralRestraint,
remediateBackboneDehedralRestraint,
fixBackboneAtomsOfDihedralRestraint,
isLikePheOrTyr,
getRdcCode,
getRestraintName,
Expand Down Expand Up @@ -1455,15 +1455,16 @@ def exitRestraint_statement(self, ctx: AmberMRParser.Restraint_statementContext)

for atom1, atom2 in itertools.product(self.atomSelectionSet[0],
self.atomSelectionSet[1]):
if isIdenticalRestraint([atom1, atom2], self.__nefT):
atoms = [atom1, atom2]
if isIdenticalRestraint(atoms, self.__nefT):
continue
if self.__createSfDict and isinstance(memberId, int):
star_atom1 = getStarAtom(self.__authToStarSeq, self.__authToOrigSeq, self.__offsetHolder, copy.copy(atom1))
star_atom2 = getStarAtom(self.__authToStarSeq, self.__authToOrigSeq, self.__offsetHolder, copy.copy(atom2))
if star_atom1 is None or star_atom2 is None or isIdenticalRestraint([star_atom1, star_atom2], self.__nefT):
continue
if self.__createSfDict and memberLogicCode == '.':
altAtomId1, altAtomId2 = getAltProtonIdInBondConstraint([atom1, atom2], self.__csStat)
altAtomId1, altAtomId2 = getAltProtonIdInBondConstraint(atoms, self.__csStat)
if altAtomId1 is not None or altAtomId2 is not None:
atom1, atom2 =\
self.selectRealisticBondConstraint(atom1, atom2,
Expand Down Expand Up @@ -1736,16 +1737,17 @@ def exitRestraint_statement(self, ctx: AmberMRParser.Restraint_statementContext)
self.atomSelectionSet[1],
self.atomSelectionSet[2],
self.atomSelectionSet[3]):
atoms = [atom1, atom2, atom3, atom4]
angleName = getTypeOfDihedralRestraint(peptide, nucleotide, carbohydrate,
[atom1, atom2, atom3, atom4],
atoms,
'plane_like' in dstFunc,
self.__cR, self.__ccU,
self.__representativeModelId, self.__representativeAltId, self.__modelNumName)

if angleName is not None and angleName.startswith('pseudo'):
angleName, atom2, atom3, err = remediateBackboneDehedralRestraint(angleName,
[atom1, atom2, atom3, atom4],
self.__getCurrentRestraint())
angleName, atom2, atom3, err = fixBackboneAtomsOfDihedralRestraint(angleName,
atoms,
self.__getCurrentRestraint())
self.__f.append(err)

if angleName in emptyValue and atomSelTotal != 4:
Expand Down Expand Up @@ -3656,15 +3658,16 @@ def exitRestraint_statement(self, ctx: AmberMRParser.Restraint_statementContext)

for atom1, atom2 in itertools.product(self.atomSelectionSet[0],
self.atomSelectionSet[1]):
if isIdenticalRestraint([atom1, atom2], self.__nefT):
atoms = [atom1, atom2]
if isIdenticalRestraint(atoms, self.__nefT):
continue
if self.__createSfDict and isinstance(memberId, int):
star_atom1 = getStarAtom(self.__authToStarSeq, self.__authToOrigSeq, self.__offsetHolder, copy.copy(atom1))
star_atom2 = getStarAtom(self.__authToStarSeq, self.__authToOrigSeq, self.__offsetHolder, copy.copy(atom2))
if star_atom1 is None or star_atom2 is None or isIdenticalRestraint([star_atom1, star_atom2], self.__nefT):
continue
if self.__createSfDict and memberLogicCode == '.':
altAtomId1, altAtomId2 = getAltProtonIdInBondConstraint([atom1, atom2], self.__csStat)
altAtomId1, altAtomId2 = getAltProtonIdInBondConstraint(atoms, self.__csStat)
if altAtomId1 is not None or altAtomId2 is not None:
atom1, atom2 =\
self.selectRealisticBondConstraint(atom1, atom2,
Expand Down Expand Up @@ -3983,16 +3986,17 @@ def exitRestraint_statement(self, ctx: AmberMRParser.Restraint_statementContext)
self.atomSelectionSet[1],
self.atomSelectionSet[2],
self.atomSelectionSet[3]):
atoms = [atom1, atom2, atom3, atom4]
angleName = getTypeOfDihedralRestraint(peptide, nucleotide, carbohydrate,
[atom1, atom2, atom3, atom4],
atoms,
'plane_like' in dstFunc,
self.__cR, self.__ccU,
self.__representativeModelId, self.__representativeAltId, self.__modelNumName)

if angleName is not None and angleName.startswith('pseudo'):
angleName, atom2, atom3, err = remediateBackboneDehedralRestraint(angleName,
[atom1, atom2, atom3, atom4],
self.__getCurrentRestraint())
angleName, atom2, atom3, err = fixBackboneAtomsOfDihedralRestraint(angleName,
atoms,
self.__getCurrentRestraint())
self.__f.append(err)

if angleName in emptyValue and atomSelTotal != 4:
Expand Down Expand Up @@ -9684,9 +9688,10 @@ def exitAlign_statement(self, ctx: AmberMRParser.Align_statementContext): # pyl

for atom1, atom2 in itertools.product(self.atomSelectionSet[0],
self.atomSelectionSet[1]):
if isIdenticalRestraint([atom1, atom2], self.__nefT):
atoms = [atom1, atom2]
if isIdenticalRestraint(atoms, self.__nefT):
continue
if isLongRangeRestraint([atom1, atom2], self.__polySeq if self.__gapInAuthSeq else None):
if isLongRangeRestraint(atoms, self.__polySeq if self.__gapInAuthSeq else None):
continue
if self.__debug:
print(f"subtype={self.__cur_subtype} dataset={self.dataset} n={n} "
Expand Down
5 changes: 3 additions & 2 deletions wwpdb/utils/nmr/mr/AriaMRParserListener.py
Original file line number Diff line number Diff line change
Expand Up @@ -835,15 +835,16 @@ def exitDistance_restraint(self, ctx: AriaMRParser.Distance_restraintContext):
memberLogicCode = 'OR' if len(self.atomSelectionSet[i]) * len(self.atomSelectionSet[i + 1]) > 1 else '.'
for atom1, atom2 in itertools.product(self.atomSelectionSet[i],
self.atomSelectionSet[i + 1]):
if isIdenticalRestraint([atom1, atom2], self.__nefT):
atoms = [atom1, atom2]
if isIdenticalRestraint(atoms, self.__nefT):
continue
if self.__createSfDict and isinstance(memberId, int):
star_atom1 = getStarAtom(self.__authToStarSeq, self.__authToOrigSeq, self.__offsetHolder, copy.copy(atom1))
star_atom2 = getStarAtom(self.__authToStarSeq, self.__authToOrigSeq, self.__offsetHolder, copy.copy(atom2))
if star_atom1 is None or star_atom2 is None or isIdenticalRestraint([star_atom1, star_atom2], self.__nefT):
continue
if self.__createSfDict and memberLogicCode == '.':
altAtomId1, altAtomId2 = getAltProtonIdInBondConstraint([atom1, atom2], self.__csStat)
altAtomId1, altAtomId2 = getAltProtonIdInBondConstraint(atoms, self.__csStat)
if altAtomId1 is not None or altAtomId2 is not None:
atom1, atom2 =\
self.selectRealisticBondConstraint(atom1, atom2,
Expand Down
Loading

0 comments on commit fee3dfa

Please sign in to comment.