2022-02-18 06:55:14 +00:00
|
|
|
//
|
|
|
|
// This file holds several functions specific to the main.nf workflow in the nf-core/taxprofiler 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" +
|
2023-03-13 11:13:17 +00:00
|
|
|
"* The pipeline\n" +
|
|
|
|
" https://doi.org/10.5281/zenodo.7728364\n\n" +
|
2022-11-24 14:51:12 +00:00
|
|
|
'* The nf-core framework\n' +
|
|
|
|
' https://doi.org/10.1038/s41587-020-0439-x\n\n' +
|
|
|
|
'* Software dependencies\n' +
|
2022-02-18 06:55:14 +00:00
|
|
|
" https://github.com/${workflow.manifest.name}/blob/master/CITATIONS.md"
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2022-12-08 13:18:23 +00:00
|
|
|
// Generate help string
|
2022-02-18 06:55:14 +00:00
|
|
|
//
|
|
|
|
public static String help(workflow, params, log) {
|
|
|
|
def command = "nextflow run ${workflow.manifest.name} --input samplesheet.csv --genome GRCh37 -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
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2022-12-08 13:18:23 +00:00
|
|
|
// Generate parameter summary log string
|
2022-02-18 06:55:14 +00:00
|
|
|
//
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2022-12-08 13:18:23 +00:00
|
|
|
// 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)
|
2022-02-18 06:55:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Print parameter summary log to screen
|
|
|
|
log.info paramsSummaryLog(workflow, params, log)
|
|
|
|
|
2022-12-08 13:18:23 +00:00
|
|
|
// Validate workflow parameters via the JSON schema
|
|
|
|
if (params.validate_params) {
|
|
|
|
NfcoreSchema.validateParameters(workflow, params, log)
|
|
|
|
}
|
|
|
|
|
2022-02-18 06:55:14 +00:00
|
|
|
// 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
|
2022-12-19 12:10:58 +00:00
|
|
|
if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) {
|
2022-02-18 06:55:14 +00:00
|
|
|
Utils.checkCondaChannels(log)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check AWS batch settings
|
|
|
|
NfcoreTemplate.awsBatch(workflow, params)
|
|
|
|
|
|
|
|
// Check input has been provided
|
|
|
|
if (!params.input) {
|
|
|
|
log.error "Please provide an input samplesheet to the pipeline e.g. '--input samplesheet.csv'"
|
|
|
|
System.exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Get attribute from genome config file e.g. fasta
|
|
|
|
//
|
2022-08-30 13:43:03 +00:00
|
|
|
public static Object getGenomeAttribute(params, attribute) {
|
2022-02-18 06:55:14 +00:00
|
|
|
if (params.genomes && params.genome && params.genomes.containsKey(params.genome)) {
|
|
|
|
if (params.genomes[ params.genome ].containsKey(attribute)) {
|
2022-08-30 13:43:03 +00:00
|
|
|
return params.genomes[ params.genome ][ attribute ]
|
2022-02-18 06:55:14 +00:00
|
|
|
}
|
|
|
|
}
|
2022-08-30 13:43:03 +00:00
|
|
|
return null
|
2022-02-18 06:55:14 +00:00
|
|
|
}
|
2022-11-24 14:51:12 +00:00
|
|
|
|
2022-02-18 06:55:14 +00:00
|
|
|
}
|