lib/Bio/MUST/Core/Tree/Forest.pm

filter: Statementstmt 97.7% 44 / 45 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 90.9% 10 / 11 Podpod 100% 3 / 3 totaltotal 96.7% 59 / 61 CC 3 SCAR 3.3
CC
3
Cov
98%
__ANON__
2.0
restore_ids
2.0
load
2.0
CRAP 1.4
« lib/Bio/MUST/Core/Ali/Stash.pm ↑ Summary lib/Bio/MUST/Core/Taxonomy/MooseNCBI.pm »
1 package Bio::MUST::Core::Tree::Forest;
2 # ABSTRACT: Collection of (bootstrap) trees
3 18 $Bio::MUST::Core::Tree::Forest::VERSION = '0.252040';
4 18 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 18 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 18 ▶use autodie;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 18 ▶use feature qw(say);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 18 ▶use Bio::Phylo::IO qw(parse);
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 18 ▶use Bio::MUST::Core::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 18 ▶use aliased 'Bio::MUST::Core::Tree';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15  
16 # public array
17 has 'trees' => (
18 traits => ['Array'],
19 is => 'ro',
20 isa => 'ArrayRef[Bio::MUST::Core::Tree]',
21 0 ▶ default => sub { [] },
Subroutine __ANON__: not called CC=1 SCAR=6.9
22 18 handles => {
23 count_trees => 'count',
24 all_trees => 'elements',
25 add_tree => 'push',
26 get_tree => 'get',
27 },
28 );
29  
30  
31  
32 1 ▶sub restore_ids {
Subroutine restore_ids: called CC=2 SCAR=6.9
Pod documented
33 1 my $self = shift;
34 1 my $mapper = shift;
35  
36 1 $_->restore_ids($mapper) for $self->all_trees;
37  
38 1 return;
39 }
40  
41  
42 1 ▶sub load {
Subroutine load: called CC=2 SCAR=6.9
Pod documented
43 1 my $class = shift;
44 1 my $infile = shift;
45  
46 1 my @trees;
47  
48 # build Bio::MUST::Core::Tree object from each Bio::Phylo::Forest::Tree
49 1 my $forest = parse(-format => 'newick', -file => $infile);
50 1 ▶ while (my $tree = $forest->next) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tree = $forest->next) 10 1 11
51 10 push @trees, Tree->new( tree => $tree );
52 }
53  
54 1 return $class->new( trees => \@trees );
55 }
56  
57  
58 2 ▶sub store {
Subroutine store: called CC=1 SCAR=0.0
Pod documented
59 2 my $self = shift;
60 2 my $outfile = shift;
61  
62 2 open my $out, '>', $outfile;
63  
64 2 say {$out} join "\n", map {
65 2 $_->tree->to_newick( -nodelabels => 0 ) # This might be an issue!
66 } $self->all_trees;
67  
68 2 close $out;
69  
70 2 return;
71 }
72  
73 18 __PACKAGE__->meta->make_immutable;
74 18 1;
75  
76 __END__
« lib/Bio/MUST/Core/Ali/Stash.pm ↑ Summary lib/Bio/MUST/Core/Taxonomy/MooseNCBI.pm »