DataProcessing/MinimumPhredFilter.pm

filter: Statementstmt 83.7% 36 / 43 Branchbran 50.0% 7 / 14 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 7 / 7 Podpod 100% 2 / 2 totaltotal 76.8% 53 / 69 CC 10 SCAR 23.8
CC
10
Cov
75%
is_valid
16.7
BEGIN
1.0
BEGIN
1.0
CRAP 10.8
« DataProcessing/Filter.pm ↑ Summary DataProcessing/AveragePhredFilter.pm »
1 # *%) $Id: MinimumPhredFilter.pm,v 1.5 2004/10/15 22:30:46 scottz Exp $
2 #
3 # Copyright (c) 2004 Scott Zuyderduyn <scottz@bccrc.ca>.
4 # All rights reserved. This program is free software; you
5 # can redistribute it and/or modify it under the same
6 # terms as Perl itself.
7  
8 package Bio::SAGE::DataProcessing::MinimumPhredFilter;
9  
10 =pod
11  
12 =head1 NAME
13  
14 Bio::SAGE::DataProcessing::MinimumPhredFilter - A filter that validates sequences based on minimum Phred score.
15  
16 =head1 SYNOPSIS
17  
18 use Bio::SAGE::DataProcessing::MinimumPhredFilter;
19 $filter = new Bio::SAGE::DataProcessing::MinimumPhredFilter->new( 20 );
20  
21 =head1 DESCRIPTION
22  
23 This module is a concrete subclass of Bio::SAGE::DataProcessing::Filter.
24 The implementation considers a sequence valid if all nucleotides have
25 a Phred score that exceeds that specified for the filter.
26  
27 =head1 INSTALLATION
28  
29 Included with Bio::SAGE::DataProcessing.
30  
31 =head1 PREREQUISITES
32  
33 This module requires the C<Bio::SAGE::DataProcessing::Filter> package.
34  
35 =head1 CHANGES
36  
37 1.10 2004.06.19 - Initial release.
38 0.01 2004.05.02 - prototype
39  
40 =cut
41  
42 1 ▶use Bio::SAGE::DataProcessing::Filter;
Subroutine BEGIN: called CC=1 SCAR=0.0
43 1 ▶use base qw( Bio::SAGE::DataProcessing::Filter );
Subroutine BEGIN: called CC=1 SCAR=0.0
44 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
45 1 ▶use diagnostics;
Subroutine BEGIN: called CC=1 SCAR=0.0
46 1 ▶use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK );
Subroutine BEGIN: called CC=1 SCAR=0.0
47  
48 #require Exporter;
49 #require AutoLoader;
50  
51 #@ISA = qw( Exporter AutoLoader );
52 1 @ISA = qw( Bio::SAGE::DataProcessing::Filter );
53 1 @EXPORT = qw();
54 1 $VERSION = $Bio::SAGE::DataProcessing::VERSION;
55  
56 1 my $PACKAGE = "Bio::SAGE::DataProcessing::MinimumPhredFilter";
57  
58 =pod
59  
60 =head1 CLASS METHODS
61  
62 =cut
63  
64 #######################################################
65 1 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
66 #######################################################
67 =pod
68  
69 =head2 new $minPhred
70  
71 Constructor.
72  
73 B<Arguments>
74  
75 I<$minPhred>
76  
77 The minimum phred value that all nucleotides in a
78 sequence must have in order to be considered valid.
79  
80 B<Usage>
81  
82 my $filter = Bio::SAGE::DataProcessing::MinimumPhredFilter->new( 20 );
83 if( $filter->is_tag_valid( "AAAAAAAAAA" ) ) {
84 print "VALID!\n";
85 }
86  
87 =cut
88  
89 1 my $class = shift;
90 1 $class->SUPER::new( @_ );
91  
92 }
93  
94 =pod
95  
96 =head1 INSTANCE METHODS
97  
98 =cut
99  
100 #######################################################
101 90 ▶sub is_valid {
Subroutine is_valid: called CC=10 SCAR=28.1
Pod documented
102 #######################################################
103 =pod
104  
105 =head2 is_valid $sequence, $scores
106  
107 This implements the is_valid subroutine required
108 in concrete subclasses of Bio::SAGE::DataProcessing::Filter.
109  
110 B<Arguments>
111  
112 I<$sequence>
113  
114 The tag sequence.
115  
116 I<$scores>
117  
118 A space-separated string of Phred scores for the
119 specified sequence.
120  
121 B<Returns>
122  
123 Returns non-zero if the valid, zero if invalid.
124  
125 B<Usage>
126  
127 my $filter = Bio::SAGE::DataProcessing::MinimumPhredFilter->new();
128 if( $filter->is_tag_valid( "AAAAAAAAAA" ) ) {
129 print "VALID!\n";
130 }
131  
132 =cut
133  
134 90 my $this = shift;
135 90 ▶ my $sequence = shift || die( $PACKAGE . "::is_valid no sequence defined." );
Condition50%1/2
shift() || die($PACKAGE . '::is_valid no sequence defined.')
l!l
900
MC/DC0%0/1
shift() || die($PACKAGE . '::is_valid no sequence defined.')
shift()
Truth table50%1/2
A
A= shift()
Aresult
11
00
136 90 my $scores = shift;
137  
138 90 ▶ if( $Bio::SAGE::DataProcessing::DEBUG >= 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Bio::SAGE::DataProcessing::DEBUG >= 1) 0 90 90
139 0 print STDERR $PACKAGE . "::is_valid looking at " . $scores . "\n";
140 }
141  
142 0 ▶ if( !defined( $scores ) ) { return 1; }
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $scores) 0 90 90
143  
144 90 my $min_phred = $this->{'args'}[0];
145  
146 90 ▶ if( $min_phred == 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($min_phred == 0) 0 90 90
147 0 ▶ if( $Bio::SAGE::DataProcessing::DEBUG >= 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Bio::SAGE::DataProcessing::DEBUG >= 1) 0 0 0
148 0 print STDERR $PACKAGE . "::is_valid no need to check, minimum phred is 0\n";
149 }
150 0 return 1;
151 }
152  
153 90 my @scores = split( /\s/, $scores );
154 90 foreach my $score ( @scores ) {
155 2044 ▶ if( $score < $min_phred ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($score < $min_phred) 29 2015 2044
156 29 ▶ if( $Bio::SAGE::DataProcessing::DEBUG >= 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Bio::SAGE::DataProcessing::DEBUG >= 1) 0 29 29
157 0 print STDERR $PACKAGE . "::is_valid $score does not meet minimum $min_phred\n";
158 }
159 29 return 0;
160 }
161 }
162  
163 61 ▶ if( $Bio::SAGE::DataProcessing::DEBUG >= 1 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Bio::SAGE::DataProcessing::DEBUG >= 1) 0 61 61
164 0 print STDERR $PACKAGE . "::is_valid scores passed\n";
165 }
166  
167 61 return 1;
168  
169 }
170  
171 #######################################################
172 #######################################################
173 =pod
174  
175 =head2 compare $scores1, $scores2
176  
177 The default implementation provided by the base class
178 Bio::SAGE::DataProcessing::Filter is used. See the
179 documentation for the base class for more information.
180  
181 =cut
182  
183 1 1;
184  
185 __END__
« DataProcessing/Filter.pm ↑ Summary DataProcessing/AveragePhredFilter.pm »