From 5a4c39b73f1e89814ba82b0293cf8c5349faa117 Mon Sep 17 00:00:00 2001 From: Manuel Holtgrewe Date: Tue, 10 Jan 2023 11:31:12 +0100 Subject: [PATCH] fix: make GNU parallel more robust with --plain and --workdir (#328) (#331) --- snappy_wrappers/wrappers/bcftools/call_joint/wrapper.py | 6 ++++++ snappy_wrappers/wrappers/bcftools_call/wrapper.py | 3 ++- snappy_wrappers/wrappers/gatk3_hc/wrapper.py | 3 ++- snappy_wrappers/wrappers/gatk3_ug/wrapper.py | 3 ++- snappy_wrappers/wrappers/gatk4_hc/combine_gvcfs/wrapper.py | 3 ++- snappy_wrappers/wrappers/gatk4_hc/discover/wrapper.py | 3 ++- snappy_wrappers/wrappers/gatk4_hc/joint/wrapper.py | 3 ++- snappy_wrappers/wrappers/varscan/call_joint/wrapper.py | 3 +++ 8 files changed, 21 insertions(+), 6 deletions(-) diff --git a/snappy_wrappers/wrappers/bcftools/call_joint/wrapper.py b/snappy_wrappers/wrappers/bcftools/call_joint/wrapper.py index 3dacb0015..b65bb2b86 100644 --- a/snappy_wrappers/wrappers/bcftools/call_joint/wrapper.py +++ b/snappy_wrappers/wrappers/bcftools/call_joint/wrapper.py @@ -48,11 +48,17 @@ # Hack: get back bin directory of base/root environment. export PATH=$PATH:$(dirname $(dirname $(which conda)))/bin +export TMPDIR=$(mktemp -d) +trap "rm -rf $TMPDIR" EXIT +mkdir -p $TMPDIR/parallel + snappy-genome_windows \ --fai-file $REF.fai \ --window-size {snakemake.config[step_config][somatic_variant_calling][bcftools_joint][window_length]} \ {args_ignore_chroms} \ | parallel \ + --plain \ + --workdir $TMPDIR/parallel \ --keep-order \ --verbose \ --max-procs {snakemake.config[step_config][somatic_variant_calling][bcftools_joint][num_threads]} \ diff --git a/snappy_wrappers/wrappers/bcftools_call/wrapper.py b/snappy_wrappers/wrappers/bcftools_call/wrapper.py index 0a9b7ff79..914c7323d 100644 --- a/snappy_wrappers/wrappers/bcftools_call/wrapper.py +++ b/snappy_wrappers/wrappers/bcftools_call/wrapper.py @@ -125,9 +125,10 @@ export -f run-shard # Perform parallel execution +mkdir -p $TMPDIR/parallel num_threads={snakemake.config[step_config][variant_calling][gatk4_hc_joint][num_threads]} cat $TMPDIR/final_intervals.txt \ -| parallel -j $num_threads 'run-shard {{#}} {{}}' +| parallel --plain --workdir $TMPDIR/parallel -j $num_threads 'run-shard {{#}} {{}}' # Merge the individual shards' output VCF bcftools concat \ diff --git a/snappy_wrappers/wrappers/gatk3_hc/wrapper.py b/snappy_wrappers/wrappers/gatk3_hc/wrapper.py index a4b6590c2..58701a8ef 100644 --- a/snappy_wrappers/wrappers/gatk3_hc/wrapper.py +++ b/snappy_wrappers/wrappers/gatk3_hc/wrapper.py @@ -108,9 +108,10 @@ export -f run-shard # Perform parallel execution +mkdir -p $TMPDIR/parallel num_threads={snakemake.config[step_config][variant_calling][gatk3_hc][num_threads]} cat $TMPDIR/final_intervals.txt \ -| parallel -j $num_threads 'run-shard {{#}} {{}}' +| parallel --plain --workdir $TMPDIR/parallel -j $num_threads 'run-shard {{#}} {{}}' # Merge the individual shards' output VCF bcftools concat \ diff --git a/snappy_wrappers/wrappers/gatk3_ug/wrapper.py b/snappy_wrappers/wrappers/gatk3_ug/wrapper.py index 71636ec86..52cc88fd7 100644 --- a/snappy_wrappers/wrappers/gatk3_ug/wrapper.py +++ b/snappy_wrappers/wrappers/gatk3_ug/wrapper.py @@ -109,9 +109,10 @@ export -f run-shard # Perform parallel execution +mkdir -p $TMPDIR/parallel num_threads={snakemake.config[step_config][variant_calling][gatk3_ug][num_threads]} cat $TMPDIR/final_intervals.txt \ -| parallel -j $num_threads 'run-shard {{#}} {{}}' +| parallel --plain --workdir $TMPDIR/parallel -j $num_threads 'run-shard {{#}} {{}}' # Merge the individual shards' output VCF bcftools concat \ diff --git a/snappy_wrappers/wrappers/gatk4_hc/combine_gvcfs/wrapper.py b/snappy_wrappers/wrappers/gatk4_hc/combine_gvcfs/wrapper.py index f4630cb92..25e85cd10 100644 --- a/snappy_wrappers/wrappers/gatk4_hc/combine_gvcfs/wrapper.py +++ b/snappy_wrappers/wrappers/gatk4_hc/combine_gvcfs/wrapper.py @@ -110,9 +110,10 @@ export -f run-shard # Perform parallel execution +mkdir -p $TMPDIR/parallel num_threads={snakemake.config[step_config][variant_calling][gatk4_hc_gvcf][num_threads]} cat $TMPDIR/final_intervals.txt \ -| parallel -j $num_threads 'run-shard {{#}} {{}}' +| parallel --workdir $TMPDIR/parallel --plain -j $num_threads 'run-shard {{#}} {{}}' # Merge the individual shards' output VCF bcftools concat \ diff --git a/snappy_wrappers/wrappers/gatk4_hc/discover/wrapper.py b/snappy_wrappers/wrappers/gatk4_hc/discover/wrapper.py index e5eefc6a4..6167215cd 100644 --- a/snappy_wrappers/wrappers/gatk4_hc/discover/wrapper.py +++ b/snappy_wrappers/wrappers/gatk4_hc/discover/wrapper.py @@ -113,9 +113,10 @@ export -f run-shard # Perform parallel execution +mkdir -p $TMPDIR/parallel num_threads={snakemake.config[step_config][variant_calling][gatk4_hc_gvcf][num_threads]} cat $TMPDIR/final_intervals.txt \ -| parallel -j $num_threads 'run-shard {{#}} {{}}' +| parallel --workdir $TMPDIR/parallel --plain -j $num_threads 'run-shard {{#}} {{}}' # Merge the individual shards' output VCF bcftools concat \ diff --git a/snappy_wrappers/wrappers/gatk4_hc/joint/wrapper.py b/snappy_wrappers/wrappers/gatk4_hc/joint/wrapper.py index f8a153656..e441ed9fb 100644 --- a/snappy_wrappers/wrappers/gatk4_hc/joint/wrapper.py +++ b/snappy_wrappers/wrappers/gatk4_hc/joint/wrapper.py @@ -111,9 +111,10 @@ export -f run-shard # Perform parallel execution +mkdir -p $TMPDIR/parallel num_threads={snakemake.config[step_config][variant_calling][gatk4_hc_joint][num_threads]} cat $TMPDIR/final_intervals.txt \ -| parallel -j $num_threads 'run-shard {{#}} {{}}' +| parallel --plain --workdir $TMPDIR/parallel -j $num_threads 'run-shard {{#}} {{}}' # Merge the individual shards' output VCF bcftools concat \ diff --git a/snappy_wrappers/wrappers/varscan/call_joint/wrapper.py b/snappy_wrappers/wrappers/varscan/call_joint/wrapper.py index e9bcc9af4..40f6c73da 100644 --- a/snappy_wrappers/wrappers/varscan/call_joint/wrapper.py +++ b/snappy_wrappers/wrappers/varscan/call_joint/wrapper.py @@ -108,9 +108,12 @@ }} +mkdir -p $TMPDIR/parallel for vartype in snp indel; do generate_intervals \ | parallel \ + --plain \ + --workdir $TMPDIR/parallel --keep-order \ --verbose \ --max-procs {snakemake.config[step_config][somatic_variant_calling][varscan_joint][num_cores]} \