def place_peaks(self, spectrum): hc_axes = pyutil.order(('1H', '13C'), spectrum.nuclei) if spectrum.dimension != 2 or hc_axes == None: self.progress_report('Spectrum must 2D with H and C axes.') return molecule = spectrum.molecule condition = spectrum.condition self.stoppable_loop('resonances', 50) for rH in condition.resonance_list(): self.check_for_stop() if rH.atom.nucleus == '1H': catom = atoms.attached_heavy_atom(rH.atom, molecule) if catom and catom.nucleus == '13C': rC = condition.find_resonance(catom) if rC: assignment = pyutil.permute((rH, rC), hc_axes) if not spectrum.find_peak(assignment): freq = pyutil.permute((rH.frequency, rC.frequency), hc_axes) pos = sputil.alias_onto_spectrum(freq, spectrum) peak = spectrum.place_peak(pos) peak.assign(hc_axes[0], rH.group.name, rH.atom.name) peak.assign(hc_axes[1], rC.group.name, rC.atom.name) if freq != pos: peak.alias = pyutil.subtract_tuples(freq, pos) peak.show_assignment_label()
def mirror_assignment(assignment, spectrum, c13_spectrum, n15_spectrum): aH, aCN, aH2 = noesy.noesy_hsqc_axes(spectrum) labelled_proton = assignment[aH].atom unlabelled_proton = assignment[aH2].atom mol = spectrum.molecule other_heavy_atom = atoms.attached_heavy_atom(unlabelled_proton, mol) if other_heavy_atom == None: hname = atoms.attached_heavy_atom_name(unlabelled_proton, mol) if hname == None: raise AttachedAtomUnknown, unlabelled_proton else: raise AtomUnknown, (unlabelled_proton.group.name, hname) nucleus = other_heavy_atom.nucleus if nucleus == '13C': mirror_spectrum = c13_spectrum elif nucleus == '15N': mirror_spectrum = n15_spectrum else: raise NoHeavyAtomSpectrum, other_heavy_atom a = noesy.noesy_hsqc_assignment(mirror_spectrum, unlabelled_proton, labelled_proton, other_heavy_atom) if a == None: raise AtomUnassigned, other_heavy_atom return (a, mirror_spectrum)
def nearby_noesy_hsqc_assignments(spectrum, position, ppm_range): res_lists = nearby_resonances(spectrum, position, ppm_range) aH, aCN, aH2 = noesy_hsqc_axes(spectrum) rH = res_lists[aH] rCN = res_lists[aCN] rH2 = res_lists[aH2] rHCN = [] m = spectrum.molecule c = spectrum.condition for r in rH: cnatom = atoms.attached_heavy_atom(r.atom, m) if cnatom != None: rheavy = c.find_resonance(cnatom) if rheavy != None and rheavy in rCN: rHCN.append((r, rheavy)) alist = [] for rh, rcn in rHCN: for rh2 in rH2: a = [None, None, None] a[aH] = rh a[aCN] = rcn a[aH2] = rh2 alist.append(tuple(a)) return tuple(alist)
def atom_pairs_to_hsqc_assignments(spectrum, atom_pairs): heavy_nucleus = spectrum.nuclei[spectrum.heavy_atom_axis] alist = [] for h, h2 in atom_pairs: cn = atoms.attached_heavy_atom(h, spectrum.molecule) if cn and cn.nucleus == heavy_nucleus: assignment = noesy_hsqc_assignment(spectrum, h, h2, cn) if assignment: alist.append(assignment) return tuple(alist)
def identify_hsqc_axes(spectrum): mol = spectrum.molecule a1, a2 = axes.proton_axes(spectrum) aCN = axes.heavy_atom_axes(spectrum)[0] for p in spectrum.peak_list(): if p.is_assigned: res = p.resonances() h1 = atoms.attached_heavy_atom(res[a1].atom, mol) h2 = atoms.attached_heavy_atom(res[a2].atom, mol) if h1 and h2 and h1 != h2: if h1 == res[aCN].atom: set_noesy_hsqc_axes(spectrum, a1, aCN, a2) return elif h2 == res[aCN].atom: set_noesy_hsqc_axes(spectrum, a2, aCN, a1) return aH = axes.attached_proton_axis(spectrum, aCN) if aH == None: aH = 2 aH2 = axes.second_nucleus_axis(spectrum, '1H', aH) set_noesy_hsqc_axes(spectrum, aH, aCN, aH2)
def extend_noesy_assignment(spectrum, hres): if hres and spectrum.dimension == 3: heavy = atoms.attached_heavy_atom(hres[0].atom, spectrum.molecule) if heavy == None: return None aH, aCN, aH2 = noesy_hsqc_axes(spectrum) if heavy.nucleus == spectrum.nuclei[aCN]: return noesy_hsqc_assignment(spectrum, hres[0].atom, hres[1].atom, heavy) else: return None return hres