line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Bio::Tradis::Parser::Fastq; |
2
|
|
|
|
|
|
|
$Bio::Tradis::Parser::Fastq::VERSION = '1.3.3'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Basic FastQ parser. |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
6
|
|
|
6
|
|
100346
|
use Moose; |
|
6
|
|
|
|
|
390375
|
|
|
6
|
|
|
|
|
30
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has 'file' => ( is => 'rw', isa => 'Str', required => 1 ); |
9
|
|
|
|
|
|
|
has '_fastq_handle' => ( |
10
|
|
|
|
|
|
|
is => 'ro', |
11
|
|
|
|
|
|
|
isa => 'FileHandle', |
12
|
|
|
|
|
|
|
required => 0, |
13
|
|
|
|
|
|
|
lazy => 1, |
14
|
|
|
|
|
|
|
builder => '_build__fastq_handle' |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
has '_currentread' => ( |
17
|
|
|
|
|
|
|
is => 'rw', |
18
|
|
|
|
|
|
|
isa => 'Str', |
19
|
|
|
|
|
|
|
required => 0, |
20
|
|
|
|
|
|
|
writer => '_set_currentread' |
21
|
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
### Private methods ### |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub _build__fastq_handle { |
25
|
16
|
|
|
16
|
|
35
|
my ($self) = @_; |
26
|
16
|
|
|
|
|
353
|
my $fastqfile = $self->file; |
27
|
|
|
|
|
|
|
|
28
|
16
|
50
|
|
|
|
631
|
open( my $fqh, "<", $fastqfile ) or die "Cannot open $fastqfile"; |
29
|
16
|
|
|
|
|
396
|
return $fqh; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
### Public methods ### |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub next_read { |
36
|
170
|
|
|
170
|
0
|
1437
|
my ($self) = @_; |
37
|
170
|
|
|
|
|
3647
|
my $fqh = $self->_fastq_handle; |
38
|
|
|
|
|
|
|
|
39
|
170
|
|
|
|
|
599
|
my $read = <$fqh>; |
40
|
170
|
100
|
|
|
|
360
|
if ( defined($read) ) { |
41
|
158
|
|
|
|
|
3809
|
$self->_set_currentread($read); |
42
|
158
|
|
|
|
|
448
|
return 1; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
else { |
45
|
12
|
|
|
|
|
60
|
return 0; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub read_info { |
50
|
158
|
|
|
158
|
0
|
259
|
my ($self) = @_; |
51
|
158
|
|
|
|
|
3287
|
my $fqh = $self->_fastq_handle; |
52
|
|
|
|
|
|
|
|
53
|
158
|
|
|
|
|
220
|
my @fastq_read; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
# get id |
56
|
158
|
|
|
|
|
3161
|
my $id = $self->_currentread; |
57
|
158
|
|
|
|
|
308
|
chomp($id); |
58
|
158
|
|
|
|
|
530
|
$id =~ s/^\@//; |
59
|
158
|
|
|
|
|
321
|
push( @fastq_read, $id ); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# get sequence |
62
|
158
|
|
|
|
|
323
|
my $seq = <$fqh>; |
63
|
158
|
|
|
|
|
236
|
chomp($seq); |
64
|
158
|
|
|
|
|
243
|
push( @fastq_read, $seq ); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# skip + line |
67
|
158
|
|
|
|
|
238
|
my $skip = <$fqh>; |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# get quality |
70
|
158
|
|
|
|
|
263
|
my $qual = <$fqh>; |
71
|
158
|
|
|
|
|
211
|
chomp($qual); |
72
|
158
|
|
|
|
|
252
|
push( @fastq_read, $qual ); |
73
|
|
|
|
|
|
|
|
74
|
158
|
|
|
|
|
559
|
return @fastq_read; |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
79
|
6
|
|
|
6
|
|
37809
|
no Moose; |
|
6
|
|
|
|
|
13
|
|
|
6
|
|
|
|
|
31
|
|
80
|
|
|
|
|
|
|
1; |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
__END__ |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=pod |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=encoding UTF-8 |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 NAME |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Bio::Tradis::Parser::Fastq - Basic FastQ parser. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 VERSION |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
version 1.3.3 |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 SYNOPSIS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Parses fastq files. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
use Bio::Tradis::Parser::Fastq; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
my $pipeline = Bio::Tradis::Parser::Fastq->new(file => 'abc'); |
103
|
|
|
|
|
|
|
$pipeline->next_read; |
104
|
|
|
|
|
|
|
$pipeline->read_info; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=next_read |
107
|
|
|
|
|
|
|
Moves to the next read. Returns 1 if read exists, returns 0 |
108
|
|
|
|
|
|
|
if EOF |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=read_info |
111
|
|
|
|
|
|
|
Returns an array of info for the read in an array. |
112
|
|
|
|
|
|
|
0 = id |
113
|
|
|
|
|
|
|
1 = sequence |
114
|
|
|
|
|
|
|
2 = quality string |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 AUTHOR |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Carla Cummins <path-help@sanger.ac.uk> |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute. |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
This is free software, licensed under: |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
The GNU General Public License, Version 3, June 2007 |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |