예제 #1
0
  def add_spectrum(self, spectrum, table, row):

    if spectrum.dimension != 3:
      return
    
    #
    # Make spectrum checkbutton
    #
    cb = tkutil.checkbutton(table.frame, spectrum.name, 0)
    cb.button['selectcolor'] = sputil.spectrum_color(spectrum)
    choose_cb = pyutil.precompose(sputil.choose_spectrum_cb, spectrum,
                                  table.chosen_spectra)
    cb.add_callback(choose_cb)
    cb.button.grid(row = row, column = 0, sticky = 'w')
    table.spectrum_to_checkbutton[spectrum] = cb

    #
    # Make axis order menu.  Set default xyz axis order for triple
    # resonance spectra to HCN.
    #
    hcn_order = pyutil.order(('1H', '13C', '15N'), spectrum.nuclei)
    aom = axes.axis_order_menu(table.frame, spectrum.nuclei,
                               initial_order = hcn_order)
    aom.frame.grid(row = row, column = 1, sticky = 'w')
    table.axis_order_menu[spectrum] = aom
예제 #2
0
  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()
예제 #3
0
    def add_spectrum(self, spectrum, table, row):

        pat_name, pat_axes = expectedpeaks.recall_pattern(spectrum)

        #
        # Make spectrum checkbutton
        #
        cb = tkutil.checkbutton(table.frame, spectrum.name, 0)
        cb.button['selectcolor'] = sputil.spectrum_color(spectrum)
        choose_cb = pyutil.precompose(sputil.choose_spectrum_cb, spectrum,
                                      table.chosen_spectra)
        cb.add_callback(choose_cb)
        cb.button.grid(row=row, column=0, sticky='w')
        if pat_name:
            cb.set_state(1)
        table.spectrum_to_checkbutton[spectrum] = cb

        #
        # Make peak pattern menu
        #
        epeak_types = expectedpeaks.expected_peak_descriptions.keys()
        pm = tkutil.option_menu(table.frame, '', epeak_types)
        pm.frame.grid(row=row, column=1, sticky='w')
        table.spectrum_epeak_menus[spectrum] = pm

        #
        # Get default spectrum peak pattern and axis order
        #
        if pat_name == None:
            pat_name = expectedpeaks.default_spectrum_pattern_name(spectrum)
            if pat_name == None:
                pat_name = pm.get()
            pat_list = expectedpeaks.expected_peak_descriptions[pat_name]
            pat_nuclei = expectedpeaks.pattern_nuclei(pat_list[0])
            pat_axes = pyutil.order(pat_nuclei, spectrum.nuclei)

        #
        # Make axis order menu
        #
        aom = axes.axis_order_menu(table.frame,
                                   spectrum.nuclei,
                                   initial_order=pat_axes)
        aom.frame.grid(row=row, column=2, sticky='w')
        table.axis_order_menu[spectrum] = aom

        #
        # Register a callback to limit the menu choices for axis order.
        #
        def restrict_axis_order_cb(pat_name, aom=aom):
            import expectedpeaks
            pat_list = expectedpeaks.expected_peak_descriptions[pat_name]
            pat_nuclei = expectedpeaks.pattern_nuclei(pat_list[0])
            aom.restrict_menu_permutations(pat_nuclei)

        pm.add_callback(restrict_axis_order_cb)

        pm.set(pat_name)
예제 #4
0
  def add_spectrum(self, spectrum, table, row):

    pat_name, pat_axes = expectedpeaks.recall_pattern(spectrum)

    #
    # Make spectrum checkbutton
    #
    cb = tkutil.checkbutton(table.frame, spectrum.name, 0)
    cb.button['selectcolor'] = sputil.spectrum_color(spectrum)
    choose_cb = pyutil.precompose(sputil.choose_spectrum_cb, spectrum,
                                  table.chosen_spectra)
    cb.add_callback(choose_cb)
    cb.button.grid(row = row, column = 0, sticky = 'w')
    if pat_name:
      cb.set_state(1)
    table.spectrum_to_checkbutton[spectrum] = cb

    #
    # Make peak pattern menu
    #
    epeak_types = expectedpeaks.expected_peak_descriptions.keys()
    pm = tkutil.option_menu(table.frame, '', epeak_types)
    pm.frame.grid(row = row, column = 1, sticky = 'w')
    table.spectrum_epeak_menus[spectrum] = pm

    #
    # Get default spectrum peak pattern and axis order
    #
    if pat_name == None:
      pat_name = expectedpeaks.default_spectrum_pattern_name(spectrum)
      if pat_name == None:
        pat_name = pm.get()
      pat_list = expectedpeaks.expected_peak_descriptions[pat_name]
      pat_nuclei = expectedpeaks.pattern_nuclei(pat_list[0])
      pat_axes = pyutil.order(pat_nuclei, spectrum.nuclei)

    #
    # Make axis order menu
    #
    aom = axes.axis_order_menu(table.frame, spectrum.nuclei,
                               initial_order = pat_axes)
    aom.frame.grid(row = row, column = 2, sticky = 'w')
    table.axis_order_menu[spectrum] = aom

    #
    # Register a callback to limit the menu choices for axis order.
    #
    def restrict_axis_order_cb(pat_name, aom=aom):
      import expectedpeaks
      pat_list = expectedpeaks.expected_peak_descriptions[pat_name]
      pat_nuclei = expectedpeaks.pattern_nuclei(pat_list[0])
      aom.restrict_menu_permutations(pat_nuclei)
    pm.add_callback(restrict_axis_order_cb)

    pm.set(pat_name)
예제 #5
0
  def default_axis_orders(self):

    axis_orders = {}
    spectra = self.session.project.spectrum_list()
    for spectrum in spectra:
      if spectrum.dimension == 3:
        order = pyutil.order(('1H', '13C', '15N'), spectrum.nuclei)
        if order == None:
          order = (0, 1, 2)
        axis_orders[spectrum] = order
    return axis_orders
예제 #6
0
  def autoassign_assignment_system(self, tsp_list, tolerances):

    asp_list = []
    for type, spectrum, phase in tsp_list:
      axis_names = self.autoassign_axis_names(spectrum, type)
      tol = pyutil.table_values(tolerances, axis_names)
      self.progress_report('Calculating expected peaks for ' + spectrum.name)
      pat_name = self.type_to_pattern_name[type]
      if spectrum.dimension == 3:
        pat_axes = axes.amide_axes(spectrum)
      else:
        pat_axes = pyutil.order(('1H', '15N'), spectrum.nuclei)
      asp = expectedpeaks.assignable_spectrum_from_pattern(spectrum, tol,
                                                           pat_name, pat_axes,
                                                           self)
      asp.autoassign_type = type
      asp.autoassign_phase = phase
      asp_list.append(asp)

    return expectedpeaks.assignment_system(asp_list)