Skip to content

Commit

Permalink
fix: remove hard coded contig names from gcnv wrappers (#489 ) (#490)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolai-vKuegelgen authored Apr 8, 2024
1 parent af961cc commit 4b89594
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
16 changes: 13 additions & 3 deletions snappy_wrappers/wrappers/gcnv/contig_ploidy/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 13 additions & 2 deletions snappy_wrappers/wrappers/gcnv/post_germline_calls/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 4b89594

Please sign in to comment.