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

Add --empty-template flag for creating modules #2175

Merged
merged 17 commits into from
Feb 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

### Modules

- Add an `--empty-template` option to create a module without TODO statements or examples ([#2175](https://github.com/nf-core/tools/pull/2175))

### Subworkflows

### General
Expand Down
14 changes: 11 additions & 3 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -678,8 +678,16 @@ def remove(ctx, dir, tool):
@click.option("-f", "--force", is_flag=True, default=False, help="Overwrite any files if they already exist")
@click.option("-c", "--conda-name", type=str, default=None, help="Name of the conda package to use")
@click.option("-p", "--conda-package-version", type=str, default=None, help="Version of conda package to use")
@click.option("-i", "--minimal", is_flag=True, default=False, help="Create a minimal version of the template")
def create_module(ctx, tool, dir, author, label, meta, no_meta, force, conda_name, conda_package_version, minimal):
@click.option(
"-i",
"--empty-template",
is_flag=True,
default=False,
help="Create a version of the template without TODOs or examples",
mirpedrol marked this conversation as resolved.
Show resolved Hide resolved
)
def create_module(
ctx, tool, dir, author, label, meta, no_meta, force, conda_name, conda_package_version, empty_template
):
"""
Create a new DSL2 module from the nf-core template.

Expand All @@ -701,7 +709,7 @@ def create_module(ctx, tool, dir, author, label, meta, no_meta, force, conda_nam
# Run function
try:
module_create = nf_core.modules.ModuleCreate(
dir, tool, author, label, has_meta, force, conda_name, conda_package_version, minimal
dir, tool, author, label, has_meta, force, conda_name, conda_package_version, empty_template
)
module_create.create()
except UserWarning as e:
Expand Down
4 changes: 2 additions & 2 deletions nf_core/components/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def __init__(
force=False,
conda_name=None,
conda_version=None,
minimal=False,
empty_template=False,
):
super().__init__(component_type, directory)
self.directory = directory
Expand All @@ -57,7 +57,7 @@ def __init__(
self.singularity_container = None
self.docker_container = None
self.file_paths = {}
self.not_minimal = not minimal
self.not_empty_template = not empty_template

def create(self):
"""
Expand Down
14 changes: 7 additions & 7 deletions nf_core/module-template/modules/main.nf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{%- if not_minimal -%}
{%- if not_empty_template -%}
// TODO nf-core: If in doubt look at other nf-core/modules to see how we are doing things! :)
// https://github.com/nf-core/modules/tree/master/modules/nf-core/
// You can also ask for help via your pull request or on the #modules channel on the nf-core Slack workspace:
Expand All @@ -21,7 +21,7 @@ process {{ component_name_underscore|upper }} {
tag {{ '"$meta.id"' if has_meta else "'$bam'" }}
label '{{ process_label }}'

{% if not_minimal -%}
{% if not_empty_template -%}
// TODO nf-core: List required Conda package(s).
// Software MUST be pinned to channel (i.e. "bioconda"), version (i.e. "1.10").
// For Conda, the build (i.e. "h9402c20_2") must be EXCLUDED to support installation on different operating systems.
Expand All @@ -33,7 +33,7 @@ process {{ component_name_underscore|upper }} {
'{{ docker_container if docker_container else 'quay.io/biocontainers/YOUR-TOOL-HERE' }}' }"

input:
{% if not_minimal -%}
{% if not_empty_template -%}
// TODO nf-core: Where applicable all sample-specific information e.g. "id", "single_end", "read_group"
// MUST be provided as an input via a Groovy Map called "meta".
// This information may not be required in some instances e.g. indexing reference genome files:
Expand All @@ -46,13 +46,13 @@ process {{ component_name_underscore|upper }} {
{%- endif %}

output:
{% if not_minimal -%}
{% if not_empty_template -%}
// TODO nf-core: Named file extensions MUST be emitted for ALL output channels
{{ 'tuple val(meta), path("*.bam")' if has_meta else 'path "*.bam"' }}, emit: bam
{%- else -%}
{{ 'tuple val(meta), path("*")' if has_meta else 'path "*"' }}, emit: output
{%- endif %}
{% if not_minimal -%}
{% if not_empty_template -%}
// TODO nf-core: List additional required output channels/values here
{%- endif %}
path "versions.yml" , emit: versions
Expand All @@ -65,7 +65,7 @@ process {{ component_name_underscore|upper }} {
{% if has_meta -%}
def prefix = task.ext.prefix ?: "${meta.id}"
{%- endif %}
{% if not_minimal -%}
{% if not_empty_template -%}
// TODO nf-core: Where possible, a command MUST be provided to obtain the version number of the software e.g. 1.10
// If the software is unable to output a version number on the command-line then it can be manually specified
// e.g. https://github.com/nf-core/modules/blob/master/modules/nf-core/homer/annotatepeaks/main.nf
Expand All @@ -77,7 +77,7 @@ process {{ component_name_underscore|upper }} {
// TODO nf-core: Please indent the command appropriately (4 spaces!!) to help with readability ;)
{%- endif %}
"""
{% if not_minimal -%}
{% if not_empty_template -%}
samtools \\
sort \\
$args \\
Expand Down
24 changes: 12 additions & 12 deletions nf_core/module-template/modules/meta.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: "{{ component_name_underscore }}"
{% if not_minimal -%}
{% if not_empty_template -%}
## TODO nf-core: Add a description of the module and list keywords
{%- endif -%}
description: write your description here
keywords:
- sort
tools:
- "{{ component }}":
{% if not_minimal -%}
{% if not_empty_template -%}
## TODO nf-core: Add a description and other details for the software below
{% endif -%}
description: "{{ tool_description }}"
Expand All @@ -17,7 +17,7 @@ tools:
doi: ""
licence: "{{ tool_licence }}"

{% if not_minimal -%}
{% if not_empty_template -%}
## TODO nf-core: Add a description of all of the variables used as input
{% endif -%}
input:
Expand All @@ -28,15 +28,15 @@ input:
Groovy Map containing sample information
e.g. [ id:'test', single_end:false ]
{% endif %}
{% if not_minimal -%}
{% if not_empty_template -%}
## TODO nf-core: Delete / customise this example input
{%- endif %}
- {{ 'bam:' if not_minimal else "input:" }}
- {{ 'bam:' if not_empty_template else "input:" }}
type: file
description: {{ 'Sorted BAM/CRAM/SAM file' if not_minimal else "" }}
pattern: {{ '"*.{bam,cram,sam}"' if not_minimal else "" }}
description: {{ 'Sorted BAM/CRAM/SAM file' if not_empty_template else "" }}
pattern: {{ '"*.{bam,cram,sam}"' if not_empty_template else "" }}

{% if not_minimal -%}
{% if not_empty_template -%}
## TODO nf-core: Add a description of all of the variables used as output
{% endif -%}
output:
Expand All @@ -51,13 +51,13 @@ output:
type: file
description: File containing software versions
pattern: "versions.yml"
{% if not_minimal -%}
{% if not_empty_template -%}
## TODO nf-core: Delete / customise this example output
{%- endif %}
- {{ 'bam:' if not_minimal else "output:" }}
- {{ 'bam:' if not_empty_template else "output:" }}
type: file
description: {{ 'Sorted BAM/CRAM/SAM file' if not_minimal else "" }}
pattern: {{ '"*.{bam,cram,sam}"' if not_minimal else "" }}
description: {{ 'Sorted BAM/CRAM/SAM file' if not_empty_template else "" }}
pattern: {{ '"*.{bam,cram,sam}"' if not_empty_template else "" }}

authors:
- "{{ author }}"
4 changes: 2 additions & 2 deletions nf_core/module-template/tests/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{%- if not_minimal -%}
{%- if not_empty_template -%}
## TODO nf-core: Please run the following command to build this file:
# nf-core modules create-test-yml {{ tool }}{%- if subtool %}/{{ subtool }}{%- endif %}
{% endif -%}
Expand All @@ -8,7 +8,7 @@
- "{{ component }}{% if subtool -%}"
- "{{ component }}/{{ subtool }}{%- endif %}"
files:
{% if not_minimal -%}
{% if not_empty_template -%}
- path: "output/{{ component }}/test.bam"
md5sum: e667c7caad0bc4b7ac383fd023c654fc
- path: "output/{{ component }}/versions.yml"
Expand Down
4 changes: 2 additions & 2 deletions nf_core/modules/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(
force=False,
conda_name=None,
conda_version=None,
minimal=False,
empty_template=False,
):
super().__init__(
"modules",
Expand All @@ -28,5 +28,5 @@ def __init__(
force,
conda_name,
conda_version,
minimal,
empty_template,
)