Skip to content

Commit

Permalink
adds tests for the new recipes
Browse files Browse the repository at this point in the history
  • Loading branch information
Emil Bertilsson committed Dec 17, 2021
1 parent af92035 commit 18326d2
Show file tree
Hide file tree
Showing 11 changed files with 2,437 additions and 1 deletion.
41 changes: 40 additions & 1 deletion lib/MIP/Test/Fixtures.pm
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ sub test_add_io_for_recipe {
strict_type => 1,
},
step => {
allow => [qw{ fastq bam vcf }],
allow => [qw{ fastq bam vcf vcf.gz hdf5 tsv }],
default => q{fastq},
store => \$step,
strict_type => 1,
Expand Down Expand Up @@ -143,6 +143,39 @@ sub test_add_io_for_recipe {
$parameter_href->{$recipe_name}{outfile_suffix} =
$outfile_suffix ? $outfile_suffix : q{.vcf};
}
if ( $step eq q{vcf.gz} ) {

%{ $file_info_href->{io}{$chain_id}{$id}{$recipe_name} } = test_mip_hashes(
{
mip_hash_name => q{io_vcf_gz},
}
);
@{ $parameter_href->{cache}{order_recipes_ref} } = @order_recipes;
$parameter_href->{$recipe_name}{outfile_suffix} =
$outfile_suffix ? $outfile_suffix : q{.vcf.gz};
}
if ( $step eq q{hdf5} ) {

%{ $file_info_href->{io}{$chain_id}{$id}{$recipe_name} } = test_mip_hashes(
{
mip_hash_name => q{io_hdf5},
}
);
@{ $parameter_href->{cache}{order_recipes_ref} } = @order_recipes;
$parameter_href->{$recipe_name}{outfile_suffix} =
$outfile_suffix ? $outfile_suffix : q{.hdf5};
}
if ( $step eq q{tsv} ) {

%{ $file_info_href->{io}{$chain_id}{$id}{$recipe_name} } = test_mip_hashes(
{
mip_hash_name => q{io_tsv},
}
);
@{ $parameter_href->{cache}{order_recipes_ref} } = @order_recipes;
$parameter_href->{$recipe_name}{outfile_suffix} =
$outfile_suffix ? $outfile_suffix : q{.tsv};
}
return;
}

Expand Down Expand Up @@ -275,6 +308,9 @@ sub test_mip_hashes {
io
io_bam
io_vcf
io_vcf_gz
io_hdf5
io_tsv
job_id
pedigree
primary_contig
Expand Down Expand Up @@ -315,6 +351,9 @@ sub test_mip_hashes {
io => catfile( $Bin, qw{ data test_data io.yaml } ),
io_bam => catfile( $Bin, qw{ data test_data io_bam.yaml } ),
io_vcf => catfile( $Bin, qw{ data test_data io_vcf.yaml } ),
io_vcf_gz => catfile( $Bin, qw{ data test_data io_vcf_gz.yaml } ),
io_hdf5 => catfile( $Bin, qw{ data test_data io_hdf5.yaml } ),
io_tsv => catfile( $Bin, qw{ data test_data io_tsv.yaml } ),
job_id => catfile( $Bin, qw{ data test_data job_id.yaml } ),
pedigree => catfile( $Bin, qw{ data test_data pedigree_wes.yaml } ),
primary_contig => catfile( $Bin, qw{ data test_data primary_contig.yaml } ),
Expand Down
117 changes: 117 additions & 0 deletions t/analysis_gatk_collectreadcounts.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/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 catfile };
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 };
use Test::Trap;

## MIPs lib/
use lib catdir( dirname($Bin), q{lib} );
use MIP::Constants qw{ $COLON $COMMA $SPACE };
use MIP::Test::Fixtures qw{ test_add_io_for_recipe test_log test_mip_hashes };

BEGIN {

use MIP::Test::Fixtures qw{ test_import };

### Check all internal dependency modules and imports
## Modules with import
my %perl_module = (
q{MIP::Recipes::Analysis::Gatk_collectreadcounts} =>
[qw{ analysis_gatk_collectreadcounts }],
q{MIP::Test::Fixtures} => [qw{ test_add_io_for_recipe test_log test_mip_hashes }],
);

test_import( { perl_module_href => \%perl_module, } );
}

use MIP::Recipes::Analysis::Gatk_collectreadcounts qw{ analysis_gatk_collectreadcounts };

diag( q{Test analysis_gatk_collectreadcounts from Gatk_collectreadcounts.pm}
. $COMMA
. $SPACE . q{Perl}
. $SPACE
. $PERL_VERSION
. $SPACE
. $EXECUTABLE_NAME );

my $log = test_log( { log_name => q{MIP}, no_screen => 1, } );

