diff --git a/snappy_wrappers/wrappers/gcnv/contig_ploidy/wrapper.py b/snappy_wrappers/wrappers/gcnv/contig_ploidy/wrapper.py index 75b877a02..2aae0a4b1 100644 --- a/snappy_wrappers/wrappers/gcnv/contig_ploidy/wrapper.py +++ b/snappy_wrappers/wrappers/gcnv/contig_ploidy/wrapper.py @@ -43,14 +43,24 @@ export OMP_NUM_THREADS={snakemake.threads} export THEANO_FLAGS="base_compiledir=$TMPDIR/theano_compile_dir" +# Get contig name style +egrep "^@SQ\s+SN:chr[0-9XY]{1,2}\s+" {snakemake.input.interval_list} > /dev/null && true +exit_status=$? +if [[ $exit_status == 0 ]]; then + STYLE="chr" +else + STYLE="" +fi + + PRIORS=$TMPDIR/ploidy_priors.tsv echo -e "CONTIG_NAME\tPLOIDY_PRIOR_0\tPLOIDY_PRIOR_1\tPLOIDY_PRIOR_2\tPLOIDY_PRIOR_3" \ > $PRIORS for i in {{1..22}}; do - echo -e "$i\t0\t0.01\t0.98\t0.01" >> $PRIORS + echo -e "$STYLE$i\t0\t0.01\t0.98\t0.01" >> $PRIORS done -echo -e "X\t0.01\t0.49\t0.49\t0.01" >> $PRIORS -echo -e "Y\t0.495\t0.495\t0.01\t0" >> $PRIORS +echo -e "${{STYLE}}X\t0.01\t0.49\t0.49\t0.01" >> $PRIORS +echo -e "${{STYLE}}Y\t0.495\t0.495\t0.01\t0" >> $PRIORS set -x diff --git a/snappy_wrappers/wrappers/gcnv/post_germline_calls/wrapper.py b/snappy_wrappers/wrappers/gcnv/post_germline_calls/wrapper.py index 639c37b59..0f02a761b 100644 --- a/snappy_wrappers/wrappers/gcnv/post_germline_calls/wrapper.py +++ b/snappy_wrappers/wrappers/gcnv/post_germline_calls/wrapper.py @@ -25,14 +25,25 @@ fi done +# Get contig name style +# Note: the sample_index in '{snakemake.input.ploidy}' and '{snakemake.input.calls[0]}' are NOT guaranteed to be the same +# -> Sample_0 should always exist and the contig names (which we care for) are the same +tail -n +2 $(dirname {snakemake.input.ploidy})/ploidy-calls/SAMPLE_0/contig_ploidy.tsv | egrep "^chr[0-9XY]{1,2}\s[0-9]\s[0-9.]+" > /dev/null && true +exit_status=$? +if [[ $exit_status == 0 ]]; then + STYLE="chr" +else + STYLE="" +fi + gatk PostprocessGermlineCNVCalls \ $(for x in {paths_calls}; do echo --calls-shard-path $(dirname $x)/cnv_calls-calls; done) \ $(for x in {paths_models}; do echo --model-shard-path $(dirname $x)/cnv_calls-model; done) \ --contig-ploidy-calls $(dirname {snakemake.input.ploidy})/ploidy-calls \ --sample-index $sample_index \ --autosomal-ref-copy-number 2 \ - --allosomal-contig X \ - --allosomal-contig Y \ + --allosomal-contig ${{STYLE}}X \ + --allosomal-contig ${{STYLE}}Y \ --output-genotyped-intervals ${{itv_vcf%.gz}} \ --output-genotyped-segments ${{seg_vcf%.gz}} \ --output-denoised-copy-ratios {snakemake.output.ratio_tsv} diff --git a/snappy_wrappers/wrappers/gcnv/post_germline_calls_case_mode/wrapper.py b/snappy_wrappers/wrappers/gcnv/post_germline_calls_case_mode/wrapper.py index 6847ea534..5952dd3be 100644 --- a/snappy_wrappers/wrappers/gcnv/post_germline_calls_case_mode/wrapper.py +++ b/snappy_wrappers/wrappers/gcnv/post_germline_calls_case_mode/wrapper.py @@ -29,14 +29,23 @@ exit 1 fi +# Get contig name style; SAMPLE_0 is guaranteed to exist +tail -n +2 $(dirname {snakemake.input.ploidy})/ploidy-calls/SAMPLE_0/contig_ploidy.tsv | grep "^chr[0-9XY]{1,2}\s[0-9]\s[0-9.]+$" > /dev/null && true +exit_status=$? +if [[ $exit_status == 0 ]]; then + STYLE="chr" +else + STYLE="" +fi + gatk PostprocessGermlineCNVCalls \ $(for x in {paths_calls}; do echo --calls-shard-path $(dirname $x)/cnv_calls-calls; done) \ $(for x in {paths_models}; do echo --model-shard-path $x; done) \ --contig-ploidy-calls $(dirname {snakemake.input.ploidy})/ploidy-calls \ --sample-index $sample_index \ --autosomal-ref-copy-number 2 \ - --allosomal-contig X \ - --allosomal-contig Y \ + --allosomal-contig ${{STYLE}}X \ + --allosomal-contig ${{STYLE}}Y \ --output-genotyped-intervals ${{itv_vcf%.gz}} \ --output-genotyped-segments ${{seg_vcf%.gz}} \ --output-denoised-copy-ratios {snakemake.output.ratio_tsv}