From ea733ffc4fd5e8b4b3842564b5438b5a0db6fd45 Mon Sep 17 00:00:00 2001 From: Marina Gourtovaia Date: Fri, 31 May 2024 17:45:07 +0100 Subject: [PATCH 1/2] Changed mark duplicate method retrieval. Ensured mark duplicate method can be inferred for a product with multiple studies. --- lib/npg_pipeline/product/release.pm | 24 +++++++++++++-- t/20-function-seq_alignment.t | 47 +++++++++++++++++++++++++++-- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/lib/npg_pipeline/product/release.pm b/lib/npg_pipeline/product/release.pm index e240921b..2d5a71ca 100644 --- a/lib/npg_pipeline/product/release.pm +++ b/lib/npg_pipeline/product/release.pm @@ -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}; @@ -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 @@ -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 @@ -412,6 +428,8 @@ study: =item Readonly +=item Try::Tiny + =item WTSI::DNAP::Utilities::Loggable =item npg_tracking::util::pipeline_config @@ -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 diff --git a/t/20-function-seq_alignment.t b/t/20-function-seq_alignment.t index 8cf940f3..3bf52866 100644 --- a/t/20-function-seq_alignment.t +++ b/t/20-function-seq_alignment.t @@ -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; @@ -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); @@ -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 = ( @@ -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 From 1b3c555223690f3c948dfafabdd2d4b38427ae28 Mon Sep 17 00:00:00 2001 From: Marina Gourtovaia Date: Thu, 11 Jul 2024 11:01:50 +0100 Subject: [PATCH 2/2] Updated the list of Changes --- Changes | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Changes b/Changes index d2f3d7ae..7ad65ee2 100644 --- a/Changes +++ b/Changes @@ -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