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 collapse
- 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
-
#entry_overrun ⇒ Object
readonly
string after this entry.
-
#options ⇒ Object
readonly
parser options (in some cases, options can be automatically set by the parser).
-
#original_string ⇒ Object
readonly
original string before parsing.
Instance Method Summary collapse
-
#initialize(str, options = nil) ⇒ Newick
constructor
Creates a new Newick object.
-
#reparse ⇒ Object
Re-parses the tree from the original string.
-
#tree ⇒ Object
Gets the tree.
Constructor Details
#initialize(str, options = nil) ⇒ Newick
Creates a new Newick object. options for parsing can be set.
Note: molphy-style bootstrap values may be parsed, even if the options is set to :traditional or :disabled. Note: 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 = :disabled or :molphy to disable the feature (or at least one NHX tag exists).
267 268 269 270 271 272 |
# File 'lib/bio/db/newick.rb', line 267 def initialize(str, = nil) str = str.sub(/\;(.*)/m, ';') @original_string = str @entry_overrun = $1 @options = ( or {}) end |
Instance Attribute Details
#entry_overrun ⇒ Object (readonly)
string after this entry
282 283 284 |
# File 'lib/bio/db/newick.rb', line 282 def entry_overrun @entry_overrun end |
#options ⇒ Object (readonly)
parser options (in some cases, options can be automatically set by the parser)
276 277 278 |
# File 'lib/bio/db/newick.rb', line 276 def @options end |
#original_string ⇒ Object (readonly)
original string before parsing
279 280 281 |
# File 'lib/bio/db/newick.rb', line 279 def original_string @original_string end |
Instance Method Details
#reparse ⇒ Object
Re-parses the tree from the original string. Returns self. This method is useful after changing parser options.
297 298 299 300 301 |
# File 'lib/bio/db/newick.rb', line 297 def reparse remove_instance_variable(:tree) self.tree self end |
#tree ⇒ Object
Gets the tree. Returns a Bio::Tree object.
286 287 288 289 290 291 292 |
# File 'lib/bio/db/newick.rb', line 286 def tree if !defined?(@tree) @tree = __parse_newick(@original_string, @options) else @tree end end |