Phylo/Taxa/TaxaLinker.pm

filter: Statementstmt 80.4% 37 / 46 Branchbran 50.0% 2 / 4 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 76.9% 10 / 13 Podpod 100% 5 / 5 totaltotal 78.0% 57 / 73 CC 4 SCAR 7.5
CC
4
Cov
77%
make_taxa
6.0
set_taxa
3.0
unset_taxa
2.0
CRAP 2.1
« Phylo/Forest/Tree.pm ↑ Summary Phylo/Matrices/Datatype/Illumina.pm »
1 package Bio::Phylo::Taxa::TaxaLinker;
2 40 ▶use Bio::Phylo;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 40 ▶use Bio::Phylo::Mediators::TaxaMediator;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 40 ▶use Bio::Phylo::Util::Exceptions 'throw';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 40 ▶use Bio::Phylo::Util::CONSTANT qw'_TAXA_ looks_like_object';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 40 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 40 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 40 my $logger = Bio::Phylo->get_logger;
9 40 my $mediator = 'Bio::Phylo::Mediators::TaxaMediator';
10 40 my $TYPE_CONSTANT = _TAXA_;
11  
12 =head1 NAME
13  
14 Bio::Phylo::Taxa::TaxaLinker - Superclass for objects that link to taxa objects
15  
16 =head1 SYNOPSIS
17  
18 use Bio::Phylo::Factory;
19 my $fac = Bio::Phylo::Factory->new;
20  
21 my $matrix = $fac->create_matrix;
22 my $taxa = $fac->create_taxa;
23  
24 if ( $matrix->isa('Bio::Phylo::Taxa::TaxaLinker') ) {
25 $matrix->set_taxa( $taxa );
26 }
27  
28 =head1 DESCRIPTION
29  
30 This module is a superclass for objects that link to L<Bio::Phylo::Taxa> objects.
31  
32 =head1 METHODS
33  
34 =head2 MUTATORS
35  
36 =over
37  
38 =item set_taxa()
39  
40 Associates invocant with Bio::Phylo::Taxa argument.
41  
42 Type : Mutator
43 Title : set_taxa
44 Usage : $obj->set_taxa( $taxa );
45 Function: Links the invocant object
46 to a taxa object.
47 Returns : Modified $obj
48 Args : A Bio::Phylo::Taxa object.
49  
50 =cut
51  
52 56 ▶sub set_taxa : Clonable DeepClonable {
Subroutine set_taxa: called CC=3 SCAR=11.0
Pod documented
53 56 my ( $self, $taxa ) = @_;
54 56 ▶ if ( $taxa and looks_like_object $taxa, $TYPE_CONSTANT ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($taxa and &looks_like_object($taxa, $TYPE_CONSTANT)) { } 52 4 56
Condition66%2/3
$taxa and &looks_like_object($taxa, $TYPE_CONSTANT)
!ll&&!rl&&r
4052
MC/DC50%1/2
$taxa and &looks_like_object($taxa, $TYPE_CONSTANT)
$taxa &looks_like_object($taxa, $TYPE_CONSTANT)
Truth table66%2/3
A and B
A= $taxaB= &looks_like_object($taxa, $TYPE_CONSTANT)
ABresult
0X0
100
111
55 52 $logger->info("setting taxa '$taxa'");
56 52 $mediator->set_link(
57 '-one' => $taxa,
58 '-many' => $self,
59 );
60 }
61 else {
62 4 $logger->info("re-setting taxa link");
63 4 $mediator->remove_link( '-many' => $self );
64 }
65 56 $self->check_taxa;
66 56 return $self;
67 40 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
68  
69 =item unset_taxa()
70  
71 Removes association between invocant and Bio::Phylo::Taxa object.
72  
73 Type : Mutator
74 Title : unset_taxa
75 Usage : $obj->unset_taxa();
76 Function: Removes the link between invocant object and taxa
77 Returns : Modified $obj
78 Args : NONE
79  
80 =cut
81  
82 0 ▶sub unset_taxa {
Subroutine unset_taxa: not called CC=1 SCAR=6.9
Pod documented
83 0 my $self = shift;
84 0 $logger->info("unsetting taxa");
85 0 $self->set_taxa();
86 0 return $self;
87 }
88  
89 =back
90  
91 =head2 ACCESSORS
92  
93 =over
94  
95 =item get_taxa()
96  
97 Retrieves association between invocant and Bio::Phylo::Taxa object.
98  
99 Type : Accessor
100 Title : get_taxa
101 Usage : my $taxa = $obj->get_taxa;
102 Function: Retrieves the Bio::Phylo::Taxa
103 object linked to the invocant.
104 Returns : Bio::Phylo::Taxa
105 Args : NONE
106 Comments: This method returns the Bio::Phylo::Taxa
107 object to which the invocant is linked.
108 The returned object can therefore contain
109 *more* taxa than are actually in the matrix.
110  
111 =cut
112  
113 155 ▶sub get_taxa {
Subroutine get_taxa: called CC=1 SCAR=0.0
Pod documented
114 155 my $self = shift;
115 155 $logger->debug("getting taxa");
116 155 return $mediator->get_link( '-source' => $self );
117 }
118  
119 =item check_taxa()
120  
121 Performs sanity check on taxon relationships.
122  
123 Type : Interface method
124 Title : check_taxa
125 Usage : $obj->check_taxa
126 Function: Performs sanity check on taxon relationships
127 Returns : $obj
128 Args : NONE
129  
130 =cut
131  
132 0 ▶sub check_taxa {
Subroutine check_taxa: not called CC=1 SCAR=6.9
Pod documented
133 0 throw 'NotImplemented' => 'Not implemented!';
134 }
135  
136 =item make_taxa()
137  
138 Creates a taxa block from the objects contents if none exists yet.
139  
140 Type : Decorated interface method
141 Title : make_taxa
142 Usage : my $taxa = $obj->make_taxa
143 Function: Creates a taxa block from the objects contents if none exists yet.
144 Returns : $taxa
145 Args : NONE
146  
147 =cut
148  
149 0 ▶sub make_taxa {
Subroutine make_taxa: not called CC=2 SCAR=17.9
Pod documented
150 0 my $self = shift;
151 0 ▶ if ( my $taxa = $self->get_taxa ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $taxa = $self->get_taxa) { } 0 0 0
152 0 return $taxa;
153 }
154 else {
155 0 throw 'NotImplemented' => 'Not implemented!';
156 }
157 }
158  
159 148 ▶sub _cleanup {
Subroutine _cleanup: called CC=1 SCAR=0.0
160 148 my $self = shift;
161 }
162  
163 =back
164  
165 =head1 SEE ALSO
166  
167 There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo>
168 for any user or developer questions and discussions.
169  
170 =over
171  
172 =item L<Bio::Phylo::Matrices::Matrix>
173  
174 The matrix object subclasses L<Bio::Phylo::Taxa::TaxaLinker>.
175  
176 =item L<Bio::Phylo::Forest>
177  
178 The forest object subclasses L<Bio::Phylo::Taxa::TaxaLinker>.
179  
180 =item L<Bio::Phylo::Manual>
181  
182 Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>.
183  
184 =back
185  
186 =head1 CITATION
187  
188 If you use Bio::Phylo in published research, please cite it:
189  
190 B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen>
191 and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl.
192 I<BMC Bioinformatics> B<12>:63.
193 L<http://dx.doi.org/10.1186/1471-2105-12-63>
194  
195 =cut
196  
197 40 1;
« Phylo/Forest/Tree.pm ↑ Summary Phylo/Matrices/Datatype/Illumina.pm »