-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.nf
141 lines (111 loc) · 3.41 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
include { EXFETCH } from './workflows/exfetch.nf'
help_message = """
E X F E T C H P I P E L I N E
===============================
exfetch retrieves exon-derived sequences (nucleotides or translated)
from a specified list of gene IDs.
Usage:
nextflow run main.nf --list <list> --fasta <fasta> --gff <gff>
nextflow run main.nf -params-file <yaml>
Required arguments:
--list <list> : A list of gene IDs to retrieve sequences for.
--fasta <fasta> : A reference FASTA file containing the genome sequence.
--gff <gff> : A GFF file containing the gene annotations.
Optional arguments:
--outdir <outdir> : Output directory (default: exfetch_out).
--translate : Translate the exons to amino acids.
--filter <filter> : Filter the GFF features to some specific type [default: ${params.filter}].
--version : Print the version number.
--help : Print this help message.
"""
init_summary = """
E X F E T C H P I P E L I N E
===============================
list : ${params.list}
fasta : ${params.fasta}
gff : ${params.gff}
outdir : ${params.outdir}
translate : ${params.translate}
filter : ${params.filter}
---
Run as : ${workflow.commandLine}
Started at : ${workflow.start}
Config files : ${workflow.configFiles}
--
"""
def validateParams() {
if (params.help) {
println help_message
System.exit(0)
}
if (params.version) {
println "${params.manifest.name} v${params.manifest.version}"
System.exit(0)
}
if (params.list == null || params.fasta == null || params.gff == null) {
println help_message
System.exit(1)
}
if (!file(params.list).exists()) {
println "Error: List file not found: ${params.list}"
System.exit(1)
}
if (!file(params.fasta).exists()) {
println "Error: FASTA file not found: ${params.fasta}"
System.exit(1)
}
if (!file(params.gff).exists()) {
println "Error: GFF file not found: ${params.gff}"
System.exit(1)
}
}
def completionMsg() {
if (workflow.success) {
if (workflow.stats.ignoredCount == 0) {
log.info "Pipeline completed successfully!"
}
else {
log.info "Pipeline completed successully, but with errored processes"
}
}
else {
log.error "Pipeline completed with errors"
}
}
workflow {
main:
// Validate input parameters
validateParams()
// Initialization Summary - Everything looks good so far
log.info init_summary
ch_versions = Channel.empty()
// WORKFLOW: After validation, main workflow is launched here
EXFETCH(
params.list,
params.fasta,
params.gff,
params.outdir,
params.translate,
params.filter,
ch_versions,
)
ch_versions = ch_versions.mix(EXFETCH.out.versions)
ch_report = EXFETCH.out.report
// Save versions of all tools used in the pipeline
ch_versions.collectFile(
storeDir: "${params.outdir}/pipeline_info/",
name: 'versions.yml',
sort: true,
newLine: true
)
// Save the final report
ch_report.collectFile(
storeDir: "${params.outdir}/",
name: 'report.txt',
newLine: true
)
// Display any error encountered during the workflow
workflow.onComplete {
completionMsg()
}
}