-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from jeromekelleher/more-real-examples
More real examples
- Loading branch information
Showing
11 changed files
with
154 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,34 @@ | ||
import pathlib | ||
|
||
import pytest | ||
|
||
from bio2zarr import vcf2zarr | ||
from vcztools.vcf_writer import write_vcf | ||
from .utils import assert_vcfs_close | ||
|
||
|
||
def vcz_path_cache(vcf_path): | ||
""" | ||
Store converted files in a cache to speed up tests. We're not testing | ||
vcf2zarr here, so no point in running over and over again. | ||
""" | ||
cache_path = pathlib.Path("vcz_test_cache") | ||
if not cache_path.exists(): | ||
cache_path.mkdir() | ||
cached_vcz_path = (cache_path / vcf_path.name).with_suffix(".vcz") | ||
if not cached_vcz_path.exists(): | ||
vcf2zarr.convert([vcf_path], cached_vcz_path, worker_processes=0) | ||
return cached_vcz_path | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"vcf_file", ["sample.vcf.gz"] | ||
"vcf_file", | ||
["sample.vcf.gz", "1kg_2020_chr20_annotations.bcf", "1kg_2020_chrM.vcf.gz"], | ||
) | ||
@pytest.mark.parametrize("implementation", ["c", "numba"]) | ||
def test_vcf_to_zarr_to_vcf__real_files(shared_datadir, tmp_path, vcf_file, implementation): | ||
path = shared_datadir / "vcf" / vcf_file | ||
intermediate_icf = tmp_path.joinpath("intermediate.icf") | ||
intermediate_vcz = tmp_path.joinpath("intermediate.vcz") | ||
output = tmp_path.joinpath("output.vcf") | ||
|
||
vcf2zarr.convert( | ||
[path], intermediate_vcz, icf_path=intermediate_icf, worker_processes=0 | ||
) | ||
|
||
write_vcf(intermediate_vcz, output, implementation=implementation) | ||
|
||
assert_vcfs_close(path, output) | ||
def test_vcf_to_zarr_to_vcf__real_files(tmp_path, vcf_file, implementation): | ||
original = pathlib.Path("tests/data/vcf") / vcf_file | ||
vcz = vcz_path_cache(original) | ||
generated = tmp_path.joinpath("output.vcf") | ||
write_vcf(vcz, generated, implementation=implementation) | ||
assert_vcfs_close(original, generated) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters