lib/Bio/Tradis/Parser/Fastq.pm

filter: Statementstmt 100% 38 / 38 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 2 totaltotal 93.8% 46 / 49 CC 3 SCAR 4.6
CC
3
Cov
98%
_build__fastq_handle
2.0
next_read
2.0
BEGIN
1.0
CRAP 1.6
« lib/Bio/Tradis/DetectTags.pm ↑ Summary lib/Bio/Tradis/TradisPlot.pm »
1 package Bio::Tradis::Parser::Fastq;
2 9 $Bio::Tradis::Parser::Fastq::VERSION = '1.4.5';
3 # ABSTRACT: Basic FastQ parser.
4  
5  
6 9 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 has 'file' => ( is => 'rw', isa => 'Str', required => 1 );
9 9 has '_fastq_handle' => (
10 is => 'ro',
11 isa => 'FileHandle',
12 required => 0,
13 lazy => 1,
14 builder => '_build__fastq_handle'
15 );
16 9 has '_currentread' => (
17 is => 'rw',
18 isa => 'Str',
19 required => 0,
20 writer => '_set_currentread'
21 );
22 ### Private methods ###
23  
24 22 ▶sub _build__fastq_handle {
Subroutine _build__fastq_handle: called CC=2 SCAR=7.0
25 22 my ($self) = @_;
26 22 my $fastqfile = $self->file;
27  
28 22 ▶ open( my $fqh, "<", $fastqfile ) or die "Cannot open $fastqfile";
Branch: 1 branch
BranchTrueFalseTotal
open my $fqh, "<", $fastqfile or die "Cannot open $fastqfile" 22 0 22
29 22 return $fqh;
30 }
31  
32 ### Public methods ###
33  
34  
35 227 ▶sub next_read {
Subroutine next_read: called CC=2 SCAR=6.9
Pod undocumented
36 227 my ($self) = @_;
37 227 my $fqh = $self->_fastq_handle;
38  
39 227 my $read = <$fqh>;
40 227 ▶ if ( defined($read) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $read) { } 213 14 227
41 213 $self->_set_currentread($read);
42 213 return 1;
43 }
44 else {
45 14 return 0;
46 }
47 }
48  
49 213 ▶sub read_info {
Subroutine read_info: called CC=1 SCAR=0.0
Pod undocumented
50 213 my ($self) = @_;
51 213 my $fqh = $self->_fastq_handle;
52  
53 213 my @fastq_read;
54  
55 # get id
56 213 my $id = $self->_currentread;
57 213 chomp($id);
58 213 $id =~ s/^\@//;
59 213 push( @fastq_read, $id );
60  
61 # get sequence
62 213 my $seq = <$fqh>;
63 213 chomp($seq);
64 213 push( @fastq_read, $seq );
65  
66 # skip + line
67 213 my $skip = <$fqh>;
68  
69 # get quality
70 213 my $qual = <$fqh>;
71 213 chomp($qual);
72 213 push( @fastq_read, $qual );
73  
74 213 return @fastq_read;
75  
76 }
77  
78 9 __PACKAGE__->meta->make_immutable;
79 9 ▶no Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
80 9 1;
81  
82 __END__
« lib/Bio/Tradis/DetectTags.pm ↑ Summary lib/Bio/Tradis/TradisPlot.pm »