blib/lib/Bio/Tradis/Parser/Fastq.pm

filter: Statementstmt 100% 37 / 37 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 93.7% 45 / 48 CC 3 SCAR 4.6
CC
3
Cov
98%
_build__fastq_handle
2.0
next_read
2.0
BEGIN
1.0
CRAP 1.6
« blib/lib/Bio/Tradis/Analysis/Exceptions.pm ↑ Summary blib/lib/Bio/Tradis/TradisPlot.pm »
1 package Bio::Tradis::Parser::Fastq;
2  
3 # ABSTRACT: Basic FastQ parser.
4  
5  
6 5 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 5 has 'file' => ( is => 'rw', isa => 'Str', required => 1 );
9 5 has '_fastq_handle' => (
10 is => 'ro',
11 isa => 'FileHandle',
12 required => 0,
13 lazy => 1,
14 builder => '_build__fastq_handle'
15 );
16 5 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 9 ▶ my ($self) = @_;
Subroutine _build__fastq_handle: called CC=2 SCAR=7.0
26 9 my $fastqfile = $self->file;
27  
28 9 ▶ open( my $fqh, "<", $fastqfile ) or die "Cannot open $fastqfile";
Branch: 1 branch
BranchTrueFalseTotal
open my $fqh, "<", $fastqfile or die "Cannot open $fastqfile" 0 9 9
29 9 return $fqh;
30 }
31  
32 ### Public methods ###
33  
34  
35 sub next_read {
36 86 ▶ my ($self) = @_;
Subroutine next_read: called CC=2 SCAR=6.9
Pod undocumented
37 86 my $fqh = $self->_fastq_handle;
38  
39 86 my $read = <$fqh>;
40 86 ▶ if ( defined($read) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $read) { } 78 8 86
41 78 $self->_set_currentread($read);
42 78 return 1;
43 }
44 else {
45 8 return 0;
46 }
47 }
48  
49 sub read_info {
50 78 ▶ my ($self) = @_;
Subroutine read_info: called CC=1 SCAR=0.0
Pod undocumented
51 78 my $fqh = $self->_fastq_handle;
52  
53 78 my @fastq_read;
54  
55 # get id
56 78 my $id = $self->_currentread;
57 78 chomp($id);
58 78 $id =~ s/^\@//;
59 78 push( @fastq_read, $id );
60  
61 # get sequence
62 78 my $seq = <$fqh>;
63 78 chomp($seq);
64 78 push( @fastq_read, $seq );
65  
66 # skip + line
67 78 my $skip = <$fqh>;
68  
69 # get quality
70 78 my $qual = <$fqh>;
71 78 chomp($qual);
72 78 push( @fastq_read, $qual );
73  
74 78 return @fastq_read;
75  
76 }
77  
78 5 __PACKAGE__->meta->make_immutable;
79 5 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
80 5 1;
81  
82 __END__
83  
84 =pod
85  
86 =head1 NAME
87  
88 Bio::Tradis::Parser::Fastq - Basic FastQ parser.
89  
90 =head1 VERSION
91  
92 version 1.132190
93  
94 =head1 SYNOPSIS
95  
96 Parses fastq files.
97 use Bio::Tradis::Parser::Fastq;
98  
99 my $pipeline = Bio::Tradis::Parser::Fastq->new(file => 'abc');
100 $pipeline->next_read;
101 $pipeline->read_info;
102  
103 =next_read
104 Moves to the next read. Returns 1 if read exists, returns 0
105 if EOF
106  
107 =read_info
108 Returns an array of info for the read in an array.
109 0 = id
110 1 = sequence
111 2 = quality string
112  
113 =head1 AUTHOR
114  
115 Carla Cummins <cc21@sanger.ac.uk>
116  
117 =head1 COPYRIGHT AND LICENSE
118  
119 This software is Copyright (c) 2013 by Wellcome Trust Sanger Institute.
120  
121 This is free software, licensed under:
122  
123 The GNU General Public License, Version 3, June 2007
124  
125 =cut
« blib/lib/Bio/Tradis/Analysis/Exceptions.pm ↑ Summary blib/lib/Bio/Tradis/TradisPlot.pm »