Skip to content

Commit

Permalink
feat(htslib): Refactor and move up one dir
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikstranneheim committed Nov 26, 2019
1 parent e684435 commit 81076dc
Show file tree
Hide file tree
Showing 13 changed files with 43 additions and 53 deletions.
17 changes: 5 additions & 12 deletions lib/MIP/Program/Utility/Htslib.pm → lib/MIP/Program/Htslib.pm
@@ -1,4 +1,4 @@
package MIP::Program::Utility::Htslib;
package MIP::Program::Htslib;

use 5.026;
use Carp;
Expand All @@ -15,6 +15,7 @@ use warnings qw{ FATAL utf8 };
use Readonly;

## MIPs lib/
use MIP::Constants qw{ $SPACE };
use MIP::Unix::Standard_streams qw{ unix_standard_streams };
use MIP::Unix::Write_to_file qw{ unix_write_to_file };

Expand All @@ -23,15 +24,12 @@ BEGIN {
use base qw{ Exporter };

# Set the version for version checking
our $VERSION = 1.01;
our $VERSION = 1.02;

# Functions and variables which can be optionally exported
our @EXPORT_OK = qw{ htslib_bgzip htslib_tabix };
}

## Constants
Readonly my $SPACE => q{ };

sub htslib_bgzip {

## Function : Perl wrapper for writing bgzip recipe to $filehandle or return commands array. Based on htslib 1.3.1.
Expand Down Expand Up @@ -101,7 +99,6 @@ sub htslib_bgzip {
## Stores commands depending on input parameters
my @commands = q{bgzip};

## Options
if ($decompress) {

push @commands, q{--decompress};
Expand All @@ -116,7 +113,6 @@ sub htslib_bgzip {
push @commands, q{--stdout};
}

## Infile
if ($infile_path) {

push @commands, $infile_path;
Expand All @@ -134,8 +130,8 @@ sub htslib_bgzip {
unix_write_to_file(
{
commands_ref => \@commands,
separator => $SPACE,
filehandle => $filehandle,
separator => $SPACE,
}
);
return @commands;
Expand Down Expand Up @@ -244,7 +240,6 @@ sub htslib_tabix {
## Stores commands depending on input parameters
my @commands = q{tabix};

## Options
if ($force) {

push @commands, q{--force};
Expand Down Expand Up @@ -279,13 +274,11 @@ sub htslib_tabix {
push @commands, q{--sequence} . $SPACE . $sequence;
}

## Infile
if ($infile_path) {

push @commands, $infile_path;
}

# Limit output to regions
if ( @{$regions_ref} ) {

push @commands, join $SPACE, @{$regions_ref};
Expand All @@ -303,8 +296,8 @@ sub htslib_tabix {
unix_write_to_file(
{
commands_ref => \@commands,
separator => $SPACE,
filehandle => $filehandle,
separator => $SPACE,
}
);
return @commands;
Expand Down
12 changes: 6 additions & 6 deletions lib/MIP/Recipes/Analysis/Cadd.pm
Expand Up @@ -27,7 +27,7 @@ BEGIN {
use base qw{ Exporter };

# Set the version for version checking
our $VERSION = 1.04;
our $VERSION = 1.05;

# Functions and variables which can be optionally exported
our @EXPORT_OK = qw{ analysis_cadd analysis_cadd_gb_38 };
Expand All @@ -36,9 +36,9 @@ BEGIN {

## Constants
Readonly my $GENOME_BUILD_NR_38 => 38;
Readonly my $REGION_START => q{2};
Readonly my $REGION_END => q{2};
Readonly my $SEQUENCE_NAME => q{1};
Readonly my $REGION_START => 2;
Readonly my $REGION_END => 2;
Readonly my $SEQUENCE_NAME => 1;

sub analysis_cadd {

Expand Down Expand Up @@ -139,7 +139,7 @@ sub analysis_cadd {
use MIP::Parse::File qw{ parse_io_outfiles };
use MIP::Program::Variantcalling::Bcftools qw{ bcftools_annotate bcftools_view };
use MIP::Program::Cadd qw{ cadd };
use MIP::Program::Utility::Htslib qw{ htslib_tabix };
use MIP::Program::Htslib qw{ htslib_tabix };
use MIP::Processmanagement::Processes qw{ submit_recipe };
use MIP::Sample_info qw{ set_recipe_outfile_in_sample_info };
use MIP::Recipes::Analysis::Xargs qw{ xargs_command };
Expand Down Expand Up @@ -516,7 +516,7 @@ sub analysis_cadd_gb_38 {
use MIP::Program::Gzip qw{ gzip };
use MIP::Program::Variantcalling::Bcftools qw{ bcftools_annotate bcftools_view };
use MIP::Program::Cadd qw{ cadd };
use MIP::Program::Utility::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Program::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Processmanagement::Processes qw{ submit_recipe };
use MIP::Sample_info qw{ set_recipe_outfile_in_sample_info };
use MIP::Recipes::Analysis::Xargs qw{ xargs_command };
Expand Down
4 changes: 2 additions & 2 deletions lib/MIP/Recipes/Analysis/Endvariantannotationblock.pm
Expand Up @@ -25,7 +25,7 @@ BEGIN {
use base qw{ Exporter };

# Set the version for version checking
our $VERSION = 1.07;
our $VERSION = 1.08;

# Functions and variables which can be optionally exported
our @EXPORT_OK = qw{ analysis_endvariantannotationblock };
Expand Down Expand Up @@ -155,7 +155,7 @@ sub analysis_endvariantannotationblock {
use MIP::Gnu::Software::Gnu_grep qw{ gnu_grep };
use MIP::Parse::File qw{ parse_io_outfiles };
use MIP::Processmanagement::Processes qw{ submit_recipe };
use MIP::Program::Utility::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Program::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Program::Variantcalling::Gatk qw{ gatk_concatenate_variants };
use MIP::Sample_info qw{ set_most_complete_vcf set_recipe_metafile_in_sample_info };
use MIP::Script::Setup_script qw{ setup_script };
Expand Down
4 changes: 2 additions & 2 deletions lib/MIP/Recipes/Analysis/Prepareforvariantannotationblock.pm
Expand Up @@ -25,7 +25,7 @@ BEGIN {
use base qw{ Exporter };

# Set the version for version checking
our $VERSION = 1.07;
our $VERSION = 1.08;

# Functions and variables which can be optionally exported
our @EXPORT_OK = qw{ analysis_prepareforvariantannotationblock };
Expand Down Expand Up @@ -150,7 +150,7 @@ sub analysis_prepareforvariantannotationblock {
use MIP::Get::Parameter qw{ get_recipe_attributes get_recipe_resources };
use MIP::Parse::File qw{ parse_io_outfiles };
use MIP::Processmanagement::Processes qw{ submit_recipe };
use MIP::Program::Utility::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Program::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Recipes::Analysis::Xargs qw{ xargs_command };
use MIP::Script::Setup_script qw(setup_script);

Expand Down
6 changes: 3 additions & 3 deletions lib/MIP/Recipes/Analysis/Vcf_rerun_reformat.pm
Expand Up @@ -26,7 +26,7 @@ BEGIN {
use base qw{ Exporter };

# Set the version for version checking
our $VERSION = 1.06;
our $VERSION = 1.07;

# Functions and variables which can be optionally exported
our @EXPORT_OK = qw{ analysis_vcf_rerun_reformat_sv analysis_vcf_rerun_reformat };
Expand Down Expand Up @@ -137,7 +137,7 @@ sub analysis_vcf_rerun_reformat_sv {
use MIP::Parse::File qw{ parse_io_outfiles };
use MIP::Processmanagement::Processes qw{ submit_recipe };
use MIP::Program::Variantcalling::Bcftools qw{ bcftools_view };
use MIP::Program::Utility::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Program::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Script::Setup_script qw{ setup_script };
use MIP::Set::File qw{ set_io_files };

Expand Down Expand Up @@ -372,7 +372,7 @@ sub analysis_vcf_rerun_reformat {
use MIP::Parse::File qw{ parse_io_outfiles };
use MIP::Processmanagement::Processes qw{ submit_recipe };
use MIP::Program::Variantcalling::Bcftools qw{ bcftools_view };
use MIP::Program::Utility::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Program::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Script::Setup_script qw{ setup_script };

### PREPROCESSING:
Expand Down
4 changes: 2 additions & 2 deletions lib/MIP/Recipes/Analysis/Vep.pm
Expand Up @@ -29,7 +29,7 @@ BEGIN {
use base qw{ Exporter };

# Set the version for version checking
our $VERSION = 1.23;
our $VERSION = 1.24;

# Functions and variables which can be optionally exported
our @EXPORT_OK =
Expand Down Expand Up @@ -1682,7 +1682,7 @@ sub _subset_vcf {

check( $tmpl, $arg_href, 1 ) or croak q{Could not parse arguments!};

use MIP::Program::Utility::Htslib qw{ htslib_bgzip };
use MIP::Program::Htslib qw{ htslib_bgzip };
use MIP::Program::Variantcalling::Bcftools qw{ bcftools_index bcftools_view };

## Prepare for bcftools_view
Expand Down
6 changes: 3 additions & 3 deletions lib/MIP/Recipes/Analysis/Vt_core.pm
Expand Up @@ -24,7 +24,7 @@ BEGIN {
use base qw{ Exporter };

# Set the version for version checking
our $VERSION = 1.07;
our $VERSION = 1.08;

# Functions and variables which can be optionally exported
our @EXPORT_OK = qw{ analysis_vt_core analysis_vt_core_rio };
Expand Down Expand Up @@ -203,7 +203,7 @@ sub analysis_vt_core {
use MIP::Gnu::Coreutils qw{ gnu_mv };
use MIP::Gnu::Software::Gnu_sed qw{ gnu_sed };
use MIP::Processmanagement::Processes qw{ submit_recipe };
use MIP::Program::Utility::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Program::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Program::Variantcalling::Allele_frequency qw{ calculate_af max_af };
use MIP::Program::Variantcalling::Bcftools qw{ bcftools_view bcftools_index };
use MIP::Program::Variantcalling::Vt qw{ vt_decompose vt_normalize vt_uniq };
Expand Down Expand Up @@ -578,7 +578,7 @@ sub analysis_vt_core_rio {
use MIP::Gnu::Software::Gnu_sed qw{ gnu_sed };
use MIP::Processmanagement::Slurm_processes
qw{ slurm_submit_job_no_dependency_add_to_samples };
use MIP::Program::Utility::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Program::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Program::Variantcalling::Allele_frequency qw{ calculate_af max_af };
use MIP::Program::Variantcalling::Bcftools qw{ bcftools_view bcftools_index };
use MIP::Program::Variantcalling::Vt qw{ vt_decompose vt_normalize vt_uniq };
Expand Down
4 changes: 2 additions & 2 deletions lib/MIP/Recipes/Download/Clinvar.pm
Expand Up @@ -27,7 +27,7 @@ BEGIN {
use base qw{ Exporter };

# Set the version for version checking
our $VERSION = 1.02;
our $VERSION = 1.03;

# Functions and variables which can be optionally exported
our @EXPORT_OK = qw{ download_clinvar };
Expand Down Expand Up @@ -124,7 +124,7 @@ sub download_clinvar {

use MIP::Get::Parameter qw{ get_recipe_resources };
use MIP::Gnu::Coreutils qw{ gnu_rm };
use MIP::Program::Utility::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Program::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Program::Variantcalling::Bcftools qw{ bcftools_annotate };
use MIP::Recipes::Download::Get_reference qw{ get_reference };
use MIP::Script::Setup_script qw{ setup_script };
Expand Down
4 changes: 2 additions & 2 deletions lib/MIP/Recipes/Download/Dbnsfp.pm
Expand Up @@ -27,7 +27,7 @@ BEGIN {
use base qw{ Exporter };

# Set the version for version checking
our $VERSION = 1.02;
our $VERSION = 1.03;

# Functions and variables which can be optionally exported
our @EXPORT_OK = qw{ download_dbnsfp };
Expand Down Expand Up @@ -132,7 +132,7 @@ sub download_dbnsfp {
use MIP::Gnu::Coreutils qw{ gnu_cat gnu_head gnu_sort };
use MIP::Gnu::Software::Gnu_grep qw{ gnu_grep };
use MIP::Language::Awk qw{ awk };
use MIP::Program::Utility::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Program::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Recipes::Download::Get_reference qw{ get_reference };
use MIP::Script::Setup_script qw{ setup_script };
use MIP::Processmanagement::Slurm_processes
Expand Down
4 changes: 2 additions & 2 deletions lib/MIP/Recipes/Download/Genomic_superdups.pm
Expand Up @@ -27,7 +27,7 @@ BEGIN {
use base qw{ Exporter };

# Set the version for version checking
our $VERSION = 1.03;
our $VERSION = 1.04;

# Functions and variables which can be optionally exported
our @EXPORT_OK = qw{ download_genomic_superdups };
Expand Down Expand Up @@ -129,7 +129,7 @@ sub download_genomic_superdups {
use MIP::Gnu::Coreutils qw{ gnu_cut gnu_sort gnu_uniq };
use MIP::Gnu::Software::Gnu_grep qw{ gnu_grep };
use MIP::Parse::File qw{ parse_file_suffix };
use MIP::Program::Utility::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Program::Htslib qw{ htslib_bgzip htslib_tabix };
use MIP::Recipes::Download::Get_reference qw{ get_reference };
use MIP::Script::Setup_script qw{ setup_script };
use MIP::Processmanagement::Slurm_processes
Expand Down
4 changes: 2 additions & 2 deletions lib/MIP/Recipes/Download/Gnomad.pm
Expand Up @@ -26,7 +26,7 @@ BEGIN {
use base qw{ Exporter };

# Set the version for version checking
our $VERSION = 1.04;
our $VERSION = 1.05;

# Functions and variables which can be optionally exported
our @EXPORT_OK = qw{ download_gnomad };
Expand Down Expand Up @@ -123,7 +123,7 @@ sub download_gnomad {

use MIP::Get::Parameter qw{ get_recipe_resources };
use MIP::Program::Rtg qw{ rtg_vcfsubset };
use MIP::Program::Utility::Htslib qw{ htslib_tabix };
use MIP::Program::Htslib qw{ htslib_tabix };
use MIP::Recipes::Download::Get_reference qw{ get_reference };
use MIP::Script::Setup_script qw{ setup_script };
use MIP::Processmanagement::Slurm_processes
Expand Down
17 changes: 7 additions & 10 deletions t/htslib_bgzip.t
Expand Up @@ -20,10 +20,12 @@ use Readonly;

## MIPs lib/
use lib catdir( dirname($Bin), q{lib} );
use MIP::Constants qw{ $COMMA $SPACE };
use MIP::Test::Commands qw{ test_function };
use MIP::Test::Fixtures qw{ test_standard_cli };

my $VERBOSE = 1;
our $VERSION = 1.00;
our $VERSION = 1.01;

$VERBOSE = test_standard_cli(
{
Expand All @@ -32,29 +34,24 @@ $VERBOSE = test_standard_cli(
}
);

## Constants
Readonly my $COMMA => q{,};
Readonly my $SPACE => q{ };

BEGIN {

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

### Check all internal dependency modules and imports
## Modules with import
my %perl_module = (
q{MIP::Program::Utility::Htslib} => [qw{ htslib_bgzip }],
q{MIP::Test::Fixtures} => [qw{ test_standard_cli }],
q{MIP::Program::Htslib} => [qw{ htslib_bgzip }],
q{MIP::Test::Fixtures} => [qw{ test_standard_cli }],
);

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

use MIP::Program::Utility::Htslib qw{ htslib_bgzip };
use MIP::Test::Commands qw{ test_function };
use MIP::Program::Htslib qw{ htslib_bgzip };

diag( q{Test htslib_bgzip from Htslib.pm v}
. $MIP::Program::Utility::Htslib::VERSION
. $MIP::Program::Htslib::VERSION
. $COMMA
. $SPACE . q{Perl}
. $SPACE
Expand Down
10 changes: 5 additions & 5 deletions t/htslib_tabix.t
Expand Up @@ -25,7 +25,7 @@ use MIP::Test::Commands qw{ test_function };
use MIP::Test::Fixtures qw{ test_standard_cli };

my $VERBOSE = 1;
our $VERSION = 1.01;
our $VERSION = 1.02;

$VERBOSE = test_standard_cli(
{
Expand All @@ -41,18 +41,18 @@ BEGIN {
### Check all internal dependency modules and imports
## Modules with import
my %perl_module = (
q{MIP::Program::Utility::Htslib} => [qw{ htslib_tabix }],
q{MIP::Test::Fixtures} => [qw{ test_standard_cli }],
q{MIP::Program::Htslib} => [qw{ htslib_tabix }],
q{MIP::Test::Fixtures} => [qw{ test_standard_cli }],
);

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

use MIP::Program::Utility::Htslib qw{ htslib_tabix };
use MIP::Program::Htslib qw{ htslib_tabix };
use MIP::Test::Commands qw{ test_function };

diag( q{Test htslib_tabix from Htslib.pm v}
. $MIP::Program::Utility::Htslib::VERSION
. $MIP::Program::Htslib::VERSION
. $COMMA
. $SPACE . q{Perl}
. $SPACE
Expand Down

0 comments on commit 81076dc

Please sign in to comment.