-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathalignReadsToReference.nf
135 lines (127 loc) · 4.18 KB
/
alignReadsToReference.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
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
//nextflow.enable.moduleBinaries = true
include {
getInputFastqs;
getSEInputFastqs;
getInputAlignments;
sortAlignmentByName;
convertAlignmentToFastq;
bwaAligner;
alignReadsBWA;
dragenAligner;
tmapAligner;
convertSamToBam;
convertBamToCram;
sortAlignment;
sortAlignmentToBam;
sortCram;
indexAlignment;
indexAlignment as indexCram;
indexAndCopyAlignment;
markDuplicatesGatk;
markDuplicates;
markDupSambam;
indexAlignment as indexMarkedAlignment;
recalibrateBaseQualityScores;
applyBaseQualityRecalibrator;
markDuplicatesSpark;
fixAlignmentTags;
fixAlignmentMate;
recalibrateBaseQualityScoresSpark;
} from "${projectDir}/modules/alignmentPipeline.nf"
workflow {
println "\nAlignment workflow begins here\n"
if( params.input_ftype.toUpperCase() == "FASTQ" ) {
println "INPUT FILE TYPE IS FASTQ\n"
if(params.pe == false) {
println "SINGLE END READS\n"
fastq = getSEInputFastqs().view()
}
else {
println "PAIRED END READS\n"
fastq = getInputFastqs()
}
}
else {
println "INPUT FILE TYPE IS ALIGNMENT (BAM/CRAM)\n"
alignment = getInputAlignments()
alignmentSortedByName = sortAlignmentByName(alignment)
fastq = convertAlignmentToFastq(alignmentSortedByName)
}
if( params.aligner == "DRAGMAP" ) {
sam = dragenAligner(fastq)
}
else if( params.aligner == "TMAP" ) {
sam = tmapAligner(fastq)
}
else {
//sam = bwaAligner(fastq)
dupsMarked = alignReadsBWA(fastq)
}
if(!(params.buildVersion == 't2t')) {
dupsMarkedIndexed = indexMarkedAlignment(dupsMarked)
recalTable = recalibrateBaseQualityScores(dupsMarkedIndexed)
dupsMarkedIndexed.combine(recalTable, by: 0).set { applyBQSR_input }
recalibrated = applyBaseQualityRecalibrator(applyBQSR_input)
}
else {
dupsMarkedIndexed = indexAndCopyAlignment(dupsMarked)
}
/*
* alignment = fixAlignmentMate(sam)
*
* if(params.buildVersion == 't2t') {
* if(params.spark == true) {
* dupsMarked = markDuplicatesSpark(alignment)
* fixedAlignment = fixAlignmentTags(dupsMarked)
* }
* else {
*
* //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
* // BQSR is not implemented for t2t reference //
* // because there are no gatk bundles for yet //
* //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=//
*
* if(params.dup_marker.toUpperCase() == "SAMTOOLS") {
* sortedAlignment = sortAlignment(alignment)
* dupsMarked = markDuplicates(sortedAlignment)
* dupsMarkedIndexed = indexAndCopyAlignment(dupsMarked)
* }
* else {
* sortedAlignment = sortAlignmentToBam(alignment)
* dupsMarked = markDupSambam(sortedAlignment)
* dupsMarkedIndexed = indexAndCopyAlignment(dupsMarked)
* }
* }
* }
* else {
* if(params.spark == true) {
* dupsMarked = markDuplicatesSpark(alignment)
* fixedAlignment = fixAlignmentTags(dupsMarked)
* recalibrated = recalibrateBaseQualityScoresSpark(fixedAlignment)
* cram = convertBamToCram(recalibrated)
* }
* else {
* if(params.dup_marker.toUpperCase() == "SAMTOOLS") {
* sortedAlignment = sortAlignment(alignment)
* dupsMarked = markDuplicates(sortedAlignment)
* }
* else {
* sortedAlignment = sortAlignmentToBam(alignment)
* dupsMarked = markDupSambam(sortedAlignment)
* }
*
* dupsMarkedIndexed = indexMarkedAlignment(dupsMarked)
* recalTable = recalibrateBaseQualityScores(dupsMarkedIndexed)
* dupsMarkedIndexed.combine(recalTable, by: 0).set { applyBQSR_input }
* recalibrated = applyBaseQualityRecalibrator(applyBQSR_input)
* //cram = convertBamToCram(recalibrated)
* }
* }
*
*/
}
workflow.onComplete {
println "\nDone! Check results in ${params.output_dir}\n"
}