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