Class Bio::Newick
In: lib/bio/db/newick.rb
Parent: Object

Newick standard phylogenetic tree parser class.

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

Methods

new   reparse   tree  

Classes and Modules

Class Bio::Newick::ParseError

Constants

DELIMITER = RS = ";"   delemiter of the entry
Edge = Bio::Tree::Edge   same as Bio::Tree::Edge
Node = Bio::Tree::Node   same as Bio::Tree::Node

Attributes

entry_overrun  [R]  string after this entry
options  [R]  parser options (in some cases, options can be automatically set by the parser)
original_string  [R]  original string before parsing

Public Class methods

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

Available options:

:bootstrap_style::traditional for traditional bootstrap style, :molphy for molphy style, :disabled to ignore bootstrap strings. For details of default actions, please read the notes below.
:parser::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).

[Source]

     # File lib/bio/db/newick.rb, line 315
315:     def initialize(str, options = nil)
316:       str = str.sub(/\;(.*)/m, ';')
317:       @original_string = str
318:       @entry_overrun = $1
319:       @options = (options or {})
320:     end

Public Instance methods

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

[Source]

     # File lib/bio/db/newick.rb, line 345
345:     def reparse
346:       if defined?(@tree)
347:         remove_instance_variable(:@tree)
348:       end
349:       self.tree
350:       self
351:     end

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

[Source]

     # File lib/bio/db/newick.rb, line 334
334:     def tree
335:       if !defined?(@tree)
336:         @tree = __parse_newick(@original_string, @options)
337:       else
338:         @tree
339:       end
340:     end

[Validate]