class Bio::Tree

Private Instance Methods

__to_newick_format_label(str, options) click to toggle source

formats Newick label (unquoted_label or quoted_label)

# File lib/iroki/main/main.rb, line 26
def __to_newick_format_label(str, options)
  if __get_option(:parser, options) == :naive then
    return str.to_s
  end

  str = str.to_s
  if /([\(\)\,\:\[\]\_\'\x00-\x1f\x7f])/ =~ str then
    # quoted_label
    if __get_option(:parser, options) == :iroki
      return str
    else
      return "\'" + str.gsub(/\'/, "\'\'") + "\'"
    end
  end
  # unquoted_label
  return str.gsub(/ /, '_')
end