From e58aa05806ae3eca53115342cefdc0ec2c1ca3d7 Mon Sep 17 00:00:00 2001 From: jemten Date: Wed, 13 Oct 2021 14:21:00 +0200 Subject: [PATCH 1/3] fixing qccollect test --- lib/MIP/Main/Qccollect.pm | 2 +- t/parse_limit_qc_output.t | 87 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 t/parse_limit_qc_output.t diff --git a/lib/MIP/Main/Qccollect.pm b/lib/MIP/Main/Qccollect.pm index e5533d5cf..b46f1ef80 100644 --- a/lib/MIP/Main/Qccollect.pm +++ b/lib/MIP/Main/Qccollect.pm @@ -38,7 +38,7 @@ BEGIN { our $VERSION = q{2.1.10}; # Functions and variables which can be optionally exported - our @EXPORT_OK = qw{ mip_qccollect }; + our @EXPORT_OK = qw{ mip_qccollect parse_limit_qc_output }; } sub mip_qccollect { diff --git a/t/parse_limit_qc_output.t b/t/parse_limit_qc_output.t new file mode 100644 index 000000000..42ea783cf --- /dev/null +++ b/t/parse_limit_qc_output.t @@ -0,0 +1,87 @@ +#! /usr/bin/env perl + +use 5.026; +use Carp; +use charnames qw{ :full :short }; +use English qw{ -no_match_vars }; +use File::Basename qw{ dirname }; +use File::Spec::Functions qw{ catdir }; +use FindBin qw{ $Bin }; +use open qw{ :encoding(UTF-8) :std }; +use Params::Check qw{ allow check last_error }; +use Test::More; +use utf8; +use warnings qw{ FATAL utf8 }; + +## CPANM +use autodie qw { :all }; +use Modern::Perl qw{ 2018 }; + +## MIPs lib/ +use lib catdir( dirname($Bin), q{lib} ); +use MIP::Constants qw{ $COMMA $SPACE }; + +BEGIN { + + use MIP::Test::Fixtures qw{ test_import }; + +### Check all internal dependency modules and imports +## Modules with import + my %perl_module = ( q{MIP::Main::Qccollect} => [qw{ parse_limit_qc_output }], ); + + test_import( { perl_module_href => \%perl_module, } ); +} + +use MIP::Main::Qccollect qw{ parse_limit_qc_output }; + +diag( q{Test parse_limit_qc_output from Qccollect.pm} + . $COMMA + . $SPACE . q{Perl} + . $SPACE + . $PERL_VERSION + . $SPACE + . $EXECUTABLE_NAME ); + +## Given a qc data hash +my %qc_data = ( + sample => { + sample_id => { + recipe_output_file => { + collectmultiplemetrics => { + header => q{data}, + }, + }, + another_file => { + collecthsmetrics => { + header => q{data}, + }, + }, + }, + }, +); + +## When executing sub +parse_limit_qc_output( + { + limit_qc_output => 1, + qc_href => \%qc_data, + } +); + +## Then remove key collectmultiplemetrics +my %expected_qc_data = ( + sample => { + sample_id => { + recipe_output_file => {}, + another_file => { + collecthsmetrics => { + header => q{data}, + }, + }, + }, + }, +); + +is_deeply( \%qc_data, \%expected_qc_data, q{Delete qc data from hash} ); + +done_testing(); From 18c58a342e20870c12a1e41448c53d164e88b0a7 Mon Sep 17 00:00:00 2001 From: jemten Date: Wed, 13 Oct 2021 14:28:54 +0200 Subject: [PATCH 2/3] fixing variant annotation recipe test --- t/analysis_variant_annotation.t | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/t/analysis_variant_annotation.t b/t/analysis_variant_annotation.t index ac700cf96..d8ae7bbee 100644 --- a/t/analysis_variant_annotation.t +++ b/t/analysis_variant_annotation.t @@ -47,7 +47,7 @@ diag( q{Test analysis_variant_annotation from Variant_annotation.pm} . $SPACE . $EXECUTABLE_NAME ); -my $log = test_log( { log_name => q{MIP}, no_screen => 1, } ); +test_log( { log_name => q{MIP}, no_screen => 1, } ); ## Given analysis parameters my $recipe_name = q{variant_annotation}; @@ -109,4 +109,24 @@ my $is_ok = analysis_variant_annotation( ## Then return TRUE ok( $is_ok, q{ Executed analysis recipe } . $recipe_name ); +## Given no loqusdb file in toml - alters the bcftools command +$active_parameter{vcfanno_config} = + catfile( $Bin, qw{ data references grch37_vcfanno_config_bad_template-v1.0-.toml } ); + +$is_ok = analysis_variant_annotation( + { + active_parameter_href => \%active_parameter, + case_id => $case_id, + file_info_href => \%file_info, + job_id_href => \%job_id, + parameter_href => \%parameter, + profile_base_command => $slurm_mock_cmd, + recipe_name => $recipe_name, + sample_info_href => \%sample_info, + } +); + +## Then still return TRUE +ok( $is_ok, q{ Executed analysis recipe } . $recipe_name ); + done_testing(); From aea41eb0aace793df88bf952ea1ecdc2b84994a9 Mon Sep 17 00:00:00 2001 From: jemten Date: Wed, 13 Oct 2021 14:36:27 +0200 Subject: [PATCH 3/3] fixed uninitalized log --- t/parse_containers.t | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/t/parse_containers.t b/t/parse_containers.t index a83b77aee..f80453a4a 100644 --- a/t/parse_containers.t +++ b/t/parse_containers.t @@ -20,7 +20,7 @@ use Modern::Perl qw{ 2018 }; ## MIPs lib/ use lib catdir( dirname($Bin), q{lib} ); use MIP::Constants qw{ $COMMA $SPACE }; -use MIP::Test::Fixtures qw{ test_mip_hashes }; +use MIP::Test::Fixtures qw{ test_log test_mip_hashes }; BEGIN { @@ -30,7 +30,7 @@ BEGIN { ## Modules with import my %perl_module = ( q{MIP::Environment::Container} => [qw{ parse_containers }], - q{MIP::Test::Fixtures} => [qw{ test_mip_hashes }], + q{MIP::Test::Fixtures} => [qw{ test_log test_mip_hashes }], ); test_import( { perl_module_href => \%perl_module, } ); @@ -46,6 +46,8 @@ diag( q{Test parse_containers from Container.pm} . $SPACE . $EXECUTABLE_NAME ); +test_log( {} ); + my %active_parameter = test_mip_hashes( { mip_hash_name => q{active_parameter},