Skip to content

Commit e272fb0

Browse files
Update tests
1 parent 096c8d0 commit e272fb0

File tree

11 files changed

+24
-5
lines changed

11 files changed

+24
-5
lines changed

bio2zarr/vcf_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,13 +369,16 @@ class IndexedVcf(contextlib.AbstractContextManager):
369369
def __init__(self, vcf_path, index_path=None):
370370
self.vcf = None
371371
vcf_path = pathlib.Path(vcf_path)
372+
if not vcf_path.exists():
373+
raise FileNotFoundError(vcf_path)
372374
# TODO use constants here instead of strings
373375
if index_path is None:
374376
index_path = vcf_path.with_suffix(vcf_path.suffix + ".tbi")
375377
if not index_path.exists():
376378
index_path = vcf_path.with_suffix(vcf_path.suffix + ".csi")
377379
if not index_path.exists():
378-
raise ValueError("Cannot find .tbi or .csi file.")
380+
raise FileNotFoundError(
381+
"Cannot find .tbi or .csi file for {vcf_path}")
379382
else:
380383
index_path = pathlib.Path(index_path)
381384

394 Bytes
Binary file not shown.
99 Bytes
Binary file not shown.
345 Bytes
Binary file not shown.
112 Bytes
Binary file not shown.
398 Bytes
Binary file not shown.
100 Bytes
Binary file not shown.
347 Bytes
Binary file not shown.
112 Bytes
Binary file not shown.

tests/test_vcf_examples.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,3 +728,21 @@ def test_by_validating(name, tmp_path):
728728
out = tmp_path / "test.zarr"
729729
vcf.convert([path], out, worker_processes=0)
730730
vcf.validate(path, out)
731+
732+
733+
@pytest.mark.parametrize(
734+
["source", "suffix", "files"],
735+
[
736+
["sample.vcf.gz", "3.split", ["19:1-.vcf.gz", "20.vcf.gz", "X.vcf.gz"]],
737+
["sample.vcf.gz", "3.split", ["20.vcf.gz", "19:1-.vcf.gz", "X.vcf.gz"]],
738+
["out_of_order_contigs.vcf.gz", "2.split", ["A.vcf.gz", "B:1-.vcf.gz"]],
739+
["out_of_order_contigs.vcf.gz", "2.split", ["A.bcf", "B:1-.bcf"]],
740+
["out_of_order_contigs.vcf.gz", "2.split", ["A.vcf.gz", "B:1-.bcf"]],
741+
],
742+
)
743+
def test_by_validating_split(source, suffix, files, tmp_path):
744+
source_path = f"tests/data/vcf/{source}"
745+
split_files = [f"{source_path}.{suffix}/{f}" for f in files]
746+
out = tmp_path / "test.zarr"
747+
vcf.convert(split_files, out, worker_processes=0)
748+
vcf.validate(source_path, out)

0 commit comments

Comments
 (0)