Skip to content

Commit

Permalink
feat(rseqc): Refactor and move up one dir
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikstranneheim committed Nov 25, 2019
1 parent b0ab6a6 commit 0a7929f
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 176 deletions.
65 changes: 32 additions & 33 deletions lib/MIP/Program/Qc/Rseqc.pm → lib/MIP/Program/Rseqc.pm
@@ -1,4 +1,4 @@
package MIP::Program::Qc::Rseqc;
package MIP::Program::Rseqc;

use 5.026;
use Carp;
Expand All @@ -16,6 +16,7 @@ use autodie qw{ :all };
use Readonly;

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

Expand All @@ -24,7 +25,7 @@ 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{
Expand All @@ -41,9 +42,7 @@ BEGIN {
}

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

sub rseqc_bam2wig {

Expand Down Expand Up @@ -116,15 +115,15 @@ sub rseqc_bam2wig {
## Stores commands depending on input parameters
my @commands = qw{ bam2wig.py };

push @commands, q{--input-file} . $EQUAL . $infile_path;
push @commands, q{--input-file} . $EQUALS . $infile_path;

push @commands, q{--chromSize} . $EQUAL . $chrom_size_file_path;
push @commands, q{--chromSize} . $EQUALS . $chrom_size_file_path;

if ($strand) {
push @commands, q{--strand} . $EQUAL . $strand;
push @commands, q{--strand} . $EQUALS . $strand;
}

push @commands, q{--out-prefix} . $EQUAL . $outfile_path_prefix;
push @commands, q{--out-prefix} . $EQUALS . $outfile_path_prefix;

push @commands,
unix_standard_streams(
Expand Down Expand Up @@ -204,9 +203,9 @@ sub rseqc_bam_stat {
## Stores commands depending on input parameters
my @commands = qw{ bam_stat.py };

push @commands, q{--input-file} . $EQUAL . $infile_path;
push @commands, q{--input-file} . $EQUALS . $infile_path;

push @commands, q{--mapq} . $EQUAL . $min_map_quality;
push @commands, q{--mapq} . $EQUALS . $min_map_quality;

push @commands,
unix_standard_streams(
Expand Down Expand Up @@ -292,11 +291,11 @@ sub rseqc_genebody_coverage2 {
## Stores commands depending on input parameters
my @commands = qw{ geneBody_coverage2.py };

push @commands, q{--input-file} . $EQUAL . $infile_path;
push @commands, q{--input-file} . $EQUALS . $infile_path;

push @commands, q{--refgene} . $EQUAL . $bed_file_path;
push @commands, q{--refgene} . $EQUALS . $bed_file_path;

push @commands, q{--out-prefix} . $EQUAL . $outfile_path_prefix;
push @commands, q{--out-prefix} . $EQUALS . $outfile_path_prefix;

push @commands,
unix_standard_streams(
Expand Down Expand Up @@ -384,11 +383,11 @@ sub rseqc_infer_experiment {
## Stores commands depending on input parameters
my @commands = qw{ infer_experiment.py };

push @commands, q{--input-file} . $EQUAL . $infile_path;
push @commands, q{--input-file} . $EQUALS . $infile_path;

push @commands, q{--refgene} . $EQUAL . $bed_file_path;
push @commands, q{--refgene} . $EQUALS . $bed_file_path;

push @commands, q{--mapq} . $EQUAL . $min_map_quality;
push @commands, q{--mapq} . $EQUALS . $min_map_quality;

push @commands,
unix_standard_streams(
Expand Down Expand Up @@ -484,13 +483,13 @@ sub rseqc_inner_distance {
## Stores commands depending on input parameters
my @commands = qw{ inner_distance.py };

push @commands, q{--input-file} . $EQUAL . $infile_path;
push @commands, q{--input-file} . $EQUALS . $infile_path;

push @commands, q{--refgene} . $EQUAL . $bed_file_path;
push @commands, q{--refgene} . $EQUALS . $bed_file_path;

push @commands, q{--mapq} . $EQUAL . $min_map_quality;
push @commands, q{--mapq} . $EQUALS . $min_map_quality;

push @commands, q{--out-prefix} . $EQUAL . $outfiles_path_prefix;
push @commands, q{--out-prefix} . $EQUALS . $outfiles_path_prefix;

push @commands,
unix_standard_streams(
Expand Down Expand Up @@ -586,13 +585,13 @@ sub rseqc_junction_annotation {
## Stores commands depending on input parameters
my @commands = qw{ junction_annotation.py };

push @commands, q{--input-file} . $EQUAL . $infile_path;
push @commands, q{--input-file} . $EQUALS . $infile_path;

push @commands, q{--refgene} . $EQUAL . $bed_file_path;
push @commands, q{--refgene} . $EQUALS . $bed_file_path;

push @commands, q{--mapq} . $EQUAL . $min_map_quality;
push @commands, q{--mapq} . $EQUALS . $min_map_quality;

push @commands, q{--out-prefix} . $EQUAL . $outfiles_path_prefix;
push @commands, q{--out-prefix} . $EQUALS . $outfiles_path_prefix;

push @commands,
unix_standard_streams(
Expand Down Expand Up @@ -688,13 +687,13 @@ sub rseqc_junction_saturation {
## Stores commands depending on input parameters
my @commands = qw{ junction_saturation.py };

push @commands, q{--input-file} . $EQUAL . $infile_path;
push @commands, q{--input-file} . $EQUALS . $infile_path;

push @commands, q{--refgene} . $EQUAL . $bed_file_path;
push @commands, q{--refgene} . $EQUALS . $bed_file_path;

push @commands, q{--mapq} . $EQUAL . $min_map_quality;
push @commands, q{--mapq} . $EQUALS . $min_map_quality;

push @commands, q{--out-prefix} . $EQUAL . $outfiles_path_prefix;
push @commands, q{--out-prefix} . $EQUALS . $outfiles_path_prefix;

push @commands,
unix_standard_streams(
Expand Down Expand Up @@ -772,9 +771,9 @@ sub rseqc_read_distribution {
## Stores commands depending on input parameters
my @commands = qw{ read_distribution.py };

push @commands, q{--input-file} . $EQUAL . $infile_path;
push @commands, q{--input-file} . $EQUALS . $infile_path;

push @commands, q{--refgene} . $EQUAL . $bed_file_path;
push @commands, q{--refgene} . $EQUALS . $bed_file_path;

push @commands,
unix_standard_streams(
Expand Down Expand Up @@ -862,11 +861,11 @@ sub rseqc_read_duplication {
## Stores commands depending on input parameters
my @commands = qw{ read_duplication.py };

push @commands, q{--input-file} . $EQUAL . $infile_path;
push @commands, q{--input-file} . $EQUALS . $infile_path;

push @commands, q{--mapq} . $EQUAL . $min_map_quality;
push @commands, q{--mapq} . $EQUALS . $min_map_quality;

push @commands, q{--out-prefix} . $EQUAL . $outfiles_path_prefix;
push @commands, q{--out-prefix} . $EQUALS . $outfiles_path_prefix;

push @commands,
unix_standard_streams(
Expand Down
4 changes: 2 additions & 2 deletions lib/MIP/Recipes/Analysis/Genebody_coverage.pm
Expand Up @@ -25,7 +25,7 @@ BEGIN {
use base qw{ Exporter };

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

# Functions and variables which can be optionally exported
our @EXPORT_OK = qw{ analysis_genebody_coverage };
Expand Down Expand Up @@ -135,7 +135,7 @@ sub analysis_genebody_coverage {
use MIP::Get::File qw{ get_io_files };
use MIP::Get::Parameter qw{ get_recipe_attributes get_recipe_resources };
use MIP::Gnu::Coreutils qw{ gnu_cp gnu_rm };
use MIP::Program::Qc::Rseqc qw{ rseqc_bam2wig rseqc_genebody_coverage2 };
use MIP::Program::Rseqc qw{ rseqc_bam2wig rseqc_genebody_coverage2 };
use MIP::Parse::File qw{ parse_io_outfiles };
use MIP::Processmanagement::Processes qw{ submit_recipe };
use MIP::Sample_info qw{ set_recipe_outfile_in_sample_info };
Expand Down
4 changes: 2 additions & 2 deletions lib/MIP/Recipes/Analysis/Rseqc.pm
Expand Up @@ -27,7 +27,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_rseqc };
Expand Down Expand Up @@ -153,7 +153,7 @@ sub analysis_rseqc {
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::Qc::Rseqc
use MIP::Program::Rseqc
qw{ rseqc_bam_stat rseqc_infer_experiment rseqc_inner_distance rseqc_junction_annotation rseqc_junction_saturation rseqc_read_distribution rseqc_read_duplication };
use MIP::Script::Setup_script qw{ setup_script };

Expand Down
32 changes: 15 additions & 17 deletions t/rseqc_bam2wig.t
Expand Up @@ -20,10 +20,12 @@ use Readonly;

## MIPs lib/
use lib catdir( dirname($Bin), q{lib} );
use MIP::Constants qw{ $COMMA $EQUALS $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 @@ -33,10 +35,7 @@ $VERBOSE = test_standard_cli(
);

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

BEGIN {

Expand All @@ -45,18 +44,17 @@ BEGIN {
### Check all internal dependency modules and imports
## Modules with import
my %perl_module = (
q{MIP::Program::Qc::Rseqc} => [qw{ rseqc_bam2wig }],
q{MIP::Test::Fixtures} => [qw{ test_standard_cli }],
q{MIP::Program::Rseqc} => [qw{ rseqc_bam2wig }],
q{MIP::Test::Fixtures} => [qw{ test_standard_cli }],
);

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

use MIP::Program::Qc::Rseqc qw{ rseqc_bam2wig };
use MIP::Test::Commands qw{ test_function };
use MIP::Program::Rseqc qw{ rseqc_bam2wig };

diag( q{Test rseqc_bam2wig from Rseqc.pm v}
. $MIP::Program::Qc::Rseqc::VERSION
. $MIP::Program::Rseqc::VERSION
. $COMMA
. $SPACE . q{Perl}
. $SPACE
Expand Down Expand Up @@ -91,34 +89,34 @@ my %base_argument = (
my %required_argument = (
chrom_size_file_path => {
input => catfile(qw{ a file.txt }),
expected_output => q{--chromSize} . $EQUAL . catfile(qw{ a file.txt }),
expected_output => q{--chromSize} . $EQUALS . catfile(qw{ a file.txt }),
},
infile_path => {
input => catfile(qw{ a infile.bam }),
expected_output => q{--input-file} . $EQUAL . catfile(qw{ a infile.bam }),
expected_output => q{--input-file} . $EQUALS . catfile(qw{ a infile.bam }),
},
outfile_path_prefix => {
input => catfile(qw{test outfile_prefix }),
expected_output => q{--out-prefix} . $EQUAL . catfile(qw{ test outfile_prefix }),
expected_output => q{--out-prefix} . $EQUALS . catfile(qw{ test outfile_prefix }),
},
);

my %specific_argument = (
chrom_size_file_path => {
input => catfile(qw{ a file.txt }),
expected_output => q{--chromSize} . $EQUAL . catfile(qw{ a file.txt }),
expected_output => q{--chromSize} . $EQUALS . catfile(qw{ a file.txt }),
},
infile_path => {
input => catfile(qw{ a infile.bam }),
expected_output => q{--input-file} . $EQUAL . catfile(qw{ a infile.bam }),
expected_output => q{--input-file} . $EQUALS . catfile(qw{ a infile.bam }),
},
strand => {
input => q{1++,1--,2+-,2-+},
expected_output => q{--strand} . $EQUAL . q{1++,1--,2+-,2-+},
expected_output => q{--strand} . $EQUALS . q{1++,1--,2+-,2-+},
},
outfile_path_prefix => {
input => catfile(qw{test outfile_prefix }),
expected_output => q{--out-prefix} . $EQUAL . catfile(qw{ test outfile_prefix }),
expected_output => q{--out-prefix} . $EQUALS . catfile(qw{ test outfile_prefix }),
},
);

Expand Down
24 changes: 11 additions & 13 deletions t/rseqc_bam_stat.t
Expand Up @@ -20,10 +20,12 @@ use Readonly;

## MIPs lib/
use lib catdir( dirname($Bin), q{lib} );
use MIP::Constants qw{ $COMMA $EQUALS $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 @@ -33,10 +35,7 @@ $VERBOSE = test_standard_cli(
);

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

BEGIN {

Expand All @@ -45,18 +44,17 @@ BEGIN {
### Check all internal dependency modules and imports
## Modules with import
my %perl_module = (
q{MIP::Program::Qc::Rseqc} => [qw{ rseqc_bam_stat }],
q{MIP::Test::Fixtures} => [qw{ test_standard_cli }],
q{MIP::Program::Rseqc} => [qw{ rseqc_bam_stat }],
q{MIP::Test::Fixtures} => [qw{ test_standard_cli }],
);

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

use MIP::Program::Qc::Rseqc qw{ rseqc_bam_stat };
use MIP::Test::Commands qw{ test_function };
use MIP::Program::Rseqc qw{ rseqc_bam_stat };

diag( q{Test rseqc_bam_stat from Rseqc.pm v}
. $MIP::Program::Qc::Rseqc::VERSION
. $MIP::Program::Rseqc::VERSION
. $COMMA
. $SPACE . q{Perl}
. $SPACE
Expand Down Expand Up @@ -91,18 +89,18 @@ my %base_argument = (
my %required_argument = (
infile_path => {
input => catfile(qw{ a test infile.bam }),
expected_output => q{--input-file} . $EQUAL . catfile(qw{ a test infile.bam }),
expected_output => q{--input-file} . $EQUALS . catfile(qw{ a test infile.bam }),
},
);

my %specific_argument = (
infile_path => {
input => catfile(qw{ a test infile.bam }),
expected_output => q{--input-file} . $EQUAL . catfile(qw{ a test infile.bam }),
expected_output => q{--input-file} . $EQUALS . catfile(qw{ a test infile.bam }),
},
min_map_quality => {
input => $MIN_MAP_QUALITY,
expected_output => q{--mapq} . $EQUAL . $MIN_MAP_QUALITY,
expected_output => q{--mapq} . $EQUALS . $MIN_MAP_QUALITY,
},
);

Expand Down

0 comments on commit 0a7929f

Please sign in to comment.