@@ -314,6 +314,23 @@ def test_vcf_dexplode_partition(self, mocked, tmp_path):
314314 str (icf_path ), 1 , ** DEFAULT_DEXPLODE_PARTITION_ARGS
315315 )
316316
317+ @mock .patch ("bio2zarr.vcf.explode_partition" )
318+ def test_vcf_dexplode_partition_one_based (self , mocked , tmp_path ):
319+ runner = ct .CliRunner (mix_stderr = False )
320+ icf_path = tmp_path / "icf"
321+ icf_path .mkdir ()
322+ result = runner .invoke (
323+ cli .vcf2zarr ,
324+ f"dexplode-partition { icf_path } 1 --one-based" ,
325+ catch_exceptions = False ,
326+ )
327+ assert result .exit_code == 0
328+ assert len (result .stdout ) == 0
329+ assert len (result .stderr ) == 0
330+ mocked .assert_called_once_with (
331+ str (icf_path ), 0 , ** DEFAULT_DEXPLODE_PARTITION_ARGS
332+ )
333+
317334 @mock .patch ("bio2zarr.vcf.explode_partition" )
318335 def test_vcf_dexplode_partition_missing_dir (self , mocked , tmp_path ):
319336 runner = ct .CliRunner (mix_stderr = False )
@@ -436,6 +453,23 @@ def test_vcf_dencode_partition(self, mocked, tmp_path):
436453 str (zarr_path ), 1 , ** DEFAULT_DENCODE_PARTITION_ARGS
437454 )
438455
456+ @mock .patch ("bio2zarr.vcf.encode_partition" )
457+ def test_vcf_dencode_partition_one_based (self , mocked , tmp_path ):
458+ runner = ct .CliRunner (mix_stderr = False )
459+ zarr_path = tmp_path / "zarr"
460+ zarr_path .mkdir ()
461+ result = runner .invoke (
462+ cli .vcf2zarr ,
463+ f"dencode-partition { zarr_path } 1 --one-based" ,
464+ catch_exceptions = False ,
465+ )
466+ assert result .exit_code == 0
467+ assert len (result .stdout ) == 0
468+ assert len (result .stderr ) == 0
469+ mocked .assert_called_once_with (
470+ str (zarr_path ), 0 , ** DEFAULT_DENCODE_PARTITION_ARGS
471+ )
472+
439473 @mock .patch ("bio2zarr.vcf.encode_finalise" )
440474 def test_vcf_dencode_finalise (self , mocked , tmp_path ):
441475 runner = ct .CliRunner (mix_stderr = False )
@@ -489,7 +523,8 @@ def test_convert_plink(self, mocked):
489523class TestVcfEndToEnd :
490524 vcf_path = "tests/data/vcf/sample.vcf.gz"
491525
492- def test_dexplode (self , tmp_path ):
526+ @pytest .mark .parametrize ("one_based" , [False , True ])
527+ def test_dexplode (self , tmp_path , one_based ):
493528 icf_path = tmp_path / "icf"
494529 runner = ct .CliRunner (mix_stderr = False )
495530 result = runner .invoke (
@@ -501,11 +536,11 @@ def test_dexplode(self, tmp_path):
501536 assert result .stdout .strip () == "3"
502537
503538 for j in range (3 ):
504- result = runner . invoke (
505- cli . vcf2zarr ,
506- f"dexplode-partition { icf_path } { j } " ,
507- catch_exceptions = False ,
508- )
539+ if one_based :
540+ cmd = f"dexplode-partition { icf_path } { j + 1 } --one-based"
541+ else :
542+ cmd = f"dexplode-partition { icf_path } { j } "
543+ result = runner . invoke ( cli . vcf2zarr , cmd , catch_exceptions = False )
509544 assert result .exit_code == 0
510545 result = runner .invoke (
511546 cli .vcf2zarr , f"dexplode-finalise { icf_path } " , catch_exceptions = False
@@ -552,7 +587,8 @@ def test_encode(self, tmp_path):
552587 # Arbitrary check
553588 assert "variant_position" in result .stdout
554589
555- def test_dencode (self , tmp_path ):
590+ @pytest .mark .parametrize ("one_based" , [False , True ])
591+ def test_dencode (self , tmp_path , one_based ):
556592 icf_path = tmp_path / "icf"
557593 zarr_path = tmp_path / "zarr"
558594 runner = ct .CliRunner (mix_stderr = False )
@@ -569,12 +605,12 @@ def test_dencode(self, tmp_path):
569605 assert result .stdout .split ()[0 ] == "3"
570606
571607 for j in range (3 ):
572- result = runner . invoke (
573- cli . vcf2zarr ,
574- f"dencode-partition { zarr_path } { j } " ,
575- catch_exceptions = False ,
576- )
577- assert result .exit_code == 0
608+ if one_based :
609+ cmd = f"dencode-partition { zarr_path } { j + 1 } --one-based"
610+ else :
611+ cmd = f"dencode-partition { zarr_path } { j } "
612+ result = runner . invoke ( cli . vcf2zarr , cmd , catch_exceptions = False )
613+ assert result .exit_code == 0
578614
579615 result = runner .invoke (
580616 cli .vcf2zarr , f"dencode-finalise { zarr_path } " , catch_exceptions = False
0 commit comments