Skip to content

Commit 8e756bc

Browse files
Merge branch 'master' into GH1151-fix-roh-hmm-cache-name
2 parents 8276c57 + c66eb1a commit 8e756bc

9 files changed

Lines changed: 44 additions & 23 deletions

File tree

malariagen_data/adar1.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ def __init__(
130130
tqdm_class=tqdm_class,
131131
taxon_colors=TAXON_COLORS,
132132
virtual_contigs=None,
133-
gene_names=None,
134133
inversion_tag_path=None,
135134
unrestricted_use_only=unrestricted_use_only,
136135
surveillance_use_only=surveillance_use_only,

malariagen_data/adir1.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ def __init__(
130130
tqdm_class=tqdm_class,
131131
taxon_colors=TAXON_COLORS,
132132
virtual_contigs=None,
133-
gene_names=None,
134133
inversion_tag_path=None,
135134
unrestricted_use_only=unrestricted_use_only,
136135
surveillance_use_only=surveillance_use_only,

malariagen_data/af1.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ def __init__(
132132
tqdm_class=tqdm_class,
133133
taxon_colors=TAXON_COLORS,
134134
virtual_contigs=None,
135-
gene_names=None,
136135
inversion_tag_path=None,
137136
unrestricted_use_only=unrestricted_use_only,
138137
surveillance_use_only=surveillance_use_only,

malariagen_data/ag3.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,6 @@ def __init__(
212212
taxon_colors=TAXON_COLORS,
213213
aim_species_colors=AIM_SPECIES_COLORS,
214214
virtual_contigs=VIRTUAL_CONTIGS,
215-
gene_names=GENE_NAMES,
216215
inversion_tag_path=INVERSION_TAG_PATH,
217216
unrestricted_use_only=unrestricted_use_only,
218217
surveillance_use_only=surveillance_use_only,

malariagen_data/amin1.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ def __init__(
130130
tqdm_class=tqdm_class,
131131
taxon_colors=TAXON_COLORS,
132132
virtual_contigs=None,
133-
gene_names=None,
134133
inversion_tag_path=None,
135134
unrestricted_use_only=unrestricted_use_only,
136135
surveillance_use_only=surveillance_use_only,

malariagen_data/anoph/aim_data.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,24 @@ def __init__(
4040
# to the superclass constructor.
4141
super().__init__(**kwargs)
4242

43-
# Store possible values for the `aims` parameter.
44-
# TODO Consider moving this to data resource configuration.
45-
self._aim_ids = aim_ids
46-
self._aim_palettes = aim_palettes
43+
# Read AIM parameters from the JSON config, falling back to
44+
# constructor args for backward compatibility.
45+
config = self.config
46+
_aim_ids = config.get("AIM_IDS", None)
47+
if _aim_ids is not None:
48+
self._aim_ids: Optional[aim_params.aim_ids] = tuple(_aim_ids)
49+
else:
50+
self._aim_ids = aim_ids
51+
52+
_aim_palettes = config.get("AIM_PALETTES", None)
53+
if _aim_palettes is not None:
54+
# Convert lists to tuples for each palette entry.
55+
self._aim_palettes: Optional[aim_params.aim_palettes] = {
56+
k: tuple(v)
57+
for k, v in _aim_palettes.items() # type: ignore
58+
}
59+
else:
60+
self._aim_palettes = aim_palettes
4761

4862
# Set up caches.
4963
self._cache_aim_variants: Dict[str, xr.Dataset] = dict()

malariagen_data/anoph/genome_features.py

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class AnophelesGenomeFeaturesData(AnophelesGenomeSequenceData):
2323
def __init__(
2424
self,
2525
*,
26-
gff_gene_type: str,
27-
gff_gene_name_attribute: str,
28-
gff_default_attributes: Tuple[str, ...],
26+
gff_gene_type: Optional[str] = None,
27+
gff_gene_name_attribute: Optional[str] = None,
28+
gff_default_attributes: Optional[Tuple[str, ...]] = None,
2929
gene_names: Optional[Mapping[str, str]] = None,
3030
**kwargs,
3131
):
@@ -34,16 +34,30 @@ def __init__(
3434
# to the superclass constructor.
3535
super().__init__(**kwargs)
3636

37-
# TODO Consider moving these parameters to configuration, as they could
38-
# change if the GFF ever changed.
39-
self._gff_gene_type = gff_gene_type
40-
self._gff_gene_name_attribute = gff_gene_name_attribute
41-
self._gff_default_attributes = gff_default_attributes
37+
# Read GFF parameters from the JSON config, falling back to
38+
# constructor args for backward compatibility.
39+
config = self.config
40+
self._gff_gene_type = config.get("GFF_GENE_TYPE", gff_gene_type or "gene")
41+
self._gff_gene_name_attribute = config.get(
42+
"GFF_GENE_NAME_ATTRIBUTE", gff_gene_name_attribute or "Name"
43+
)
44+
_default_attrs = config.get("GFF_DEFAULT_ATTRIBUTES", None)
45+
if _default_attrs is not None:
46+
self._gff_default_attributes = tuple(_default_attrs)
47+
elif gff_default_attributes is not None:
48+
self._gff_default_attributes = gff_default_attributes
49+
else:
50+
self._gff_default_attributes = ("ID", "Parent", "Name", "description")
4251

4352
# Allow manual override of gene names.
44-
if gene_names is None:
45-
gene_names = dict()
46-
self._gene_name_overrides = gene_names
53+
# Read from config if available, falling back to constructor arg.
54+
_gene_names = config.get("GENE_NAMES", None)
55+
if _gene_names is not None:
56+
self._gene_name_overrides = _gene_names
57+
elif gene_names is not None:
58+
self._gene_name_overrides = gene_names
59+
else:
60+
self._gene_name_overrides = dict()
4761

4862
# Setup caches.
4963
self._cache_genome_features: Dict[Tuple[str, ...], pd.DataFrame] = dict()

malariagen_data/anopheles.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,6 @@ def __init__(
136136
taxon_colors: Optional[Mapping[str, str]] = None,
137137
aim_species_colors: Optional[Mapping[str, str]] = None,
138138
virtual_contigs: Optional[Mapping[str, Sequence[str]]] = None,
139-
gene_names: Optional[Mapping[str, str]] = None,
140139
inversion_tag_path: Optional[str] = None,
141140
unrestricted_use_only: Optional[bool] = None,
142141
surveillance_use_only: Optional[bool] = None,
@@ -174,7 +173,6 @@ def __init__(
174173
taxon_colors=taxon_colors,
175174
aim_species_colors=aim_species_colors,
176175
virtual_contigs=virtual_contigs,
177-
gene_names=gene_names,
178176
inversion_tag_path=inversion_tag_path,
179177
unrestricted_use_only=unrestricted_use_only,
180178
surveillance_use_only=surveillance_use_only,

malariagen_data/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ def _dask_compress_dataarray(a, indexer, indexer_computed, dim):
361361

362362

363363
def _da_compress(
364-
indexer: da.Array | np.ndarray,
364+
indexer: Union[da.Array, np.ndarray],
365365
data: da.Array,
366366
axis: int,
367367
indexer_computed: Optional[np.ndarray] = None,

0 commit comments

Comments
 (0)