-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.nf
129 lines (88 loc) · 3.46 KB
/
main.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
#!/usr/bin/env nextflow
/// To use DSL-2 will need to include this
nextflow.enable.dsl=2
// Import subworkflows to be run in the workflow
include { checkInputs } from './modules/check_cohort'
include { samtoolsStats } from './modules/samtoolsStats'
include { sambambaFlag } from './modules/sambambaFlagstat'
include { mosdepth } from './modules/mosdepth'
include { qualimapBamqc } from './modules/qualimapBamqc'
//include { multiqc } from './modules/multiqc'
/// Print a header for your pipeline
log.info """\
============================================
============================================
B A M - Q C
============================================
============================================
-._ _.--'"`'--._ _.--'"`'--._ _.--'"`'--._
'-:`.'|`|"':-. '-:`.'|`|"':-. '-:`.'|`|"':-. '. .
'. '. | | | |'. '. | | | |'. '. | | | |'. '.
: '. '.| | | | '. '.| | | | '. '.| | | | '. '
' '. `.:_ | :_.' '. `.:_ | :_.' '. `.:_ | :_.' '.
`-..,..-' `-..,..-' `-..,..-'
~~~~ Version: 1.0 ~~~~
Created by the Sydney Informatics Hub, University of Sydney
Find documentation and more info @ https://github.com/Sydney-Informatics-Hub/bamQC-nf
Cite this pipeline @ INSERT DOI
Log issues @ https://github.com/Sydney-Informatics-Hub/bamQC-nf/issues
All default parameters are set in `nextflow.config`.
"""
/// Help function
// This is an example of how to set out the help function that
// will be run if run command is incorrect (if set in workflow)
// or missing
def helpMessage() {
log.info"""
OOPS, YOU FORGOT SOME REQUIRED ARGUMENTS!
Usage: nextflow run https://github.com/Sydney-Informatics-Hub/bamQC-nf --cohort <manifest.tsv>
Required Arguments:
--cohort Specify tab-separated input file. Default
is ./samples.tsv
Optional Arguments:
--outDir Specify path to output directory. Default
is ./Stats_out
--cpus Set the number of threads. Default is 8.
--flagstat Run Samtools flagstat, rather than Samtools
stats. Default is samtools stats.
--qualimap Run Qualimap bamqc tool (optional)
""".stripIndent()
}
/// Main workflow structure. Include some input/runtime tests here.
workflow {
// Show help message if --help is run or if any required params are not
// provided at runtime
if ( params.help || params.cohort == false ){
// Invoke the help function above and exit
helpMessage()
exit 1
// consider adding some extra contigencies here.
// if none of the above are a problem, then run the workflow
} else {
// Check inputs
checkInputs(Channel.fromPath(params.cohort, checkIfExists: true))
// Split cohort file to collect info for each sample
cohort = checkInputs.out
.splitCsv(header: true, sep:"\t")
.map { row -> tuple(row.sampleID, file(row.bam), file(row.bai)) }
if (params.flagstat) {
// Run sambambaFlagstats
sambambaFlag(cohort)
}
// Run samtoolsStats if --flagstat not specified
else { samtoolsStats(cohort)
}
// Run mosdepth
mosdepth(cohort)
if (params.qualimap) {
// Run qualimapBamQC
qualimapBamqc(cohort)
}
// Run multiqc to aggregate reports
// Still under development
//multiqc()
}}
workflow.onComplete {
log.info ( workflow.success ? "\nDone! Outputs are in `${params.outDir}`, runtime info is in `./run_Info`"
: "Oops .. something went wrong" )
}