-
Notifications
You must be signed in to change notification settings - Fork 1
/
postAlignmentProcessing.nf
75 lines (68 loc) · 2.32 KB
/
postAlignmentProcessing.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
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
//nextflow.enable.moduleBinaries = true
include {
getInputBams;
sortBamByName;
convertBamToFastq;
convertSamToBam;
convertBamToCram;
sortBam;
indexBam;
indexAndCopyBam;
markDuplicatesGatk;
markDuplicates;
indexBam as indexMarkedBam;
recalibrateBaseQualityScores;
applyBaseQualityRecalibrator;
markDuplicatesSpark;
fixBamTags;
fixAlignmentMate;
recalibrateBaseQualityScoresSpark;
} from "${projectDir}/modules/alignmentPipeline.nf"
workflow {
println "\nAlignment workflow begins here\n"
if( params.input_ftype == "FASTQ" ) {
error: "INPUT FILE TYPE MUST BE BAM\n"
}
else if( params.input_ftype == "BAM" ) {
println "INPUT FILE TYPE IS BAM\n"
inputbam = getInputBams()
bam = fixAlignmentMate(inputbam)
}
else { error "\nERROR: You must specify a file type! Options are FASTQ and BAM (case sensitive)\n" }
//cram = convertBamToCram(fixedsam)
if(params.buildVersion == 't2t') {
if(params.sparkMode == false) {
sortedBam = sortBam(bam)
//indexedBam = indexBam(sortedBam)
markedBam = markDuplicates(indexedBam)
markedIndexedBam = indexMarkedBam(markedBam)
}
else {
markedBam = markDuplicatesSpark(bam)
fixedBam = fixBamTags(markedBam)
}
}
else {
if(params.sparkMode == false) {
sortedBam = sortBam(bam)
//indexedBam = indexBam(sortedBam)
markedBam = markDuplicates(sortedBam)
markedIndexedBam = indexAndCopyBam(markedBam)
//cram = convertBamToCram(sortedBam)
//markedIndexedBam = indexMarkedBam(finalBam)
recalTable = recalibrateBaseQualityScores(markedIndexedBam)
markedIndexedBam.combine(recalTable, by: 0).set { applyBQSR_input }
recalBam = applyBaseQualityRecalibrator(applyBQSR_input)
cram = convertBamToCram(recalBam)
}
else {
markedBam = markDuplicatesSpark(bam)
fixedBam = fixBamTags(markedBam)
recalBam = recalibrateBaseQualityScoresSpark(fixedBam)
cram = convertBamToCram(recalBam)
}
}
}
workflow.onComplete { println "\nDone! Check results in ${params.outputDir}\n" }