-
Notifications
You must be signed in to change notification settings - Fork 136
Expand file tree
/
Copy pathtest_bioconductor_skeleton.py
More file actions
251 lines (208 loc) · 8.58 KB
/
Copy pathtest_bioconductor_skeleton.py
File metadata and controls
251 lines (208 loc) · 8.58 KB
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
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
import pytest
from bioconda_utils import bioconductor_skeleton
from bioconda_utils import cran_skeleton
from bioconda_utils import utils
config = {"channels": ["conda-forge", "bioconda"]}
def test_cran_write_recipe(tmpdir):
cran_skeleton.write_recipe("locfit", recipe_dir=str(tmpdir), recursive=False)
assert tmpdir.join("r-locfit", "meta.yaml").exists()
assert tmpdir.join("r-locfit", "build.sh").exists()
assert tmpdir.join("r-locfit", "bld.bat").exists()
def test_cran_write_recipe_no_windows(tmpdir):
cran_skeleton.write_recipe(
"locfit", recipe_dir=str(tmpdir), recursive=False, no_windows=True
)
assert tmpdir.join("r-locfit", "meta.yaml").exists()
assert tmpdir.join("r-locfit", "build.sh").exists()
assert not tmpdir.join("r-locfit", "bld.bat").exists()
for line in tmpdir.join("r-locfit", "meta.yaml").readlines():
if "skip: True" in line:
assert "[win]" in line
@pytest.fixture(scope="module")
def bioc_fetch():
release = bioconductor_skeleton.latest_bioconductor_release_version()
return bioconductor_skeleton.fetchPackages(release)
@pytest.mark.skip(reason="Does not work since new bioconductor release?")
def test_bioc_write_recipe_skip_in_condaforge(tmpdir, bioc_fetch):
bioconductor_skeleton.write_recipe(
"edgeR",
recipe_dir=str(tmpdir),
config=config,
recursive=True,
packages=bioc_fetch,
skip_if_in_channels=["conda-forge"],
)
for pkg in [
"bioconductor-edger",
"bioconductor-limma",
]:
assert tmpdir.join(pkg).exists()
for pkg in ["r-cpp", "r-lattice", "r-locfit"]:
assert not tmpdir.join(pkg).exists()
@pytest.mark.skip(reason="Does not work since new bioconductor release?")
def test_bioc_write_recipe_no_skipping(tmpdir, bioc_fetch):
bioconductor_skeleton.write_recipe(
"edgeR",
recipe_dir=str(tmpdir),
config=config,
recursive=True,
packages=bioc_fetch,
skip_if_in_channels=None,
)
for pkg in [
"bioconductor-edger",
"bioconductor-limma",
"r-rcpp",
# sometime locfit and lattice don't build correctly, but we should
# eventually ensure they are here as well.
# 'r-locfit',
# 'r-lattice',
]:
assert tmpdir.join(pkg).exists()
@pytest.mark.skip(reason="Does not work since new bioconductor release?")
def test_meta_contents(tmpdir, bioc_fetch):
config = {"channels": ["conda-forge", "bioconda"]}
bioconductor_skeleton.write_recipe(
"edgeR",
recipe_dir=str(tmpdir),
config=config,
recursive=False,
packages=bioc_fetch,
)
edger_meta = utils.load_first_metadata(str(tmpdir.join("bioconductor-edger"))).meta
assert "r-rcpp" in edger_meta["requirements"]["run"]
# The rendered meta has {{ compiler('c') }} filled in, so we need to check
# for one of those filled-in values.
names = [i.split()[0] for i in edger_meta["requirements"]["build"]]
assert (
"libstdcxx-ng" in names or "clang_osx-64" in names or "clang_osx-arm64" in names
)
# bioconductor, bioarchive, and cargoport
assert len(edger_meta["source"]["url"]) == 3
@pytest.mark.skip(
reason="Does not currently work inside of the CI (cannot find the release) although it seems to work fine locally."
)
def test_find_best_bioc_version():
assert bioconductor_skeleton.find_best_bioc_version("DESeq2", "1.40.1") == "3.17"
# Non-existent version:
with pytest.raises(bioconductor_skeleton.PackageNotFoundError):
bioconductor_skeleton.find_best_bioc_version("DESeq2", "5000")
# Version existed at some point in the past, but only exists now on
# bioaRchive:
with pytest.raises(bioconductor_skeleton.PackageNotFoundError):
bioconductor_skeleton.BioCProjectPage("BioBase", pkg_version="2.37.2")
def test_pkg_version():
# version specified, but not bioc version
b = bioconductor_skeleton.BioCProjectPage("DESeq2", pkg_version="1.14.1")
assert b.version == "1.14.1"
assert b.bioc_version == "3.4"
assert b.bioconductor_tarball_url == (
"https://bioconductor.org/packages/3.4/bioc/src/contrib/DESeq2_1.14.1.tar.gz"
)
assert b.bioarchive_url is None
assert b.cargoport_url == (
"https://depot.galaxyproject.org/software/bioconductor-deseq2/bioconductor-deseq2_1.14.1_src_all.tar.gz"
) # noqa: E501
# bioc version specified, but not package version
b = bioconductor_skeleton.BioCProjectPage("edgeR", bioc_version="3.5")
assert b.version == "3.18.1"
assert b.bioc_version == "3.5"
assert b.bioconductor_tarball_url == (
"https://bioconductor.org/packages/3.5/bioc/src/contrib/edgeR_3.18.1.tar.gz"
)
assert b.bioarchive_url is None
assert b.cargoport_url == (
"https://depot.galaxyproject.org/software/bioconductor-edger/bioconductor-edger_3.18.1_src_all.tar.gz"
) # noqa: E501
def test_bioarchive_exists_but_not_bioconductor():
"""
BioCProjectPage init tries to find the package on the bioconductor site.
Sometimes bioaRchive has cached the tarball but it no longer exists on the
bioconductor site. In those cases, we're raising a PackageNotFoundError.
It's possible to build a recipe based on a package only found in
bioarchive, but I'm not sure we want to support that in an automated
fashion. In those cases it would be best to build the recipe manually.
"""
with pytest.raises(bioconductor_skeleton.PackageNotFoundError):
bioconductor_skeleton.BioCProjectPage("BioBase", pkg_version="2.37.2")
def test_bioarchive_exists():
# package found on both bioconductor and bioarchive.
b = bioconductor_skeleton.BioCProjectPage("DESeq", pkg_version="1.26.0")
assert (
b.bioarchive_url == "https://bioarchive.galaxyproject.org/DESeq_1.26.0.tar.gz"
)
def test_annotation_data(tmpdir, bioc_fetch):
bioconductor_skeleton.write_recipe(
"AHCytoBands", str(tmpdir), config, recursive=False, packages=bioc_fetch
)
meta = utils.load_first_metadata(
str(tmpdir.join("bioconductor-ahcytobands")), finalize=False
).meta
assert "curl" in {dep.split()[0] for dep in meta["requirements"]["run"]}
assert len(meta["source"]["url"]) == 4
assert not tmpdir.join("bioconductor-ahcytobands", "build.sh").exists()
assert tmpdir.join("bioconductor-ahcytobands", "post-link.sh").exists()
assert tmpdir.join("bioconductor-ahcytobands", "pre-unlink.sh").exists()
def test_experiment_data(tmpdir, bioc_fetch):
bioconductor_skeleton.write_recipe(
"Affyhgu133A2Expr",
str(tmpdir),
config,
recursive=False,
packages=bioc_fetch,
)
meta = utils.load_first_metadata(
str(tmpdir.join("bioconductor-affyhgu133a2expr")), finalize=False
).meta
assert "curl" in {dep.split()[0] for dep in meta["requirements"]["run"]}
assert len(meta["source"]["url"]) == 4
assert not tmpdir.join("bioconductor-affyhgu133a2expr", "build.sh").exists()
assert tmpdir.join("bioconductor-affyhgu133a2expr", "post-link.sh").exists()
assert tmpdir.join("bioconductor-affyhgu133a2expr", "pre-unlink.sh").exists()
def test_nonexistent_pkg(tmpdir, bioc_fetch):
# no such package exists in the current bioconductor
with pytest.raises(bioconductor_skeleton.PackageNotFoundError):
bioconductor_skeleton.write_recipe(
"nonexistent",
str(tmpdir),
config,
recursive=True,
packages=bioc_fetch,
)
# package exists, but not this version
with pytest.raises(bioconductor_skeleton.PackageNotFoundError):
bioconductor_skeleton.write_recipe(
"DESeq",
str(tmpdir),
config,
recursive=True,
pkg_version="5000",
packages=bioc_fetch,
)
@pytest.mark.skip(reason="Does not work since new bioconductor release?")
def test_overwrite(tmpdir, bioc_fetch):
bioconductor_skeleton.write_recipe(
"edgeR",
recipe_dir=str(tmpdir),
config=config,
recursive=False,
packages=bioc_fetch,
)
# Same thing with force=False returns ValueError
with pytest.raises(ValueError):
bioconductor_skeleton.write_recipe(
"edgeR",
recipe_dir=str(tmpdir),
config=config,
recursive=False,
packages=bioc_fetch,
)
# But same thing with force=True is OK
bioconductor_skeleton.write_recipe(
"edgeR",
recipe_dir=str(tmpdir),
config=config,
recursive=False,
force=True,
packages=bioc_fetch,
)