diff --git a/Changes b/Changes index 038a1149..2cb9ed79 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,13 @@ LIST OF CHANGES --------------- + - Changed pipeline daemons so that they pick up runs performed on the + instruments by a manufacturer with a name given by a new attribute - + instrument_name. By default this name is set to 'Illumina' so that + the daemons continue picking up Illumina-only runs even if other + runs are present in the run tracking database. + - Deleted redundant t::dbic_util::test_schema_wh method. + release 68.7.1 (2024-12-17) - Fix perlbrew installation by installing libdevel-patchperl-perl in runner - Changed/extended tests for npg_pipeline::function::autoqc to ensure that diff --git a/MANIFEST b/MANIFEST index 19c74e46..c6d548f4 100644 --- a/MANIFEST +++ b/MANIFEST @@ -139,6 +139,7 @@ t/data/cache/my_samplesheet_12376.csv t/data/dbic_fixtures/000-Designation.yml t/data/dbic_fixtures/000-EntityType.yml t/data/dbic_fixtures/000-InstrumentStatusDict.yml +t/data/dbic_fixtures/000-Manufacturer.yml t/data/dbic_fixtures/000-RunLaneStatusDict.yml t/data/dbic_fixtures/000-RunStatusDict.yml t/data/dbic_fixtures/000-Tag.yml diff --git a/lib/npg_pipeline/daemon.pm b/lib/npg_pipeline/daemon.pm index 2c63fc08..33892ee3 100644 --- a/lib/npg_pipeline/daemon.pm +++ b/lib/npg_pipeline/daemon.pm @@ -21,6 +21,7 @@ with qw{ our $VERSION = '0'; Readonly::Scalar my $SLEEPY_TIME => 900; +Readonly::Scalar my $DEFAULT_INSTRUMENT_MANUFACTURER => 'Illumina'; has 'pipeline_script_name' => ( isa => q{Str}, @@ -30,12 +31,21 @@ has 'pipeline_script_name' => ( builder => 'build_pipeline_script_name', ); +has 'manufacturer_name' => ( + isa => q{Str}, + is => q{ro}, + default => $DEFAULT_INSTRUMENT_MANUFACTURER, + documentation => 'Instrument manufacturer name, defaults to Illumina. ' . + 'Runs on instruments by this manufacturer only will be ' . + 'considered by this daemon.', +); + has 'dry_run' => ( isa => q{Bool}, is => q{ro}, required => 0, default => 0, - documentation => 'dry run mode flag, false by default', + documentation => 'Dry run mode flag, false by default', ); has 'seen' => ( @@ -58,6 +68,7 @@ sub _build_npg_tracking_schema { sub runs_with_status { my ($self, $status_name, $from_time) = @_; + if (!$status_name) { $self->logcroak(q[Need status name]); } @@ -73,7 +84,8 @@ sub runs_with_status { } return - map { $_->run() } + grep { $_->instrument_format->manufacturer->name eq $self->manufacturer_name } + map { $_->run() } $self->npg_tracking_schema()->resultset(q[RunStatus])->search( $condition, {prefetch=>q[run_status_dict], order_by => q[me.date],} @@ -194,8 +206,8 @@ case of error. =head2 runs_with_status With one argument, which should be a valid run status description, -returns a list of DBIx::Class::Row objects from the Run result set, -which correspond to runs with the current status descriptiongiven +returns a list of C objects from the C result set, +which correspond to runs with the current status description given by the argument. # find runs with current status 'archival pending' @@ -215,6 +227,9 @@ should be after the time given by the second argument. In both cases a list of returned objects is sorted in the assending run status timestamp order. +Only runs performed on the instruments by the manufacturer given by +the C attribute are chosen. + If no run satisfies the conditions given by the argument(s), an empty list is returned. diff --git a/t/50-npg_pipeline-daemon-analysis.t b/t/50-npg_pipeline-daemon-analysis.t index 76b8809d..6dab77c6 100644 --- a/t/50-npg_pipeline-daemon-analysis.t +++ b/t/50-npg_pipeline-daemon-analysis.t @@ -1,6 +1,6 @@ use strict; use warnings; -use Test::More tests => 12; +use Test::More tests => 8; use Test::Exception; use Cwd qw{ getcwd abs_path }; use File::Path qw{ make_path }; @@ -30,19 +30,38 @@ my $schema = t::dbic_util->new()->test_schema(); my $test_run = $schema->resultset(q[Run])->find(1234); $test_run->update_run_status('analysis pending', 'pipeline',); -my %h = map { $_ => 1 } (1234, 4330, 4999, 5222); -my @statuses = (); -for my $r ($schema->resultset(q[Run])->search({})->all()) { - my $id = $r->id_run; - if ($h{$id}) { - cmp_ok ($r->current_run_status_description, 'eq', - 'analysis pending', "test run $id is analysis pending"); - } else { - push @statuses, $r->current_run_status_description; +subtest 'runs and statuses' => sub { + plan tests => 10; + + my %h = map { $_ => 1 } (1234, 4330, 4999, 5222, 100000); + my @other_statuses = (); + for my $r ($schema->resultset(q[Run])->search({})->all()) { + my $id = $r->id_run; + if ($h{$id}) { + cmp_ok ($r->current_run_status_description, 'eq', + 'analysis pending', "test run $id is analysis pending"); + } else { + push @other_statuses, $r->current_run_status_description; + } } -} -is (scalar(grep { $_ eq 'analysis pending' } @statuses), 0, - 'other test runs are not analysis pending'); + is (scalar(grep { $_ eq 'analysis pending' } @other_statuses), 0, + 'other test runs are not analysis pending'); + + my $runner = npg_pipeline::daemon::analysis->new(npg_tracking_schema => $schema); + is ($runner->manufacturer_name, 'Illumina', 'default manufacturer name'); + my @run_ids = sort { $a <=> $b } map { $_->id_run } + $runner->runs_with_status('analysis pending'); + is (join(q[,], @run_ids), '1234,4330,4999,5222', 'correct Illumina runs IDs'); + + $runner = npg_pipeline::daemon::analysis->new( + manufacturer_name => 'Element Biosciences', + npg_tracking_schema => $schema + ); + is ($runner->manufacturer_name, 'Element Biosciences', + 'manufacturer name as set'); + @run_ids = map { $_->id_run } $runner->runs_with_status('analysis pending'); + ok ((@run_ids == 1) && ($run_ids[0] == 100000), 'One Element Biosciences run'); +}; my $rf_path = '/some/path'; diff --git a/t/data/dbic_fixtures/000-Manufacturer.yml b/t/data/dbic_fixtures/000-Manufacturer.yml new file mode 100644 index 00000000..4bede90a --- /dev/null +++ b/t/data/dbic_fixtures/000-Manufacturer.yml @@ -0,0 +1,7 @@ +--- +- id_manufacturer: 20 + name: Element Biosciences +- id_manufacturer: 10 + name: Illumina +- id_manufacturer: 16 + name: Roche/454 diff --git a/t/data/dbic_fixtures/100-InstrumentFormat.yml b/t/data/dbic_fixtures/100-InstrumentFormat.yml index b23a8bb3..4626deca 100644 --- a/t/data/dbic_fixtures/100-InstrumentFormat.yml +++ b/t/data/dbic_fixtures/100-InstrumentFormat.yml @@ -30,3 +30,11 @@ default_columns: 4 days_between_washes: 28 runs_between_washes: 1 +- id_instrument_format: 12 + id_manufacturer: 20 + model: AVITI23 + iscurrent: 1 + default_tiles: 0 + default_columns: 0 + days_between_washes: 30 + runs_between_washes: 1 diff --git a/t/data/dbic_fixtures/200-Instrument.yml b/t/data/dbic_fixtures/200-Instrument.yml index 732bbc40..996093f1 100644 --- a/t/data/dbic_fixtures/200-Instrument.yml +++ b/t/data/dbic_fixtures/200-Instrument.yml @@ -106,4 +106,12 @@ iscurrent: 1 ipaddr: instrument_comp: HS1 +- id_instrument: 70 + name: AVITI2301 + id_instrument_format: 12 + external_name: '' + serial: '' + iscurrent: 1 + ipaddr: ~ + instrument_comp: ~ diff --git a/t/data/dbic_fixtures/300-Run.yml b/t/data/dbic_fixtures/300-Run.yml index eafbe7ac..ae9df049 100644 --- a/t/data/dbic_fixtures/300-Run.yml +++ b/t/data/dbic_fixtures/300-Run.yml @@ -379,4 +379,18 @@ id_run_pair: ~ is_paired: 0 priority: 3 + team: A +- actual_cycle_count: 316 + batch_id: ~ + expected_cycle_count: 316 + flowcell_id: ~ + folder_name: 'elembio_run' + folder_path_glob: 't/data' + id_instrument: 70 + id_instrument_format: 12 + id_run: 100000 + id_run_pair: ~ + is_paired: 1 + priority: 1 team: A + diff --git a/t/data/dbic_fixtures/400-RunStatus.yml b/t/data/dbic_fixtures/400-RunStatus.yml index ec875eea..9e11037b 100644 --- a/t/data/dbic_fixtures/400-RunStatus.yml +++ b/t/data/dbic_fixtures/400-RunStatus.yml @@ -113,3 +113,22 @@ id_run_status_dict: 4 id_user: 7 iscurrent: 1 +- id_run_status: 45 + id_run: 100000 + date: 2024-11-23 02:14:17 + id_run_status_dict: 2 + id_user: 7 + iscurrent: 0 +- id_run_status: 46 + id_run: 100000 + date: 2024-11-23 12:23:10 + id_run_status_dict: 4 + id_user: 7 + iscurrent: 0 +- id_run_status: 47 + id_run: 100000 + date: 2024-11-23 12:44:40 + id_run_status_dict: 6 + id_user: 7 + iscurrent: 1 + diff --git a/t/dbic_util.pm b/t/dbic_util.pm index 368ac51d..0c162bfc 100644 --- a/t/dbic_util.pm +++ b/t/dbic_util.pm @@ -25,13 +25,6 @@ sub test_schema_mlwh { ); } -sub test_schema_wh { - my ($self, $fixture_path) = @_; - return $self->create_test_db( - 'npg_warehouse::Schema', $fixture_path - ); -} - no Moose; __PACKAGE__->meta->make_immutable(); 1;