lib/Bio/MUST/Core/Ali/Stash.pm

filter: Statementstmt 100% 49 / 49 Branchbran 100% 4 / 4 Conditioncond 100% 2 / 2 MC/DCmcdc 100% 1 / 1 Subroutinesub 100% 12 / 12 Podpod 100% 2 / 2 totaltotal 100% 70 / 70 CC 4 SCAR 4.3
CC
4
Cov
100%
load
3.0
get_seq_with_id
2.0
BEGIN
1.0
CRAP 1.5
« lib/Bio/MUST/Core/PostPred.pm ↑ Summary lib/Bio/MUST/Core/Tree/Forest.pm »
1 package Bio::MUST::Core::Ali::Stash;
2 # ABSTRACT: Thin wrapper for an indexed Ali read from disk
3 18 $Bio::MUST::Core::Ali::Stash::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 Smart::Comments;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 18 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 18 ▶use Bio::MUST::Core::Types;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 18 ▶use Bio::MUST::Core::Constants qw(:seqids);
Subroutine BEGIN: called CC=1 SCAR=0.0
16 18 ▶use aliased 'Bio::MUST::Core::Ali';
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 # ATTRIBUTES
19  
20  
21 18 has 'seqs' => (
22 is => 'ro',
23 isa => 'Bio::MUST::Core::Ali',
24 required => 1,
25 handles => [
26 qw(filename count_comments all_comments get_comment
27 guessing all_seq_ids has_uniq_ids is_protein is_aligned
28 get_seq first_seq all_seqs filter_seqs count_seqs
29 gapmiss_regex
30 )
31 ], # comment-related methods needed by IdList
32 );
33  
34  
35 18 has 'lookup' => (
36 is => 'ro',
37 isa => 'Bio::MUST::Core::IdList',
38 init_arg => undef,
39 lazy => 1,
40 builder => '_build_lookup',
41 handles => [ qw(index_for) ],
42 );
43  
44 18 with 'Bio::MUST::Core::Roles::Aliable';
45  
46 ## no critic (ProhibitUnusedPrivateSubroutines)
47  
48 2 ▶sub _build_lookup {
Subroutine _build_lookup: called CC=1 SCAR=0.0
49 2 return shift->seqs->new_lookup;
50 }
51  
52 ## use critic
53  
54 # ACCESSORS
55  
56  
57 3 ▶sub get_seq_with_id {
Subroutine get_seq_with_id: called CC=2 SCAR=6.9
Pod documented
58 3 my $self = shift;
59 3 my $id = shift;
60  
61 # override Ali method with faster lookup-based alternative
62 3 my $index = $self->index_for($id);
63 3 ▶ return $self->get_seq($index)
Branch: 1 branch
BranchTrueFalseTotal
if defined $index 2 1 3
64 if defined $index;
65  
66 1 carp "[BMC] Warning: cannot find seq with id: $id; returning undef!";
67 1 return;
68 }
69  
70 # I/O methods
71  
72  
73 2 ▶sub load {
Subroutine load: called CC=3 SCAR=11.0
Pod documented
74 2 my $class = shift;
75 2 my $infile = shift;
76 2 ▶ my $args = shift // {}; # HashRef (should not be empty...)
Condition100%2/2
shift() // {}
l!l
11
MC/DC100%1/1
shift() // {}
shift()
Truth table100%2/2
A
A= shift()
Aresult
11
00
77  
78 2 my $seqs = Ali->load($infile);
79 2 $seqs->dont_guess;
80  
81 2 ▶ if ( $args->{truncate_ids} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($args->{"truncate_ids"}) 1 1 2
82 1 my $mapper = $seqs->regex_mapper( q{}, $DEF_ID );
83 1 $seqs->shorten_ids($mapper);
84 }
85  
86 2 return $class->new(seqs => $seqs);
87 }
88  
89 18 __PACKAGE__->meta->make_immutable;
90 18 1;
91  
92 __END__
« lib/Bio/MUST/Core/PostPred.pm ↑ Summary lib/Bio/MUST/Core/Tree/Forest.pm »