line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Phylo::Taxa::Taxon; |
2
|
18
|
|
|
18
|
|
67383
|
use strict; |
|
18
|
|
|
|
|
35
|
|
|
18
|
|
|
|
|
488
|
|
3
|
18
|
|
|
18
|
|
86
|
use warnings; |
|
18
|
|
|
|
|
32
|
|
|
18
|
|
|
|
|
476
|
|
4
|
18
|
|
|
18
|
|
86
|
use base 'Bio::Phylo::NeXML::Writable'; |
|
18
|
|
|
|
|
31
|
|
|
18
|
|
|
|
|
2616
|
|
5
|
18
|
|
|
18
|
|
112
|
use Bio::Phylo::Util::CONSTANT qw':objecttypes looks_like_object'; |
|
18
|
|
|
|
|
37
|
|
|
18
|
|
|
|
|
3584
|
|
6
|
18
|
|
|
18
|
|
120
|
use Bio::Phylo::Mediators::TaxaMediator; |
|
18
|
|
|
|
|
34
|
|
|
18
|
|
|
|
|
2923
|
|
7
|
|
|
|
|
|
|
{ |
8
|
|
|
|
|
|
|
my $TYPE_CONSTANT = _TAXON_; |
9
|
|
|
|
|
|
|
my $CONTAINER_CONSTANT = _TAXA_; |
10
|
|
|
|
|
|
|
my $DATUM_CONSTANT = _DATUM_; |
11
|
|
|
|
|
|
|
my $NODE_CONSTANT = _NODE_; |
12
|
|
|
|
|
|
|
my $logger = __PACKAGE__->get_logger; |
13
|
|
|
|
|
|
|
my $mediator = 'Bio::Phylo::Mediators::TaxaMediator'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Bio::Phylo::Taxa::Taxon - Operational taxonomic unit |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 SYNOPSIS |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
use Bio::Phylo::IO qw(parse); |
22
|
|
|
|
|
|
|
use Bio::Phylo::Factory; |
23
|
|
|
|
|
|
|
my $fac = Bio::Phylo::Factory->new; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# array of names |
26
|
|
|
|
|
|
|
my @apes = qw( |
27
|
|
|
|
|
|
|
Homo_sapiens |
28
|
|
|
|
|
|
|
Pan_paniscus |
29
|
|
|
|
|
|
|
Pan_troglodytes |
30
|
|
|
|
|
|
|
Gorilla_gorilla |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# newick string |
34
|
|
|
|
|
|
|
my $str = '(((Pan_paniscus,Pan_troglodytes),'; |
35
|
|
|
|
|
|
|
$str .= 'Homo_sapiens),Gorilla_gorilla);'; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# create tree object |
38
|
|
|
|
|
|
|
my $tree = parse( |
39
|
|
|
|
|
|
|
-format => 'newick', |
40
|
|
|
|
|
|
|
-string => $str |
41
|
|
|
|
|
|
|
)->first; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# instantiate taxa object |
44
|
|
|
|
|
|
|
my $taxa = $fac->create_taxa; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# instantiate taxon objects, insert in taxa object |
47
|
|
|
|
|
|
|
foreach( @apes ) { |
48
|
|
|
|
|
|
|
my $taxon = $fac->create_taxon( |
49
|
|
|
|
|
|
|
-name => $_, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
$taxa->insert($taxon); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# crossreference tree and taxa |
55
|
|
|
|
|
|
|
$tree->cross_reference($taxa); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# iterate over nodes |
58
|
|
|
|
|
|
|
while ( my $node = $tree->next ) { |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# check references |
61
|
|
|
|
|
|
|
if ( $node->get_taxon ) { |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
# prints crossreferenced tips |
64
|
|
|
|
|
|
|
print "match: ", $node->get_name, "\n"; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 DESCRIPTION |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
The taxon object models a single operational taxonomic unit. It is useful for |
71
|
|
|
|
|
|
|
cross-referencing datum objects and tree nodes. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 METHODS |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head2 MUTATORS |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=over |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=item set_data() |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Associates argument data with invocant. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
Type : Mutator |
84
|
|
|
|
|
|
|
Title : set_data |
85
|
|
|
|
|
|
|
Usage : $taxon->set_data( $datum ); |
86
|
|
|
|
|
|
|
Function: Associates data with |
87
|
|
|
|
|
|
|
the current taxon. |
88
|
|
|
|
|
|
|
Returns : Modified object. |
89
|
|
|
|
|
|
|
Args : Must be an object of type |
90
|
|
|
|
|
|
|
Bio::Phylo::Matrices::Datum |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=cut |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub set_data : Clonable { |
95
|
10
|
|
|
10
|
1
|
23
|
my ( $self, $datum ) = @_; |
96
|
10
|
50
|
|
|
|
36
|
if ( not defined $datum ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
97
|
0
|
|
|
|
|
0
|
return $self; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
elsif ( ref $datum eq 'ARRAY' ) { |
100
|
3
|
|
|
|
|
4
|
for my $d ( @{ $datum } ) { |
|
3
|
|
|
|
|
8
|
|
101
|
4
|
|
|
|
|
18
|
$self->set_data($d); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
elsif ( looks_like_object $datum, $DATUM_CONSTANT ) { |
105
|
5
|
|
|
|
|
15
|
$mediator->set_link( |
106
|
|
|
|
|
|
|
'-one' => $self, |
107
|
|
|
|
|
|
|
'-many' => $datum, |
108
|
|
|
|
|
|
|
); |
109
|
|
|
|
|
|
|
} |
110
|
8
|
|
|
|
|
17
|
return $self; |
111
|
18
|
|
|
18
|
|
108
|
} |
|
18
|
|
|
|
|
126
|
|
|
18
|
|
|
|
|
124
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=item set_nodes() |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Associates argument node with invocant. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
Type : Mutator |
118
|
|
|
|
|
|
|
Title : set_nodes |
119
|
|
|
|
|
|
|
Usage : $taxon->set_nodes($node); |
120
|
|
|
|
|
|
|
Function: Associates tree nodes |
121
|
|
|
|
|
|
|
with the current taxon. |
122
|
|
|
|
|
|
|
Returns : Modified object. |
123
|
|
|
|
|
|
|
Args : A Bio::Phylo::Forest::Node object |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub set_nodes : Clonable { |
128
|
6
|
|
|
6
|
1
|
16
|
my ( $self, $node ) = @_; |
129
|
6
|
50
|
|
|
|
26
|
if ( not defined $node ) { |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
130
|
0
|
|
|
|
|
0
|
return $self; |
131
|
|
|
|
|
|
|
} |
132
|
|
|
|
|
|
|
elsif ( ref $node eq 'ARRAY' ) { |
133
|
3
|
|
|
|
|
6
|
for my $n ( @{ $node } ) { |
|
3
|
|
|
|
|
7
|
|
134
|
0
|
|
|
|
|
0
|
$self->set_nodes($n); |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
elsif ( looks_like_object $node, $NODE_CONSTANT ) { |
138
|
1
|
|
|
|
|
4
|
$mediator->set_link( |
139
|
|
|
|
|
|
|
'-one' => $self, |
140
|
|
|
|
|
|
|
'-many' => $node, |
141
|
|
|
|
|
|
|
); |
142
|
|
|
|
|
|
|
} |
143
|
4
|
|
|
|
|
10
|
return $self; |
144
|
18
|
|
|
18
|
|
4911
|
} |
|
18
|
|
|
|
|
83
|
|
|
18
|
|
|
|
|
64
|
|
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item unset_datum() |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Removes association between argument data and invocant. |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
Type : Mutator |
151
|
|
|
|
|
|
|
Title : unset_datum |
152
|
|
|
|
|
|
|
Usage : $taxon->unset_datum($node); |
153
|
|
|
|
|
|
|
Function: Disassociates datum from |
154
|
|
|
|
|
|
|
the invocant taxon (i.e. |
155
|
|
|
|
|
|
|
removes reference). |
156
|
|
|
|
|
|
|
Returns : Modified object. |
157
|
|
|
|
|
|
|
Args : A Bio::Phylo::Matrix::Datum object |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub unset_datum { |
162
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $datum ) = @_; |
163
|
0
|
|
|
|
|
0
|
$mediator->remove_link( |
164
|
|
|
|
|
|
|
'-one' => $self, |
165
|
|
|
|
|
|
|
'-many' => $datum, |
166
|
|
|
|
|
|
|
); |
167
|
0
|
|
|
|
|
0
|
return $self; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=item unset_node() |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Removes association between argument node and invocant. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Type : Mutator |
175
|
|
|
|
|
|
|
Title : unset_node |
176
|
|
|
|
|
|
|
Usage : $taxon->unset_node($node); |
177
|
|
|
|
|
|
|
Function: Disassociates tree node from |
178
|
|
|
|
|
|
|
the invocant taxon (i.e. |
179
|
|
|
|
|
|
|
removes reference). |
180
|
|
|
|
|
|
|
Returns : Modified object. |
181
|
|
|
|
|
|
|
Args : A Bio::Phylo::Forest::Node object |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=cut |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
sub unset_node { |
186
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $node ) = @_; |
187
|
0
|
|
|
|
|
0
|
$mediator->remove_link( |
188
|
|
|
|
|
|
|
'-one' => $self, |
189
|
|
|
|
|
|
|
'-many' => $node, |
190
|
|
|
|
|
|
|
); |
191
|
0
|
|
|
|
|
0
|
return $self; |
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=back |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head2 ACCESSORS |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
=over |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=item get_data() |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Retrieves associated datum objects. |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Type : Accessor |
205
|
|
|
|
|
|
|
Title : get_data |
206
|
|
|
|
|
|
|
Usage : @data = @{ $taxon->get_data }; |
207
|
|
|
|
|
|
|
Function: Retrieves data associated |
208
|
|
|
|
|
|
|
with the current taxon. |
209
|
|
|
|
|
|
|
Returns : An ARRAY reference of |
210
|
|
|
|
|
|
|
Bio::Phylo::Matrices::Datum |
211
|
|
|
|
|
|
|
objects. |
212
|
|
|
|
|
|
|
Args : None. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=cut |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
sub get_data { |
217
|
24
|
|
|
24
|
1
|
34
|
my $self = shift; |
218
|
24
|
|
50
|
|
|
69
|
return $mediator->get_link( |
219
|
|
|
|
|
|
|
'-source' => $self, |
220
|
|
|
|
|
|
|
'-type' => $DATUM_CONSTANT, |
221
|
|
|
|
|
|
|
) || []; |
222
|
|
|
|
|
|
|
} |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=item get_nodes() |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
Retrieves associated node objects. |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
Type : Accessor |
229
|
|
|
|
|
|
|
Title : get_nodes |
230
|
|
|
|
|
|
|
Usage : @nodes = @{ $taxon->get_nodes }; |
231
|
|
|
|
|
|
|
Function: Retrieves tree nodes associated |
232
|
|
|
|
|
|
|
with the current taxon. |
233
|
|
|
|
|
|
|
Returns : An ARRAY reference of |
234
|
|
|
|
|
|
|
Bio::Phylo::Trees::Node objects |
235
|
|
|
|
|
|
|
Args : None. |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=cut |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
sub get_nodes { |
240
|
24
|
|
|
24
|
1
|
31
|
my $self = shift; |
241
|
24
|
|
50
|
|
|
51
|
return $mediator->get_link( |
242
|
|
|
|
|
|
|
'-source' => $self, |
243
|
|
|
|
|
|
|
'-type' => $NODE_CONSTANT, |
244
|
|
|
|
|
|
|
) || []; |
245
|
|
|
|
|
|
|
} |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=begin comment |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
Type : Internal method |
250
|
|
|
|
|
|
|
Title : _container |
251
|
|
|
|
|
|
|
Usage : $taxon->_container; |
252
|
|
|
|
|
|
|
Function: |
253
|
|
|
|
|
|
|
Returns : CONSTANT |
254
|
|
|
|
|
|
|
Args : |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
=end comment |
257
|
|
|
|
|
|
|
|
258
|
|
|
|
|
|
|
=cut |
259
|
|
|
|
|
|
|
|
260
|
365
|
|
|
365
|
|
597
|
sub _container { $CONTAINER_CONSTANT } |
261
|
|
|
|
|
|
|
|
262
|
|
|
|
|
|
|
=begin comment |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
Type : Internal method |
265
|
|
|
|
|
|
|
Title : _type |
266
|
|
|
|
|
|
|
Usage : $taxon->_type; |
267
|
|
|
|
|
|
|
Function: |
268
|
|
|
|
|
|
|
Returns : CONSTANT |
269
|
|
|
|
|
|
|
Args : |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
=end comment |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
=cut |
274
|
|
|
|
|
|
|
|
275
|
424
|
|
|
424
|
|
748
|
sub _type { $TYPE_CONSTANT } |
276
|
2
|
|
|
2
|
|
5
|
sub _tag { 'otu' } |
277
|
|
|
|
|
|
|
|
278
|
|
|
|
|
|
|
=back |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=cut |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
# podinherit_insert_token |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=head1 SEE ALSO |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo> |
287
|
|
|
|
|
|
|
for any user or developer questions and discussions. |
288
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=over |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=item L<Bio::Phylo::NeXML::Writable> |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
The taxon objects inherits from the L<Bio::Phylo::NeXML::Writable> object. The methods defined |
294
|
|
|
|
|
|
|
there are also applicable to the taxon object. |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
=item L<Bio::Phylo::Manual> |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>. |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
=back |
301
|
|
|
|
|
|
|
|
302
|
|
|
|
|
|
|
=head1 CITATION |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
If you use Bio::Phylo in published research, please cite it: |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen> |
307
|
|
|
|
|
|
|
and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl. |
308
|
|
|
|
|
|
|
I<BMC Bioinformatics> B<12>:63. |
309
|
|
|
|
|
|
|
L<http://dx.doi.org/10.1186/1471-2105-12-63> |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
=cut |
312
|
|
|
|
|
|
|
|
313
|
|
|
|
|
|
|
} |
314
|
|
|
|
|
|
|
1; |