def get_settings(self):

        self.condition = self.condition_widget.condition()

        if self.condition == None:
            self.progress_report('Must select a condition.')
            return 0

        self.min_ppm = pyutil.string_to_float(self.ppm_range_widget[0].get())
        self.max_ppm = pyutil.string_to_float(self.ppm_range_widget[1].get())
        self.ppm_step = pyutil.string_to_float(self.ppm_step_widget.get())

        if self.min_ppm == None or self.max_ppm == None or self.ppm_step == None:
            self.progress_report('Must set ppm min, max, and step.')
            return 0

        self.atoms_per_line = 1

        atoms = tuple(map(string.strip, string.split(self.atoms.get(), ',')))
        if atoms == ('', ):
            atoms = ()
        self.atoms_to_show = atoms

        self.show_aa_range = self.typical_range.get()

        return 1
  def get_settings(self):

    self.spectrum = self.spectrum_widget.spectrum()
    if self.spectrum == None:
      self.progress_report('Must select a spectrum.')
      return 0

    anum = pyutil.string_to_int(self.axis_variable.get())
    if anum == None:
      self.progress_report('Must select a spectrum axis.')
      return 0
    else:
      self.axis = anum - 1
    
    self.min_linewidth = pyutil.string_to_float(self.lw_ranges[0].get())
    self.max_linewidth = pyutil.string_to_float(self.lw_ranges[1].get())
    self.linewidth_step = pyutil.string_to_float(self.lw_step.get())
    if (self.min_linewidth == None or self.max_linewidth == None or
        self.linewidth_step == None):
      self.progress_report('Must select linewidth min, max, and step.')
      return 0

    self.atoms_per_line = 1

    atoms = tuple(map(string.strip, string.split(self.atoms.get(), ',')))
    if atoms == ('',):
      atoms = ()
    self.atoms_to_show = atoms

    return 1
Beispiel #3
0
    def get_settings(self):

        self.spectrum = self.spectrum_widget.spectrum()
        if self.spectrum == None:
            self.progress_report('Must select a spectrum.')
            return 0

        anum = pyutil.string_to_int(self.axis_variable.get())
        if anum == None:
            self.progress_report('Must select a spectrum axis.')
            return 0
        else:
            self.axis = anum - 1

        self.min_linewidth = pyutil.string_to_float(self.lw_ranges[0].get())
        self.max_linewidth = pyutil.string_to_float(self.lw_ranges[1].get())
        self.linewidth_step = pyutil.string_to_float(self.lw_step.get())
        if (self.min_linewidth == None or self.max_linewidth == None
                or self.linewidth_step == None):
            self.progress_report('Must select linewidth min, max, and step.')
            return 0

        self.atoms_per_line = 1

        atoms = tuple(map(string.strip, string.split(self.atoms.get(), ',')))
        if atoms == ('', ):
            atoms = ()
        self.atoms_to_show = atoms

        return 1
Beispiel #4
0
  def get_settings(self):

    self.condition = self.condition_widget.condition()

    if self.condition == None:
      self.progress_report('Must select a condition.')
      return 0

    self.min_ppm = pyutil.string_to_float(self.ppm_range_widget[0].get())
    self.max_ppm = pyutil.string_to_float(self.ppm_range_widget[1].get())
    self.ppm_step = pyutil.string_to_float(self.ppm_step_widget.get())

    if self.min_ppm == None or self.max_ppm == None or self.ppm_step == None:
      self.progress_report('Must set ppm min, max, and step.')
      return 0

    self.atoms_per_line = 1

    atoms = tuple(map(string.strip, string.split(self.atoms.get(), ',')))
    if atoms == ('',):
      atoms = ()
    self.atoms_to_show = atoms

    self.show_aa_range = self.typical_range.get()

    return 1
Beispiel #5
0
  def get_settings(self):
    settings = pyutil.generic_class()

    settings.c13_spectrum = self.c13_spect.spectrum()
    settings.n15_spectrum = self.n15_spect.spectrum()
    settings.c13_ppm_range = tkutil.float_variable_values(self.c13_ppm_range)
    settings.n15_ppm_range = tkutil.float_variable_values(self.n15_ppm_range)
    settings.show_type = self.show_type.get()
    settings.exclude_mirrors = self.exclude_mirrors.state()
    if settings.exclude_mirrors:
      ftext = self.c13_n15_factor.get()
      settings.c13_n15_factor = pyutil.string_to_float(ftext, 1)
      ftext = self.min_mirror_factor.get()
      settings.min_mirror_factor = pyutil.string_to_float(ftext, 0)
    return settings