## Given analysis parameters
my $recipe_name = q{gatk_collectreadcounts};
my $slurm_mock_cmd = catfile( $Bin, qw{ data modules slurm-mock.pl } );

my %active_parameter = test_mip_hashes(
{
mip_hash_name => q{active_parameter},
recipe_name => $recipe_name,
}
);
$active_parameter{$recipe_name} = 1;
$active_parameter{recipe_core_number}{$recipe_name} = 1;
$active_parameter{recipe_time}{$recipe_name} = 1;
my $sample_id = $active_parameter{sample_ids}[0];

my %file_info = test_mip_hashes(
{
mip_hash_name => q{file_info},
recipe_name => $recipe_name,
}
);

my %job_id;
my %parameter = test_mip_hashes(
{
mip_hash_name => q{recipe_parameter},
recipe_name => $recipe_name,
}
);

test_add_io_for_recipe(
{
file_info_href => \%file_info,
id => $sample_id,
outfile_suffix => q{.hdf5},
parameter_href => \%parameter,
recipe_name => $recipe_name,
step => q{bam},
}
);

my %sample_info = test_mip_hashes(
{
mip_hash_name => q{qc_sample_info},
recipe_name => $recipe_name,
}
);

my $is_ok = analysis_gatk_collectreadcounts(
{
active_parameter_href => \%active_parameter,
file_info_href => \%file_info,
job_id_href => \%job_id,
parameter_href => \%parameter,
profile_base_command => $slurm_mock_cmd,
recipe_name => $recipe_name,
sample_id => $sample_id,
sample_info_href => \%sample_info,
}
);

## Then return TRUE
ok( $is_ok, q{ Executed analysis recipe } . $recipe_name );

done_testing();
117 changes: 117 additions & 0 deletions t/analysis_gatk_denoisereadcounts.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
#!/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 catfile };
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 };
use Test::Trap;

## MIPs lib/
use lib catdir( dirname($Bin), q{lib} );
use MIP::Constants qw{ $COLON $COMMA $SPACE };
use MIP::Test::Fixtures qw{ test_add_io_for_recipe test_log test_mip_hashes };

BEGIN {

use MIP::Test::Fixtures qw{ test_import };

### Check all internal dependency modules and imports
## Modules with import
my %perl_module = (
q{MIP::Recipes::Analysis::Gatk_denoisereadcounts} =>
[qw{ analysis_gatk_denoisereadcounts }],
q{MIP::Test::Fixtures} => [qw{ test_add_io_for_recipe test_log test_mip_hashes }],
);

test_import( { perl_module_href => \%perl_module, } );
}

use MIP::Recipes::Analysis::Gatk_denoisereadcounts qw{ analysis_gatk_denoisereadcounts };

diag( q{Test analysis_gatk_denoisereadcounts from Gatk_denoisereadcounts.pm}
. $COMMA
. $SPACE . q{Perl}
. $SPACE
. $PERL_VERSION
. $SPACE
. $EXECUTABLE_NAME );

my $log = test_log( { log_name => q{MIP}, no_screen => 1, } );

## Given analysis parameters
my $recipe_name = q{gatk_denoisereadcounts};
my $slurm_mock_cmd = catfile( $Bin, qw{ data modules slurm-mock.pl } );

my %active_parameter = test_mip_hashes(
{
mip_hash_name => q{active_parameter},
recipe_name => $recipe_name,
}
);
$active_parameter{$recipe_name} = 1;
$active_parameter{recipe_core_number}{$recipe_name} = 1;
$active_parameter{recipe_time}{$recipe_name} = 1;
my $sample_id = $active_parameter{sample_ids}[0];

my %file_info = test_mip_hashes(
{
mip_hash_name => q{file_info},
recipe_name => $recipe_name,
}
);

my %job_id;
my %parameter = test_mip_hashes(
{
mip_hash_name => q{recipe_parameter},
recipe_name => $recipe_name,
}
);

test_add_io_for_recipe(
{
file_info_href => \%file_info,
id => $sample_id,
outfile_suffix => q{.tsv},
parameter_href => \%parameter,
recipe_name => $recipe_name,
step => q{hdf5},
}
);

my %sample_info = test_mip_hashes(
{
mip_hash_name => q{qc_sample_info},
recipe_name => $recipe_name,
}
);

my $is_ok = analysis_gatk_denoisereadcounts(
{
active_parameter_href => \%active_parameter,
file_info_href => \%file_info,
job_id_href => \%job_id,
parameter_href => \%parameter,
profile_base_command => $slurm_mock_cmd,
recipe_name => $recipe_name,
sample_id => $sample_id,
sample_info_href => \%sample_info,
}
);

## Then return TRUE
ok( $is_ok, q{ Executed analysis recipe } . $recipe_name );

done_testing();
Loading

0 comments on commit 18326d2

Please sign in to comment.