-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.nf
105 lines (84 loc) · 2.88 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
#!/usr/bin/env nextflow
nextflow.enable.dsl = 2
// modules
include { PANORAMA_GET_FASTA } from "./modules/panorama"
include { PANORAMA_GET_COMET_PARAMS } from "./modules/panorama"
include { PANORAMA_GET_RAW_FILE } from "./modules/panorama"
include { PANORAMA_GET_RAW_FILE_LIST } from "./modules/panorama"
// Sub workflows
include { wf_magnum_percolator } from "./workflows/magnum_percolator"
//
// The main workflow
//
workflow {
if(params.fasta.startsWith("https://")) {
PANORAMA_GET_FASTA(params.fasta)
fasta = PANORAMA_GET_FASTA.out.panorama_file
} else {
fasta = file(params.fasta, checkIfExists: true)
}
if(params.magnum_conf.startsWith("https://")) {
PANORAMA_GET_MAGNUM_CONF(params.magnum_conf)
magnum_conf = PANORAMA_GET_MAGNUM_CONF.out.panorama_file
} else {
magnum_conf = file(params.magnum_conf, checkIfExists: true)
}
if(params.spectra_dir.contains("https://")) {
spectra_dirs_ch = Channel.from(params.spectra_dir)
.splitText() // split multiline input
.map{ it.trim() } // removing surrounding whitespace
.filter{ it.length() > 0 } // skip empty lines
// get raw files from panorama
PANORAMA_GET_RAW_FILE_LIST(spectra_dirs_ch)
placeholder_ch = PANORAMA_GET_RAW_FILE_LIST.out.raw_file_placeholders.transpose()
PANORAMA_GET_RAW_FILE(placeholder_ch)
spectra_files_ch = PANORAMA_GET_RAW_FILE.out.panorama_file
from_raw_files = true;
} else {
spectra_dir = file(params.spectra_dir, checkIfExists: true)
// get our mzML files
mzml_files = file("$spectra_dir/*.mzML")
// get our raw files
raw_files = file("$spectra_dir/*.raw")
if(mzml_files.size() < 1 && raw_files.size() < 1) {
error "No raw or mzML files found in: $spectra_dir"
}
if(mzml_files.size() > 0) {
spectra_files_ch = Channel.fromList(mzml_files)
from_raw_files = false;
} else {
spectra_files_ch = Channel.fromList(raw_files)
from_raw_files = true;
}
}
wf_magnum_percolator(spectra_files_ch, magnum_conf, fasta, from_raw_files)
}
//
// Used for email notifications
//
def email() {
// Create the email text:
def (subject, msg) = EmailTemplate.email(workflow, params)
// Send the email:
if (params.email) {
sendMail(
to: "$params.email",
subject: subject,
body: msg
)
}
}
//
// This is a dummy workflow for testing
//
workflow dummy {
println "This is a workflow that doesn't do anything."
}
// Email notifications:
workflow.onComplete {
try {
email()
} catch (Exception e) {
println "Warning: Error sending completion email."
}
}