Skip to content

Commit

Permalink
Merge pull request #7 from DKFZ-ODCF/create-warning-upon-too-many-ind…
Browse files Browse the repository at this point in the history
…els-and-exit0-upon-lt50-germline-variants

Create warning upon too many indels and exit0 upon lt50 germline variants
  • Loading branch information
vinjana authored Oct 30, 2019
2 parents 78f3c5f + e5c0024 commit f59db01
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ library(vcfR)
vcf <- read.vcfR(opt$vcf)
vcf <- as.data.frame(cbind(vcf@fix, vcf@gt))
vcf$POS <- as.integer(as.character(vcf$POS))

vcf$CHR <- as.character(vcf$CHR)
dat$CHR <- as.character(dat$CHR)

vcf %>% left_join(dat %>% select(CHR:ALT, TiN_Class) %>% rename("CHROM"="CHR")) %>%
rename("#CHROM"="CHROM") %>%
write_tsv(opt$Ovcf, na=".")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ then
VCF_NORMAL_HEADER_COL=`basename ${FILENAME_CONTROL_BAM} | sed 's/.bam$//'`
fi

LOGFILE=$(dirname "$FILENAME_RARE_GERMLINE")/checkSampleSwap_TiN.log

${PERL_BINARY} ${TOOL_CHECK_SAMPLE_SWAP_SCRIPT} \
--pid=${PID} \
--raw_file=${FILENAME_VCF_RAW} \
Expand All @@ -48,13 +50,17 @@ ${PERL_BINARY} ${TOOL_CHECK_SAMPLE_SWAP_SCRIPT} \
--outfile_rareGermline=${FILENAME_RARE_GERMLINE} \
--outfile_somaticRescue=${FILENAME_SOMATIC_RESCUE} \
--outfile_allSomatic=${FILENAME_ALL_SOMATIC} \
--outfile_swapJson=${FILENAME_SWAP_JSON}
--outfile_swapJson=${FILENAME_SWAP_JSON} \
2>&1 | tee "$LOGFILE"

