Skip to content

Commit 6472ae0

Browse files
Test local/non local path
1 parent f80e1c2 commit 6472ae0

File tree

1 file changed

+80
-33
lines changed

1 file changed

+80
-33
lines changed

tests/test_vcf_examples.py

Lines changed: 80 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ class Test1000G2020Example:
546546
@pytest.fixture(scope="class")
547547
def ds(self, tmp_path_factory):
548548
out = tmp_path_factory.mktemp("data") / "example.vcf.zarr"
549-
vcf2zarr.convert([self.data_path], out, worker_processes=0, local_alleles=True)
549+
vcf2zarr.convert([self.data_path], out, worker_processes=0)
550550
return sg.load_dataset(out)
551551

552552
def test_position(self, ds):
@@ -617,33 +617,85 @@ def test_variant_MLEAC(self, ds):
617617
)
618618
nt.assert_array_equal(ds.variant_MLEAC.values, MLEAC)
619619

620-
# def test_call_AD(self, ds):
621-
# call_AD = [
622-
# [[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
623-
# [[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
624-
# [[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
625-
# [[446, 0, 0, -2, -2], [393, 0, 0, -2, -2], [486, 0, 0, -2, -2]],
626-
# [[446, 0, 0, 0, -2], [393, 0, 0, 0, -2], [486, 0, 0, 0, -2]],
627-
# [[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
628-
# [[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
629-
# [[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
630-
# [[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
631-
# [[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
632-
# [[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
633-
# [[446, 0, 0, 0, 0], [393, 0, 0, 0, 0], [486, 0, 0, 0, 0]],
634-
# [[446, 0, 0, 0, 0], [393, 0, 0, 0, 0], [486, 0, 0, 0, 0]],
635-
# [[446, 0, 0, 0, 0], [393, 0, 0, 0, 0], [486, 0, 0, 0, 0]],
636-
# [[446, 0, 0, 0, -2], [393, 0, 0, 0, -2], [486, 0, 0, 0, -2]],
637-
# [[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
638-
# [[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
639-
# [[446, 0, 0, -2, -2], [393, 0, 0, -2, -2], [486, 0, 0, -2, -2]],
640-
# [[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
641-
# [[446, 0, 0, -2, -2], [393, 0, 0, -2, -2], [486, 0, 0, -2, -2]],
642-
# [[446, 0, 0, 0, -2], [393, 0, 0, 0, -2], [486, 0, 0, 0, -2]],
643-
# [[446, 0, 0, 0, 0], [393, 0, 0, 0, 0], [486, 0, 0, 0, 0]],
644-
# [[446, 0, 0, 0, -2], [393, 0, 0, 0, -2], [486, 0, 0, 0, -2]],
645-
# ]
646-
# nt.assert_array_equal(ds.call_AD.values, call_AD)
620+
def test_call_AD(self, ds):
621+
call_AD = [
622+
[[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
623+
[[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
624+
[[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
625+
[[446, 0, 0, -2, -2], [393, 0, 0, -2, -2], [486, 0, 0, -2, -2]],
626+
[[446, 0, 0, 0, -2], [393, 0, 0, 0, -2], [486, 0, 0, 0, -2]],
627+
[[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
628+
[[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
629+
[[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
630+
[[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
631+
[[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
632+
[[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
633+
[[446, 0, 0, 0, 0], [393, 0, 0, 0, 0], [486, 0, 0, 0, 0]],
634+
[[446, 0, 0, 0, 0], [393, 0, 0, 0, 0], [486, 0, 0, 0, 0]],
635+
[[446, 0, 0, 0, 0], [393, 0, 0, 0, 0], [486, 0, 0, 0, 0]],
636+
[[446, 0, 0, 0, -2], [393, 0, 0, 0, -2], [486, 0, 0, 0, -2]],
637+
[[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
638+
[[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
639+
[[446, 0, 0, -2, -2], [393, 0, 0, -2, -2], [486, 0, 0, -2, -2]],
640+
[[446, 0, -2, -2, -2], [393, 0, -2, -2, -2], [486, 0, -2, -2, -2]],
641+
[[446, 0, 0, -2, -2], [393, 0, 0, -2, -2], [486, 0, 0, -2, -2]],
642+
[[446, 0, 0, 0, -2], [393, 0, 0, 0, -2], [486, 0, 0, 0, -2]],
643+
[[446, 0, 0, 0, 0], [393, 0, 0, 0, 0], [486, 0, 0, 0, 0]],
644+
[[446, 0, 0, 0, -2], [393, 0, 0, 0, -2], [486, 0, 0, 0, -2]],
645+
]
646+
nt.assert_array_equal(ds.call_AD.values, call_AD)
647+
648+
def test_call_PID(self, ds):
649+
call_PGT = ds["call_PGT"].values
650+
assert np.all(call_PGT == ".")
651+
assert call_PGT.shape == (23, 3)
652+
653+
654+
class Test1000G2020ExampleLocalAlleles:
655+
data_path = "tests/data/vcf/1kg_2020_chrM.vcf.gz"
656+
657+
@pytest.fixture(scope="class")
658+
def ds(self, tmp_path_factory):
659+
out = tmp_path_factory.mktemp("data") / "example.vcf.zarr"
660+
vcf2zarr.convert([self.data_path], out, worker_processes=0, local_alleles=True)
661+
return sg.load_dataset(out)
662+
663+
def test_position(self, ds):
664+
# fmt: off
665+
pos = [
666+
26, 35, 40, 41, 42, 46, 47, 51, 52, 53, 54, 55, 56,
667+
57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
668+
]
669+
# fmt: on
670+
nt.assert_array_equal(ds.variant_position.values, pos)
671+
672+
def test_alleles(self, ds):
673+
alleles = [
674+
["C", "T", "", "", ""],
675+
["G", "A", "", "", ""],
676+
["T", "C", "", "", ""],
677+
["C", "T", "CT", "", ""],
678+
["T", "TC", "C", "TG", ""],
679+
["T", "C", "", "", ""],
680+
["G", "A", "", "", ""],
681+
["T", "C", "", "", ""],
682+
["T", "C", "", "", ""],
683+
["G", "A", "", "", ""],
684+
["G", "A", "", "", ""],
685+
["TA", "TAA", "T", "CA", "AA"],
686+
["ATT", "*", "ATTT", "ACTT", "A"],
687+
["T", "C", "G", "*", "TC"],
688+
["T", "A", "C", "*", ""],
689+
["T", "A", "", "", ""],
690+
["T", "A", "", "", ""],
691+
["C", "A", "T", "", ""],
692+
["G", "A", "", "", ""],
693+
["T", "C", "A", "", ""],
694+
["C", "T", "CT", "A", ""],
695+
["TG", "T", "CG", "TGG", "TCGG"],
696+
["G", "T", "*", "A", ""],
697+
]
698+
nt.assert_array_equal(ds.variant_allele.values, alleles)
647699

648700
def test_call_LAD(self, ds):
649701
call_LAD = [
@@ -682,11 +734,6 @@ def test_call_LAA(self, ds):
682734
# call_LPL = np.tile([0, -2, -2], (23, 3, 1))
683735
# nt.assert_array_equal(ds.call_LPL.values, call_LPL)
684736

685-
def test_call_PID(self, ds):
686-
call_PGT = ds["call_PGT"].values
687-
assert np.all(call_PGT == ".")
688-
assert call_PGT.shape == (23, 3)
689-
690737

691738
class Test1000G2020AnnotationsExample:
692739
data_path = "tests/data/vcf/1kg_2020_chr20_annotations.bcf"

0 commit comments

Comments
 (0)