Commit 0898e9c2 authored by Aaron Petkau's avatar Aaron Petkau

Fixed issue when encountering fastqc results that are invalid. Skipping over these files

parent de6d8cdd
......@@ -45,7 +45,9 @@ A spreadsheet listing the estimated coverage for each sample in the project(s).
* Perl
* Perl Modules
* `Excel::Writer::XLSX` - Install with `cpanm Excel::Writer::XLSX`
* `Excel::Writer::XLSX`
* `Try::Tiny`
* Install with `cpanm Excel::Writer::XLSX Try::Tiny`
# Legal
......
......@@ -10,6 +10,7 @@ use Term::ANSIColor;
use Data::Dumper;
use Time::Piece;
use Excel::Writer::XLSX;
use Try::Tiny;
my $usage = <<"HELP";
Usage:
......@@ -151,22 +152,32 @@ foreach my $project_id (@project_ids) {
my ($forward_qc_link) = grep { $_->{'rel'} eq 'sequencefile/qc' } @{$forward->{'links'}};
my ($reverse_qc_link) = grep { $_->{'rel'} eq 'sequencefile/qc' } @{$reverse->{'links'}};
my $forward_qc = Parse::CPAN::Meta->load_json_string(
$client->get($forward_qc_link->{'href'})->{'content'})->{'resource'};
my $reverse_qc = Parse::CPAN::Meta->load_json_string(
$client->get($reverse_qc_link->{'href'})->{'content'})->{'resource'};
my $forward_qc;
my $reverse_qc;
my $skip = 0;
try {
$forward_qc = Parse::CPAN::Meta->load_json_string(
$client->get($forward_qc_link->{'href'})->{'content'})->{'resource'};
$reverse_qc = Parse::CPAN::Meta->load_json_string(
$client->get($reverse_qc_link->{'href'})->{'content'})->{'resource'};
} catch {
warn "invalid fastqc results for sample=$sample->{'sampleName'}, sequence_file_id=$sequence_file_pair->{'identifier'}, sequence_file_label=$sequence_file_pair->{'label'}. Will skip these files.";
$skip=1;
};
if (not $skip) {
my $total_bases = $forward_qc->{'totalBases'} + $reverse_qc->{'totalBases'};
my $coverage = sprintf "%0.0f",($total_bases/$reference_size);
my $total_bases = $forward_qc->{'totalBases'} + $reverse_qc->{'totalBases'};
my $coverage = sprintf "%0.0f",($total_bases/$reference_size);
my $project_date = localtime($project_info->{'createdDate'}/1000)->strftime('%F %T');
my $sample_date = localtime($sample->{'createdDate'}/1000)->strftime('%F %T');
my $sample_updated_date = localtime($sample->{'modifiedDate'}/1000)->strftime('%F %T');
my $project_date = localtime($project_info->{'createdDate'}/1000)->strftime('%F %T');
my $sample_date = localtime($sample->{'createdDate'}/1000)->strftime('%F %T');
my $sample_updated_date = localtime($sample->{'modifiedDate'}/1000)->strftime('%F %T');
my $file_pair_label = $sequence_file_pair->{'label'};
my $file_pair_label = $sequence_file_pair->{'label'};
$report_worksheet->write_row($row,0,[$project_info->{'name'},$sample->{'sampleName'},$coverage,$total_bases,$reference_size,$project_info->{'identifier'},$sample->{'identifier'},$sequence_file_pair->{'identifier'},$file_pair_label]);
$row++;
$report_worksheet->write_row($row,0,[$project_info->{'name'},$sample->{'sampleName'},$coverage,$total_bases,$reference_size,$project_info->{'identifier'},$sample->{'identifier'},$sequence_file_pair->{'identifier'},$file_pair_label]);
$row++;
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment