-
Notifications
You must be signed in to change notification settings - Fork 417
/
WorkflowMain.groovy
executable file
·99 lines (87 loc) · 3.63 KB
/
WorkflowMain.groovy
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
//
// This file holds several functions specific to the main.nf workflow in the nf-core/sarek pipeline
//
class WorkflowMain {
//
// Citation string for pipeline
//
public static String citation(workflow) {
return "If you use ${workflow.manifest.name} for your analysis please cite:\n\n" +
"* The pipeline\n" +
" https://doi.org/10.12688/f1000research.16665.2\n" +
" https://doi.org/10.5281/zenodo.4468605\n\n" +
"* The nf-core framework\n" +
" https://doi.org/10.1038/s41587-020-0439-x\n\n" +
"* Software dependencies\n" +
" https://github.com/${workflow.manifest.name}/blob/master/CITATIONS.md"
}
//
// Generate help string
//
public static String help(workflow, params, log) {
def command = "nextflow run ${workflow.manifest.name} --input samplesheet.tsv --genome GRCh38 -profile docker"
def help_string = ''
help_string += NfcoreTemplate.logo(workflow, params.monochrome_logs)
help_string += NfcoreSchema.paramsHelp(workflow, params, command)
help_string += '\n' + citation(workflow) + '\n'
help_string += NfcoreTemplate.dashedLine(params.monochrome_logs)
return help_string
}
//
// Generate parameter summary log string
//
public static String paramsSummaryLog(workflow, params, log) {
def summary_log = ''
summary_log += NfcoreTemplate.logo(workflow, params.monochrome_logs)
summary_log += NfcoreSchema.paramsSummaryLog(workflow, params)
summary_log += '\n' + citation(workflow) + '\n'
summary_log += NfcoreTemplate.dashedLine(params.monochrome_logs)
return summary_log
}
//
// Validate parameters and print summary to screen
//
public static void initialise(workflow, params, log) {
// Print help to screen if required
if (params.help) {
log.info help(workflow, params, log)
System.exit(0)
}
// Print workflow version and exit on --version
if (params.version) {
String workflow_version = NfcoreTemplate.version(workflow)
log.info "${workflow.manifest.name} ${workflow_version}"
System.exit(0)
}
// Print parameter summary log to screen
log.info paramsSummaryLog(workflow, params, log)
// Validate workflow parameters via the JSON schema
if (params.validate_params) {
NfcoreSchema.validateParameters(workflow, params, log)
}
// Check that a -profile or Nextflow config has been provided to run the pipeline
NfcoreTemplate.checkConfigProvided(workflow, log)
// Check that conda channels are set-up correctly
if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) {
Utils.checkCondaChannels(log)
}
// Check AWS batch settings
NfcoreTemplate.awsBatch(workflow, params)
// Check input has been provided
if (!params.input && !params.build_only_index) {
log.warn "No samplesheet specified, attempting to restart from csv files present in ${params.outdir}"
WorkflowSarek.retrieveInput(params, log)
}
}
//
// Get attribute from genome config file e.g. fasta
//
public static Object getGenomeAttribute(params, attribute) {
if (params.genomes && params.genome && params.genomes.containsKey(params.genome)) {
if (params.genomes[ params.genome ].containsKey(attribute)) {
return params.genomes[ params.genome ][ attribute ]
}
}
return null
}
}