class Bio::Newick

Newick standard phylogenetic tree parser class.

This is alpha version. Incompatible changes may be made frequently.



delemiter of the entry


same as Bio::Tree::Edge


same as Bio::Tree::Node



string after this entry


parser options (in some cases, options can be automatically set by the parser)


original string before parsing

Public Class Methods

new(str, options = nil) click to toggle source

Creates a new Newick object. options for parsing can be set.

Available options:


:traditional for traditional bootstrap style, :molphy for molphy style, :disabled to ignore bootstrap strings. For details of default actions, please read the notes below.


:naive for using naive parser, compatible with BioRuby 1.1.0, which ignores quoted strings and do not convert underscores to spaces.

Notes for bootstrap style: Molphy-style bootstrap values may always be parsed, even if the options[:bootstrap_style] is set to :traditional or :disabled.

Note for default or traditional bootstrap style: By default, if all of the internal node’s names are numeric and there are no NHX and no molphy-style boostrap values, the names of internal nodes are regarded as bootstrap values. options[:bootstrap_style] = :disabled or :molphy to disable the feature (or at least one NHX tag exists).

   # File lib/bio/db/newick.rb
71 def initialize(str, options = nil)
72   str = str.sub(/\;(.*)/m, ';')
73   @original_string = str
74   @entry_overrun = $1
75   @options = (options or {})
76 end

Public Instance Methods

reparse() click to toggle source

Re-parses the tree from the original string. Returns self. This method is useful after changing parser options.

    # File lib/bio/db/newick.rb
101 def reparse
102   if defined?(@tree)
103     remove_instance_variable(:@tree)
104   end
105   self.tree
106   self
107 end
tree() click to toggle source

Gets the tree. Returns a Bio::Tree object.

   # File lib/bio/db/newick.rb
90 def tree
91   if !defined?(@tree)
92     @tree = __parse_newick(@original_string, @options)
93   else
94     @tree
95   end
96 end