def calcQshift(project): """Calculate per residue Q factors between assignment and shiftx results """ if project is None: nTmessage("calcQshift: no project defined") return None # end if if not project.molecule: nTmessage("calcQshift: no molecule defined") return None # end if nTdetail("==> Calculating Q-factors for chemical shift") for res in project.molecule.allResidues(): atms = res.allAtoms() bb = NTlist() heavy = NTlist() protons = NTlist() for a in atms: if a.isBackbone(): bb.append(a) if a.isProton(): protons.append(a) else: heavy.append(a) # end for result = project.validationData.getResult(res, constants.SHIFTX_KEY, QshiftxResult()) if result is None: nTmessage("calcQshift: error setting QshiftResult for residue %s", res) return None # end if result[QshiftxResult.ALL_ATOMS] = _calcQshift(project, atms) result[QshiftxResult.BACKBONE] = _calcQshift(project, bb) result[QshiftxResult.HEAVY_ATOMS] = _calcQshift(project, heavy) result[QshiftxResult.PROTONS] = _calcQshift(project, protons) # LEGACY qshiftDict = legacyQshiftDict() for k in [QshiftxResult.ALL_ATOMS, QshiftxResult.BACKBONE, QshiftxResult.HEAVY_ATOMS, QshiftxResult.PROTONS]: qshiftDict[k] = result[k] qshiftDict["residue"] = res res.Qshift = qshiftDict
def save(self, path = None): """ Create a SML file Return self or None on error Sort the list on id before saving, to preserve (original) order from save to restore. """ # sort the list on id number NTsort( self, byItem='id', inplace=True) if not path: path = self.objectPath if self.SMLhandler.toFile(self, path) != self: nTerror('%s.save: failed creating "%s"' % (self.__CLASS__, path)) return None #end if # restore original sorting if self._byItem: NTsort( self, byItem=self._byItem, inplace=True) nTdetail('==> Saved %s to "%s"', self, path) return self