|
14 | 14 | compressor=None, |
15 | 15 | worker_processes=1, |
16 | 16 | show_progress=True, |
17 | | - local_alleles=False, |
18 | 17 | ) |
19 | 18 |
|
20 | 19 | DEFAULT_DEXPLODE_PARTITION_ARGS = dict() |
|
24 | 23 | column_chunk_size=64, |
25 | 24 | compressor=None, |
26 | 25 | show_progress=True, |
27 | | - local_alleles=False, |
28 | 26 | ) |
29 | 27 |
|
30 | 28 | DEFAULT_ENCODE_ARGS = dict( |
|
49 | 47 |
|
50 | 48 | DEFAULT_DENCODE_FINALISE_ARGS = dict(show_progress=True) |
51 | 49 |
|
| 50 | +DEFAULT_MKSHCHEMA_ARGS = dict( |
| 51 | + variants_chunk_size=None, |
| 52 | + samples_chunk_size=None, |
| 53 | + local_alleles=False, |
| 54 | +) |
| 55 | + |
52 | 56 | DEFAULT_CONVERT_ARGS = dict( |
53 | 57 | variants_chunk_size=None, |
54 | 58 | samples_chunk_size=None, |
@@ -297,29 +301,6 @@ def test_vcf_explode_missing_and_existing_vcf(self, mocked, tmp_path): |
297 | 301 | assert "'no_such_file' does not exist" in result.stderr |
298 | 302 | mocked.assert_not_called() |
299 | 303 |
|
300 | | - @pytest.mark.parametrize("local_alleles", [False, True]) |
301 | | - @mock.patch("bio2zarr.vcf2zarr.explode") |
302 | | - def test_vcf_explode_local_alleles(self, mocked, tmp_path, local_alleles): |
303 | | - icf_path = tmp_path / "icf" |
304 | | - runner = ct.CliRunner(mix_stderr=False) |
305 | | - |
306 | | - if local_alleles: |
307 | | - local_alleles_flag = "--local-alleles" |
308 | | - else: |
309 | | - local_alleles_flag = "--no-local-alleles" |
310 | | - |
311 | | - result = runner.invoke( |
312 | | - cli.vcf2zarr_main, |
313 | | - f"explode {self.vcf_path} {icf_path} {local_alleles_flag}", |
314 | | - catch_exceptions=False, |
315 | | - ) |
316 | | - assert result.exit_code == 0 |
317 | | - assert len(result.stdout) == 0 |
318 | | - assert len(result.stderr) == 0 |
319 | | - args = dict(DEFAULT_EXPLODE_ARGS) |
320 | | - args["local_alleles"] = local_alleles |
321 | | - mocked.assert_called_once_with(str(icf_path), (self.vcf_path,), **args) |
322 | | - |
323 | 304 | @pytest.mark.parametrize(("progress", "flag"), [(True, "-P"), (False, "-Q")]) |
324 | 305 | @mock.patch("bio2zarr.vcf2zarr.explode_init", return_value=FakeWorkSummary(5)) |
325 | 306 | def test_vcf_dexplode_init(self, mocked, tmp_path, progress, flag): |
@@ -462,7 +443,7 @@ def test_mkschema(self, mocked, tmp_path): |
462 | 443 | runner = ct.CliRunner(mix_stderr=False) |
463 | 444 | result = runner.invoke( |
464 | 445 | cli.vcf2zarr_main, |
465 | | - f"mkschema {tmp_path} --variants-chunk-size=3 " "--samples-chunk-size=4", |
| 446 | + f"mkschema {tmp_path} --variants-chunk-size=3 --samples-chunk-size=4", |
466 | 447 | catch_exceptions=False, |
467 | 448 | ) |
468 | 449 | assert result.exit_code == 0 |
@@ -726,6 +707,29 @@ def test_mkschema(self, tmp_path): |
726 | 707 | assert d["samples_chunk_size"] == 2 |
727 | 708 | assert d["variants_chunk_size"] == 3 |
728 | 709 |
|
| 710 | + @pytest.mark.parametrize("local_alleles", [False, True]) |
| 711 | + def test_mkschema_local_alleles(self, tmp_path, local_alleles): |
| 712 | + icf_path = tmp_path / "icf" |
| 713 | + local_alleles_flag = {True: "--local-alleles", False: "--no-local-alleles"}[ |
| 714 | + local_alleles |
| 715 | + ] |
| 716 | + runner = ct.CliRunner(mix_stderr=False) |
| 717 | + result = runner.invoke( |
| 718 | + cli.vcf2zarr_main, |
| 719 | + f"explode {self.vcf_path} {icf_path}", |
| 720 | + catch_exceptions=False, |
| 721 | + ) |
| 722 | + assert result.exit_code == 0 |
| 723 | + result = runner.invoke( |
| 724 | + cli.vcf2zarr_main, |
| 725 | + f"mkschema {icf_path} {local_alleles_flag}", |
| 726 | + catch_exceptions=False, |
| 727 | + ) |
| 728 | + assert result.exit_code == 0 |
| 729 | + d = json.loads(result.stdout) |
| 730 | + call_LA_exists = "call_LA" in [f["name"] for f in d["fields"]] |
| 731 | + assert call_LA_exists == local_alleles |
| 732 | + |
729 | 733 | def test_encode(self, tmp_path): |
730 | 734 | icf_path = tmp_path / "icf" |
731 | 735 | zarr_path = tmp_path / "zarr" |
|
0 commit comments