def read_index(index_path: PathType, storage_options: Optional[Dict[str, str]] = None) -> Any: url = str(index_path) if url.endswith(TABIX_EXTENSION): return read_tabix(url, storage_options=storage_options) elif url.endswith(CSI_EXTENSION): return read_csi(url, storage_options=storage_options) else: raise ValueError("Only .tbi or .csi indexes are supported.")
def test_record_counts_tbi(shared_datadir, vcf_file, is_path): # Check record counts in tabix with actual count of VCF vcf_path = path_for_test(shared_datadir, vcf_file, is_path) tabix_path = get_tabix_path(vcf_path) assert tabix_path is not None tabix = read_tabix(tabix_path) for i, contig in enumerate(tabix.sequence_names): assert tabix.record_counts[i] == count_variants(vcf_path, contig)
def test_read_tabix__invalid_tbi(shared_datadir, file, is_path): with pytest.raises(ValueError, match=r"File not in Tabix format."): read_tabix(path_for_test(shared_datadir, file, is_path))