Skip to content

Commit c3d7118

Browse files
Tristan DennisTristan Dennis
authored andcommitted
make plink_params.py containing overwrite and output dir, fix type defs and docstring
1 parent 033fc8a commit c3d7118

3 files changed

Lines changed: 23 additions & 38 deletions

File tree

malariagen_data/anoph/base_params.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -308,18 +308,3 @@ def validate_sample_selection_params(
308308
to select SNPs to be included
309309
""",
310310
]
311-
312-
overwrite: TypeAlias = Annotated[
313-
bool,
314-
"""
315-
A boolean indicating whether a previously written file with the same name ought
316-
to be overwritten. Default is False.
317-
""",
318-
]
319-
320-
output_dir: TypeAlias = Annotated[
321-
str,
322-
"""
323-
A string indicating the desired output file location
324-
""",
325-
]
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
"""Parameters for Plink converter functions."""
2+
3+
from typing_extensions import Annotated, TypeAlias
4+
5+
overwrite: TypeAlias = Annotated[
6+
bool,
7+
"""
8+
A boolean indicating whether a previously written file with the same name ought
9+
to be overwritten. Default is False.
10+
""",
11+
]
12+
13+
output_dir: TypeAlias = Annotated[
14+
str,
15+
"""
16+
A string indicating the desired output file location
17+
""",
18+
]

malariagen_data/anoph/to_plink.py

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from ..util import dask_compress_dataset
99
from .snp_data import AnophelesSnpData
1010
from . import base_params
11+
from . import plink_params
1112
from . import pca_params
1213
from numpydoc_decorator import doc # type: ignore
1314

@@ -44,25 +45,13 @@ def __init__(
4445
set when instantiating the API client.
4546
""",
4647
)
47-
def _create_plink_outfile(
48-
self,
49-
*,
50-
output_dir,
51-
region,
52-
n_snps,
53-
min_minor_ac,
54-
thin_offset,
55-
max_missing_an,
56-
):
57-
return f"{output_dir}/{region}.{n_snps}.{min_minor_ac}.{max_missing_an}.{thin_offset}"
58-
5948
def biallelic_snps_to_plink(
6049
self,
61-
output_dir: base_params.output_dir,
50+
output_dir: plink_params.output_dir,
6251
region: base_params.regions,
6352
n_snps: base_params.n_snps,
53+
overwrite: plink_params.overwrite = False,
6454
thin_offset: base_params.thin_offset = 0,
65-
overwrite: base_params.overwrite = False,
6655
sample_sets: Optional[base_params.sample_sets] = None,
6756
sample_query: Optional[base_params.sample_query] = None,
6857
sample_indices: Optional[base_params.sample_indices] = None,
@@ -77,15 +66,8 @@ def biallelic_snps_to_plink(
7766
inline_array: base_params.inline_array = base_params.inline_array_default,
7867
chunks: base_params.chunks = base_params.native_chunks,
7968
):
80-
# Define output file
81-
plink_file_path = self._create_plink_outfile(
82-
output_dir=output_dir,
83-
region=region,
84-
n_snps=n_snps,
85-
thin_offset=thin_offset,
86-
min_minor_ac=min_minor_ac,
87-
max_missing_an=max_missing_an,
88-
)
69+
# Define output files
70+
plink_file_path = f"{output_dir}/{region}.{n_snps}.{min_minor_ac}.{max_missing_an}.{thin_offset}"
8971

9072
bed_file_path = f"{plink_file_path}.bed"
9173

0 commit comments

Comments
 (0)