Skip to content

Commit 0843cf0

Browse files
authored
Merge branch 'master' into GH182_add_params_to_plot_frequencies_time_series
2 parents f956a1e + 21988d4 commit 0843cf0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

malariagen_data/anoph/base.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,14 +327,18 @@ def _discover_releases(self) -> Tuple[str, ...]:
327327
)
328328
# Note: this matches v3, v3. and v3.1, but not v3001.1
329329
version_pattern = re.compile(f"^v{self._major_version_number}(\\..*)?$")
330+
# To sort the versions numerically, we use a lambda function for the "key" parameter of sorted().
331+
# The lambda function splits each version string into a list of its integer parts, using split('.') and int(), e.g. [3, 1],
332+
# which sorted() then uses to determine the order, as opposed to the default lexicographic order.
330333
discovered_releases = tuple(
331334
sorted(
332335
[
333336
self._path_to_release(d)
334337
for d in sub_dirs
335338
if version_pattern.match(d)
336339
and self._fs.exists(f"{self._base_path}/{d}/manifest.tsv")
337-
]
340+
],
341+
key=lambda v: [int(part) for part in v.split(".")],
338342
)
339343
)
340344
return discovered_releases

malariagen_data/anopheles.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1183,6 +1183,11 @@ def _gene_cnv_frequencies(
11831183

11841184
freq_cols[f"frq_{coh}"] = np.concatenate([amp_freq_coh, del_freq_coh])
11851185

1186+
if len(coh_dict) == 0:
1187+
raise ValueError(
1188+
"No cohorts available for the given sample selection parameters and minimum cohort size."
1189+
)
1190+
11861191
debug("build a dataframe with the frequency columns")
11871192
df_freqs = pd.DataFrame(freq_cols)
11881193

0 commit comments

Comments
 (0)