line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Gonzales::Seq::IO::fastq; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
78656
|
use Mouse; |
|
1
|
|
|
|
|
30886
|
|
|
1
|
|
|
|
|
3
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
389
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
40
|
|
6
|
1
|
|
|
1
|
|
7
|
use strict; |
|
1
|
|
|
|
|
8
|
|
|
1
|
|
|
|
|
19
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
23
|
use 5.010; |
|
1
|
|
|
|
|
5
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.083'; # VERSION |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
has cache => ( is => 'rw' ); |
31
|
|
|
|
|
|
|
has variant => ( is => 'rw', default => 'sanger' ); |
32
|
|
|
|
|
|
|
has _ascii_offset => ( is => 'rw' ); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub BUILD { |
35
|
1
|
|
|
1
|
1
|
280
|
my ($self) = @_; |
36
|
|
|
|
|
|
|
|
37
|
1
|
50
|
|
|
|
8
|
if ( $self->variant eq 'solexa' ) { $self->_cache_solexa } |
|
1
|
0
|
|
|
|
4
|
|
|
|
0
|
|
|
|
|
|
38
|
0
|
|
|
|
|
0
|
elsif ( $self->variant eq 'illumina' ) { $self->_cache_non_solexa } |
39
|
0
|
|
|
|
|
0
|
elsif ( $self->variant eq 'sanger' ) { $self->_cache_non_solexa } |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub _cache_solexa { |
43
|
1
|
|
|
1
|
|
2
|
my ($self) = @_; |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
|
|
3
|
my ( @c2q, @q2c, @sol2phred, %phred_fp2chr, @phred_int2chr ); |
46
|
|
|
|
|
|
|
|
47
|
1
|
|
|
|
|
3
|
my $ascii_offset = $VARIANT{'solexa'}{'ascii_offset'}; |
48
|
1
|
|
|
|
|
34
|
for ( my $i = 0; $i < $VARIANT{'solexa'}{'q_end'} - $VARIANT{'solexa'}{'q_start'} + 1; $i++ ) { |
49
|
68
|
|
|
|
|
130
|
my $q = $i + $VARIANT{'solexa'}{'q_start'}; |
50
|
68
|
|
|
|
|
84
|
my $c = $q + $ascii_offset; |
51
|
68
|
|
|
|
|
106
|
$c2q[$c] = $q; |
52
|
68
|
|
|
|
|
133
|
$q2c[$i] = chr($c); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# solexa <=> solexa mapping speedup (retain floating pt precision) |
55
|
68
|
|
|
|
|
215
|
my $s2p = 10 * log( 1 + 10**( $q / 10.0 ) ) / log(10); |
56
|
68
|
|
|
|
|
107
|
$sol2phred[$i] = $s2p; |
57
|
|
|
|
|
|
|
|
58
|
68
|
|
|
|
|
274
|
$phred_fp2chr{$s2p} = chr($c); |
59
|
|
|
|
|
|
|
|
60
|
68
|
100
|
|
|
|
133
|
next if $q < 0; # skip loop; PHRED scores greater than 0 |
61
|
63
|
100
|
|
|
|
177
|
my $p2s = sprintf( "%.0f", ( $q <= 1 ) ? -5 : 10 * log( -1 + 10**( $q / 10.0 ) ) / log(10) ); |
62
|
|
|
|
|
|
|
# sanger/illumina PHRED <=> Solexa char mapping speedup |
63
|
63
|
|
|
|
|
218
|
$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
|
|
|
|
|
18
|
q_end => $VARIANT{'solexa'}{'q_end'}, |
74
|
|
|
|
|
|
|
ascii_offset => $ascii_offset, |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
); |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _cache_non_solexa { |
80
|
0
|
|
|
0
|
|
|
my ($self) = @_; |
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++ ) { |
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
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
1; |