/usr/share/perl5/Bio/Tradis/Parser/Fastq.pm is in bio-tradis 1.3.3+dfsg-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | package Bio::Tradis::Parser::Fastq;
# ABSTRACT: Basic FastQ parser.
=head1 SYNOPSIS
Parses fastq files.
use Bio::Tradis::Parser::Fastq;
my $pipeline = Bio::Tradis::Parser::Fastq->new(file => 'abc');
$pipeline->next_read;
$pipeline->read_info;
=cut
use Moose;
has 'file' => ( is => 'rw', isa => 'Str', required => 1 );
has '_fastq_handle' => (
is => 'ro',
isa => 'FileHandle',
required => 0,
lazy => 1,
builder => '_build__fastq_handle'
);
has '_currentread' => (
is => 'rw',
isa => 'Str',
required => 0,
writer => '_set_currentread'
);
### Private methods ###
sub _build__fastq_handle {
my ($self) = @_;
my $fastqfile = $self->file;
open( my $fqh, "<", $fastqfile ) or die "Cannot open $fastqfile";
return $fqh;
}
### Public methods ###
=next_read
Moves to the next read. Returns 1 if read exists, returns 0
if EOF
=cut
sub next_read {
my ($self) = @_;
my $fqh = $self->_fastq_handle;
my $read = <$fqh>;
if ( defined($read) ) {
$self->_set_currentread($read);
return 1;
}
else {
return 0;
}
}
=read_info
Returns an array of info for the read in an array.
0 = id
1 = sequence
2 = quality string
=cut
sub read_info {
my ($self) = @_;
my $fqh = $self->_fastq_handle;
my @fastq_read;
# get id
my $id = $self->_currentread;
chomp($id);
$id =~ s/^\@//;
push( @fastq_read, $id );
# get sequence
my $seq = <$fqh>;
chomp($seq);
push( @fastq_read, $seq );
# skip + line
my $skip = <$fqh>;
# get quality
my $qual = <$fqh>;
chomp($qual);
push( @fastq_read, $qual );
return @fastq_read;
}
__PACKAGE__->meta->make_immutable;
no Moose;
1;
|