### Check the perl run was success or not
if [[ $? == 0 ]]
### Check whether Perl run was success or not
if [[ $? -eq 0 ]]
then
touch ${FILENAME_CHECKPOINT_SWAP}
exit 0
touch "$FILENAME_CHECKPOINT_SWAP"
exit 0
elif grep -P 'Less than \d+ rare germline variants' "$LOGFILE"; then
touch "$FILENAME_CHECKPOINT_SWAP"
exit 0
else
exit 1
exit 1
fi
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export TABIX_BINARY=tabix
export BEDTOOLS_BINARY=bedtools
export SAMTOOLS_BINARY=samtools
export PYPY_BINARY=pypy
export RSCRIPT_BINARY=Rscript
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ export BGZIP_BINARY=bgzip
export TABIX_BINARY=tabix
export BEDTOOLS_BINARY=bedtools
export PYPY_BINARY=pypy-c
export RSCRIPT_BINARY=Rscript
35 changes: 29 additions & 6 deletions resources/analysisTools/indelCallingWorkflow/filter_vcf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,38 @@ functional_var_count=`cat ${somatic_functional_indel_vcf} | wc -l | cut -f1 -d "
if [[ $functional_var_count -le $MAX_VARIANT_SCREENSHOTS ]]
then

[[ "${isControlWorkflow}" == true ]] && ${PYTHON_BINARY} ${TOOL_SCREENSHOT} --vcf=${somatic_functional_indel_vcf} --control=${FILENAME_CONTROL_BAM} --tumor=${FILENAME_TUMOR_BAM} --ref=${REFERENCE_GENOME} --prefix=${VCF_SCREENSHOTS_PREFIX} --window=${WINDOW_SIZE} --annotations=${REPEAT_MASKER} --samtoolsbin=${SAMTOOLS_BINARY} --tabixbin=${TABIX_BINARY}
[[ "${isNoControlWorkflow}" == true ]] && ${PYTHON_BINARY} ${TOOL_SCREENSHOT} --vcf=${somatic_functional_indel_vcf} --tumor=${FILENAME_TUMOR_BAM} --ref=${REFERENCE_GENOME} --prefix=${VCF_SCREENSHOTS_PREFIX} --window=${WINDOW_SIZE} --annotations=${REPEAT_MASKER} --samtoolsbin=${SAMTOOLS_BINARY} --tabixbin=${TABIX_BINARY}
if [[ "${isControlWorkflow}" == true ]]; then
${PYTHON_BINARY} ${TOOL_SCREENSHOT} \
--vcf=${somatic_functional_indel_vcf} \
--control=${FILENAME_CONTROL_BAM} \
--tumor=${FILENAME_TUMOR_BAM} \
--ref=${REFERENCE_GENOME} \
--prefix=${VCF_SCREENSHOTS_PREFIX} \
--window=${WINDOW_SIZE} \
--annotations=${REPEAT_MASKER} \
--samtoolsbin=${SAMTOOLS_BINARY} \
--tabixbin=${TABIX_BINARY}
fi

pngs=(`ls *.pdf`)
sorted=$(printf "%s\n" ${pngs[@]}|sort -k1,1V)
if [[ "${isNoControlWorkflow}" == true ]]; then
${PYTHON_BINARY} ${TOOL_SCREENSHOT} \
--vcf=${somatic_functional_indel_vcf} \
--tumor=${FILENAME_TUMOR_BAM} \
--ref=${REFERENCE_GENOME} \
--prefix=${VCF_SCREENSHOTS_PREFIX} \
--window=${WINDOW_SIZE} \
--annotations=${REPEAT_MASKER} \
--samtoolsbin=${SAMTOOLS_BINARY} \
--tabixbin=${TABIX_BINARY}
fi
pngs=(`ls *.pdf`)
sorted=$(printf "%s\n" ${pngs[@]}|sort -k1,1V)

${GHOSTSCRIPT_BINARY} -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=${combined_screen_shots} ${sorted}
${GHOSTSCRIPT_BINARY} -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=${combined_screen_shots} ${sorted}
else
printf "WARNINGS: No screenshots done, more than $MAX_VARIANT_SCREENSHOTS (cvalue - MAX_VARIANT_SCREENSHOTS) functional variants present in ${somatic_functional_indel_vcf} \n"
printf "WARNINGS: No screenshots done, more than $MAX_VARIANT_SCREENSHOTS (cvalue - MAX_VARIANT_SCREENSHOTS) functional variants present in ${somatic_functional_indel_vcf}\n"
$RSCRIPT_BINARY "$TOOL_TEXT_PDF" "WARNING\nNo screenshots done. More than $MAX_VARIANT_SCREENSHOTS functional variants." \
> "$combined_screen_shots"
fi

#### Indel QC json file
Expand Down
15 changes: 15 additions & 0 deletions resources/analysisTools/indelCallingWorkflow/textPdf.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env Rscript

args <- commandArgs(trailingOnly=TRUE)
if (length(args) == 0) {
text <- ""
} else {
text <- args[1]
}

write(text, stdout())

pdf("/dev/stdout", height=3, width=6)
plot.new()
mtext(text)
ignore <- dev.off()
1 change: 1 addition & 0 deletions resources/configurationFiles/analysisIndelCalling.xml
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@
<tool name="screenshot" value="visualize.py" basepath="indelCallingWorkflow"/>
<tool name="vcfFilterByCrit" value="vcf_filter_by_crit.py" basepath="indelCallingWorkflow"/>
<tool name="platypusIndelJson" value="indel_json_v1.0.pl" basepath="indelCallingWorkflow"/>
<tool name="textPdf" value="textPdf.R" basepath="indelCallingWorkflow"/>

<!--## SwapChecker -->
<tool name="checkSampleSwapScript" value="checkSampleSwap_TiN.pl" basepath="indelCallingWorkflow"/>
Expand Down

0 comments on commit f59db01

Please sign in to comment.