| 1 | package Bio::AssemblyImprovement::Util::GetReadLengthsRole; | ||||||||||||||||||||||||||||
| 2 | # ABSTRACT: Role for getting the read lengths from a fastq file (useful when reads are of varying lengths) | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use Moose::Role; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Bio::SeqIO; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 0 | ▶ | sub _get_read_names_and_lengths { | ||||||||||||||||||||||||||
|
Subroutine
_get_read_names_and_lengths: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 0 | my ( $self, $input_filename) = @_; | |||||||||||||||||||||||||||
| 12 | 0 | ▶ | return undef unless(defined($input_filename)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 0 | my %read_names_with_length; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 0 | ▶ | if ( $input_filename =~ /\.fq$/ || $input_filename =~ /\.fastq$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$input_filename =~ /\.fq$/ or $input_filename =~ /\.fastq$/
MC/DC0%0/2
$input_filename =~ /\.fq$/ or $input_filename =~ /\.fastq$/
$input_filename =~ /\.fq$/
$input_filename =~ /\.fastq$/
Truth table0%0/3
A or B
A= $input_filename =~ /\.fq$/B= $input_filename =~ /\.fastq$/
| |||||||||||||||||||||||||||||
| 17 | 0 | my $fastq_obj = Bio::SeqIO->new( -file => $input_filename , -format => 'Fastq'); | |||||||||||||||||||||||||||
| 18 | 0 | ▶ | while(my $seq = $fastq_obj->next_seq()){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | # Add the read name and the read length to the hash | ||||||||||||||||||||||||||||
| 20 | 0 | $read_names_with_length{ $seq->id() } = length( $seq->seq() ); | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | return \%read_names_with_length; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | else { | ||||||||||||||||||||||||||||
| 26 | 0 | return undef; # Error message? | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 2 | ▶ | sub _get_read_lengths { | ||||||||||||||||||||||||||
|
Subroutine
_get_read_lengths: called CC=5 SCAR=17.1
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 2 | my ( $self, $input_filename) = @_; | |||||||||||||||||||||||||||
| 33 | 2 | ▶ | return undef unless(defined($input_filename)); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 2 | my @read_lengths; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | 2 | ▶ | if ( $input_filename =~ /\.fq$/ || $input_filename =~ /\.fastq$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$input_filename =~ /\.fq$/ or $input_filename =~ /\.fastq$/
MC/DC0%0/2
$input_filename =~ /\.fq$/ or $input_filename =~ /\.fastq$/
$input_filename =~ /\.fq$/
$input_filename =~ /\.fastq$/
Truth table33%1/3
A or B
A= $input_filename =~ /\.fq$/B= $input_filename =~ /\.fastq$/
| |||||||||||||||||||||||||||||
| 38 | 2 | my $fastq_obj = Bio::SeqIO->new( -file => $input_filename , -format => 'Fastq'); | |||||||||||||||||||||||||||
| 39 | 2 | ▶ | while(my $seq = $fastq_obj->next_seq()){ | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | # Add the read lengths to an array | ||||||||||||||||||||||||||||
| 41 | 8 | push( @read_lengths, length($seq->seq()) ); | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | 2 | return \@read_lengths; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | else { | ||||||||||||||||||||||||||||
| 46 | 0 | return undef; # Error message? | |||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 4 | ▶ | no Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 51 | 4 | 1; | |||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | __END__ | ||||||||||||||||||||||||||||