-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.nf
More file actions
executable file
·75 lines (61 loc) · 2.72 KB
/
main.nf
File metadata and controls
executable file
·75 lines (61 loc) · 2.72 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
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 -- mask regions for outbreak analysis
* Author: christian.jena@gmail.com
*/
/**************************
* WORKFLOWS
**************************/
include { get_fasta; get_fastq } from './modules/test_data.nf'
include { mask_regions_wf } from './workflows/mask_regions.nf'
include { identify_logo_wf } from './workflows/identify_logo.nf'
/* Custom functions and Messages */
include { exit_with_error } from './lib/functions.nf'
include { checkForWhitespace } from './lib/functions.nf'
include { helpMSG } from './lib/messages.nf'
include { defaultMSG } from './lib/messages.nf'
include { keepMSG } from './lib/messages.nf'
workflow {
/**************************
* Help messages & checks
**************************/
// help message
params.help ? { exit 0, helpMSG() }() : defaultMSG()
// error codes
if (!workflow.profile.contains('test') && ![params.fasta, params.fastq].any{it}) {
exit_with_error(6, "Input missing See also --help for more.")}
if (params.profile && !params.profile.startsWith('-')) {exit_with_error(1, "[--profile] is WRONG use [-profile].")}
if (!workflow.profile.contains('test') && ![params.fasta,params.fastq]) {exit_with_error(1, "Provide both --fasta and --fastq input files.")}
if ( workflow.profile == 'standard' ) {exit_with_error(1, "NO EXECUTION PROFILE SELECTED, using [-profile local,docker]")}
workflow.onError = {
println workflow.errorReport
}
/**************************
* INPUTs
**************************/
// nanopore reads (fastq)
fastq_input_ch = params.fastq ?
Channel.fromPath(params.fastq, checkIfExists: true)
.map { it -> tuple(it.simpleName, it) } :
Channel.empty()
checkForWhitespace('--fastq', params.fastq)
// nanopore assembly (fasta)
fasta_input_ch = params.fasta ?
Channel.fromPath(params.fasta, checkIfExists: true)
.map { it -> tuple(it.simpleName, it) } :
Channel.empty()
checkForWhitespace('--fasta', params.fasta)
/**************************
* WORKFLOW LOGIC
**************************/
// 0. Test data
fasta_test_ch = workflow.profile.contains('test') ? get_fasta() : Channel.empty()
fastq_test_ch = workflow.profile.contains('test') ? get_fastq() : Channel.empty()
// 1. Main Workflow
fastq_ch = fastq_input_ch.mix(fastq_test_ch)
fasta_ch = fasta_input_ch.mix(fasta_test_ch)
if (params.keep_coordinates) {keepMSG()}
mask_regions_wf(fastq_ch, fasta_ch)
identify_logo_wf(mask_regions_wf.out.chromosome_degen, mask_regions_wf.out.bam)
}