def mismatches(self, r2ns): mismatches = 0 for r, (num, sym) in r2ns.items(): atom_name = r.atom.name from_sym = r.group.symbol from_stats = shiftstats_ncIDP.atom_statistics(r.group.number,from_sym, atom_name, self.RC_prediction) if from_stats != None: stats = shiftstats_ncIDP.atom_statistics(num, sym, atom_name, self.RC_prediction) if stats == None: mismatches = mismatches + 1 return mismatches
def deviation_text(self, resonance, shift): # Added by kT on 30th Nov 2010 follwing the suggestions by Tom Goddard # from our e-mail correspondence (16th Sep 2010) asys = self.assignments.assignment_system self.RC_prediction = shiftstats_ncIDP.sequence_resonance_statistics(asys.sequence) # The end of the addition stats = shiftstats_ncIDP.atom_statistics(resonance.number, resonance.symbol, resonance.atom_name, self.RC_prediction ) if stats == None or stats.shift_deviation == 0: return '' dev = (shift - stats.average_shift) / stats.shift_deviation return '(%+.3f SD)' % dev
def mean_deviation(self, r2ns): total_dev = 0 dev_count = 0 for r, (num, sym) in r2ns.items(): stats = shiftstats_ncIDP.atom_statistics(num,sym, r.atom.name, self.RC_prediction) if stats and stats.shift_deviation != 0: dev = abs(r.frequency - stats.average_shift) / stats.shift_deviation total_dev = total_dev + dev dev_count = dev_count + 1 if dev_count == 0: return None return total_dev / dev_count
def shifts_cb(self): if self.read_range(): self.offset_list.clear() heading = 'Group Atom Shift Expected Dev Peaks' self.offset_list.heading['text'] = heading def nsa_value(r): return (r.group.number, r.group.symbol, r.atom.name) # here we get the resonance list reslist = pyutil.sort_by_function_value(self.resonances, nsa_value) for r in reslist: stats = shiftstats_ncIDP.atom_statistics(r.group.number,r.group.symbol, r.atom.name, self.RC_prediction) if stats: dev = abs(r.frequency - stats.average_shift) / stats.shift_deviation expected = '%6.4g %+6.1f' % (stats.average_shift, dev) else: expected = '' line = '%5s %5s %6.4g %14s %4d' % (r.group.name, r.atom.name, r.frequency, expected, r.peak_count) self.offset_list.append(line, r)