@@ -14,24 +14,24 @@ def assert_part_counts_non_zero(part_counts, index_file):
14
14
assert np .all (part_counts > 0 )
15
15
16
16
17
- class TestIndexedVcf :
17
+ class TestVcfFile :
18
18
def get_instance (self , index_file ):
19
19
vcf_path = data_path / ("." .join (list (index_file .split ("." ))[:- 1 ]))
20
- return vcf_utils .IndexedVcf (vcf_path , data_path / index_file )
20
+ return vcf_utils .VcfFile (vcf_path , data_path / index_file )
21
21
22
22
def test_context_manager_success (self ):
23
23
# Nominal case
24
- with vcf_utils .IndexedVcf (data_path / "sample.bcf" ) as iv :
24
+ with vcf_utils .VcfFile (data_path / "sample.bcf" ) as iv :
25
25
assert iv .vcf is not None
26
26
assert iv .vcf is None
27
27
28
28
def test_context_manager_error (self ):
29
29
with pytest .raises (FileNotFoundError , match = "no-such-file" ):
30
- with vcf_utils .IndexedVcf (data_path / "no-such-file.bcf" ):
30
+ with vcf_utils .VcfFile (data_path / "no-such-file.bcf" ):
31
31
pass
32
32
33
33
def test_indels_filtered (self ):
34
- with vcf_utils .IndexedVcf (data_path / "chr_m_indels.vcf.gz" ) as vfile :
34
+ with vcf_utils .VcfFile (data_path / "chr_m_indels.vcf.gz" ) as vfile :
35
35
# Hand-picked example that results in filtering
36
36
region = vcf_utils .Region ("chrM" , 300 , 314 )
37
37
pos = [var .POS for var in vfile .variants (region )]
@@ -173,7 +173,7 @@ def test_partition_into_n_parts_unindexed(
173
173
):
174
174
copy_path = tmp_path / vcf_file
175
175
shutil .copyfile (data_path / vcf_file , copy_path )
176
- indexed_vcf = vcf_utils .IndexedVcf (copy_path )
176
+ indexed_vcf = vcf_utils .VcfFile (copy_path )
177
177
regions = list (indexed_vcf .partition_into_regions (num_parts = num_parts ))
178
178
assert len (regions ) == 1
179
179
part_variant_counts = np .array (
@@ -238,12 +238,12 @@ def test_partition_invalid_arguments(self):
238
238
@pytest .mark .parametrize ("path" , ["y" , data_path / "xxx" , "/x/y.csi" ])
239
239
def test_missing_index_file (self , path ):
240
240
with pytest .raises (FileNotFoundError , match = "Specified index path" ):
241
- vcf_utils .IndexedVcf (data_path / "sample.vcf.gz" , path )
241
+ vcf_utils .VcfFile (data_path / "sample.vcf.gz" , path )
242
242
243
243
def test_bad_index_format (self ):
244
244
vcf_file = data_path / "sample.vcf.gz"
245
245
with pytest .raises (ValueError , match = "Only .tbi or .csi indexes" ):
246
- vcf_utils .IndexedVcf (vcf_file , vcf_file )
246
+ vcf_utils .VcfFile (vcf_file , vcf_file )
247
247
248
248
@pytest .mark .parametrize (
249
249
"filename" ,
@@ -256,11 +256,11 @@ def test_bad_index_format(self):
256
256
],
257
257
)
258
258
def test_unindexed_single_contig (self , tmp_path , filename ):
259
- f1 = vcf_utils .IndexedVcf (data_path / filename )
259
+ f1 = vcf_utils .VcfFile (data_path / filename )
260
260
assert f1 .index is not None
261
261
copy_path = tmp_path / filename
262
262
shutil .copyfile (data_path / filename , copy_path )
263
- f2 = vcf_utils .IndexedVcf (copy_path )
263
+ f2 = vcf_utils .VcfFile (copy_path )
264
264
assert f2 .index is None
265
265
crc1 = f1 .contig_record_counts ()
266
266
assert len (crc1 ) == 1
@@ -280,7 +280,7 @@ def test_unindexed_single_contig(self, tmp_path, filename):
280
280
def test_unindexed_multi_contig (self , tmp_path , filename ):
281
281
copy_path = tmp_path / filename
282
282
shutil .copyfile (data_path / filename , copy_path )
283
- f = vcf_utils .IndexedVcf (copy_path )
283
+ f = vcf_utils .VcfFile (copy_path )
284
284
with pytest .raises (ValueError , match = "Multi-contig VCFs must be indexed" ):
285
285
list (f .variants ())
286
286
0 commit comments