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

Fix issue where tool and subtool have the same name #3156

Merged
merged 3 commits into from
Sep 5, 2024
Merged
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
13 changes: 8 additions & 5 deletions nf_core/components/nfcore_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,15 @@ def __init__(
self.process_name = ""
self.environment_yml: Optional[Path] = Path(self.component_dir, "environment.yml")

name_index = (
len(self.component_dir.parts)
- 1
- self.component_dir.parts[::-1].index(self.component_name.split("/")[0])
)
component_list = self.component_name.split("/")

name_index = len(self.component_dir.parts) - 1 - self.component_dir.parts[::-1].index(component_list[0])
if len(component_list) != 1 and component_list[0] == component_list[1]:
# Handle cases where the subtool has the same name as the tool
name_index -= 1

repo_dir = self.component_dir.parts[:name_index][-1]

self.org = repo_dir
self.nftest_testdir = Path(self.component_dir, "tests")
self.nftest_main_nf = Path(self.nftest_testdir, "main.nf.test")
Expand Down
9 changes: 9 additions & 0 deletions tests/modules/test_lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ def test_modules_lint_trimgalore(self):
assert len(module_lint.passed) > 0
assert len(module_lint.warned) >= 0

def test_modules_lint_tabix_tabix(self):
"""Test linting the tabix/tabix module"""
self.mods_install.install("tabix/tabix")
module_lint = nf_core.modules.lint.ModuleLint(directory=self.pipeline_dir)
module_lint.lint(print_results=False, module="tabix/tabix")
assert len(module_lint.failed) == 0, f"Linting failed with {[x.__dict__ for x in module_lint.failed]}"
assert len(module_lint.passed) > 0
assert len(module_lint.warned) >= 0

def test_modules_lint_empty(self):
"""Test linting a pipeline with no modules installed"""
self.mods_remove.remove("fastqc", force=True)
Expand Down
Loading