Skip to content

Commit

Permalink
fix: gcnv contig wrapper scripts do not clean their output folders (#443
Browse files Browse the repository at this point in the history
) (#468)
  • Loading branch information
Nicolai-vKuegelgen authored Nov 29, 2023
1 parent 50d0781 commit 618f10d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions snappy_wrappers/wrappers/gcnv/call_cnvs_case_mode/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
export OMP_NUM_THREADS=16
export THEANO_FLAGS="base_compiledir=$TMPDIR/theano_compile_dir"
# Force full replacement of previous results
# (this also solves issues when gatk tries to shutil copy file ownership)
if [ -d $(dirname {snakemake.output.done}) ]
then
rm -rf $(dirname {snakemake.output.done})
fi
gatk GermlineCNVCaller \
--run-mode CASE \
$(for tsv in {paths_tsv}; do echo -I $tsv; done) \
Expand Down
13 changes: 13 additions & 0 deletions snappy_wrappers/wrappers/gcnv/contig_ploidy_case_mode/wrapper.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pathlib
import sys

from snakemake.shell import shell

Expand Down Expand Up @@ -38,6 +39,12 @@
set -x
# Force full replacement of previous results
if [ -d {out_path}/ploidy_calls ]
then
rm -rf {out_path}/ploidy_calls
fi
gatk DetermineGermlineContigPloidy \
--model {snakemake.params.args[model]} \
$(for tsv in {paths_tsv}; do echo -I $tsv; done) \
Expand All @@ -51,6 +58,12 @@
path_name = sample_dir / "sample_name.txt"
with path_name.open("rt") as inputf:
sample_name = inputf.read().strip()
if sample_name not in sex_map:
msg = f"Encountered an unexpected sample {sample_name} (undefined in samplesheet)."
print(msg, file=sys.stderr) # for slurm log
with open(snakemake.log[0], "a") as log:
log.write(msg)
sys.exit(0)
sample_sex = sex_map[sample_name]
path_call = sample_dir / "contig_ploidy.tsv"
with path_call.open("rt") as inputf:
Expand Down

0 comments on commit 618f10d

Please sign in to comment.