| Bio-Phylo documentation | Contained in the Bio-Phylo distribution. |
Bio::Phylo::Taxa::Taxon - Operational taxonomic unit
use Bio::Phylo::IO qw(parse);
use Bio::Phylo::Factory;
my $fac = Bio::Phylo::Factory->new;
# array of names
my @apes = qw(
Homo_sapiens
Pan_paniscus
Pan_troglodytes
Gorilla_gorilla
);
# newick string
my $str = '(((Pan_paniscus,Pan_troglodytes),';
$str .= 'Homo_sapiens),Gorilla_gorilla);';
# create tree object
my $tree = parse(
-format => 'newick',
-string => $str
)->first;
# instantiate taxa object
my $taxa = $fac->create_taxa;
# instantiate taxon objects, insert in taxa object
foreach( @apes ) {
my $taxon = $fac->create_taxon(
-name => $_,
);
$taxa->insert($taxon);
}
# crossreference tree and taxa
$tree->crossreference($taxa);
# iterate over nodes
while ( my $node = $tree->next ) {
# check references
if ( $node->get_taxon ) {
# prints crossreferenced tips
print "match: ", $node->get_name, "\n";
}
}
The taxon object models a single operational taxonomic unit. It is useful for cross-referencing datum objects and tree nodes.
Taxon constructor.
Type : Constructor
Title : new
Usage : my $taxon = Bio::Phylo::Taxa::Taxon->new;
Function: Instantiates a Bio::Phylo::Taxa::Taxon
object.
Returns : A Bio::Phylo::Taxa::Taxon object.
Args : none.
Associates argument data with invocant.
Type : Mutator
Title : set_data
Usage : $taxon->set_data( $datum );
Function: Associates data with
the current taxon.
Returns : Modified object.
Args : Must be an object of type
Bio::Phylo::Matrices::Datum
Associates argument node with invocant.
Type : Mutator
Title : set_nodes
Usage : $taxon->set_nodes($node);
Function: Associates tree nodes
with the current taxon.
Returns : Modified object.
Args : A Bio::Phylo::Forest::Node object
Removes association between argument data and invocant.
Type : Mutator
Title : unset_datum
Usage : $taxon->unset_datum($node);
Function: Disassociates datum from
the invocant taxon (i.e.
removes reference).
Returns : Modified object.
Args : A Bio::Phylo::Matrix::Datum object
Removes association between argument node and invocant.
Type : Mutator
Title : unset_node
Usage : $taxon->unset_node($node);
Function: Disassociates tree node from
the invocant taxon (i.e.
removes reference).
Returns : Modified object.
Args : A Bio::Phylo::Forest::Node object
Retrieves associated datum objects.
Type : Accessor
Title : get_data
Usage : @data = @{ $taxon->get_data };
Function: Retrieves data associated
with the current taxon.
Returns : An ARRAY reference of
Bio::Phylo::Matrices::Datum
objects.
Args : None.
Retrieves associated node objects.
Type : Accessor
Title : get_nodes
Usage : @nodes = @{ $taxon->get_nodes };
Function: Retrieves tree nodes associated
with the current taxon.
Returns : An ARRAY reference of
Bio::Phylo::Trees::Node objects
Args : None.
The taxon objects inherits from the Bio::Phylo object. The methods defined there are also applicable to the taxon object.
Also see the manual: Bio::Phylo::Manual and http://rutgervos.blogspot.com.
If you use Bio::Phylo in published research, please cite it:
Rutger A Vos, Jason Caravas, Klaas Hartmann, Mark A Jensen and Chase Miller, 2011. Bio::Phylo - phyloinformatic analysis using Perl. BMC Bioinformatics 12:63. http://dx.doi.org/10.1186/1471-2105-12-63
$Id: Taxon.pm 1660 2011-04-02 18:29:40Z rvos $
| Bio-Phylo documentation | Contained in the Bio-Phylo distribution. |
# $Id: Taxon.pm 1660 2011-04-02 18:29:40Z rvos $ package Bio::Phylo::Taxa::Taxon; use strict; use base 'Bio::Phylo::NeXML::Writable'; use Bio::Phylo::Util::CONSTANT qw':objecttypes looks_like_object'; use Bio::Phylo::Mediators::TaxaMediator; { my $TYPE_CONSTANT = _TAXON_; my $CONTAINER_CONSTANT = _TAXA_; my $DATUM_CONSTANT = _DATUM_; my $NODE_CONSTANT = _NODE_; my $logger = __PACKAGE__->get_logger; my $mediator = 'Bio::Phylo::Mediators::TaxaMediator';
# sub new {
# # could be child class
# my $class = shift;
#
# # notify user
# $logger->info("constructor called for '$class'");
#
# # go up inheritance tree, eventually get an ID
# return $class->SUPER::new( '-tag' => __PACKAGE__->_tag, @_ );
# }
sub set_data { my ( $self, $datum ) = @_; if ( looks_like_object $datum, $DATUM_CONSTANT ) { $mediator->set_link( '-one' => $self, '-many' => $datum, ); } return $self; }
sub set_nodes {
my ( $self, $node ) = @_;
if ( looks_like_object $node, $NODE_CONSTANT ) {
$mediator->set_link(
'-one' => $self,
'-many' => $node,
);
}
return $self;
}
sub unset_datum {
my ( $self, $datum ) = @_;
$mediator->remove_link(
'-one' => $self,
'-many' => $datum,
);
return $self;
}
sub unset_node {
my ( $self, $node ) = @_;
$mediator->remove_link(
'-one' => $self,
'-many' => $node,
);
return $self;
}
sub get_data {
my $self = shift;
return $mediator->get_link(
'-source' => $self,
'-type' => $DATUM_CONSTANT,
);
}
sub get_nodes {
my $self = shift;
return $mediator->get_link(
'-source' => $self,
'-type' => $NODE_CONSTANT,
);
}
sub DESTROY {
my $self = shift;
# notify user
#$logger->debug("destructor called for '$self'");
# recurse up inheritance tree for cleanup
$self->SUPER::DESTROY;
}
sub _container { $CONTAINER_CONSTANT }
sub _type { $TYPE_CONSTANT } sub _tag { 'otu' }
# podinherit_insert_token
} 1;