-
Notifications
You must be signed in to change notification settings - Fork 9
/
main.nf
98 lines (80 loc) · 3.16 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
#!/usr/bin/env nextflow
/*
========================================================================================
fmalmeida/bacannot: A Generic Pipeline for Prokariotic Genome Annotation
========================================================================================
Github : https://github.com/fmalmeida/bacannot
----------------------------------------------------------------------------------------
*/
nextflow.enable.dsl = 2
import org.yaml.snakeyaml.Yaml
/*
========================================================================================
VALIDATE & PRINT PARAMETER SUMMARY
========================================================================================
*/
WorkflowMain.initialise(workflow, params, log)
/*
========================================================================================
NAMED WORKFLOWS FOR PIPELINE
========================================================================================
*/
include { PARSE_SAMPLESHEET } from './workflows/parse_samples.nf'
include { BACANNOT } from './workflows/bacannot.nf'
include { CREATE_DBS } from './workflows/bacannot_dbs.nf'
/*
========================================================================================
RUN ALL WORKFLOWS
========================================================================================
*/
workflow {
if (params.get_dbs || params.get_zenodo_db) {
CREATE_DBS()
} else {
if (params.input) {
// check if user gave path to bacannot databases
if (!params.bacannot_db) {
// Message to user
exit("""
ERROR!
A major error has occurred!
==> User forgot to set path to databases with --bacannot_db. Online documentation is available at: https://bacannot.readthedocs.io/en/latest/
Please, read the docs.
Cheers.
""")
} else {
bacannot_db = file(params.bacannot_db, checkIfExists: true)
}
// Load yaml
samplesheet_yaml = file(params.input, checkIfExists: true)
parameter_yaml = samplesheet_yaml.readLines().join("\n")
new Yaml().load(parameter_yaml).each { k, v -> params[k] = v }
// Copy YAML samplesheet to output directory so user has a copy of it
file(params.output).mkdir()
samplesheet_yaml.copyTo(params.output + "/" + "${samplesheet_yaml.getName()}")
// Parse YAML file
PARSE_SAMPLESHEET(params.samplesheet)
// Run annotation
BACANNOT(
PARSE_SAMPLESHEET.out,
bacannot_db,
(params.custom_db) ? Channel.fromPath( params.custom_db.split(',').collect{ it } ) : Channel.empty(),
(params.ncbi_proteins) ? Channel.fromPath( params.ncbi_proteins ) : Channel.empty()
)
} else {
// Message to user
println("""
ERROR!
A major error has occurred!
==> A samplesheet has not been provided. Please, provide a samplesheet to run the analysis. Online documentation is available at: https://bacannot.readthedocs.io/en/latest/
Please, read the docs.
Cheers.
""")
}
}
}
/*
========================================================================================
THE END
========================================================================================
*/