Skip to content

Commit

Permalink
Better sorting of freebayes outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
iracooke committed Apr 2, 2024
1 parent b097472 commit 60bfac6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ workflow {
ch_baicollection = ch_mapped_marked_bais.map{m,b -> b} | collect
ch_chunk_vcfs = freebayes(ch_bamcollection,ch_baicollection,genome_fasta,genome_fai,ch_regions,file(params.populations)) | collect

freebayes_collect(ch_chunk_vcfs)
freebayes_collect(ch_chunk_vcfs,"${projectDir}/bash/sort_vcf_files.sh")

// bcftools
mpileup_call(ch_bamcollection,ch_baicollection,genome_fasta,genome_fai)
Expand Down
3 changes: 2 additions & 1 deletion modules/freebayes.nf
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ process freebayes_collect {

input:
path(vcf)
path('sort_vcf_files.sh')

output:
path("*.vcf.gz"), emit: vcf
Expand All @@ -100,7 +101,7 @@ process freebayes_collect {
def prefix="freebayes"

"""
cat *.vcf | vcffirstheader | vcfstreamsort -w 1000 > ${prefix}.vcf
sort_vcf_files.sh | xargs cat | vcffirstheader | vcfstreamsort -w 1000 > ${prefix}.vcf
bgzip ${prefix}.vcf
tabix ${prefix}.vcf.gz
Expand Down
1 change: 1 addition & 0 deletions shell/sort_vcf_files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ls *.vcf | awk -F "[:.-]" '{print $1,$2,$3,$4,$5}' | sort -k2,2 -k4,4n | awk '{printf("%s.%s.%s:%s-%s.vcf\n",$1,$2,$3,$4,$5)}'

0 comments on commit 60bfac6

Please sign in to comment.