Class: Bio::Newick
Overview
Newick standard phylogenetic tree parser class.
This is alpha version. Incompatible changes may be made frequently.
Defined Under Namespace
Classes: ParseError
Constant Summary
- DELIMITER =
delemiter of the entry
RS = ";"
- Edge =
same as Bio::Tree::Edge
Bio::Tree::Edge
- Node =
same as Bio::Tree::Node
Bio::Tree::Node
Instance Attribute Summary (collapse)
-
- (Object) entry_overrun
readonly
string after this entry.
-
- (Object) options
readonly
parser options (in some cases, options can be automatically set by the parser).
-
- (Object) original_string
readonly
original string before parsing.
Instance Method Summary (collapse)
-
- (Newick) initialize(str, options = nil)
constructor
Creates a new Newick object.
-
- (Object) reparse
Re-parses the tree from the original string.
-
- (Object) tree
Gets the tree.
Constructor Details
- (Newick) initialize(str, options = nil)
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).
315 316 317 318 319 320 |
# File 'lib/bio/db/newick.rb', line 315 def initialize(str, = nil) str = str.sub(/\;(.*)/m, ';') @original_string = str @entry_overrun = $1 @options = ( or {}) end |
Instance Attribute Details
- (Object) entry_overrun (readonly)
string after this entry
330 331 332 |
# File 'lib/bio/db/newick.rb', line 330 def entry_overrun @entry_overrun end |
- (Object) options (readonly)
parser options (in some cases, options can be automatically set by the parser)
324 325 326 |
# File 'lib/bio/db/newick.rb', line 324 def @options end |
- (Object) original_string (readonly)
original string before parsing
327 328 329 |
# File 'lib/bio/db/newick.rb', line 327 def original_string @original_string end |
Instance Method Details
- (Object) reparse
Re-parses the tree from the original string. Returns self. This method is useful after changing parser options.
345 346 347 348 349 350 351 |
# File 'lib/bio/db/newick.rb', line 345 def reparse if defined?(@tree) remove_instance_variable(:@tree) end self.tree self end |
- (Object) tree
Gets the tree. Returns a Bio::Tree object.
334 335 336 337 338 339 340 |
# File 'lib/bio/db/newick.rb', line 334 def tree if !defined?(@tree) @tree = __parse_newick(@original_string, @options) else @tree end end |