|
| 1 | +# Copyright (c) TileDB, Inc. |
| 2 | +# Licensed under the MIT License. |
| 3 | +""" |
| 4 | +VCF sample ingestion with Carrara URIs. |
| 5 | +""" |
| 6 | + |
| 7 | +from __future__ import annotations |
| 8 | + |
| 9 | +import pytest |
| 10 | +import tiledbvcf |
| 11 | + |
| 12 | + |
| 13 | +@pytest.mark.carrara |
| 14 | +def test_ingest_samples( |
| 15 | + carrara_login: None, carrara_group_path: str, vcf_sample_uris: list[str] |
| 16 | +) -> None: |
| 17 | + """Ingest two BCF samples into a remote Carrara dataset and verify total count.""" |
| 18 | + with tiledbvcf.Dataset(carrara_group_path, mode="w") as ds: |
| 19 | + ds.create_dataset() |
| 20 | + ds.ingest_samples(vcf_sample_uris) |
| 21 | + |
| 22 | + with tiledbvcf.Dataset(carrara_group_path, mode="r") as ds: |
| 23 | + assert ds.count() == 14 |
| 24 | + |
| 25 | + |
| 26 | +@pytest.mark.carrara |
| 27 | +def test_ingest_and_region_query( |
| 28 | + carrara_login: None, carrara_group_path: str, vcf_sample_uris: list[str] |
| 29 | +) -> None: |
| 30 | + """Ingest samples and verify a region-filtered count.""" |
| 31 | + with tiledbvcf.Dataset(carrara_group_path, mode="w") as ds: |
| 32 | + ds.create_dataset() |
| 33 | + ds.ingest_samples(vcf_sample_uris) |
| 34 | + |
| 35 | + with tiledbvcf.Dataset(carrara_group_path, mode="r") as ds: |
| 36 | + assert ds.count(regions=["1:12700-13400"]) == 6 |
| 37 | + |
| 38 | + |
| 39 | +@pytest.mark.carrara |
| 40 | +def test_ingest_and_sample_query( |
| 41 | + carrara_login: None, carrara_group_path: str, vcf_sample_uris: list[str] |
| 42 | +) -> None: |
| 43 | + """Ingest samples and verify a sample- and region-filtered count.""" |
| 44 | + with tiledbvcf.Dataset(carrara_group_path, mode="w") as ds: |
| 45 | + ds.create_dataset() |
| 46 | + ds.ingest_samples(vcf_sample_uris) |
| 47 | + |
| 48 | + with tiledbvcf.Dataset(carrara_group_path, mode="r") as ds: |
| 49 | + assert ds.count(samples=["HG00280"], regions=["1:12700-13400"]) == 4 |
| 50 | + |
| 51 | + |
| 52 | +@pytest.mark.carrara |
| 53 | +def test_ingest_incremental( |
| 54 | + carrara_login: None, carrara_group_path: str, vcf_sample_uris: list[str] |
| 55 | +) -> None: |
| 56 | + """Ingest one sample, verify count, then add a second sample and re-verify.""" |
| 57 | + first, second = vcf_sample_uris[0], vcf_sample_uris[1] |
| 58 | + |
| 59 | + with tiledbvcf.Dataset(carrara_group_path, mode="w") as ds: |
| 60 | + ds.create_dataset() |
| 61 | + ds.ingest_samples([first]) |
| 62 | + |
| 63 | + with tiledbvcf.Dataset(carrara_group_path, mode="r") as ds: |
| 64 | + count_after_first = ds.count() |
| 65 | + assert count_after_first > 0 |
| 66 | + |
| 67 | + with tiledbvcf.Dataset(carrara_group_path, mode="w") as ds: |
| 68 | + ds.ingest_samples([second]) |
| 69 | + |
| 70 | + with tiledbvcf.Dataset(carrara_group_path, mode="r") as ds: |
| 71 | + assert ds.count() == 14 |
| 72 | + assert ds.count() > count_after_first |
0 commit comments