-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.nf
158 lines (142 loc) · 5.76 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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/usr/bin/env nextflow
nextflow.enable.dsl=2
def helpMessage() {
log.info """
Usage:
The typical command for running the pipeline is as follows:
./nextflow run extractions.nf -c nextflow.config
Edit the nextflow.config file to add run parameters
""".stripIndent()
}
// Show help message
params.help = ""
if (params.help) {
helpMessage()
exit 0
}
// ////////////////////////////////////////////////////
// /* -- VALIDATE INPUTS -- */
// ////////////////////////////////////////////////////
def validations() {
try {
file(params.run_dir, checkIfExists: true)
} catch (e) {
println "\nRun directory not found. See reference in config or provide it at runtime via --run_dir.\n\nExiting\n"
exit 1
}
if (!(params.sample_sheets.isEmpty() || (params.sample_sheets instanceof Map && params.sample_sheets.every { k, v -> v instanceof String } ))) {
println "Parameter 'sample_sheets' is not a map of strings (or empty), please correct and rerun.\n\nExiting\n"
exit 1
}
}
validations()
// ////////////////////////////////////////////////////
// /* -- PROCESSES -- */
// ////////////////////////////////////////////////////
include { check_RTAComplete; bcl2fastq; xml_parse } from './modules/bcl2fastq/main.nf'
include { md5checksums } from './modules/md5sum/main.nf'
include { check_params; runtime_snapshot; mail_extraction_complete } from './modules/workflow_records/main.nf'
// include { verify_indices } from './modules/verify_indices/main.nf'
// ////////////////////////////////////////////////////
// /* -- WORKFLOW -- */
// ////////////////////////////////////////////////////
workflow extractions {
main:
// snapshot run params
runtime_snapshot(workflow.configFiles.toSet().last(), params.run_dir)
// Find samplesheets
if (params.sample_sheets.isEmpty()) {
Channel.fromPath("${params.run_dir}/*[Dd][Ee][Mm][Uu][Xx]*.csv", type: 'file')
.set{ sample_sheets }
println 'No sample sheets explicitly provided, using the following sheets found in the directory'
sample_sheets | view()
} else {
Channel.fromList(params.sample_sheets.keySet())
.set{ sample_sheets }
}
// print out params being used
check_params(params.run_dir, sample_sheets, params.barcode_mismatches) | view()
// Wait for RTA complete
check_RTAComplete()
// Run bcl2fastq
bcl2fastq(check_RTAComplete.out, params.run_dir, sample_sheets, params.barcode_mismatches)
// Parse output
xml_parse(bcl2fastq.out.label, bcl2fastq.out.output_dir)
if (params.emails?.trim()){
mail_extraction_complete(xml_parse.out.label, xml_parse.out.demux_file_path)
}
// compute md5sums in actual folder, don't rely on copied data being similar
if (params.compute_md5sums) {
md5checksums(bcl2fastq.out.label.collect())
}
emit:
bcl2fastq.out.output_dir
}
workflow {
if (params.delay_start.toFloat() > 0) {
println "Delaying worfklow by ${params.delay_start} hours"
Thread.sleep((params.delay_start.toFloat()*1000*3600).intValue())
}
println "Workflow start: $workflow.start"
extractions()
}
// workflow.onComplete {
// if (workflow.profile != 'dryrun') {
// if (params.emails?.trim()){
// def msg = """\
// Pipeline execution summary
// ---------------------------
// Completed at : ${workflow.complete}
// Duration : ${workflow.duration}
// Success : ${workflow.success}
// workDir : ${workflow.workDir}
// exit status : ${workflow.exitStatus}
// runDir : ${params.run_dir}
// NF runName : ${workflow.runName}
// """
// .stripIndent()
// sendMail(to: "${params.emails}", subject: 'Extraction Complete', body: msg)
// }
// }
// }
// ////////////////////////////////////////////////////
// /* -- IN DEVELOPMENT -- */
// ////////////////////////////////////////////////////
// process sync_bcl {
// //container = "amazon/aws-cli"
// //containerOptions = "-v $HOME/.aws/credentials"
// input:
// path run_dir
// output:
// stdout
// """
// aws --profile "tki-aws-account-65-rhedcloud/RHEDcloudAdministratorRole" \\
// s3 sync ${params.run_dir} s3://yerkes-gencore-archive/2022_runs/${params.run_name}/ \\
// --exclude "*.fastq.gz" --exclude "localcheck*.txt" --exclude "remotecheck*.txt" --exclude "md5-*-Data.txt" --exclude "md5-*-Fastq.txt" \\
// --no-follow-symlinks --only-show-errors --dryrun
// #aws --profile "tki-aws-account-65-rhedcloud/RHEDcloudAdministratorRole" \\
// # s3 ls --recursive s3://yerkes-gencore-fastq-archive/2022_runs/${params.run_name}/ | \\
// # gawk '{print \$3,\$4}' | sort | sed 's/2022_runs\///1' > remotecheckfastq-${params.run_name}-Fastq.txt
// """
// }
// process sync_fastq {
// input:
// path x
// val y
// output:
// stdout
// """
// aws --profile "tki-aws-account-65-rhedcloud/RHEDcloudAdministratorRole" \\
// s3 sync ${x} s3://yerkes-gencore-fastq-archive/2022_runs/${params.run_name}/ \\
// --exclude "*" --include "*.fastq.gz" \\
// --no-follow-symlinks --only-show-errors --dryrun
// """
// }
// process init_repo {
// conda 'conda-forge::gh'
// output:
// stdout
// """
// gh repo create yerkes-gencore/${params.project_name} --template yerkes-gencore/bulk_template --private
// """
// }