Bio::Tree NodeNHX
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Summary
Bio::Tree::NodeNHX - A Simple Tree Node with support for NHX tags
Package variables
No package variables defined.
Included modules
Bio::Tree::Node
Inherit
Bio::Tree::Node
Synopsis
    use Bio::Tree::NodeNHX;
    my $nodeA = new Bio::Tree::NodeNHX();
    my $nodeL = new Bio::Tree::NodeNHX();
    my $nodeR = new Bio::Tree::NodeNHX();

    my $node = new Bio::Tree::NodeNHX();
    $node->add_Descendents($nodeL);
    $node->add_Descendents($nodeR);

    print "node is not a leaf \n" if( $node->is_leaf);
Description
Makes a Tree Node with NHX tags, suitable for building a Tree. See
Bio::Tree::Node for a full list of functionality.
Methods
newDescriptionCode
DESTROY
No description
Code
to_string
No description
Code
nhx_tag
No description
Code
Methods description
newcode    nextTop
 Title   : new
 Usage   : my $obj = new Bio::Tree::NodeNHX();
 Function: Builds a new Bio::Tree::NodeNHX object
 Returns : Bio::Tree::NodeNHX
 Args    : -left          => pointer to Left descendent (optional)
           -right         => pointer to Right descenent (optional)
	   -branch_length => branch length [integer] (optional)
           -bootstrap     => value   bootstrap value (string)
           -description   => description of node
           -id            => unique id for node
           -nhx           => hashref of NHX tags and values
Methods code
newdescriptionprevnextTop
sub new {
  my($class,@args) = @_;

  my $self = $class->SUPER::new(@args);
  my ($nhx) = $self->_rearrange([qw(NHX)], @args);

  $self->nhx_tag($nhx);

  return $self;
}
DESTROYdescriptionprevnextTop
sub DESTROY {
    my ($self) = @_;
    # try to insure that everything is cleaned up
$self->SUPER::DESTROY(); if( defined $self->{'_desc'} && ref($self->{'_desc'}) =~ /ARRAY/i ) { while( my ($nodeid,$node) = each %{ $self->{'_desc'} } ) { $node->{'_ancestor'} = undef; # insure no circular references
$node->DESTROY(); $node = undef; } $self->{'_desc'} = {}; }
}
to_stringdescriptionprevnextTop
sub to_string {
   my ($self) = @_;
   return sprintf("%s%s%s",
		  defined $self->id ? $self->id : '',
		  defined $self->branch_length ? ':' . $self->branch_length : ' ',
		  '[' . join(":", "&&NHX", map { "$_=" . $self->nhx_tag($_) } keys %{$self->nhx_tag || {}}) . ']'
		 );
}
nhx_tagdescriptionprevnextTop
sub nhx_tag {
    my ($self, $tags) = @_;

    if (defined $self->bootstrap) {
	$self->{'_nhx_tag'}->{'B'} = $self->bootstrap;
    }

    if (defined $tags && (ref $tags eq 'HASH')) {
	$self->{'_nhx_tag'} = $tags;
	if (exists $self->{'_nhx_tag'}->{'B'}) {
	    if (defined $self->bootstrap &&
		($self->bootstrap != $self->{'_nhx_tag'}) ) {
		$self->warn("bootstrap value (" . $self->bootstrap . ") being overwritten by NHX B: value ($self->{'_nhx_tag'}->{'B'})!");
	    }
	    $self->bootstrap($self->{'_nhx_tag'}->{'B'});
	}
    } elsif (defined $tags and ! ref $tags) {
	return $self->{'_nhx_tag'}->{$tags};
    }
        return $self->{'_nhx_tag'};
}
General documentation
FEEDBACKTop
Mailing ListsTop
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
  bioperl-l@bioperl.org              - General discussion
  http://bioperl.org/MailList.shtml  - About the mailing lists
Reporting BugsTop
Report bugs to the Bioperl bug tracking system to help us keep track
of the bugs and their resolution. Bug reports can be submitted via
the web:
  http://bugzilla.bioperl.org/
AUTHOR - Aaron MackeyTop
Email amackey@virginia.edu
CONTRIBUTORSTop
The NHX (New Hampshire eXtended) format was created by Chris Zmasek,
and is described at:
  http://www.genetics.wustl.edu/eddy/forester/NHX.html
APPENDIXTop
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _