Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Template: add option to exclude the workflows directory from pipeline template #3171

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
- add option to exclude tower.yml from pipeline template ([#3134](https://github.com/nf-core/tools/pull/3134))
- run nf-core lint `--release` on PRs to master ([#3148](https://github.com/nf-core/tools/pull/3148))
- Add tests to ensure all files are part of a template customisation group and all groups are tested ([#3099](https://github.com/nf-core/tools/pull/3099))
- add option to exclude the workflows directory from pipeline template ([#3170](https://github.com/nf-core/tools/pull/3170))

### Linting

Expand Down
91 changes: 89 additions & 2 deletions nf_core/pipeline-template/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,18 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*/

{%- if workflows_dir %}
include { {{ short_name|upper }} } from './workflows/{{ short_name }}'
{%- else %}
{%- if modules %}
{% if fastqc %}include { FASTQC } from './modules/nf-core/fastqc/main'{% endif %}
{% if multiqc %}include { MULTIQC } from './modules/nf-core/multiqc/main'{% endif %}
{% if nf_schema %}include { paramsSummaryMap } from 'plugin/nf-schema'{% endif %}
{% if multiqc %}include { paramsSummaryMultiqc } from './subworkflows/nf-core/utils_nfcore_pipeline'{% endif %}
include { softwareVersionsToYAML } from './subworkflows/nf-core/utils_nfcore_pipeline'
{% if citations or multiqc %}include { methodsDescriptionText } from './subworkflows/local/utils_nfcore_{{ short_name }}_pipeline'{% endif %}
{%- endif %}
{%- endif %}
{%- if modules %}
include { PIPELINE_INITIALISATION } from './subworkflows/local/utils_nfcore_{{ short_name }}_pipeline'
include { PIPELINE_COMPLETION } from './subworkflows/local/utils_nfcore_{{ short_name }}_pipeline'
Expand Down Expand Up @@ -49,17 +60,93 @@ workflow {{ prefix_nodash|upper }}_{{ short_name|upper }} {
take:
samplesheet // channel: samplesheet read in from --input

{% if workflows_dir %}
main:

//
// WORKFLOW: Run pipeline
//
{{ short_name|upper }} (
samplesheet
)
{% else %}
{%- if modules %}
main:
ch_versions = Channel.empty()
{% if multiqc %}ch_multiqc_files = Channel.empty(){% endif %}

{%- if fastqc %}
//
// MODULE: Run FastQC
//
FASTQC (
samplesheet
)
{% if multiqc %}ch_multiqc_files = ch_multiqc_files.mix(FASTQC.out.zip.collect{it[1]}){% endif %}
ch_versions = ch_versions.mix(FASTQC.out.versions.first())
{%- endif %}

//
// Collate and save software versions
//
softwareVersionsToYAML(ch_versions)
.collectFile(
storeDir: "${params.outdir}/pipeline_info",
name: {% if is_nfcore %}'nf_core_' {% else %} '' {% endif %} + 'pipeline_software_' + {% if multiqc %} 'mqc_' {% else %} '' {% endif %} + 'versions.yml',
sort: true,
newLine: true
).set { ch_collated_versions }

{% if multiqc %}
//
// MODULE: MultiQC
//
ch_multiqc_config = Channel.fromPath(
"$projectDir/assets/multiqc_config.yml", checkIfExists: true)
ch_multiqc_custom_config = params.multiqc_config ?
Channel.fromPath(params.multiqc_config, checkIfExists: true) :
Channel.empty()
ch_multiqc_logo = params.multiqc_logo ?
Channel.fromPath(params.multiqc_logo, checkIfExists: true) :
Channel.empty()

{% if nf_schema %}
summary_params = paramsSummaryMap(
workflow, parameters_schema: "nextflow_schema.json")
ch_workflow_summary = Channel.value(paramsSummaryMultiqc(summary_params))
ch_multiqc_files = ch_multiqc_files.mix(
ch_workflow_summary.collectFile(name: 'workflow_summary_mqc.yaml'))
{% endif %}

{%- if citations %}
ch_multiqc_custom_methods_description = params.multiqc_methods_description ?
file(params.multiqc_methods_description, checkIfExists: true) :
file("$projectDir/assets/methods_description_template.yml", checkIfExists: true)
ch_methods_description = Channel.value(
methodsDescriptionText(ch_multiqc_custom_methods_description))
{%- endif %}

ch_multiqc_files = ch_multiqc_files.mix(ch_collated_versions)
{%- if citations %}
ch_multiqc_files = ch_multiqc_files.mix(
ch_methods_description.collectFile(
name: 'methods_description_mqc.yaml',
sort: true
)
)
{%- endif %}

MULTIQC (
ch_multiqc_files.collect(),
ch_multiqc_config.toList(),
ch_multiqc_custom_config.toList(),
ch_multiqc_logo.toList()
)
{%- endif %}
{%- endif %}
{%- endif %}
{%- if multiqc %}{%- if modules %}
emit:
multiqc_report = {{ short_name|upper }}.out.multiqc_report // channel: /path/to/multiqc_report.html
multiqc_report = {% if workflows_dir %}{{ short_name|upper }}.out.multiqc_report{% else %}MULTIQC.out.report.toList(){% endif %} // channel: /path/to/multiqc_report.html
{%- endif %}{%- endif %}
}
/*
Expand Down
12 changes: 12 additions & 0 deletions nf_core/pipelines/create/template_features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,18 @@ modules:
- "modules.json"
nfcore_pipelines: False
custom_pipelines: True
workflows_dir:
skippable_paths:
- "workflows"
short_description: "Add workflows directory"
description: "Add a directory to store Nextflow workflows"
help_text: |
This will add a directory to store Nextflow workflows.
This is useful to keep the pipeline structure clean and organized.

The pipeline structure will have a `main.nf` file in the root directory. This will contain the main workflow and call the rest of the workflows in the `workflows` directory.
nfcore_pipelines: False
custom_pipelines: True
changelog:
skippable_paths:
- "CHANGELOG.md"
Expand Down
Loading