-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.nf
More file actions
executable file
·48 lines (39 loc) · 1.34 KB
/
main.nf
File metadata and controls
executable file
·48 lines (39 loc) · 1.34 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
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
// Import modules
include { DOWNLOAD } from './modules/download'
include { SAMPLE } from './modules/sample'
// Define input channel
ch_download_input = Channel
.fromPath(params.input)
.splitCsv()
.flatten()
.map { link ->
def fileName = link.tokenize('/')[-1] // Get the filename from the URL
def extension = fileName.endsWith('.tar.gz') ? 'tar.gz' : fileName.tokenize('.')[-1] // Get extension
def baseName = fileName.replaceFirst(/\.(tar\.gz|bam)$/, '') // Remove extension
[baseName, link, extension]
}
// Main workflow
workflow {
// Download NGS files
ngsFiles = DOWNLOAD( ch_download_input )
ngsFilesSamples = ngsFiles
.flatMap { id, file ->
if (file instanceof List) {
file.collect { [id, it] }
} else {
[[id, file]]
}
}
.map { id, file ->
def name = file.baseName.replaceFirst(/\..*$/, '') // Remove extension
def extension = file.name.endsWith('.fastq.gz') ? 'fastq.gz' : file.name.tokenize('.')[-1] // Get extension
tuple(name, file, extension)
}
// Sample NGS files
sampleFiles = SAMPLE( ngsFilesSamples )
}
workflow.onComplete {
println ( workflow.success ? "COMPLETED!" : "FAILED" )
}