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