Skip to content

Commit 7aa3256

Browse files
authored
Merge branch 'master' into fix/issue-484-pydantic-validate-call
2 parents 2bb8c06 + 10b360b commit 7aa3256

26 files changed

+1456
-79
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.idea
22
.vscode
33
__pycache__
4+
.mypy_cache
45
*.pyc
56
dist
67
.venv/

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ To get setup for development, see [this video if you prefer VS Code](https://you
4949
For detailed setup instructions, see:
5050
- [Linux setup guide](LINUX_SETUP.md)
5151
- [macOS setup guide](MACOS_SETUP.md)
52+
- [Windows setup guide](WINDOWS_SETUP.md)
5253
- [Google Colab (TPU) setup guide](docs/source/colab_tpu_runtime.rst)
5354
Detailed instructions can be found in the [Contributors guide](https://github.com/malariagen/malariagen-data-python/blob/master/CONTRIBUTING.md).
5455

WINDOWS_SETUP.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Windows Setup Guide
2+
3+
To get setup for development on Windows, see
4+
[this video if you prefer VS Code](https://youtu.be/zddl3n1DCFM),
5+
or [this older video if you prefer PyCharm](https://youtu.be/QniQi-Hoo9A),
6+
and the instructions below.
7+
8+
## 1. Fork and clone this repo
9+
```bash
10+
git clone https://github.com/[username]/malariagen-data-python.git
11+
cd malariagen-data-python
12+
```
13+
14+
## 2. Install Python
15+
16+
Download and install Python 3.10 from the official website:
17+
https://www.python.org/downloads/windows/
18+
19+
During installation, check the box that says Add Python to PATH
20+
before clicking Install.
21+
22+
Verify the installation worked:
23+
```bash
24+
python --version
25+
```
26+
27+
## 3. Install pipx and poetry
28+
```bash
29+
python -m pip install --user pipx
30+
python -m pipx ensurepath
31+
pipx install poetry
32+
```
33+
34+
After running ensurepath, close and reopen PowerShell before continuing.
35+
36+
## 4. Create and activate development environment
37+
```bash
38+
poetry install
39+
poetry shell
40+
```
41+
42+
## 5. Install pre-commit hooks
43+
```bash
44+
pipx install pre-commit
45+
pre-commit install
46+
```
47+
48+
## 6. Add upstream remote and get latest code
49+
```bash
50+
git remote add upstream https://github.com/malariagen/malariagen-data-python
51+
git pull upstream master
52+
```
53+
54+
Note: On Windows the default branch is called master, not main.
55+
56+
## 7. Verify everything works
57+
```bash
58+
python -c "import malariagen_data; print('Setup successful!')"
59+
```
60+
61+
## Common Issues on Windows
62+
63+
**poetry not found after install**
64+
65+
Close and reopen PowerShell, then try again.
66+
67+
**git not recognized**
68+
69+
Install Git from https://git-scm.com/download/win
70+
and restart PowerShell.
71+
72+
**python not recognized**
73+
74+
Reinstall Python and make sure to check
75+
Add Python to PATH during installation.
76+
77+
**fatal: not a git repository**
78+
79+
Make sure you are inside the malariagen-data-python
80+
folder before running any git commands.
81+
```bash
82+
cd malariagen-data-python
83+
```
84+
85+
**error: pathspec main did not match**
86+
87+
On Windows use master instead of main.
88+
```bash
89+
git checkout master
90+
```

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/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/base_params.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,14 @@ def _validate_sample_selection_params(
189189
"Random seed used for reproducible down-sampling.",
190190
]
191191

192+
gene: TypeAlias = Annotated[
193+
str,
194+
"""
195+
Gene identifier. Can be either a gene ID or gene name.
196+
Gene names are matched case-insensitively.
197+
""",
198+
]
199+
192200
transcript: TypeAlias = Annotated[
193201
str,
194202
"Gene transcript identifier.",

malariagen_data/anoph/cnv_frq.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,11 @@ def _gene_cnv(
9090
inline_array,
9191
):
9292
# Sanity check.
93-
assert isinstance(region, Region)
93+
if not isinstance(region, Region):
94+
raise TypeError(
95+
f"Expected region to be a Region object, "
96+
f"got {type(region).__name__}: {region!r}"
97+
)
9498

9599
# Access genes within the region of interest.
96100
df_genome_features = self.genome_features(region=region)
@@ -260,7 +264,11 @@ def _gene_cnv_frequencies(
260264
debug = self._log.debug
261265

262266
debug("sanity check - this function is one region at a time")
263-
assert isinstance(region, Region)
267+
if not isinstance(region, Region):
268+
raise TypeError(
269+
f"Expected region to be a Region object, "
270+
f"got {type(region).__name__}: {region!r}"
271+
)
264272

265273
debug("get gene copy number data")
266274
ds_cnv = self.gene_cnv(
@@ -504,7 +512,11 @@ def _gene_cnv_frequencies_advanced(
504512
debug = self._log.debug
505513

506514
debug("sanity check - here we deal with one region only")
507-
assert isinstance(region, Region)
515+
if not isinstance(region, Region):
516+
raise TypeError(
517+
f"Expected region to be a Region object, "
518+
f"got {type(region).__name__}: {region!r}"
519+
)
508520

509521
debug("access gene CNV calls")
510522
ds_cnv = self.gene_cnv(

0 commit comments

Comments
 (0)