Phylo/Unparsers/Mrp.pm untested

filter: Statementstmt 0.0% 0 / 30 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 42 CC 3 SCAR 16.7
CC
3
Cov
0%
_to_string
12.0
BEGIN
2.0
BEGIN
2.0
CRAP 5.3
1 package Bio::Phylo::Unparsers::Mrp;
2 use strict;
3 use warnings;
4 use base 'Bio::Phylo::Unparsers::Abstract';
5 use Bio::Phylo::Util::CONSTANT qw'/looks_like/ :objecttypes';
6 use Bio::Phylo::Util::Exceptions 'throw';
7 use Bio::Phylo::Factory;
8  
9 my $factory = Bio::Phylo::Factory->new;
10  
11 =head1 NAME
12  
13 Bio::Phylo::Unparsers::Mrp - Serializer used by Bio::Phylo::IO, no serviceable parts inside
14  
15 =head1 DESCRIPTION
16  
17 This module turns a L<Bio::Phylo::Forest> object into an MRP nexus
18 formatted matrix. It is called by the L<Bio::Phylo::IO> facade, don't call it
19 directly.
20  
21 =begin comment
22  
23 Type : Wrapper
24 Title : _to_string
25 Usage : my $mrp_string = $mrp->_to_string;
26 Function: Stringifies a matrix object into
27 an MRP nexus formatted table.
28 Alias :
29 Returns : SCALAR
30 Args : Bio::Phylo::Matrices::Matrix;
31  
32 =end comment
33  
34 =cut
35  
36 sub _to_string {
37 my $self = shift;
38 my $forest = $self->{'PHYLO'};
39 if ( looks_like_implementor $forest, 'get_forests' ) {
40 ($forest) = @{ $forest->get_forests };
41 }
42 if ( looks_like_implementor $forest, 'make_matrix' ) {
43 my $proj = $factory->create_project;
44 my $matrix = $forest->make_matrix;
45 $proj->insert( $matrix->get_taxa, $matrix );
46 return $proj->to_nexus( '-charstatelabels' => 1 );
47 }
48 else {
49 throw 'ObjectMismatch' => "Can't make MRP matrix out of $forest";
50 }
51 }
52  
53 # podinherit_insert_token
54  
55 =head1 SEE ALSO
56  
57 There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo>
58 for any user or developer questions and discussions.
59  
60 =over
61  
62 =item L<Bio::Phylo::IO>
63  
64 The mrp unparser is called by the L<Bio::Phylo::IO> object.
65 Look there to learn how to create mrp matrices.
66  
67 =item L<Bio::Phylo::Manual>
68  
69 Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>.
70  
71 =back
72  
73 =head1 CITATION
74  
75 If you use Bio::Phylo in published research, please cite it:
76  
77 B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen>
78 and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl.
79 I<BMC Bioinformatics> B<12>:63.
80 L<http://dx.doi.org/10.1186/1471-2105-12-63>
81  
82 =cut
83  
84 1;