Beispiel #6
0
  def parse_peak_line(self, line, dim):

    fields = string.split(line, None, dim + 1)
    if len(fields) < dim + 1:
      return None

    assignment = sputil.parse_assignment(fields[0])
    if assignment == None or len(assignment) != dim:
      self.unreadable.listbox.insert('end', line)
      return None

    frequency = []
    for a in range(dim):
      f = pyutil.string_to_float(fields[a+1])
      if f == None:
        self.unreadable.listbox.insert('end', line)
        return None
      frequency.append(f)

    if len(fields) > dim + 1:
      note = fields[dim + 1]
    else:
      note = ''

    return (assignment, frequency, note)
    def parse_peak_line(self, line, dim):

        fields = string.split(line, None, dim + 1)
        if len(fields) < dim + 1:
            return None

        assignment = sputil.parse_assignment(fields[0])
        if assignment == None or len(assignment) != dim:
            self.unreadable.listbox.insert('end', line)
            return None

        frequency = []
        for a in range(dim):
            f = pyutil.string_to_float(fields[a + 1])
            if f == None:
                self.unreadable.listbox.insert('end', line)
                return None
            frequency.append(f)

        if len(fields) > dim + 1:
            note = fields[dim + 1]
        else:
            note = ''

        return (assignment, frequency, note)
  def read_tolerances(self):

    tolerances = {}
    for e in self.tolerances:
      atom_name = e.label['text']
      tolerance = pyutil.string_to_float(e.variable.get(), 0)
      tolerances[atom_name] = tolerance
    tolerances['{CA CB }'] = min(tolerances['CA'], tolerances['CB'])
    return tolerances
Beispiel #9
0
  def get_settings(self):

    match_tolerances = {}
    for nucleus in ('1H', '13C', '15N'):
      tol = pyutil.string_to_float(self.tolerances[nucleus].get(), 0)
      match_tolerances[nucleus] = tol

    max_unmatched = pyutil.string_to_int(self.max_unmatched.get(), 0)
    
    return (match_tolerances, max_unmatched)
Beispiel #10
0
  def spectrum_times(self):

    st = []
    for s, (b, e) in self.spectrum_widgets.items():
      if b.variable.get():
        ttext = e.variable.get()
        t = pyutil.string_to_float(ttext)
        st.append((s, t))
        s.save_value('relaxation_time_parameter', ttext)
    st.sort(self.spectrum_time_order)
    return tuple(st)
def parse_mardi_line(line):

    atom1 = string.strip(line[0:4])
    n1 = pyutil.string_to_int(line[4:7])
    atom2 = string.strip(line[8:12])
    n2 = pyutil.string_to_int(line[12:15])

    if n1 == None or n2 == None:
        return None

    bounds = string.split(line[15:])
    if len(bounds) < 2:
        return None

    lower = pyutil.string_to_float(bounds[0])
    upper = pyutil.string_to_float(bounds[1])

    if lower == None or upper == None:
        return None

    return n1, atom1, n2, atom2, lower, upper
  def set_resonance_shift(self, symbol, number, atom_name, sequence,
                          shift_text, rtable):

    shift = pyutil.string_to_float(shift_text)
    if shift == None:
      return

    r = sequence.resonance(number, symbol, atom_name)
    if r == None:
      return

    rtable[r] = shift
Beispiel #13
0
def parse_mardi_line(line):

  atom1 = string.strip(line[0:4])
  n1 = pyutil.string_to_int(line[4:7])
  atom2 = string.strip(line[8:12])
  n2 = pyutil.string_to_int(line[12:15])

  if n1 == None or n2 == None:
    return None
  
  bounds = string.split(line[15:])
  if len(bounds) < 2:
    return None

  lower = pyutil.string_to_float(bounds[0])
  upper = pyutil.string_to_float(bounds[1])

  if lower == None or upper == None:
    return None

  return n1, atom1, n2, atom2, lower, upper
