-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.nf
142 lines (123 loc) · 5.33 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
130
131
132
133
134
135
136
137
138
139
140
141
142
#!/usr/bin/env nextflow
// enable dsl2
nextflow.enable.dsl = 2
// Modules
include { helpStatement } from './modules/help.nf'
// subworkflows
include { illuminaDehosting } from './workflows/illumina_dehosting.nf'
include { nanoporeNanostripperDehosting } from './workflows/nanopore_dehosting.nf'
include { nanoporeMinimap2Dehosting } from './workflows/nanopore_dehosting.nf'
// Print Help
if ( params.help ) {
helpStatement()
exit 0
}
// Checking that everything is found before starting process
if ( params.illumina ) {
if ( !params.directory ) {
println("Please specify a directory containing paired fastq reads with --directory <path/to/fastqs>")
System.exit(1)
}
} else if ( params.nanopore ) {
// Pick a pipeline and validate inputs for it
if ( !params.nanostripper && !params.minimap2 ) {
println("Please specify the tool to dehost nanopore data")
System.exit(1)
} else if ( params.nanostripper && params.minimap2 ) {
println("Please specify one of `--nanostripper` or `--minimap2`")
System.exit(1)
// Nanostripper Validation
} else if ( params.nanostripper ) {
if ( !params.fast5_directory ) {
println("Please specify a directory containing barcoded fast5 files with --fast5_directory <path/to/BARCODES/>")
System.exit(1)
}
// Minimap2 Validation
} else {
if ( !params.fastq_directory ) {
println("Please specify a directory containing fastq files or barcoded fastq directories with --fastq_directory <path/to/fastqs>")
System.exit(1)
}
}
// Run name for sorting out nanopore outputs in default output directory
if ( !params.run_name) {
println("Please specify a run name for seperating out nanopore runs")
System.exit(1)
}
} else {
println('Please specify either --illumina or --nanopore for the type of sequencing data that will be dehosted')
System.exit(1)
}
// Main
workflow {
Channel.fromPath( "${params.human_ref}")
.set{ ch_HumanReference }
Channel.fromPath( "${params.cov2019_ref}")
.set{ ch_CovidReference }
if ( params.illumina ) {
// Single-end or paired-end run - We don't support single end Illumina at this time
if ( params.single_end ){
Channel.fromPath( "${params.directory}/*.fastq", type: 'file', maxDepth: 1 )
.set{ ch_fastqs }
println('Single end reads pipeline is not yet available')
System.exit(1)
} else {
Channel.fromFilePairs( params.fastqpaths, flat: true, maxDepth: 1)
.set{ ch_fastqs }
illuminaDehosting(ch_fastqs, ch_HumanReference, ch_CovidReference)
}
} else if ( params.nanopore ) {
// Minimap2 with Fastqs input
if ( params.minimap2 ) {
// First check if barcoded or not, need to
barcodedFastq = file("${params.fastq_directory}/*{barcode,unclassified}*", type: 'dir', maxDepth: 1)
nonBarcodedFastq = file("${params.fastq_directory}/*.fastq*", type: 'file', maxDepth: 1)
if ( barcodedFastq ) {
Channel.fromPath( barcodedFastq )
.filter{ d ->
def count = 0
for (x in d.listFiles()) {
if (x.isFile()) {
count += 1
}
}
count > 0
}.set{ ch_fastq }
} else if ( nonBarcodedFastq ) {
Channel.fromPath( nonBarcodedFastq )
.set{ ch_fastq }
} else {
println('Unable to figure out input')
System.exit(1)
}
nanoporeMinimap2Dehosting(ch_fastq, ch_HumanReference, ch_CovidReference)
// Nanostripper with Fast5s input
} else {
// First check if barcoded
barcodedFast5 = file("${params.fast5_directory}/*{barcode,unclassified}*", type: 'dir', maxDepth: 1)
nonBarcodedFast5 = file("${params.fast5_directory}/*.fast5", type: 'file', maxDepth: 1)
// Use barcode to parallelize running if there are any
// Doesn't like softlinked directories, checks that we have files
// If not done, errors on blank barcoded directories
if ( barcodedFast5 ) {
Channel.fromPath( barcodedFast5 )
.filter{ d ->
def count = 0
for (x in d.listFiles()) {
if (x.isFile()) {
count += 1
}
}
count > 0
}.set{ ch_fast5 }
nanoporeNanostripperDehosting(ch_fast5, ch_HumanReference, ch_CovidReference)
} else if ( nonBarcodedFast5 ) {
println('Non Barcoded Fast5 files unavailable to dehost')
System.exit(1)
} else {
println('Unable to figure out input')
System.exit(1)
}
}
}
}