Skip to content

Commit

Permalink
Updated aggregate_xlanes method
Browse files Browse the repository at this point in the history
... to use copy_init_args method instead of _driver_arguments
method mostly in order to be consistent.

Since this method is called in the run-level object, it does
not suffer from the same problems as other methods, which had
to be updated in this pr. All new tests for this commit passed
without changing the code.
  • Loading branch information
mgcam committed Jan 3, 2024
1 parent 7f1213a commit de55a4b
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 8 deletions.
11 changes: 5 additions & 6 deletions lib/st/api/lims.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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/;
Expand All @@ -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
Expand All @@ -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));
}

Expand Down
34 changes: 32 additions & 2 deletions t/40-st-lims-merge.t
Original file line number Diff line number Diff line change
Expand Up @@ -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/,
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit de55a4b

Please sign in to comment.