Skip to content

Commit 7254cc7

Browse files
Add plink2zarr script and add tests in CI
Closes #401 Systematicaly use _main suffix for entry points
1 parent 072044e commit 7254cc7

File tree

5 files changed

+33
-18
lines changed

5 files changed

+33
-18
lines changed

.github/workflows/ci.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ jobs:
6969
python -m bio2zarr vcf2zarr dencode-partition sample.vcz 1
7070
python -m bio2zarr vcf2zarr dencode-partition sample.vcz 2
7171
python -m bio2zarr vcf2zarr dencode-finalise sample.vcz
72+
- name: Run tskit2zarr example
73+
run: |
74+
python -m bio2zarr tskit2zarr convert tests/data/tskit/example.trees sample.vcz -f
75+
- name: Run plink2zarr example
76+
run: |
77+
python -m bio2zarr plink2zarr convert tests/data/plink/example sample.vcz -f
7278
- name: Run tests
7379
run: |
7480
pytest --cov=bio2zarr
@@ -137,6 +143,14 @@ jobs:
137143
run: |
138144
vcfpartition --help
139145
python -m bio2zarr vcfpartition --help
146+
- name: Check tskit2zarr CLI
147+
run: |
148+
tskit2zarr --help
149+
python -m bio2zarr tskit2zarr --help
150+
- name: Check plink2zarr CLI
151+
run: |
152+
plink2zarr --help
153+
python -m bio2zarr plink2zarr --help
140154
141155
test-numpy-version:
142156
name: Test numpy versions

bio2zarr/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ def bio2zarr():
1515
# is handy for development and for those whose PATHs aren't set
1616
# up in the right way.
1717
bio2zarr.add_command(cli.vcf2zarr_main)
18-
bio2zarr.add_command(cli.plink2zarr)
18+
bio2zarr.add_command(cli.plink2zarr_main)
19+
bio2zarr.add_command(cli.tskit2zarr_main)
1920
bio2zarr.add_command(cli.vcfpartition)
20-
bio2zarr.add_command(cli.tskit2zarr)
2121

2222
if __name__ == "__main__":
2323
bio2zarr()

bio2zarr/cli.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -582,15 +582,15 @@ def convert_plink(
582582

583583

584584
@version
585-
@click.group()
586-
def plink2zarr():
585+
@click.group(name="plink2zarr")
586+
def plink2zarr_main():
587587
"""
588588
Convert plink fileset(s) to VCF Zarr format
589589
"""
590590
pass
591591

592592

593-
plink2zarr.add_command(convert_plink)
593+
plink2zarr_main.add_command(convert_plink)
594594

595595

596596
@click.command
@@ -684,12 +684,12 @@ def convert_tskit(
684684

685685

686686
@version
687-
@click.group()
688-
def tskit2zarr():
687+
@click.group(name="tskit2zarr")
688+
def tskit2zarr_main():
689689
"""
690690
Convert tskit tree sequence(s) to VCF Zarr format
691691
"""
692692
pass
693693

694694

695-
tskit2zarr.add_command(convert_tskit)
695+
tskit2zarr_main.add_command(convert_tskit)

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ documentation = "https://sgkit-dev.github.io/bio2zarr/"
5252
vcf2zarr = "bio2zarr.cli:vcf2zarr_main"
5353
vcfpartition = "bio2zarr.cli:vcfpartition"
5454
tskit2zarr = "bio2zarr.cli:tskit2zarr_main"
55+
plink2zarr = "bio2zarr.cli:plink2zarr_main"
5556

5657
[project.optional-dependencies]
5758
dev = [

tests/test_cli.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ def test_vcf_convert_overwrite_zarr_confirm_no(self, mocked, tmp_path, response)
616616
def test_convert_plink(self, mocked, progress, flag):
617617
runner = ct.CliRunner()
618618
result = runner.invoke(
619-
cli.plink2zarr, ["convert", "in", "out", flag], catch_exceptions=False
619+
cli.plink2zarr_main, ["convert", "in", "out", flag], catch_exceptions=False
620620
)
621621
assert result.exit_code == 0
622622
assert len(result.stdout) == 0
@@ -651,7 +651,7 @@ def test_convert_tskit(self, mocked, tmp_path, progress, flag):
651651
zarr_path = tmp_path / "zarr"
652652
runner = ct.CliRunner()
653653
result = runner.invoke(
654-
cli.tskit2zarr,
654+
cli.tskit2zarr_main,
655655
f"convert {ts_path} {zarr_path} {flag}",
656656
catch_exceptions=False,
657657
)
@@ -674,7 +674,7 @@ def test_tskit_convert_overwrite_zarr_confirm_yes(self, mocked, tmp_path, respon
674674
zarr_path.mkdir()
675675
runner = ct.CliRunner()
676676
result = runner.invoke(
677-
cli.tskit2zarr,
677+
cli.tskit2zarr_main,
678678
f"convert {ts_path} {zarr_path}",
679679
catch_exceptions=False,
680680
input=response,
@@ -696,7 +696,7 @@ def test_tskit_convert_overwrite_zarr_confirm_no(self, mocked, tmp_path, respons
696696
zarr_path.mkdir()
697697
runner = ct.CliRunner()
698698
result = runner.invoke(
699-
cli.tskit2zarr,
699+
cli.tskit2zarr_main,
700700
f"convert {ts_path} {zarr_path}",
701701
catch_exceptions=False,
702702
input=response,
@@ -713,7 +713,7 @@ def test_tskit_convert_overwrite_zarr_force(self, mocked, tmp_path, force_arg):
713713
zarr_path.mkdir()
714714
runner = ct.CliRunner()
715715
result = runner.invoke(
716-
cli.tskit2zarr,
716+
cli.tskit2zarr_main,
717717
f"convert {ts_path} {zarr_path} {force_arg}",
718718
catch_exceptions=False,
719719
)
@@ -732,7 +732,7 @@ def test_tskit_convert_with_options(self, mocked, tmp_path):
732732
zarr_path = tmp_path / "zarr"
733733
runner = ct.CliRunner()
734734
result = runner.invoke(
735-
cli.tskit2zarr,
735+
cli.tskit2zarr_main,
736736
f"convert {ts_path} {zarr_path} --contig-id chr1 "
737737
"--isolated-as-missing -l 100 -w 50 -p 4",
738738
catch_exceptions=False,
@@ -1032,7 +1032,7 @@ def test_convert(self, tmp_path):
10321032
zarr_path = tmp_path / "zarr"
10331033
runner = ct.CliRunner()
10341034
result = runner.invoke(
1035-
cli.tskit2zarr,
1035+
cli.tskit2zarr_main,
10361036
f"convert {ts_path} {zarr_path}",
10371037
catch_exceptions=False,
10381038
)
@@ -1051,7 +1051,7 @@ def test_convert(self, tmp_path):
10511051
zarr_path = tmp_path / "zarr"
10521052
runner = ct.CliRunner()
10531053
result = runner.invoke(
1054-
cli.plink2zarr,
1054+
cli.plink2zarr_main,
10551055
f"convert {ts_path} {zarr_path}",
10561056
catch_exceptions=False,
10571057
)
@@ -1069,9 +1069,9 @@ def test_convert(self, tmp_path):
10691069
[
10701070
main.bio2zarr,
10711071
cli.vcf2zarr_main,
1072-
cli.plink2zarr,
1072+
cli.plink2zarr_main,
10731073
cli.vcfpartition,
1074-
cli.tskit2zarr,
1074+
cli.tskit2zarr_main,
10751075
],
10761076
)
10771077
def test_version(cmd):

0 commit comments

Comments
 (0)