| 1 | package Bio::Phylo::Taxa::TaxonLinker; | ||||||||||||||||||||||||||||
| 2 | 46 | ▶ | use Bio::Phylo::Mediators::TaxaMediator; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 46 | ▶ | use Bio::Phylo::Util::Exceptions; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 46 | ▶ | use Bio::Phylo::Util::MOP; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 46 | ▶ | use Bio::Phylo::Util::Logger ':simple'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 46 | ▶ | use Bio::Phylo::Util::CONSTANT qw'_TAXON_ looks_like_object'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 46 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 46 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | { | ||||||||||||||||||||||||||||
| 10 | 46 | my $TAXON_CONSTANT = _TAXON_; | |||||||||||||||||||||||||||
| 11 | 46 | my $mediator = 'Bio::Phylo::Mediators::TaxaMediator'; | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | =head1 NAME | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | Bio::Phylo::Taxa::TaxonLinker - Superclass for objects that link to taxon objects | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | use Bio::Phylo::Factory; | ||||||||||||||||||||||||||||
| 20 | my $fac = Bio::Phylo::Factory->new; | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | my $node = $fac->create_node; | ||||||||||||||||||||||||||||
| 23 | my $taxon = $fac->create_taxon; | ||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | # just to show who's what | ||||||||||||||||||||||||||||
| 26 | if ( $node->isa('Bio::Phylo::Taxa::TaxonLinker') ) { | ||||||||||||||||||||||||||||
| 27 | $node->set_taxon( $taxon ); | ||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | # prints 'Bio::Phylo::Taxa::Taxon' | ||||||||||||||||||||||||||||
| 31 | print ref $node->get_taxon | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | This module is a superclass for objects that link to L<Bio::Phylo::Taxa::Taxon> | ||||||||||||||||||||||||||||
| 36 | objects. | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | =head1 METHODS | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | =head2 MUTATORS | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | =over | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =item set_taxon() | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | Links the invocant object to a taxon object. | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | Type : Mutator | ||||||||||||||||||||||||||||
| 49 | Title : set_taxon | ||||||||||||||||||||||||||||
| 50 | Usage : $obj->set_taxon( $taxon ); | ||||||||||||||||||||||||||||
| 51 | Function: Links the invocant object | ||||||||||||||||||||||||||||
| 52 | to a taxon object. | ||||||||||||||||||||||||||||
| 53 | Returns : Modified $obj | ||||||||||||||||||||||||||||
| 54 | Args : A Bio::Phylo::Taxa::Taxon object. | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | =cut | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 250 | ▶ | sub set_taxon : Clonable { | ||||||||||||||||||||||||||
|
Subroutine
set_taxon: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 59 | 250 | my ( $self, $taxon ) = @_; | |||||||||||||||||||||||||||
| 60 | 250 | ▶ | if ( $taxon and looks_like_object $taxon, $TAXON_CONSTANT ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$taxon and &looks_like_object($taxon, $TAXON_CONSTANT)
MC/DC50%1/2
$taxon and &looks_like_object($taxon, $TAXON_CONSTANT)
$taxon
&looks_like_object($taxon, $TAXON_CONSTANT)
Truth table66%2/3
A and B
A= $taxonB= &looks_like_object($taxon, $TAXON_CONSTANT)
| |||||||||||||||||||||||||||||
| 61 | 212 | INFO "setting taxon '$taxon'"; | |||||||||||||||||||||||||||
| 62 | 212 | $mediator->set_link( '-one' => $taxon, '-many' => $self ); | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | else { | ||||||||||||||||||||||||||||
| 65 | 34 | INFO "re-setting taxon link"; | |||||||||||||||||||||||||||
| 66 | 34 | $mediator->remove_link( '-many' => $self ); | |||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | 246 | return $self; | |||||||||||||||||||||||||||
| 69 | 46 | ▶ | } | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | =item unset_taxon() | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | Unlinks the invocant object from any taxon object. | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | Type : Mutator | ||||||||||||||||||||||||||||
| 76 | Title : unset_taxon | ||||||||||||||||||||||||||||
| 77 | Usage : $obj->unset_taxon(); | ||||||||||||||||||||||||||||
| 78 | Function: Unlinks the invocant object | ||||||||||||||||||||||||||||
| 79 | from any taxon object. | ||||||||||||||||||||||||||||
| 80 | Returns : Modified $obj | ||||||||||||||||||||||||||||
| 81 | Args : NONE | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =cut | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | 0 | ▶ | sub unset_taxon { | ||||||||||||||||||||||||||
|
Subroutine
unset_taxon: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 86 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 87 | 0 | DEBUG "unsetting taxon"; | |||||||||||||||||||||||||||
| 88 | 0 | $self->set_taxon(); | |||||||||||||||||||||||||||
| 89 | 0 | return $self; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | =back | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | =head2 ACCESSORS | ||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||
| 96 | =over | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | =item get_taxon() | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | Retrieves the Bio::Phylo::Taxa::Taxon object linked to the invocant. | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | Type : Accessor | ||||||||||||||||||||||||||||
| 103 | Title : get_taxon | ||||||||||||||||||||||||||||
| 104 | Usage : my $taxon = $obj->get_taxon; | ||||||||||||||||||||||||||||
| 105 | Function: Retrieves the Bio::Phylo::Taxa::Taxon | ||||||||||||||||||||||||||||
| 106 | object linked to the invocant. | ||||||||||||||||||||||||||||
| 107 | Returns : Bio::Phylo::Taxa::Taxon | ||||||||||||||||||||||||||||
| 108 | Args : NONE | ||||||||||||||||||||||||||||
| 109 | Comments: | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | =cut | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 567 | ▶ | sub get_taxon { | ||||||||||||||||||||||||||
|
Subroutine
get_taxon: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 114 | 567 | $mediator->get_link( '-source' => shift ); | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||
| 117 | =back | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | =cut | ||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | # podinherit_insert_token | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||
| 125 | There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo> | ||||||||||||||||||||||||||||
| 126 | for any user or developer questions and discussions. | ||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||
| 128 | =over | ||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | =item L<Bio::Phylo::Matrices::Datum> | ||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | The datum object subclasses L<Bio::Phylo::Taxa::TaxonLinker>. | ||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||
| 134 | =item L<Bio::Phylo::Forest::Node> | ||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | The node object subclasses L<Bio::Phylo::Taxa::TaxonLinker>. | ||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||
| 138 | =item L<Bio::Phylo::Manual> | ||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>. | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | =back | ||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||
| 144 | =head1 CITATION | ||||||||||||||||||||||||||||
| 145 | |||||||||||||||||||||||||||||
| 146 | If you use Bio::Phylo in published research, please cite it: | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen> | ||||||||||||||||||||||||||||
| 149 | and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl. | ||||||||||||||||||||||||||||
| 150 | I<BMC Bioinformatics> B<12>:63. | ||||||||||||||||||||||||||||
| 151 | L<http://dx.doi.org/10.1186/1471-2105-12-63> | ||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||
| 153 | =cut | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||
| 156 | 46 | 1; | |||||||||||||||||||||||||||