Skip to content

Commit ed16b06

Browse files
committed
Merge branch 'master' into GH407_allow_gene_labels
2 parents 3d4f7fc + 21988d4 commit ed16b06

2 files changed

Lines changed: 10 additions & 1 deletion

File tree

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
@@ -1191,6 +1191,11 @@ def _gene_cnv_frequencies(
11911191

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

1194+
if len(coh_dict) == 0:
1195+
raise ValueError(
1196+
"No cohorts available for the given sample selection parameters and minimum cohort size."
1197+
)
1198+
11941199
debug("build a dataframe with the frequency columns")
11951200
df_freqs = pd.DataFrame(freq_cols)
11961201

0 commit comments

Comments
 (0)