forked from connor-lab/ncov2019-artic-nf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.nf
81 lines (65 loc) · 2.55 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
#!/usr/bin/env nextflow
// enable dsl2
nextflow.preview.dsl = 2
// import subworkflows
include {articNcovNanopore} from './workflows/articNcovNanopore.nf'
include {ncovIllumina} from './workflows/illuminaNcov.nf'
if ( params.illumina ) {
if (! params.directory ) {
println("Please supply a directory containing fastqs with --directory")
System.exit(1)
}
} else if ( params.medaka || params.nanopolish ) {
if (! params.basecalled_fastq ) {
println("Please supply a directory containing basecalled fastqs with --basecalled_fastq (this is the output directory from guppy_barcoder or guppy_basecaller)")
}
if (! params.fast5_pass ) {
println("Please supply a directory containing fast5 files with --fast5_pass (this is the fast5_pass directory)")
}
if (! params.sequencing_summary ) {
println("Please supply the path to the sequencing_summary.txt file from your run with --sequencing_summary")
System.exit(1)
}
} else {
println("Please select a workflow with --nanopolish, --illumina or --medaka")
System.exit(1)
}
if ( ! params.prefix ) {
println("Please supply a prefix for your output files with --prefix")
System.exit(1)
}
// main workflow
workflow {
if ( params.illumina ) {
Channel.fromFilePairs( params.fastqSearchPath, flat: true)
.set{ ch_filePairs }
}
else {
Channel.fromPath( "${params.basecalled_fastq}" )
.set{ ch_runDirectory }
Channel.fromPath( "${params.fast5_pass}" )
.set{ ch_fast5Pass }
Channel.fromPath( "${params.sequencing_summary}" )
.set{ ch_seqSummary }
// Check to see if we have barcodes
def nanoporeBarcodeDirs = new FileNameByRegexFinder().getFileNames(params.basecalled_fastq, /.*barcode\d\d$/)
if( nanoporeBarcodeDirs ) {
// Yes, barcodes!
Channel.fromPath( "${params.basecalled_fastq}/barcode*", type: 'dir', maxDepth: 1 )
.filter{ it.listFiles().size() > 5 }
.set{ ch_fastqDirs }
} else {
// No, no barcodes
Channel.fromPath( "${params.basecalled_fastq}", type: 'dir', maxDepth: 1 )
.set{ ch_fastqDirs }
}
}
main:
if ( params.nanopolish || params.medaka ) {
articNcovNanopore(ch_fastqDirs, ch_fast5Pass, ch_seqSummary)
} else if ( params.illumina ) {
ncovIllumina(ch_filePairs)
} else {
println("Please select a workflow with --nanopolish, --illumina or --medaka")
}
}