@@ -314,6 +314,23 @@ def test_vcf_dexplode_partition(self, mocked, tmp_path):
314
314
str (icf_path ), 1 , ** DEFAULT_DEXPLODE_PARTITION_ARGS
315
315
)
316
316
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
+
317
334
@mock .patch ("bio2zarr.vcf.explode_partition" )
318
335
def test_vcf_dexplode_partition_missing_dir (self , mocked , tmp_path ):
319
336
runner = ct .CliRunner (mix_stderr = False )
@@ -436,6 +453,23 @@ def test_vcf_dencode_partition(self, mocked, tmp_path):
436
453
str (zarr_path ), 1 , ** DEFAULT_DENCODE_PARTITION_ARGS
437
454
)
438
455
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
+
439
473
@mock .patch ("bio2zarr.vcf.encode_finalise" )
440
474
def test_vcf_dencode_finalise (self , mocked , tmp_path ):
441
475
runner = ct .CliRunner (mix_stderr = False )
@@ -489,7 +523,8 @@ def test_convert_plink(self, mocked):
489
523
class TestVcfEndToEnd :
490
524
vcf_path = "tests/data/vcf/sample.vcf.gz"
491
525
492
- def test_dexplode (self , tmp_path ):
526
+ @pytest .mark .parametrize ("one_based" , [False , True ])
527
+ def test_dexplode (self , tmp_path , one_based ):
493
528
icf_path = tmp_path / "icf"
494
529
runner = ct .CliRunner (mix_stderr = False )
495
530
result = runner .invoke (
@@ -501,11 +536,11 @@ def test_dexplode(self, tmp_path):
501
536
assert result .stdout .strip () == "3"
502
537
503
538
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 )
509
544
assert result .exit_code == 0
510
545
result = runner .invoke (
511
546
cli .vcf2zarr , f"dexplode-finalise { icf_path } " , catch_exceptions = False
@@ -552,7 +587,8 @@ def test_encode(self, tmp_path):
552
587
# Arbitrary check
553
588
assert "variant_position" in result .stdout
554
589
555
- def test_dencode (self , tmp_path ):
590
+ @pytest .mark .parametrize ("one_based" , [False , True ])
591
+ def test_dencode (self , tmp_path , one_based ):
556
592
icf_path = tmp_path / "icf"
557
593
zarr_path = tmp_path / "zarr"
558
594
runner = ct .CliRunner (mix_stderr = False )
@@ -569,12 +605,12 @@ def test_dencode(self, tmp_path):
569
605
assert result .stdout .split ()[0 ] == "3"
570
606
571
607
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
578
614
579
615
result = runner .invoke (
580
616
cli .vcf2zarr , f"dencode-finalise { zarr_path } " , catch_exceptions = False
0 commit comments