Phylo/Unparsers/Taxlist.pm untested

filter: Statementstmt 0.0% 0 / 42 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 57 CC 5 SCAR 27.7
CC
5
Cov
0%
_to_string
30.0
BEGIN
2.0
BEGIN
2.0
CRAP 16.0
1 package Bio::Phylo::Unparsers::Taxlist;
2 use strict;
3 use base 'Bio::Phylo::Unparsers::Abstract';
4 use Bio::Phylo::Util::CONSTANT qw'/looks_like/ :objecttypes';
5 use Bio::Phylo::Util::Exceptions 'throw';
6 use Bio::Phylo::Util::Dependency qw'Template';
7  
8 =head1 NAME
9  
10 Bio::Phylo::Unparsers::Taxlist - Serializer used by Bio::Phylo::IO, no serviceable
11 parts inside
12  
13 =head1 DESCRIPTION
14  
15 This module creates a taxon list/table
16  
17 =begin comment
18  
19 Type : Wrapper
20 Title : _to_string
21 Usage : my $json_string = $obj->_to_string;
22 Function: Stringifies a Bio::Phylo object into an HTML string
23 Alias :
24 Returns : SCALAR
25 Args : Bio::Phylo::* object
26  
27 =end comment
28  
29 =cut
30  
31 sub _to_string {
32 my $self = shift;
33 my $obj = $self->{'PHYLO'};
34 my $taxa;
35 if ( $obj->_type == _PROJECT_ ) {
36 $taxa = $obj->get_items(_TAXON_);
37 }
38 elsif ( $obj->_type == _TAXA_ ) {
39 $taxa = $obj->get_entities;
40 }
41 else {
42 throw 'ObjectMismatch' => "Can't make taxon list string out of $obj";
43 }
44 my %predicates;
45 for my $taxon ( @{ $taxa } ) {
46 for my $meta ( @{ $taxon->get_meta } ) {
47 $predicates{$meta->get_predicate} = 1;
48 }
49 }
50 my @predicates = keys %predicates;
51 my $result = '';
52 if ( @predicates ) {
53 $result .= "name\t" . join("\t",@predicates) . "\n";
54 }
55 for my $taxon ( @{ $taxa } ) {
56 $result .= $taxon->get_name;
57 if ( @predicates ) {
58 my @values;
59 for my $predicate ( @predicates ) {
60 push @values, $taxon->get_meta_object($predicate);
61 }
62 $result .= "\t" . join("\t",@values);
63 }
64 $result .= "\n";
65 }
66 return $result;
67  
68 }
69  
70 # podinherit_insert_token
71  
72 =head1 SEE ALSO
73  
74 There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo>
75 for any user or developer questions and discussions.
76  
77 =over
78  
79 =item L<Bio::Phylo::IO>
80  
81 The taxlist unparser is called by the L<Bio::Phylo::IO> object.
82 Look there to learn how to unparse objects.
83  
84 =item L<Bio::Phylo::Manual>
85  
86 Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>.
87  
88 =back
89  
90 =head1 CITATION
91  
92 If you use Bio::Phylo in published research, please cite it:
93  
94 B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen>
95 and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl.
96 I<BMC Bioinformatics> B<12>:63.
97 L<http://dx.doi.org/10.1186/1471-2105-12-63>
98  
99 =cut
100  
101 1;