blib/lib/Bio/Gonzales/Tools/SeqMask.pm

filter: Statementstmt 81.5% 31 / 38 Branchbran 66.6% 4 / 6 Conditioncond 66.6% 2 / 3 MC/DCmcdc 50.0% 1 / 2 Subroutinesub 87.5% 7 / 8 Podpod 50.0% 1 / 2 totaltotal 77.9% 46 / 59 CC 6 SCAR 12.0
CC
6
Cov
79%
trunc_masked_ends
6.0
mask
5.0
BEGIN
1.0
CRAP 3.3
« blib/lib/Bio/Gonzales/Util/Log.pm ↑ Summary blib/lib/Bio/Gonzales/Role/BioPerl/Constructor.pm »
1 #Copyright (c) 2010 Joachim Bargsten <code at bargsten dot org>. All rights reserved.
2  
3 package Bio::Gonzales::Tools::SeqMask;
4  
5 1 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use MouseX::Foreign 'Bio::Root::Root';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 with 'Bio::Gonzales::Role::BioPerl::Constructor';
10  
11 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 1 our $VERSION = '0.062'; # VERSION
16 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 1 has seq => ( is => 'rw' );
19  
20 =head2 mask
21  
22 Title : mask
23 Usage : $obj->mask(10,40,'Z');
24 $obj->mask(10,40);
25 $obj->mask($bio_location_obj, 'Z');
26 $obj->mask($bio_location_obj);
27 Function: masks a sequence region by replacing the respective part with a
28 custom character. If the character is omitted, 'X' in case of
29 protein and 'N' in case of DNA/RNA alphabet is used to mask the
30 sequence region.
31 Returns : the object it was invoked on
32 Args : integer for start position
33 integer for end position
34 custom character to use for masking
35 OR
36 Bio::LocationI location for sequence region (strand NOT honored)
37 custom character to use for masking
38 =cut
39  
40 1 our %UNKNOWN_CHAR = (
41 dna => 'N',
42 rna => 'N',
43 protein => 'X',
44 );
45  
46 sub mask {
47 8 ▶ my ( $self, $start, $end, $char ) = @_;
Subroutine mask: called CC=5 SCAR=16.1
Pod documented
48  
49 8 ▶ if ( ref($start) && $start->isa('Bio::LocationI') ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $start and $start->isa('Bio::LocationI')) { } 2 6 8
Condition66%2/3
ref $start and $start->isa("Bio::LocationI")
!ll&&!rl&&r
602
MC/DC50%1/2
ref $start and $start->isa("Bio::LocationI")
ref $start $start->isa("Bio::LocationI")
Truth table66%2/3
A and B
A= ref $startB= $start->isa("Bio::LocationI")
ABresult
0X0
100
111
50 2 my $loc = $start;
51 2 $char = $end;
52  
53 2 for my $subloc ( $loc->each_Location() ) {
54 2 $self->mask( $subloc->start, $subloc->end, $char );
55 }
56 } else {
57 6 ▶ $char = $UNKNOWN_CHAR{ lc( $self->seq->alphabet ) }
Branch: 1 branch
BranchTrueFalseTotal
unless $char 4 2 6
58 unless ($char);
59  
60 6 $self->seq->subseq(
61 -start => $start,
62 -end => $end,
63 -replace_with => $char x ( $end - $start + 1 ),
64 );
65 }
66  
67 8 return $self;
68 }
69  
70 sub trunc_masked_ends {
71 0 ▶ my ( $self, $char ) = @_;
Subroutine trunc_masked_ends: not called CC=2 SCAR=17.9
Pod undocumented
72  
73 0 ▶ $char = $UNKNOWN_CHAR{ lc( $self->seq->alphabet ) }
Branch: 1 branch
BranchTrueFalseTotal
unless $char 0 0 0
74 unless ($char);
75  
76 0 my $seq = $self->seq->seq;
77 0 $seq =~ s/^$char+//;
78 0 $seq =~ s/$char+$//;
79 0 $self->seq->seq($seq);
80 0 return $self;
81 }
82  
83 1 1;
« blib/lib/Bio/Gonzales/Util/Log.pm ↑ Summary blib/lib/Bio/Gonzales/Role/BioPerl/Constructor.pm »