Skip to content

Commit

Permalink
Avoid chdir+tempdir to enable Devel::Cover on these pipelines
Browse files Browse the repository at this point in the history
Wonder how ? It looks like Devel::Cover is completely lost when run in a
sub-script from a different working directory. The issue appeared since I
made Utils::Test::runWorker() call runWorker.pl instead of running
Scripts::RunWorker. Fortunately, in these pipelines we can have a runnable
parameter to control the location of the output files.
  • Loading branch information
muffato committed Dec 10, 2016
1 parent 1cff8bb commit 35841ab
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ sub default_options {
# it in EHIVE_ROOT_DIR, if it is not already set in the shell
'inputfile' => $ENV{'EHIVE_ROOT_DIR'} . '/t/input_fasta.fa',
'chunk_size' => 40,
'output_dir' => '.',
'output_prefix' => 'k_split_',
'output_suffix' => '.fa',
};
Expand Down Expand Up @@ -208,6 +209,7 @@ sub pipeline_analyses {
'input_format' => $self->o('input_format'),
'inputfile' => $self->o('inputfile'),
'chunk_size' => $self->o('chunk_size'),
'output_dir' => $self->o('output_dir'),
'output_prefix' => $self->o('output_prefix'),
'output_suffix' => $self->o('output_suffix'),
'k' => $self->o('k'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ sub default_options {
# it in EHIVE_ROOT_DIR, if it is not already set in the shell
'inputfile' => $ENV{'EHIVE_ROOT_DIR'} . '/t/input_fasta.fa',
'chunk_size' => 40,
'output_dir' => '.',
'output_prefix' => 'k_split_',
'output_suffix' => '.fa',
};
Expand Down Expand Up @@ -209,6 +210,7 @@ sub pipeline_analyses {
'input_format' => $self->o('input_format'),
'inputfile' => $self->o('inputfile'),
'chunk_size' => $self->o('chunk_size'),
'output_dir' => $self->o('output_dir'),
'output_prefix' => $self->o('output_prefix'),
'output_suffix' => $self->o('output_suffix'),
'k' => $self->o('k'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ sub default_options {
# it in EHIVE_ROOT_DIR, if it is not already set in the shell
'inputfile' => $ENV{'EHIVE_ROOT_DIR'} . '/t/input_fasta.fa',
'chunk_size' => 40,
'output_dir' => '.',
'output_prefix' => 'k_split_',
'output_suffix' => '.fa',
};
Expand Down Expand Up @@ -209,6 +210,7 @@ sub pipeline_analyses {
'input_format' => $self->o('input_format'),
'inputfile' => $self->o('inputfile'),
'chunk_size' => $self->o('chunk_size'),
'output_dir' => $self->o('output_dir'),
'output_prefix' => $self->o('output_prefix'),
'output_suffix' => $self->o('output_suffix'),
'k' => $self->o('k'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ sub default_options {
# it in EHIVE_ROOT_DIR, if it is not already set in the shell
'inputfile' => $ENV{'EHIVE_ROOT_DIR'} . '/t/input_fasta.fa',
'chunk_size' => 40,
'output_dir' => '.',
'output_prefix' => 'k_split_',
'output_suffix' => '.fa',
};
Expand Down Expand Up @@ -209,6 +210,7 @@ sub pipeline_analyses {
'input_format' => $self->o('input_format'),
'inputfile' => $self->o('inputfile'),
'chunk_size' => $self->o('chunk_size'),
'output_dir' => $self->o('output_dir'),
'output_prefix' => $self->o('output_prefix'),
'output_suffix' => $self->o('output_suffix'),
'k' => $self->o('k'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ use base ('Bio::EnsEMBL::Hive::Process');
sub param_defaults {

return {
'output_dir' => '.',
'output_prefix' => 'my_chunk_',
'output_suffix' => '.fasta',
'input_format' => 'FASTA',
Expand Down Expand Up @@ -159,7 +160,7 @@ sub write_output {
my $seq_object = Bio::Seq->new(-seq => $split_sequences[$i],
-id => "split_" . $i);

my $chunk_filename = $self->param('output_prefix') . $i . $self->param('output_suffix');
my $chunk_filename = ($self->param('output_dir') ? $self->param('output_dir') . '/' : '' ) . $self->param('output_prefix') . $i . $self->param('output_suffix');
my $chunk_seqio = Bio::SeqIO->new(-file => '>' . $chunk_filename,
-format => 'fasta');

Expand Down
5 changes: 0 additions & 5 deletions t/10.pipeconfig/analysis_heir.t
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ use warnings;

use Test::More;
use Data::Dumper;
use File::Temp qw{tempdir};
use Capture::Tiny 'capture_stderr';

use Bio::EnsEMBL::Hive::Utils::Test qw(init_pipeline runWorker get_test_url_or_die);
Expand All @@ -30,9 +29,6 @@ my $expected_error_pattern = qq{WARNING: Could not find a local analysis named '
# eHive needs this to initialize the pipeline (and run db_cmd.pl)
$ENV{'EHIVE_ROOT_DIR'} ||= File::Basename::dirname( File::Basename::dirname( File::Basename::dirname( Cwd::realpath($0) ) ) );

my $dir = tempdir CLEANUP => 1;
my $original = chdir $dir;

my $pipeline_url = get_test_url_or_die();

my $init_stderr = capture_stderr {
Expand All @@ -57,4 +53,3 @@ unlike($gc_init_stderr, qr/WARNING/, 'no warning from pipeline without missing a

done_testing();

chdir $original;
5 changes: 1 addition & 4 deletions t/10.pipeconfig/gcpct.t
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ $ENV{'EHIVE_ROOT_DIR'} ||= File::Basename::dirname( File::Basename::dirname( Fil
my $inputfile = File::Basename::dirname( File::Basename::dirname( Cwd::realpath($0) ) ).'/input_fasta.fa';

my $dir = tempdir CLEANUP => 1;
my $original = chdir $dir;

my $ehive_test_pipeconfigs = $ENV{'EHIVE_TEST_PIPECONFIGS'} || 'GCPct_conf';

Expand All @@ -47,7 +46,7 @@ warn "\nInitializing the $gcpct_version pipeline ...\n\n";
# override the 'take_time' PipelineWideParameter in the loaded HivePipeline object to make the internal test Worker run quicker:
my $url = init_pipeline(
'Bio::EnsEMBL::Hive::Examples::GC::PipeConfig::'.$gcpct_version,
[-pipeline_url => $pipeline_url, -hive_force_init => 1, -inputfile => "$inputfile"],
[-pipeline_url => $pipeline_url, -hive_force_init => 1, -inputfile => "$inputfile", -output_dir => $dir],
['pipeline.param[take_time]=0'],
);

Expand Down Expand Up @@ -104,5 +103,3 @@ warn "\nInitializing the $gcpct_version pipeline ...\n\n";

done_testing();

chdir $original;

5 changes: 2 additions & 3 deletions t/10.pipeconfig/kmer.t
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ my $inputfastq = $ENV{'EHIVE_ROOT_DIR'}.'/t/input_fastq.fastq';


my $dir = tempdir CLEANUP => 1;
my $original = chdir $dir;


my $all_longmult_configs = find_submodules 'Bio::EnsEMBL::Hive::Examples::Kmer::PipeConfig';
Expand All @@ -46,13 +45,15 @@ my $kmer_pipeline_modes = 'short long';
my $kmer_param_configs = {'short' => [-seqtype => "short",
-inputfile => "$inputfastq",
-chunk_size => 40,
-output_dir => $dir,
-output_prefix => "k_split_",
-output_suffix => ".fastq",
-input_format => "FASTQ",
-k => 5],
'long' => [-seqtype => "long",
-inputfile => "$inputfasta",
-chunk_size => 40,
-output_dir => $dir,
-output_prefix => "k_split_",
-output_suffix => ".fa",
-input_format => "FASTA",
Expand Down Expand Up @@ -146,5 +147,3 @@ my $pipeline_url = get_test_url_or_die();

done_testing();

chdir $original;

0 comments on commit 35841ab

Please sign in to comment.