blib/lib/Bio/Gonzales/Seq/IO/fastq.pm

filter: Statementstmt 75.0% 36 / 48 Branchbran 50.0% 7 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 100% 1 / 1 totaltotal 71.4% 50 / 70 CC 8 SCAR 15.3
CC
8
Cov
69%
BUILD
8.1
_cache_non_solexa
6.0
_cache_solexa
4.0
CRAP 4.6
« blib/lib/Bio/Gonzales/Util/Text.pm ↑ Summary blib/lib/Bio/Gonzales/Align/IO.pm »
1 package Bio::Gonzales::Seq::IO::fastq;
2  
3 1 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 our $VERSION = '0.058'; # VERSION
11  
12 1 our %VARIANT = (
13 sanger => {
14 'ascii_offset' => 33,
15 'q_start' => 0,
16 'q_end' => 93
17 },
18 solexa => {
19 'ascii_offset' => 64,
20 'q_start' => -5,
21 'q_end' => 62
22 },
23 illumina => {
24 'ascii_offset' => 64,
25 'q_start' => 0,
26 'q_end' => 62
27 },
28 );
29  
30 1 has cache => ( is => 'rw' );
31 1 has variant => ( is => 'rw', default => 'sanger' );
32 1 has _ascii_offset => ( is => 'rw' );
33  
34 sub BUILD {
35 1 ▶ my ($self) = @_;
Subroutine BUILD: called CC=4 SCAR=20.9
Pod documented
36  
37 1 ▶ if ( $self->variant eq 'solexa' ) { $self->_cache_solexa }
Branch: 3 branches
BranchTrueFalseTotal
if ($self->variant eq 'solexa') { } 1 0 1
elsif ($self->variant eq 'illumina') { } 0 0 0
elsif ($self->variant eq 'sanger') { } 0 0 0
38 0 elsif ( $self->variant eq 'illumina' ) { $self->_cache_non_solexa }
39 0 elsif ( $self->variant eq 'sanger' ) { $self->_cache_non_solexa }
40 }
41  
42 sub _cache_solexa {
43 1 ▶ my ($self) = @_;
Subroutine _cache_solexa: called CC=4 SCAR=13.9
44  
45 1 my ( @c2q, @q2c, @sol2phred, %phred_fp2chr, @phred_int2chr );
46  
47 1 my $ascii_offset = $VARIANT{'solexa'}{'ascii_offset'};
48 1 ▶ for ( my $i = 0; $i < $VARIANT{'solexa'}{'q_end'} - $VARIANT{'solexa'}{'q_start'} + 1; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $Bio::Gonzales::Seq::IO::fastq::VARIANT{"solexa"}{"q_end"} - $Bio::Gonzales::Seq::IO::fastq::VARIANT{"solexa"}{"q_start"} + 1) 68 1 69
49 68 my $q = $i + $VARIANT{'solexa'}{'q_start'};
50 68 my $c = $q + $ascii_offset;
51 68 $c2q[$c] = $q;
52 68 $q2c[$i] = chr($c);
53  
54 # solexa <=> solexa mapping speedup (retain floating pt precision)
55 68 my $s2p = 10 * log( 1 + 10**( $q / 10.0 ) ) / log(10);
56 68 $sol2phred[$i] = $s2p;
57  
58 68 $phred_fp2chr{$s2p} = chr($c);
59  
60 68 ▶ next if $q < 0; # skip loop; PHRED scores greater than 0
Branch: 1 branch
BranchTrueFalseTotal
if $q < 0 5 63 68
61 63 ▶ my $p2s = sprintf( "%.0f", ( $q <= 1 ) ? -5 : 10 * log( -1 + 10**( $q / 10.0 ) ) / log(10) );
Branch: 1 branch
BranchTrueFalseTotal
$q <= 1 ? : 2 61 63
62 # sanger/illumina PHRED <=> Solexa char mapping speedup
63 63 $phred_int2chr[$i] = chr( $p2s + $ascii_offset );
64 }
65 $self->cache(
66 {
67 c2q => \@c2q,
68 q2c => \@q2c,
69 sol2phred => \@sol2phred,
70 phred_fp2chr => \%phred_fp2chr,
71 phred_int2chr => \@phred_int2chr,
72 q_start => $VARIANT{'solexa'}{'q_start'},
73 1 q_end => $VARIANT{'solexa'}{'q_end'},
74 ascii_offset => $ascii_offset,
75 }
76 );
77 }
78  
79 sub _cache_non_solexa {
80 0 ▶ my ($self) = @_;
Subroutine _cache_non_solexa: not called CC=2 SCAR=17.9
81 0 my $enc = $self->variant;
82 0 my ( @c2q, @q2c );
83  
84 0 my $ascii_offset = $VARIANT{$enc}{'ascii_offset'};
85 0 ▶ for ( my $i = 0; $i < $VARIANT{$enc}{'q_end'} - $VARIANT{$enc}{'q_start'} + 1; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < $Bio::Gonzales::Seq::IO::fastq::VARIANT{$enc}{"q_end"} - $Bio::Gonzales::Seq::IO::fastq::VARIANT{$enc}{"q_start"} + 1) 0 0 0
86 0 my $q = $i + $VARIANT{$enc}{'q_start'};
87 0 my $c = $q + $ascii_offset;
88 0 $c2q[$c] = $q;
89 0 $q2c[$i] = chr($c);
90  
91 }
92 $self->cache(
93 {
94 c2q => \@c2q,
95 q2c => \@q2c,
96 q_start => $VARIANT{$enc}{'q_start'},
97 0 q_end => $VARIANT{$enc}{'q_end'},
98 ascii_offset => $ascii_offset
99  
100 }
101 );
102 }
103  
104 1 __PACKAGE__->meta->make_immutable;
105  
106 1 1;
« blib/lib/Bio/Gonzales/Util/Text.pm ↑ Summary blib/lib/Bio/Gonzales/Align/IO.pm »