kkonganti@0: // kkonganti@0: // Start nanofactory workflow. Since this is a special kkonganti@0: // case workflow wherein most of the bioinformatics kkonganti@0: // tools are not used, there won't be any modules or kkonganti@0: // subworkflows and therefore all the processes kkonganti@0: // reside here. kkonganti@0: // kkonganti@0: kkonganti@0: // Include any necessary methods. kkonganti@0: include { addPadding; summaryOfParams; stopNow} \ kkonganti@0: from "${params.routines}" kkonganti@0: kkonganti@0: /* kkonganti@0: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ kkonganti@0: PROCESS DEFINITIONS FOR NANOFACTORY kkonganti@0: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ kkonganti@0: */ kkonganti@0: kkonganti@0: process SETPUBLISHDIR { kkonganti@0: label 'process_femto' kkonganti@0: module (params.enable_module ? params.enable_module : null) kkonganti@0: conda (params.enable_conda ? params.enable_conda : null) kkonganti@0: kkonganti@0: input: kkonganti@0: val options kkonganti@0: kkonganti@0: output: kkonganti@0: stdout kkonganti@0: kkonganti@0: shell: kkonganti@0: ''' kkonganti@0: project_setup.py -s !{options.sample_sheet} \ kkonganti@0: !{options.alt_settings} !{options.verbose} -b kkonganti@0: ''' kkonganti@0: } kkonganti@0: kkonganti@0: process PROJECTSETUP { kkonganti@0: label 'process_femto' kkonganti@0: publishDir "${publish_dir.trim()}", mode: 'copy', overwrite: false kkonganti@0: module (params.enable_module ? params.enable_module : null) kkonganti@0: conda (params.enable_conda ? params.enable_conda : null) kkonganti@0: kkonganti@0: input: kkonganti@0: val options kkonganti@0: val publish_dir kkonganti@0: kkonganti@0: output: kkonganti@0: stdout kkonganti@0: kkonganti@0: script: kkonganti@0: params.publish_dir = "${publish_dir.trim()}" kkonganti@0: kkonganti@0: shell: kkonganti@0: ''' kkonganti@0: project_setup.py -y -s !{options.sample_sheet} !{options.alt_settings} \ kkonganti@0: !{options.purge} !{options.runtype} !{options.logfile} \ kkonganti@0: !{options.loglevel} !{options.verbose} !{options.nocopy} \ kkonganti@0: !{options.fix_existing} kkonganti@0: kkonganti@0: cat < original_source.txt kkonganti@0: ''' kkonganti@0: } kkonganti@0: kkonganti@0: process TRIMDEMUX { kkonganti@0: label 'process_pico' kkonganti@0: module (params.enable_module ? params.enable_module : null) kkonganti@0: conda (params.enable_conda ? params.enable_conda : null) kkonganti@0: cpus "${params.guppy_threads}" kkonganti@0: kkonganti@0: input: kkonganti@0: val options kkonganti@0: val original_source kkonganti@0: kkonganti@0: output: kkonganti@0: path 'source.txt' kkonganti@0: kkonganti@0: shell: kkonganti@0: ''' kkonganti@0: trim_demux.py -s !{options.sample_sheet} !{options.verbose} \ kkonganti@0: !{options.alt_settings} !{options.guppy_config} -t !{options.guppy_threads} kkonganti@0: ''' kkonganti@0: } kkonganti@0: kkonganti@0: /* kkonganti@0: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ kkonganti@0: WORKFLOW ENTRY POINT kkonganti@0: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ kkonganti@0: */ kkonganti@0: kkonganti@0: workflow NANOFACTORY { kkonganti@0: kkonganti@0: if ( params.help ) { kkonganti@0: log.info help() kkonganti@0: } else if ( params.sample_sheet == null || kkonganti@0: params.sample_sheet.length() == 0 ) { kkonganti@0: kkonganti@0: log.info help() kkonganti@0: stopNow("Please provide absolute path to a JSON formatted sample sheet using the\n" + kkonganti@0: "--sample_sheet option.") kkonganti@0: } else { kkonganti@0: log.info summaryOfParams() kkonganti@0: kkonganti@0: options = Channel.empty() kkonganti@0: Channel kkonganti@0: .from(setOptions()) kkonganti@0: .set { options } kkonganti@0: kkonganti@0: take: kkonganti@0: options kkonganti@0: kkonganti@0: main: kkonganti@0: SETPUBLISHDIR(options) kkonganti@0: PROJECTSETUP(options, SETPUBLISHDIR.out) kkonganti@0: TRIMDEMUX(options, PROJECTSETUP.out) kkonganti@0: } kkonganti@0: } kkonganti@0: kkonganti@0: kkonganti@0: /* kkonganti@0: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ kkonganti@0: THE END kkonganti@0: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ kkonganti@0: */ kkonganti@0: kkonganti@0: kkonganti@0: /* kkonganti@0: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ kkonganti@0: HELPER METHODS FOR NANOFACTORY WORKFLOW kkonganti@0: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ kkonganti@0: */ kkonganti@0: kkonganti@0: def setOptions() { kkonganti@0: kkonganti@0: Map options = [:] kkonganti@0: kkonganti@0: options['sample_sheet'] ?= "${params.sample_sheet}" kkonganti@0: options['verbose'] = params.verbose ? "-v" : "" kkonganti@0: options['alt_settings'] = params.global_settings ? "-c ${params.global_settings}" : "" kkonganti@0: options['purge'] = params.setup_purge_existing ? "-p" : "" kkonganti@0: options['logfile'] = params.log_file ? "-l ${params.log_file}" : "" kkonganti@0: options['loglevel'] = params.log_level ? "--loglevel ${params.log_level}" : "" kkonganti@0: options['nocopy'] = params.setup_nocopy ? "--nocopy" : "" kkonganti@0: options['runtype'] = params.setup_runtype ? "-r ${params.setup_runtype}" : "" kkonganti@0: options['fix_existing'] = params.setup_fix_existing ? "-f" : "" kkonganti@0: options['guppy_config'] = params.guppy_config ? " -g ${params.guppy_config}" : "" kkonganti@0: options['mode'] = params.mode ? "-m ${params.mode}" : "-m prod" kkonganti@0: options['mail_group'] = params.mail_group ? "-g ${params.mail_group}" : "-g stakeholders" kkonganti@0: options['guppy_threads'] = params.guppy_threads ? "${params.guppy_threads}" : 1 kkonganti@0: options['pad'] = pad.toInteger() kkonganti@0: options['nocapitalize'] = true kkonganti@0: kkonganti@0: return options kkonganti@0: } kkonganti@0: kkonganti@0: def help() { kkonganti@0: kkonganti@0: Map helptext = [:] kkonganti@0: kkonganti@0: helptext['help'] = true kkonganti@0: helptext['nocapitalize'] = true kkonganti@0: helptext['Workflow'] = "${params.pipeline}" kkonganti@0: helptext['Author'] = "${params.workflow_author}" kkonganti@0: helptext['Version'] = "${params.workflow_version}\n" kkonganti@0: helptext['Usage'] = "cpipes --pipeline nanofactory [options]\n" kkonganti@0: helptext['Required'] = "" kkonganti@0: helptext['--sample_sheet'] = "The JSON-formatted sample sheet for this run. Normally provided by Pore Refiner.\n" kkonganti@0: helptext['Other options'] = "" kkonganti@0: helptext['--global_settings'] = "An alternate global settings file. If not present the installed default will be used." kkonganti@0: helptext['--log_file'] = "Path and file name to a log file relative to the project directory (Default: 'logs/workflow.log')" kkonganti@0: helptext['--log_level'] = "One of 'debug', 'info', 'warning', 'error', 'fatal' (Default: 'info')" kkonganti@0: helptext['--mode'] = "Set the run mode. One of 'dev', 'test', 'stage', or 'prod' (Default: 'prod')" kkonganti@0: helptext['--verbose'] = "Use to enable more verbose console output from each tool\n" kkonganti@0: helptext['Project setup options'] = "" kkonganti@0: helptext['--disable_project_setup'] = "Do not do project setup (Default: setup is enabled)" kkonganti@0: helptext['--setup_purge_existing'] = "Before setting up the project area delete any existing files (Default: don't purge)" kkonganti@0: helptext['--setup_nocopy'] = "During setup, do NOT copy the original data files to the scrach location (Default: copy)" kkonganti@0: helptext['--setup_runtype'] = "Set things up for the indicated run type (Currently not used)" kkonganti@0: helptext['--setup_runtype'] = "Set things up for the indicated run type (Currently not used)" kkonganti@0: helptext['--enable_module'] = "Software environment module. Ex: --enable_module 'nanofactory/current'" kkonganti@0: helptext['--enable_conda'] = "CONDA environment module. Ex: --enable_conda nanofactory\n" kkonganti@0: helptext['Help options'] = "" kkonganti@0: helptext['--help'] = "Display this message.\n" kkonganti@0: kkonganti@0: return addPadding(helptext) kkonganti@0: }