Skip to content

Commit

Permalink
Fixed consensus generation for VarScan2 and Bcftools masking referenc…
Browse files Browse the repository at this point in the history
…e genome in the first place.
  • Loading branch information
svarona committed Dec 4, 2020
1 parent 46d97f5 commit 07d1267
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -1385,17 +1385,18 @@ process VARSCAN2_CONSENSUS {
script:
prefix = "${sample}.AF${params.max_allele_freq}"
"""
cat $fasta | bcftools consensus ${vcf[0]} > ${prefix}.consensus.fa
bedtools genomecov \\
-bga \\
-ibam ${bam[0]} \\
-g $fasta \\
| awk '\$4 < $params.min_coverage' | bedtools merge > ${prefix}.mask.bed
bedtools maskfasta \\
-fi ${prefix}.consensus.fa \\
-fi $fasta \\
-bed ${prefix}.mask.bed \\
-fo ${prefix}.consensus.masked.fa
-fo ${index_base}.ref.masked.fa
cat ${index_base}.ref.masked.fa | bcftools consensus ${vcf[0]} > ${prefix}.consensus.masked.fa
header=\$(head -n 1 ${prefix}.consensus.masked.fa | sed 's/>//g')
sed -i "s/\${header}/${sample}/g" ${prefix}.consensus.masked.fa
Expand Down Expand Up @@ -1782,17 +1783,18 @@ process BCFTOOLS_CONSENSUS {

script:
"""
cat $fasta | bcftools consensus ${vcf[0]} > ${sample}.consensus.fa
bedtools genomecov \\
-bga \\
-ibam ${bam[0]} \\
-g $fasta \\
| awk '\$4 < $params.min_coverage' | bedtools merge > ${sample}.mask.bed
bedtools maskfasta \\
-fi ${sample}.consensus.fa \\
-fi $fasta \\
-bed ${sample}.mask.bed \\
-fo ${sample}.consensus.masked.fa
-fo ${index_base}.ref.masked.fa
cat ${index_base}.ref.masked.fa | bcftools consensus ${vcf[0]} > ${sample}.consensus.masked.fa
sed -i 's/${index_base}/${sample}/g' ${sample}.consensus.masked.fa
header=\$(head -n1 ${sample}.consensus.masked.fa | sed 's/>//g')
sed -i "s/\${header}/${sample}/g" ${sample}.consensus.masked.fa
Expand Down

0 comments on commit 07d1267

Please sign in to comment.