Skip to content

Commit

Permalink
Merge pull request #849 from mgcam/mark_dups4tagzero
Browse files Browse the repository at this point in the history
Changed mark duplicate method retrieval.
  • Loading branch information
mgcam authored Aug 1, 2024
2 parents eef2b72 + 1b3c555 commit ac58b48
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 6 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
LIST OF CHANGES
---------------

- Ensured mark duplicate method can be inferred for a product with multiple
studies (tag zero).

release 68.3.0 (2024-05-24)
- Removing Tidyp dependency from CI
- Added 'SampleSheet.csv' file from the top level of the run folder to
Expand Down
24 changes: 21 additions & 3 deletions lib/npg_pipeline/product/release.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use Data::Dump qw{pp};
use Moose::Role;
use List::Util qw{all any};
use Readonly;
use Try::Tiny;

with qw{WTSI::DNAP::Utilities::Loggable
npg_tracking::util::pipeline_config};
Expand Down Expand Up @@ -300,7 +301,7 @@ sub bwakit_enable {
Arg [1] : npg_pipeline::product
Example : $obj->markdup_method($product);
Description: Return mark duplicate method,
Description: Returns mark duplicate method,
the value might be undefined.
Returntype : Str
Expand All @@ -309,7 +310,22 @@ sub bwakit_enable {

sub markdup_method {
my ($self, $product) = @_;
return $self->find_study_config($product)->{markdup_method};

my $config;
try {
$config = $self->find_study_config($product);
} catch {
my $error = $_;
if ($error =~ /Multiple[ ]study[ ]ids/xms) {
$self->logwarn($error);
$self->logwarn('Falling back to the default section of the product config');
$config = $self->default_study_config();
} else {
$self->logcroak($error);
}
};

return defined $config ? $config->{markdup_method} : undef;
}

=head2 staging_deletion_delay
Expand Down Expand Up @@ -412,6 +428,8 @@ study:
=item Readonly
=item Try::Tiny
=item WTSI::DNAP::Utilities::Loggable
=item npg_tracking::util::pipeline_config
Expand All @@ -430,7 +448,7 @@ study:
=head1 LICENSE AND COPYRIGHT
Copyright (C) 2018,2019,2020,2021,2022 Genome Research Ltd.
Copyright (C) 2018,2019,2020,2021,2022,2024 Genome Research Ltd.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
47 changes: 44 additions & 3 deletions t/20-function-seq_alignment.t
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use strict;
use warnings;
use Test::More tests => 20;
use Test::More tests => 21;
use Test::Exception;
use Test::Deep;
use Test::Warn;
Expand All @@ -13,7 +13,7 @@ use Log::Log4perl qw/:levels/;
use JSON;
use Cwd;
use List::Util qw/first/;
use File::Slurp qw/edit_file_lines/;
use File::Slurp qw/edit_file_lines read_file write_file/;

use Moose::Util qw(apply_all_roles);

Expand Down Expand Up @@ -1502,7 +1502,7 @@ subtest 'miseq_primer_panel_only' => sub {
is ($d->command(), $command, 'correct command for MiSeq lane 24135_1 tag index 1');
};

subtest 'product_release_tests' => sub {
subtest 'product_release_tests and mark duplicate method' => sub {
plan tests => 269;

my %test_runs = (
Expand Down Expand Up @@ -1572,6 +1572,47 @@ subtest 'product_release_tests' => sub {
}
};

subtest 'mark duplicate method for a product with multiple studies' => sub {
plan tests => 3;

my $runfolder_path = join q[/], $dir, q[markdups_test];
mkdir $runfolder_path;
copy('t/data/miseq/46761_RunInfo.xml', "$runfolder_path/RunInfo.xml") or die 'Copy failed';
copy('t/data/miseq/46761_runParameters.xml', "$runfolder_path/runParameters.xml")
or die 'Copy failed';
my @lines = read_file(q[t/data/miseq/samplesheet_46761_bwa_mem2.csv]);
my @data = ();
# Change study ID for the first tag.
foreach my $value ((split q[,], $lines[2])) {
$value =~ s/5556/5557/;
push @data, $value;
}
$lines[2] = join q[,], @data;
my $samplesheet = "$runfolder_path/samplesheet_46761.csv";
write_file($samplesheet, @lines);
local $ENV{NPG_CACHED_SAMPLESHEET_FILE} = $samplesheet;

my $ms_gen = npg_pipeline::function::seq_alignment->new(
id_run => 46761,
runfolder_path => $runfolder_path,
conf_path => 't/data/release/config/seq_alignment',
resource => $default,
npg_tracking_schema => undef
);
my $product;
foreach my $p (@{$ms_gen->products->{data_products}}) {
if ($p->rpt_list eq '46761:1:0') {
$product = $p;
last;
}
}

is ($product->lims->study_ids, 2, 'tag zero product has two study ids');
my $method;
lives_ok { $method = $ms_gen->markdup_method($product) }
'no error calling markdup_method';
is ($method, 'biobambam', 'correct method');
};
# test overrides of bwa_mem with bwa-mem2
# 1) on sample sheet entry without [bwa_mem2] specified in reference name
# 2) on sample sheet entry without [bwa_mem2] specified in reference name, but setting bwa_mem2 attribute
Expand Down

0 comments on commit ac58b48

Please sign in to comment.