-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.nf
More file actions
162 lines (135 loc) · 6.21 KB
/
Copy pathmain.nf
File metadata and controls
162 lines (135 loc) · 6.21 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
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#!/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"
include { GET_AWS_USER_ID } from "./modules/aws"
include { BUILD_AWS_PANORAMA_SECRET } from "./modules/aws"
include { BUILD_AWS_LIMELIGHT_SECRET } from "./modules/aws"
// Sub workflows
include { wf_comet_combined_percolator } from "./workflows/comet_combined_percolator"
include { wf_comet_separate_percolator } from "./workflows/comet_separate_percolator"
// Parameter validation / summary against nextflow_schema.json
include { validateParameters; paramsSummaryLog } from 'plugin/nf-schema'
//
// The main workflow
//
workflow {
// Validate params against nextflow_schema.json, then log the resolved set.
// cast_cli_params:true coerces CLI string values (e.g. `--limelight_upload
// true`, `--limelight_project_id 1`) to their schema-declared types before
// validation on both the v1 (NF 25.10) and v2 (NF 26) parsers — without it
// the v1 default would reject the string "true" against a boolean.
validateParameters(cast_cli_params: true)
log.info paramsSummaryLog(workflow)
// Which API keys does this run actually need?
needs_panorama = params.fasta.startsWith("https://") ||
params.comet_params.startsWith("https://") ||
params.spectra_dir.contains("https://")
needs_limelight = Utils.asBool(params.limelight_upload)
on_aws = workflow.profile.tokenize(',').contains('aws')
// On AWS Batch the native `secret` directive isn't honored, so bridge the
// needed keys into AWS Secrets Manager (a local process reads the secret and
// stores it; Batch tasks fetch it back — see modules/aws.nf). Off AWS, this
// is skipped and 'none' flows through; the `secret` directive supplies the
// key directly. The secret-id channels gate the dependent processes too.
if( on_aws && (needs_panorama || needs_limelight) ) {
GET_AWS_USER_ID()
aws_user_id = GET_AWS_USER_ID.out.aws_user_id.first()
}
if( on_aws && needs_panorama ) {
BUILD_AWS_PANORAMA_SECRET(aws_user_id)
panorama_secret_id = BUILD_AWS_PANORAMA_SECRET.out.aws_secret_id.first()
} else {
panorama_secret_id = channel.value('none')
}
if( on_aws && needs_limelight ) {
BUILD_AWS_LIMELIGHT_SECRET(aws_user_id)
limelight_secret_id = BUILD_AWS_LIMELIGHT_SECRET.out.aws_secret_id.first()
} else {
limelight_secret_id = channel.value('none')
}
if(params.fasta.startsWith("https://")) {
PANORAMA_GET_FASTA(params.fasta, panorama_secret_id)
fasta = PANORAMA_GET_FASTA.out.panorama_file
} else {
fasta = file(params.fasta, checkIfExists: true)
}
if(params.comet_params.startsWith("https://")) {
PANORAMA_GET_COMET_PARAMS(params.comet_params, panorama_secret_id)
comet_params = PANORAMA_GET_COMET_PARAMS.out.panorama_file
} else {
comet_params = file(params.comet_params, checkIfExists: true)
}
if(params.spectra_dir.contains("https://")) {
spectra_dirs_ch = channel.from(params.spectra_dir)
.splitText() // split multiline input
.map{ line -> line.trim() } // removing surrounding whitespace
.filter{ line -> line.length() > 0 } // skip empty lines
// get raw files from panorama
PANORAMA_GET_RAW_FILE_LIST(spectra_dirs_ch, panorama_secret_id)
placeholder_ch = PANORAMA_GET_RAW_FILE_LIST.out.raw_file_placeholders.transpose()
PANORAMA_GET_RAW_FILE(placeholder_ch, panorama_secret_id)
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 = files("$spectra_dir/*.mzML")
// get our raw files
raw_files = files("$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;
}
}
// User-supplied (-c) config files to attach to the Limelight upload, so the
// exact run configuration is recorded with the search. Exclude the configs
// Nextflow auto-loads (the bundled nextflow.config, a launch-dir
// nextflow.config, and ~/.nextflow/config) — only files the user explicitly
// passed should be uploaded. The upload process sanitizes them (smtp
// credentials) before attaching.
auto_loaded_configs = [
file("${projectDir}/nextflow.config"),
file("${launchDir}/nextflow.config"),
file("${System.getProperty('user.home')}/.nextflow/config"),
].collect { cfg -> cfg.toAbsolutePath().normalize().toString() }
limelight_config_files = workflow.configFiles
.collect { cfg -> file(cfg) }
.findAll { cfg -> !(cfg.toAbsolutePath().normalize().toString() in auto_loaded_configs) }
if(Utils.asBool(params.process_separately)) {
wf_comet_separate_percolator(spectra_files_ch, comet_params, fasta, from_raw_files, limelight_secret_id, limelight_config_files)
} else {
wf_comet_combined_percolator(spectra_files_ch, comet_params, fasta, from_raw_files, limelight_secret_id, limelight_config_files)
}
workflow.onComplete {
try {
email()
} catch (Exception _e) {
println "Warning: Error sending completion email."
}
}
}
//
// 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
)
}
}