Skip to content

Commit 48d1097

Browse files
Add constructor and annotate parameters
1 parent c662806 commit 48d1097

2 files changed

Lines changed: 52 additions & 8 deletions

File tree

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1-
"""
2-
Type aliases for phenotype-related parameters.
3-
"""
4-
from typing import TypeAlias, Optional, Union, List
1+
from typing import TypeAlias, Optional, Union, List, Annotated
52

63
# Type alias for insecticide parameter
7-
insecticide: TypeAlias = Optional[Union[str, List[str]]]
4+
insecticide: TypeAlias = Annotated[
5+
Optional[Union[str, List[str]]],
6+
"Insecticide name(s) to filter by. Can be a single insecticide name or a list of names.",
7+
]
88

99
# Type alias for dose parameter
10-
dose: TypeAlias = Optional[Union[float, List[float]]]
10+
dose: TypeAlias = Annotated[
11+
Optional[Union[float, List[float]]],
12+
"Insecticide dose(s) to filter by. Can be a single dose value or a list of dose values.",
13+
]
1114

1215
# Type alias for phenotype parameter
13-
phenotype: TypeAlias = Optional[Union[str, List[str]]]
16+
phenotype: TypeAlias = Annotated[
17+
Optional[Union[str, List[str]]],
18+
"Phenotype outcome(s) to filter by. Can be a single phenotype value (e.g., 'alive', 'dead') or a list of values.",
19+
]

malariagen_data/anoph/phenotypes.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Callable, Optional, List, Any
44
import warnings
55
import fsspec
6-
from . import base_params, phenotype_params
6+
from malariagen_data.anoph import base_params, phenotype_params
77

88

99
class AnophelesPhenotypeData:
@@ -21,6 +21,44 @@ class AnophelesPhenotypeData:
2121
_prep_sample_sets_param: Callable[..., Any]
2222
haplotypes: Callable[..., Any]
2323

24+
def __init__(
25+
self,
26+
url: str,
27+
fs: fsspec.AbstractFileSystem,
28+
sample_metadata: Callable[..., pd.DataFrame],
29+
sample_sets: list[str],
30+
snp_calls: Callable[..., Any],
31+
prep_sample_sets_param: Callable[..., Any],
32+
haplotypes: Callable[..., Any],
33+
):
34+
"""
35+
Initialize the AnophelesPhenotypeData class.
36+
37+
Parameters
38+
----------
39+
url : str
40+
Base URL for accessing phenotype data.
41+
fs : fsspec.AbstractFileSystem
42+
File system interface for accessing remote data.
43+
sample_metadata : callable
44+
Function to retrieve sample metadata.
45+
sample_sets : list of str
46+
List of available sample sets.
47+
snp_calls : callable
48+
Function to retrieve SNP calls.
49+
prep_sample_sets_param : callable
50+
Function to prepare sample sets parameter.
51+
haplotypes : callable
52+
Function to retrieve haplotype data.
53+
"""
54+
self._url = url
55+
self._fs = fs
56+
self.sample_metadata = sample_metadata
57+
self.sample_sets = sample_sets
58+
self.snp_calls = snp_calls
59+
self._prep_sample_sets_param = prep_sample_sets_param
60+
self.haplotypes = haplotypes
61+
2462
def _load_phenotype_data(
2563
self,
2664
sample_sets: base_params.sample_sets,

0 commit comments

Comments
 (0)