Beispiel #14
0
  def show_settings(self, settings):

    match_tolerances, max_unmatched = settings

    for nucleus, tol in match_tolerances.items():
      var = self.tolerances[nucleus]
      cur_tol = pyutil.string_to_float(var.get(), 0)
      new_tol = match_tolerances[nucleus]
      if new_tol != cur_tol:
        var.set('%.3g' % new_tol)

    self.max_unmatched.set('%d' % max_unmatched)
Beispiel #15
0
  def show_settings(self, settings):

    stimes = {}
    for s, t in settings['spectrum-times']:
      stimes[s] = t
      
    for s, (b, e) in self.spectrum_widgets.items():
      b.variable.set(stimes.has_key(s))
      if (stimes.has_key(s) and
          pyutil.string_to_float(e.variable.get()) != stimes[s]):
        e.variable.set('%.5g' % stimes[s])
      
    self.trials.variable.set('%d' % settings['error-estimate-trials'])
Beispiel #16
0
  def update_cb(self):

    spectrum = self.spectrum_choice.spectrum()
    if spectrum == None:
      return

    show_note = self.note.state()
    bounds_text = self.bounds_text.variable.get()
    hmin = pyutil.string_to_float(self.height_min.get())
    hmax = pyutil.string_to_float(self.height_max.get())
    vmin = pyutil.string_to_float(self.volume_min.get())
    vmax = pyutil.string_to_float(self.volume_max.get())
    exclude_note_words = string.split(self.exclude_note_words.variable.get())
    exculde_note_words = filter(lambda w: len(w) > 0, exclude_note_words)
    require_note_words = string.split(self.require_note_words.variable.get())
    require_note_words = filter(lambda w: len(w) > 0, require_note_words)

    peaks = sputil.sort_peaks_by_assignment(spectrum.peak_list(), self)
    self.stoppable_call(self.show_peaks, peaks, show_note,
                        hmin, hmax, vmin, vmax,
                        exclude_note_words, require_note_words,
                        bounds_text)
