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

Conda name flag #989

Merged
merged 5 commits into from
Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from 2 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 @@ -6,6 +6,7 @@

* Strip values from `nf-core launch` web response which are False and have no default in the schema [[#976](https://github.com/nf-core/tools/issues/976)]
* Try to fix the fix for the automated sync when we submit too many PRs at once [[#970](https://github.com/nf-core/tools/issues/970)]
* Added `--conda-name` flag to `nf-core modules create` command to allow sidestepping questionary [[#988](https://github.com/nf-core/tools/issues/988)]

### Template

Expand Down
7 changes: 5 additions & 2 deletions nf_core/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,8 @@ def remove(ctx, pipeline_dir, tool):
@click.option("-m", "--meta", is_flag=True, default=False, help="Use Groovy meta map for sample information")
@click.option("-n", "--no-meta", is_flag=True, default=False, help="Don't use meta map for sample information")
@click.option("-f", "--force", is_flag=True, default=False, help="Overwrite any files if they already exist")
def create_module(ctx, directory, tool, author, label, meta, no_meta, force):
@click.option("-c", "--conda-name", type=str, default=None, help="Name of the conda package to use")
def create_module(ctx, directory, tool, author, label, meta, no_meta, force, conda_name):
"""
Create a new DSL2 module from the nf-core template.

Expand All @@ -465,7 +466,9 @@ def create_module(ctx, directory, tool, author, label, meta, no_meta, force):

# Run function
try:
module_create = nf_core.modules.ModuleCreate(directory, tool, author, label, has_meta, force)
module_create = nf_core.modules.ModuleCreate(
directory, tool, author, label, has_meta, force, conda_name=conda_name
KevinMenden marked this conversation as resolved.
Show resolved Hide resolved
)
module_create.create()
except UserWarning as e:
log.critical(e)
Expand Down
6 changes: 4 additions & 2 deletions nf_core/modules/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,17 @@


class ModuleCreate(object):
def __init__(self, directory=".", tool="", author=None, process_label=None, has_meta=None, force=False):
def __init__(
self, directory=".", tool="", author=None, process_label=None, has_meta=None, force=False, conda_name=None
):
self.directory = directory
self.tool = tool
self.author = author
self.process_label = process_label
self.has_meta = has_meta
self.force_overwrite = force

self.tool_conda_name = None
self.tool_conda_name = conda_name
self.subtool = None
self.tool_licence = None
self.repo_type = None
Expand Down
8 changes: 8 additions & 0 deletions tests/test_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ def test_modules_create_succeed(self):
module_create.create()
assert os.path.exists(os.path.join(self.pipeline_dir, "modules", "local", "fastqc.nf"))

def test_modules_create_different_conda_name(self):
KevinMenden marked this conversation as resolved.
Show resolved Hide resolved
""" Test creating a new module using a different conda package name """
module_create = nf_core.modules.ModuleCreate(
self.pipeline_dir, "trimgalore", "@author", "process_low", True, True, conda_name="trim-galore"
)
module_create.create()
assert os.path.exists(os.path.join(self.pipeline_dir, "modules", "local", "trimgalore.nf"))

def test_modules_create_fail_exists(self):
""" Fail at creating the same module twice"""
module_create = nf_core.modules.ModuleCreate(
Expand Down