Bio-Phylo
view release on metacpan or search on metacpan
lib/Bio/Phylo/Forest.pm view on Meta::CPAN
sub insert {
my $self = shift;
if ( $self->can_contain(@_) ) {
my $seen_default = 0;
for my $tree ( reverse @_ ) {
if ( $tree->is_default ) {
if ( not $seen_default ) {
$seen_default++;
}
else {
$tree->set_not_default;
}
}
}
if ($seen_default) {
if ( my $tree = $self->get_default_tree ) {
$tree->set_not_default;
}
}
$self->SUPER::insert(@_);
}
else {
throw 'ObjectMismatch' => "Failed insertion: @_ [in $self]";
}
}
=item get_default_tree()
lib/Bio/Phylo/Forest/Tree.pm view on Meta::CPAN
Comments: This is a flag to indicate that the invocant
is the default tree in a forest, i.e. to
capture the '*' token in nexus files.
=cut
sub set_as_default {
my $self = shift;
if ( my $forest = $self->_get_container ) {
if ( my $tree = $forest->get_default_tree ) {
$tree->set_not_default;
}
}
$default{ $self->get_id } = 1;
return $self;
}
=item set_not_default()
Sets tree to NOT be the default tree in a forest
Type : Mutator
Title : set_not_default
Usage : $tree->set_not_default;
Function: Sets tree to not be default tree in forest
Returns : $tree
Args : NONE
Comments: This is a flag to indicate that the invocant
is the default tree in a forest, i.e. to
capture the '*' token in nexus files.
=cut
sub set_not_default {
my $self = shift;
$default{ $self->get_id } = 0;
return $self;
}
=back
=head2 TESTS
=over
( run in 1.501 second using v1.01-cache-2.11-cpan-0a987023a57 )