Beispiel #17
0
  def get_settings(self):

    settings = pyutil.generic_class()
    settings.spectrum = self.spectrum_choice.spectrum()
    settings.noesy_hsqc = noesy.is_noesy_hsqc(settings.spectrum)
    settings.pdb_paths = list(self.pdb_paths.path_list)
    settings.max_distance = pyutil.string_to_float(self.max_dist.get())
    if settings.spectrum:
      dim = settings.spectrum.dimension
      settings.ppm_range = tkutil.float_variable_values(self.ppm_range)[:dim]
    else:
      settings.ppm_range = None
    settings.show_type = self.show_type.get()
    settings.show_dist = self.show_dist.get()
    
    return settings
    def get_settings(self):

        settings = pyutil.generic_class()
        settings.spectrum = self.spectrum_choice.spectrum()
        settings.noesy_hsqc = noesy.is_noesy_hsqc(settings.spectrum)
        settings.pdb_paths = list(self.pdb_paths.path_list)
        settings.max_distance = pyutil.string_to_float(self.max_dist.get())
        if settings.spectrum:
            dim = settings.spectrum.dimension
            settings.ppm_range = tkutil.float_variable_values(
                self.ppm_range)[:dim]
        else:
            settings.ppm_range = None
        settings.show_type = self.show_type.get()
        settings.show_dist = self.show_dist.get()

        return settings
    def show_settings(self, asys):

        st = self.spectrum_table
        s2cb = st.spectrum_to_checkbutton
        for cb in s2cb.values():
            cb.set_state(0)

        if asys:
            s2epm = st.spectrum_epeak_menus
            s2aom = st.axis_order_menu
            for asp in asys.assignable_spectra:
                s = asp.spectrum
                if s2cb.has_key(s):
                    s2cb[s].set_state(1)
                    if hasattr(asp, 'expected_peak_pattern_name'):
                        s2epm[s].set(asp.expected_peak_pattern_name)
                    if hasattr(asp, 'pattern_axis_order'):
                        s2aom[s].set_axis_order(asp.pattern_axis_order)
                    for axis in range(s.dimension):
                        var = self.tolerances[s.nuclei[axis]]
                        cur_tol = pyutil.string_to_float(var.get(), 0)
                        new_tol = asp.tolerances[axis]
                        if new_tol != cur_tol:
                            var.set('%.3g' % new_tol)
  def show_settings(self, settings):

    tsp_list = settings['type-spectrum-phase-list']
    if tsp_list:
      types = {}
      for type, spectrum, phase in tsp_list:
        if sparky.object_exists(spectrum):
          self.type_to_spectrum_menu[type].set(spectrum.name)
        self.type_to_phase[type].set(phase)
        types[type] = 1
      for type in self.type_to_spectrum_menu.keys():
        if not types.has_key(type):
          self.type_to_spectrum_menu[type].set('')
      
    ttable = settings['tolerance-table']
    for e in self.tolerances:
      atom_name = e.label['text']
      if ttable.has_key(atom_name):
        new_tol = ttable[atom_name]
        current_tol = pyutil.string_to_float(e.variable.get(), 0)
        if new_tol != current_tol:
          e.variable.set('%.3g' % new_tol)

    self.temp_directory.set(settings['temp-directory'])
    def get_settings(self):

        settings = pyutil.generic_class()

        settings.ref_spectrum = self.ref_menu.spectrum()
        if settings.ref_spectrum == None:
            self.progress_report('Spectrum %s not found' % self.ref_menu.get())
            return None

        settings.pick_view = self.pick_menu.view()
        if settings.pick_view == None:
            self.progress_report('View %s not found' % self.pick_menu.get())
            return None

        settings.selected_only = self.selected_only.state()

        settings.ranges = []
        for ref_axis, pick_axis, ef in self.range_entries:
            rtext = ef.variable.get()
            r = pyutil.string_to_float(rtext)
            if r != None:
                settings.ranges.append((ref_axis, pick_axis, r))

        return settings
  def get_settings(self):

    settings = pyutil.generic_class()

    settings.ref_spectrum = self.ref_menu.spectrum()
    if settings.ref_spectrum == None:
      self.progress_report('Spectrum %s not found' % self.ref_menu.get())
      return None

    settings.pick_view = self.pick_menu.view()
    if settings.pick_view == None:
      self.progress_report('View %s not found' % self.pick_menu.get())
      return None

    settings.selected_only = self.selected_only.state()

    settings.ranges = []
    for ref_axis, pick_axis, ef in self.range_entries:
      rtext = ef.variable.get()
      r = pyutil.string_to_float(rtext)
      if r != None:
        settings.ranges.append((ref_axis, pick_axis, r))

    return settings
Beispiel #23
0
  def show_settings(self, asys):

    st = self.spectrum_table
    s2cb = st.spectrum_to_checkbutton
    for cb in s2cb.values():
      cb.set_state(0)

    if asys:
      s2epm = st.spectrum_epeak_menus
      s2aom = st.axis_order_menu
      for asp in asys.assignable_spectra:
        s = asp.spectrum
        if s2cb.has_key(s):
          s2cb[s].set_state(1)
          if hasattr(asp, 'expected_peak_pattern_name'):
            s2epm[s].set(asp.expected_peak_pattern_name)
          if hasattr(asp, 'pattern_axis_order'):
            s2aom[s].set_axis_order(asp.pattern_axis_order)
          for axis in range(s.dimension):
            var = self.tolerances[s.nuclei[axis]]
            cur_tol = pyutil.string_to_float(var.get(), 0)
            new_tol = asp.tolerances[axis]          
            if new_tol != cur_tol:
              var.set('%.3g' % new_tol)
Beispiel #24
0
  def read_tolerances(self):

    ttable = {}
    for nucleus, tol in self.tolerances.items():
      ttable[nucleus] = pyutil.string_to_float(tol.get(), 0)
    return ttable
    def read_tolerances(self):

        ttable = {}
        for nucleus, tol in self.tolerances.items():
            ttable[nucleus] = pyutil.string_to_float(tol.get(), 0)
        return ttable
Beispiel #26
0
 def time_param(s, self=self):
   return pyutil.string_to_float(self.default_time_parameter(s), 0)