-
Notifications
You must be signed in to change notification settings - Fork 149
/
merge_VCF.nf
53 lines (41 loc) · 1.04 KB
/
merge_VCF.nf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env nextflow
/*
* Script to merge chromosome-wise VCF files into single VCF file
*/
nextflow.enable.dsl=2
// defaults
prefix = "out"
mergedVCF = "merged-file"
if ( params.output_prefix != "" ){
mergedVCF = params.output_prefix
}
params.outdir = ""
params.cpus = 1
process mergeVCF {
/*
Function to merge chromosome-wise VCF files into single VCF file
Returns
-------
Returns 2 files:
1) A VCF format file
2) A tabix index for that VCF
*/
publishDir "${params.outdir}",
enabled: "${params.outdir}" as Boolean,
mode:'move'
cpus params.cpus
container "${params.singularity_dir}/bcftools.sif"
cache 'lenient'
input:
path(vcfFiles)
path(indexFiles)
output:
path("${ mergedVCF }.vcf.gz*")
script:
"""
mkdir -p temp
bcftools concat --no-version -a ${ vcfFiles } -Oz -o temp-${ mergedVCF}.vcf.gz
bcftools sort -T temp -Oz temp-${ mergedVCF}.vcf.gz -o ${ mergedVCF}.vcf.gz
bcftools index -t ${ mergedVCF}.vcf.gz
"""
}