Skip to content

Commit

Permalink
Merge pull request #513 from dozy/spatial_filter_stats_parsing_update
Browse files Browse the repository at this point in the history
update parsing of spatial filter stats in spatial_filter QC check
  • Loading branch information
srl147 authored May 17, 2018
2 parents 2b40ed8 + 53935e4 commit 999e536
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 1,848 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ dist:

addons:
postgresql: "9.3"
apt:
update: true

env:
global:
Expand Down
2 changes: 2 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
LIST OF CHANGES FOR NPG-QC PACKAGE

- update parsing of spatial filter stats in spatial_filter QC check

release 64.6.2
- QC viewer changes for genotype call

Expand Down
8 changes: 4 additions & 4 deletions lib/npg_qc/autoqc/results/spatial_filter.pm
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ has 'num_spatial_filter_fail_reads'=> (
sub parse_output{
my ( $self, $stderr_output ) = @_;

#Processed 419675538 traces
#QC failed 0 traces
# expected format: "Total Processed 943540734 Failed 4338894 traces"

my $log = slurp defined $stderr_output ? $stderr_output : \*STDIN;
if($log=~/^Processed \s+ (\d+) \s+ traces$/smx) {$self->num_total_reads($1);}
if($log=~/^(?:QC[ ]failed|Removed) \s+ (\d+) \s+ traces$/smx) {$self->num_spatial_filter_fail_reads($1);}
my ($total, $fail) = ($log =~ /^Total \t Processed \s+ (\d+) \s+ Failed \s+ (\d+) \s+ traces$/smx);
$self->num_total_reads($total);
$self->num_spatial_filter_fail_reads($fail);

return;
}
Expand Down
44 changes: 23 additions & 21 deletions t/60-autoqc-results-spatial_filter.t
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ my $tempdir = tempdir( CLEANUP => 1);
{
my $r = npg_qc::autoqc::results::spatial_filter->new(
position => 1,
id_run => 8926,
id_run => 25810,
);
isa_ok ($r, 'npg_qc::autoqc::results::spatial_filter');

my $stats_output_string = slurp 't/data/autoqc/PB_cal_score_8926_1_20121209-190404.494308.out';
my $stats_output_string = slurp 't/data/autoqc/25810_1.bam.filter.stats';

$r->parse_output(\$stats_output_string);

is($r->num_total_reads, 2*209837769, 'total reads');
is($r->num_spatial_filter_fail_reads, 0, 'spatial filter fail reads');
is($r->num_total_reads, 629464762, 'total reads');
is($r->num_spatial_filter_fail_reads, 42, 'spatial filter fail reads');

lives_ok {
$r->freeze();
Expand All @@ -30,7 +31,7 @@ my $tempdir = tempdir( CLEANUP => 1);

is ($r->composition->num_components, 1, 'one component');
my $component = $r->composition->get_component(0);
is ($component->id_run, 8926, 'component id_run');
is ($component->id_run, 25810, 'component id_run');
is ($component->position, 1, 'component position');
ok (!$component->has_tag_index, 'component tag index has not been set');
is ($component->tag_index, undef, 'component tag index is undefined');
Expand All @@ -39,31 +40,31 @@ my $tempdir = tempdir( CLEANUP => 1);
{
my $r = npg_qc::autoqc::results::spatial_filter->new(
position => 2,
id_run => 8926,
id_run => 25810,
);

open my $stats_output_fh, '<',
't/data/autoqc/PB_cal_score_8926_2_20121209-190404.494309.out' or croak 'fail to open fh';
't/data/autoqc/25810_2.bam.filter.stats' or croak 'fail to open fh';
lives_ok {
local *STDIN=$stats_output_fh;
$r->parse_output();
} 'parse from (pseudo) stdin';
close $stats_output_fh or croak 'fail to close fh';

is($r->num_total_reads, 439161826, 'total reads');
is($r->num_spatial_filter_fail_reads, 358824, 'spatial filter fail reads');
is($r->num_total_reads, 649612652, 'total reads');
is($r->num_spatial_filter_fail_reads, 1024, 'spatial filter fail reads');

lives_ok {
$r->freeze();
$r->store($tempdir);
} 'no error when save data into json (store passed directory)';

my $hash = from_json( slurp qq{$tempdir/8926_2.spatial_filter.json} );
my $hash = from_json( slurp qq{$tempdir/25810_2.spatial_filter.json} );

my $expected_hash_structure = {
'num_total_reads' => 439161826,
'num_spatial_filter_fail_reads' => 358824,
'id_run' => 8926,
'num_total_reads' => 649612652,
'num_spatial_filter_fail_reads' => 1024,
'id_run' => 25810,
'info' => {},
'position' => 2,
};
Expand Down Expand Up @@ -94,30 +95,31 @@ my $tempdir = tempdir( CLEANUP => 1);
{
my $r = npg_qc::autoqc::results::spatial_filter->new(
position => 4,
id_run => 8926,
id_run => 25810,
);
open my $stats_output_fh, '<',
't/data/autoqc/PB_cal_score_8926_4_20121209-190404.494309.out' or croak 'fail to open fh';
't/data/autoqc/25810_4.bam.filter.stats' or croak 'fail to open fh';

lives_ok {
local *STDIN=$stats_output_fh;
$r->parse_output();
} 'parse from (pseudo) stdin';
close $stats_output_fh or croak 'fail to close fh';

is($r->num_total_reads, 439161826, 'total reads');
is($r->num_spatial_filter_fail_reads, 358824, 'spatial filter fail reads');
is($r->num_total_reads, 653495042, 'total reads');
is($r->num_spatial_filter_fail_reads, 115390, 'spatial filter fail reads');

lives_ok {
$r->freeze();
$r->store($tempdir);
} 'no error when save data into json (store passed directory)';

my $hash = from_json( slurp qq{$tempdir/8926_4.spatial_filter.json} );
my $hash = from_json( slurp qq{$tempdir/25810_4.spatial_filter.json} );

my $expected_hash_structure = {
'num_total_reads' => 439161826,
'num_spatial_filter_fail_reads' => 358824,
'id_run' => 8926,
'num_total_reads' => 653495042,
'num_spatial_filter_fail_reads' => 115390,
'id_run' => 25810,
'info' => {},
'position' => 4,
};
Expand Down
2 changes: 2 additions & 0 deletions t/data/autoqc/25810_1.bam.filter.stats
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Total Processed 629464762 Failed 42 traces

2 changes: 2 additions & 0 deletions t/data/autoqc/25810_2.bam.filter.stats
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Total Processed 649612652 Failed 1024 traces

2 changes: 2 additions & 0 deletions t/data/autoqc/25810_4.bam.filter.stats
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Total Processed 653495042 Failed 115390 traces

Loading

0 comments on commit 999e536

Please sign in to comment.