forked from nf-core/tools
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.py
169 lines (137 loc) · 7.83 KB
/
install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
import os
import pytest
from nf_core.modules.modules_json import ModulesJson
from nf_core.subworkflows.install import SubworkflowInstall
from ..utils import (
CROSS_ORGANIZATION_URL,
GITLAB_BRANCH_TEST_BRANCH,
GITLAB_DEFAULT_BRANCH,
GITLAB_REPO,
GITLAB_SUBWORKFLOWS_BRANCH,
GITLAB_SUBWORKFLOWS_ORG_PATH_BRANCH,
GITLAB_URL,
with_temporary_folder,
)
def test_subworkflow_install_nopipeline(self):
"""Test installing a subworkflow - no pipeline given"""
self.subworkflow_install.dir = None
assert self.subworkflow_install.install("foo") is False
@with_temporary_folder
def test_subworkflows_install_emptypipeline(self, tmpdir):
"""Test installing a subworkflow - empty dir given"""
os.mkdir(os.path.join(tmpdir, "nf-core-pipe"))
self.subworkflow_install.dir = os.path.join(tmpdir, "nf-core-pipe")
with pytest.raises(UserWarning) as excinfo:
self.subworkflow_install.install("foo")
assert "Could not find a 'main.nf' or 'nextflow.config' file" in str(excinfo.value)
def test_subworkflows_install_nosubworkflow(self):
"""Test installing a subworkflow - unrecognised subworkflow given"""
assert self.subworkflow_install.install("foo") is False
def test_subworkflows_install_bam_sort_stats_samtools(self):
"""Test installing a subworkflow - bam_sort_stats_samtools"""
assert self.subworkflow_install.install("bam_sort_stats_samtools") is not False
subworkflow_path = os.path.join(self.subworkflow_install.dir, "subworkflows", "nf-core", "bam_sort_stats_samtools")
sub_subworkflow_path = os.path.join(self.subworkflow_install.dir, "subworkflows", "nf-core", "bam_stats_samtools")
samtools_index_path = os.path.join(self.subworkflow_install.dir, "modules", "nf-core", "samtools", "index")
samtools_sort_path = os.path.join(self.subworkflow_install.dir, "modules", "nf-core", "samtools", "sort")
samtools_stats_path = os.path.join(self.subworkflow_install.dir, "modules", "nf-core", "samtools", "stats")
samtools_idxstats_path = os.path.join(self.subworkflow_install.dir, "modules", "nf-core", "samtools", "idxstats")
samtools_flagstat_path = os.path.join(self.subworkflow_install.dir, "modules", "nf-core", "samtools", "flagstat")
assert os.path.exists(subworkflow_path)
assert os.path.exists(sub_subworkflow_path)
assert os.path.exists(samtools_index_path)
assert os.path.exists(samtools_sort_path)
assert os.path.exists(samtools_stats_path)
assert os.path.exists(samtools_idxstats_path)
assert os.path.exists(samtools_flagstat_path)
def test_subworkflows_install_bam_sort_stats_samtools_twice(self):
"""Test installing a subworkflow - bam_sort_stats_samtools already there"""
self.subworkflow_install.install("bam_sort_stats_samtools")
assert self.subworkflow_install.install("bam_sort_stats_samtools") is False
def test_subworkflows_install_from_gitlab(self):
"""Test installing a subworkflow from GitLab"""
assert self.subworkflow_install_gitlab.install("bam_stats_samtools") is True
# Verify that the branch entry was added correctly
modules_json = ModulesJson(self.pipeline_dir)
assert (
modules_json.get_component_branch(self.component_type, "bam_stats_samtools", GITLAB_URL, GITLAB_REPO)
== GITLAB_SUBWORKFLOWS_BRANCH
)
def test_subworkflows_install_different_branch_fail(self):
"""Test installing a subworkflow from a different branch"""
install_obj = SubworkflowInstall(self.pipeline_dir, remote_url=GITLAB_URL, branch=GITLAB_BRANCH_TEST_BRANCH)
# The bam_stats_samtools subworkflow does not exists in the branch-test branch
assert install_obj.install("bam_stats_samtools") is False
def test_subworkflows_install_across_organizations(self):
"""Test installing a subworkflow with modules from different organizations"""
install_obj = SubworkflowInstall(self.pipeline_dir, remote_url=CROSS_ORGANIZATION_URL, branch=GITLAB_DEFAULT_BRANCH)
# The hic_bwamem2 subworkflow contains modules from different organizations
install_obj.install("get_genome_annotation")
# Verify that the installed_by entry was added correctly
modules_json = ModulesJson(self.pipeline_dir)
mod_json = modules_json.get_modules_json()
assert mod_json["repos"][CROSS_ORGANIZATION_URL]["modules"]["jvfe"]["wget"]["installed_by"] == [
"get_genome_annotation"
]
def test_subworkflows_install_tracking(self):
"""Test installing a subworkflow and finding the correct entries in installed_by section of modules.json"""
self.subworkflow_install.install("bam_sort_stats_samtools")
# Verify that the installed_by entry was added correctly
modules_json = ModulesJson(self.pipeline_dir)
mod_json = modules_json.get_modules_json()
assert mod_json["repos"]["https://github.com/nf-core/modules.git"]["subworkflows"]["nf-core"][
"bam_sort_stats_samtools"
]["installed_by"] == ["subworkflows"]
assert mod_json["repos"]["https://github.com/nf-core/modules.git"]["subworkflows"]["nf-core"]["bam_stats_samtools"][
"installed_by"
] == ["bam_sort_stats_samtools"]
assert mod_json["repos"]["https://github.com/nf-core/modules.git"]["modules"]["nf-core"]["samtools/stats"][
"installed_by"
] == ["bam_stats_samtools"]
assert mod_json["repos"]["https://github.com/nf-core/modules.git"]["modules"]["nf-core"]["samtools/sort"][
"installed_by"
] == ["bam_sort_stats_samtools"]
# Clean directory
self.subworkflow_remove.remove("bam_sort_stats_samtools")
def test_subworkflows_install_tracking_added_already_installed(self):
"""Test installing a subworkflow and finding the correct entries in installed_by section of modules.json"""
self.subworkflow_install.install("bam_sort_stats_samtools")
self.subworkflow_install.install("bam_stats_samtools")
# Verify that the installed_by entry was added correctly
modules_json = ModulesJson(self.pipeline_dir)
mod_json = modules_json.get_modules_json()
assert mod_json["repos"]["https://github.com/nf-core/modules.git"]["subworkflows"]["nf-core"][
"bam_sort_stats_samtools"
]["installed_by"] == ["subworkflows"]
assert sorted(
mod_json["repos"]["https://github.com/nf-core/modules.git"]["subworkflows"]["nf-core"]["bam_stats_samtools"][
"installed_by"
]
) == sorted(["bam_sort_stats_samtools", "subworkflows"])
# Clean directory
self.subworkflow_remove.remove("bam_sort_stats_samtools")
self.subworkflow_remove.remove("bam_stats_samtools")
def test_subworkflows_install_tracking_added_super_subworkflow(self):
"""Test installing a subworkflow and finding the correct entries in installed_by section of modules.json"""
self.subworkflow_install.install("bam_stats_samtools")
self.subworkflow_install.install("bam_sort_stats_samtools")
# Verify that the installed_by entry was added correctly
modules_json = ModulesJson(self.pipeline_dir)
mod_json = modules_json.get_modules_json()
assert mod_json["repos"]["https://github.com/nf-core/modules.git"]["subworkflows"]["nf-core"][
"bam_sort_stats_samtools"
]["installed_by"] == ["subworkflows"]
assert sorted(
mod_json["repos"]["https://github.com/nf-core/modules.git"]["subworkflows"]["nf-core"]["bam_stats_samtools"][
"installed_by"
]
) == sorted(["subworkflows", "bam_sort_stats_samtools"])
def test_subworkflows_install_alternate_remote(self):
"""Test installing a module from a different remote with the same organization path"""
install_obj = SubworkflowInstall(
self.pipeline_dir, remote_url=GITLAB_URL, branch=GITLAB_SUBWORKFLOWS_ORG_PATH_BRANCH
)
# Install a subworkflow from GitLab which is also installed from GitHub with the same org_path
with pytest.raises(Exception) as excinfo:
install_obj.install("fastqc")
assert "Could not find a 'main.nf' or 'nextflow.config' file" in str(excinfo.value)