-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariant_preprocessing.nf
More file actions
executable file
·88 lines (75 loc) · 2.12 KB
/
variant_preprocessing.nf
File metadata and controls
executable file
·88 lines (75 loc) · 2.12 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
include { SAMTOOLS_INDEX } from './mapping';
workflow VARIANT_PREPROCESSING {
take:
bam_bai
ref_files
main:
// TODO: Check if for each of the VCF in params.known_sites theres a tbi file
// otherwise create it
// def known_sites = Channel.fromFilePairs("${params.known_sites}")
vcfs = Channel.fromPath(params.known_sites)
list = IndexVCF(vcfs).collect()
CalculateRecalibration(bam_bai,
list,
ref_files.out.fai,
ref_files.out.dict,
ref_files.out.ref)
recalibrated = ApplyRecalibration(CalculateRecalibration.out,
ref_files.out.fai,
ref_files.out.dict,
ref_files.out.ref) | SAMTOOLS_INDEX
emit:
recalibrated
}
process IndexVCF {
input:
path vcf
output:
tuple path(vcf), path("*.tbi")
script:
println "Indexing ${vcf}"
"""
gatk IndexFeatureFile -I ${vcf};
"""
}
process CalculateRecalibration {
input:
tuple val(sample_id), path(bam), path(bai)
path vcfs
path ref_fai
path ref_dict
path ref
output:
tuple val(sample_id), path(bam), path(bai), path("*.table")
script:
println "Using ${vcfs} for ${sample_id}";
vcfgz = vcfs.collect().findAll { !it.name.endsWith(".tbi") };
def sites_arg = "" // Give all --known-sites files as parameters
for (vcf in vcfgz) {
println "Adding ${vcf} to site arg"
sites_arg += " --known-sites ${vcf}"
}
"""
gatk BaseRecalibrator -I ${bam} \
-R ${ref} \
${sites_arg} \
-O ${sample_id}_recal_table.table
"""
}
process ApplyRecalibration {
input:
tuple val(sample_id), path(bam), path(bai), path(table)
path ref_fai
path ref_dict
path ref
output:
tuple val(sample_id), path("*_recal.bam")
script:
"""
gatk ApplyBQSR \
-R ${ref} \
-I ${bam} \
--bqsr-recal-file ${table} \
-O ${sample_id}_recal.bam
"""
}