diff --git a/Changes b/Changes index b3f95fc29..a632f6d65 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,14 @@ LIST OF CHANGES FOR NPG-QC PACKAGE +release 69.5.0 + - measures to speed-up generation of SeqQC pages: + - add a prefetch for compositions and components when retrieving autoqc + results from a database; + - use in-line custom sort function instead of a closure for ref_match + result objects + - disable a check for circular references in serialization of autoqc + result objects + release 69.4.0 - mqc skipper not to consider runs tagged 'no_auto' or 'no_mqc_skipper' diff --git a/lib/npg_qc/autoqc/qc_store.pm b/lib/npg_qc/autoqc/qc_store.pm index 46675c68c..d0bfa304b 100644 --- a/lib/npg_qc/autoqc/qc_store.pm +++ b/lib/npg_qc/autoqc/qc_store.pm @@ -260,7 +260,7 @@ autoqc result objects corresponding to JSON files. my $query = npg_qc::autoqc::qc_store::query_non_tracking->new( id_run => 123); - my $c = $obj->load_from_staging_archive($query, $archive_dir); + my $c = $obj->load_from_staging_archive($query, $archive_dir); =cut @@ -515,6 +515,14 @@ sub _build__available_classes { return \@names; } +=head2 _db_collection4compositions + +Takes a listref of composition dbIDs, and queries all available QC result types +for each composition. Returns a collection of result objects of mixed QC +types + +=cut + sub _db_collection4compositions { my ($self, $composition_ids) = @_; @@ -525,7 +533,20 @@ sub _db_collection4compositions { if (@{$composition_ids}) { foreach my $name (@{$self->_available_classes}) { push @rows, $self->qc_schema()->resultset($name) - ->search({'me.id_seq_composition' => $composition_ids})->all(); + ->search( + { + 'me.id_seq_composition' => $composition_ids + }, + { + # later uses of this collection will need access to components + # and prefetching halves the overhead + prefetch => { + 'seq_composition' => { + 'seq_component_compositions' => 'seq_component' + } + } + } + )->all(); } } diff --git a/lib/npg_qc/autoqc/role/ref_match.pm b/lib/npg_qc/autoqc/role/ref_match.pm index eee297e4d..7925a9a28 100644 --- a/lib/npg_qc/autoqc/role/ref_match.pm +++ b/lib/npg_qc/autoqc/role/ref_match.pm @@ -32,14 +32,11 @@ sub ranked_organisms { # Deterministic ranking of organisms: # reverse numerical comparison of alignment results # followed, if necessary, by string comparison of names. - my $compare = sub { - my ($org1, $org2) = @_; - my $result = $ratings->{$org2} <=> $ratings->{$org1}; - $result ||= $org1 cmp $org2; - return $result; - }; - - my @ranked_organisms = sort { $compare->($a, $b) } keys %{$ratings}; + ## no critic (BuiltinFunctions::ProhibitReverseSortBlock) + my @ranked_organisms = sort { + $ratings->{$b} <=> $ratings->{$a} + || $a cmp $b + } keys %{$ratings}; return \@ranked_organisms; } diff --git a/lib/npg_qc/autoqc/role/result.pm b/lib/npg_qc/autoqc/role/result.pm index 7a7481dcc..fe779a54c 100644 --- a/lib/npg_qc/autoqc/role/result.pm +++ b/lib/npg_qc/autoqc/role/result.pm @@ -9,7 +9,7 @@ use Readonly; use List::MoreUtils qw(none uniq); use Digest::MD5 qw/md5_hex/; -with Storage( 'traits' => ['OnlyWhenBuilt'], +with Storage( 'traits' => [qw/OnlyWhenBuilt DisableCycleDetection/], 'format' => 'JSON', 'io' => 'File' ), 'npg_qc::autoqc::role::rpt_key'; @@ -380,7 +380,7 @@ Marina Gourtovaia Emg8@sanger.ac.ukE =head1 LICENSE AND COPYRIGHT -Copyright (C) 2014,2015,2016,2017,2018,2019,2020 Genome Research Ltd. +Copyright (C) 2014,2015,2016,2017,2018,2019,2020,2021 Genome Research Ltd. This file is part of NPG. diff --git a/t/60-autoqc-checks-check.t b/t/60-autoqc-checks-check.t index aa76d1bcd..efc7edd40 100644 --- a/t/60-autoqc-checks-check.t +++ b/t/60-autoqc-checks-check.t @@ -30,10 +30,10 @@ subtest 'validation of attributes' => sub { plan tests => 36; ; throws_ok {npg_qc::autoqc::checks::check->new(path => $path)} - qr/Either id_run or position key is undefined/, + qr/'id_run' key is undefined/, 'error on instantiating an object without any id'; throws_ok {npg_qc::autoqc::checks::check->new(path => $path, id_run => $idrun)} - qr/Either id_run or position key is undefined/, + qr/'position' key is undefined/, 'error on instantiating an object without either a position or rpt_list attr'; throws_ok {npg_qc::autoqc::checks::check->new( position => 17, path => $path, id_run => $idrun)} @@ -58,7 +58,7 @@ subtest 'validation of attributes' => sub { lives_ok {npg_qc::autoqc::checks::check->new(position => 2, id_run => $idrun)} 'no error on instantiating an object without a path/qc_in attr'; throws_ok {npg_qc::autoqc::checks::check->new(position => 2, qc_in => 't')} - qr/Either id_run or position key is undefined/, + qr/'id_run' key is undefined/, 'error on instantiating an object without either a run id or an rpt_list attr'; throws_ok {npg_qc::autoqc::checks::check->new( position => 1, path => 'nonexisting', id_run => -1)}