diff --git a/lib/st/api/lims.pm b/lib/st/api/lims.pm index 08713f95..e8367094 100644 --- a/lib/st/api/lims.pm +++ b/lib/st/api/lims.pm @@ -897,9 +897,8 @@ sub aggregate_xlanes { return; }; # End of test function - my %init = %{$self->_driver_arguments()}; - $init{'driver_type'} = $self->driver_type; - delete $init{'id_run'}; + my $init = $self->copy_init_args(); + delete $init->{'id_run'}; my $lims4compisitions = {}; my @test_attrs = qw/sample_id library_id/; @@ -908,7 +907,7 @@ sub aggregate_xlanes { if (!@pools) { $can_merge->(\@lanes, @test_attrs); # Test consistency - push @aggregated, __PACKAGE__->new(%init, rpt_list => $lanes_rpt_list); + push @aggregated, __PACKAGE__->new(%{$init}, rpt_list => $lanes_rpt_list); } else { my @sizes = uniq (map { $_->num_children } @lanes); if (@sizes != 1) { # Test consistency @@ -925,11 +924,11 @@ sub aggregate_xlanes { my $ea = each_arrayref map { [$_->children()] } @lanes; while ( my @plexes = $ea->() ) { $can_merge->(\@plexes, @test_attrs, 'tag_index'); # Test consistency - push @aggregated, __PACKAGE__->new(%init, + push @aggregated, __PACKAGE__->new(%{$init}, rpt_list => npg_tracking::glossary::rpt->deflate_rpts(\@plexes)); } # Add object for tag zero - push @aggregated, __PACKAGE__->new(%init, + push @aggregated, __PACKAGE__->new(%{$init}, rpt_list => npg_tracking::glossary::rpt->tag_zero_rpt_list($lanes_rpt_list)); } diff --git a/t/40-st-lims-merge.t b/t/40-st-lims-merge.t index d4d7a125..4fd4aa7c 100644 --- a/t/40-st-lims-merge.t +++ b/t/40-st-lims-merge.t @@ -130,9 +130,10 @@ subtest 'Create tag zero object' => sub { }; subtest 'Aggregation across lanes for pools' => sub { - plan tests => 82; + plan tests => 89; - local $ENV{NPG_CACHED_SAMPLESHEET_FILE} = 't/data/test40_lims/samplesheet_novaseq4lanes.csv'; + local $ENV{NPG_CACHED_SAMPLESHEET_FILE} = + 't/data/test40_lims/samplesheet_novaseq4lanes.csv'; my $l = st::api::lims->new(rpt_list => '25846:1:3'); throws_ok { $l->aggregate_xlanes() } qr/Not run-level object/, @@ -235,6 +236,35 @@ subtest 'Aggregation across lanes for pools' => sub { 'sample names including spiked phix'); is (join(q[:], $tag_zero->sample_names(1)), join(q[:], @sample_names), 'sample names including spiked phix'); + + local $ENV{NPG_CACHED_SAMPLESHEET_FILE} = q[]; + + my $id_run = 47995; + $l = st::api::lims->new( + id_run => $id_run, + id_flowcell_lims => 98292, + driver_type => 'ml_warehouse', + mlwh_schema => $schema_wh, + ); + + @merged = $l->aggregate_xlanes(qw/1 2/); + is (scalar @merged, 19, 'number of aggregates is number of tags plus two'); + $tag_zero = pop @merged; + $tag_spiked = pop @merged; + $tag_last = pop @merged; + $tag_first = shift @merged; + is ($tag_zero->rpt_list, "$id_run:1:0;$id_run:2:0", + 'rpt list for tag zero object'); + my @tag_zero_sample_names = $tag_zero->sample_names(); + is (@tag_zero_sample_names, 18, '18 sample names are retrieved'); + is ($tag_zero_sample_names[0], '6751STDY13219539', + 'first sample name is correct'); + is ($tag_spiked->rpt_list, "$id_run:1:888;$id_run:2:888", + 'rpt list for spiked in tag object'); + is ($tag_last->rpt_list, "$id_run:1:17;$id_run:2:17", + 'rpt list for tag 21 object'); + is ($tag_first->rpt_list, "$id_run:1:1;$id_run:2:1", + 'rpt list for tag 1 object'); }; subtest 'Aggregation across lanes for non-pools' => sub {