class Bio::NeXML::Trees
Attributes
Public Class Methods
Create a trees object.
# File lib/bio/db/nexml/trees.rb, line 578 def initialize( id = nil, options = {}, &block ) @id = id properties( options ) unless options.empty? block.arity < 1 ? instance_eval( &block ) : block.call( self ) if block_given? end
Public Instance Methods
Add a tree or a network to self.
# File lib/bio/db/nexml/trees.rb, line 591 def <<( object ) case object when Network add_network( object ) when Tree add_tree( object ) end self end
Fetch a tree or a network by id.
# File lib/bio/db/nexml/trees.rb, line 614 def []( id ) get_tree_by_id( id ) || get_network_by_id( id ) end
Add a networ to self.
# File lib/bio/db/nexml/trees.rb, line 588 def add_network; end
Add a tree to self.
# File lib/bio/db/nexml/trees.rb, line 585 def add_tree; end
Returns total number of trees and networks.
# File lib/bio/db/nexml/trees.rb, line 638 def count number_of_trees + number_of_networks end
# File lib/bio/db/nexml/trees.rb, line 558 def create_network( int = false, options = {} ) type = int ? Bio::NeXML::IntNetwork : Bio::NeXML::FloatNetwork network = type.new( Bio::NeXML.generate_id( type ), options ) self << network network end
# File lib/bio/db/nexml/trees.rb, line 551 def create_tree( int = false, options = {} ) type = int ? Bio::NeXML::IntTree : Bio::NeXML::FloatTree tree = type.new( Bio::NeXML.generate_id( type ), options ) self << tree tree end
Delete a network from self.
# File lib/bio/db/nexml/trees.rb, line 605 def delete_network; end
Delete a tree from self.
# File lib/bio/db/nexml/trees.rb, line 602 def delete_tree; end
Iterate over each element. Returns an Enumerator if no block is given.
# File lib/bio/db/nexml/trees.rb, line 658 def each( &block ) @trees.merge( @networks ).each( &block ) end
Iterate over each network. Returns an Enumerator if no block is given.
# File lib/bio/db/nexml/trees.rb, line 651 def each_network( &block ); end
Iterate over each network passing the id and the tree itself to the block. Returns an Enumerator if no block is given.
# File lib/bio/db/nexml/trees.rb, line 655 def each_network_with_id( &block ); end
Iterate over each tree. Returns an Enumerator if no block is given.
# File lib/bio/db/nexml/trees.rb, line 644 def each_tree( &block ); end
Iterate over each tree passing the id and the tree itself to the block. Returns an Enumerator if no block is given.
# File lib/bio/db/nexml/trees.rb, line 648 def each_tree_with_id( &block ); end
Fetch a network by id.
# File lib/bio/db/nexml/trees.rb, line 611 def get_network_by_id; end
Fetch a tree by id.
# File lib/bio/db/nexml/trees.rb, line 608 def get_tree_by_id; end
Returns true if the given network is containes in self; false otherwise.
# File lib/bio/db/nexml/trees.rb, line 623 def has_network?( tree ); end
Returns true if tree is containes in self.
# File lib/bio/db/nexml/trees.rb, line 620 def has_tree?( tree ); end
# File lib/bio/db/nexml/trees.rb, line 625 def include?( object ) has_tree?( object ) || has_network?( object ) end
Returns the number of networks contained in self.
# File lib/bio/db/nexml/trees.rb, line 635 def number_of_networks; end
Returns the number of trees contained in self.
# File lib/bio/db/nexml/trees.rb, line 632 def number_of_trees; end
# File lib/bio/db/nexml/trees.rb, line 537 def to_xml node = @@writer.create_node( "trees", @@writer.attributes( self, :id, :label, :otus ) ) self.each_tree do |tree| node << tree.to_xml end self.each_network do |network| node << network.to_xml end node end