Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Do not require manual maintenance of module names that finalize depen…
Browse files Browse the repository at this point in the history
…ds on
  • Loading branch information
Sam Brightman committed Jan 18, 2017
1 parent 707420a commit 026dafb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
19 changes: 4 additions & 15 deletions lib/HMF/Pipeline/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -203,21 +203,10 @@ sub sampleControlBamsAndJobs {
sub allRunningJobs {
my ($opt) = @_;

# is this split into modules actually required anywhere?
# surely better to use *all* keys instead of a hard-coded list?
my @running_jobs = uniq grep { defined } map { @$_ } grep { defined } @{$opt->{RUNNING_JOBS}}{
# flatten registered jobs into one list
"baf",
"prestats",
sort keys %{$opt->{SAMPLES}},
"slicing",
"poststats",
"somvar",
"cnv",
"sv",
"kinship",
};
return \@running_jobs;
my @running_job_chains = grep { defined } values %{$opt->{RUNNING_JOBS}};
my @running_jobs = map { @$_ } @running_job_chains;
my @unique_jobs = uniq sort grep { defined } @running_jobs;
return \@unique_jobs;
}

sub recordGitVersion {
Expand Down
15 changes: 12 additions & 3 deletions t/03-config.t
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,18 @@ is_deeply([ sampleBamAndJobs("b", $opt) ], [ "$temp_dir/b/mapping/b.bam", [ "job
is_deeply([ sampleBamAndJobs("c", $opt) ], [ "$temp_dir/c/mapping/c.bam", undef ], "bam path and no jobs for sample c"); # should return empty list?
is_deeply([ sampleBamsAndJobs($opt) ], [ {a => "$temp_dir/a/mapping/a.bam", b => "$temp_dir/b/mapping/b.bam"}, [ "job1", "job2", "joba", "jobb" ] ], "bam paths and jobs for samples");

# not really clear how to test this - allRunningJobs should probably not hard-code keys
$opt->{RUNNING_JOBS}->{somvar} = [ "fb", "vs" ];
is_deeply(allRunningJobs($opt), [ "job1", "job2", "joba", "jobb", "fb", "vs" ], "'all' running jobs");

is_deeply(allRunningJobs({RUNNING_JOBS => {}}), [], "no running jobs");
is_deeply(allRunningJobs({RUNNING_JOBS => {a => undef}}), [], "no skipped job chains");
is_deeply(allRunningJobs({RUNNING_JOBS => {a => []}}), [], "no skipped job chains");
is_deeply(allRunningJobs({RUNNING_JOBS => {a => ["job"]}}), ["job"], "single job chain");
is_deeply(allRunningJobs({RUNNING_JOBS => {a => [ "job1", "job2" ]}}), [ "job1", "job2" ], "multiple job chain");
is_deeply(allRunningJobs({RUNNING_JOBS => {a => undef, b => ["job"]}}), ["job"], "job chain after skipped job chain");
is_deeply(allRunningJobs({RUNNING_JOBS => {a => ["job1"], b => ["job2"]}}), [ "job1", "job2" ], "multiple job chains");
is_deeply(allRunningJobs({RUNNING_JOBS => {a => [undef]}}), [], "skipped job within chain");
is_deeply(allRunningJobs({RUNNING_JOBS => {a => [ undef, "job" ]}}), ["job"], "job after skipped job within chain");
is_deeply(allRunningJobs({RUNNING_JOBS => {a => [ "job", "job" ]}}), ["job"], "unique job within chain");
is_deeply(allRunningJobs({RUNNING_JOBS => {a => ["job"], b => ["job"]}}), ["job"], "unique job across chains");


my $metadata_path = catfile($temp_dir, "metadata");
Expand Down

0 comments on commit 026dafb

Please sign in to comment.