@@ -95,7 +95,7 @@ def test_contig_record_counts(self, index_file, expected):
95
95
)
96
96
def test_partition_into_one_part (self , index_file , expected ):
97
97
indexed_vcf = self .get_instance (index_file )
98
- regions = indexed_vcf .partition_into_regions (num_parts = 1 )
98
+ regions = list ( indexed_vcf .partition_into_regions (num_parts = 1 ) )
99
99
assert all (isinstance (r , vcf_utils .Region ) for r in regions )
100
100
assert [str (r ) for r in regions ] == expected
101
101
@@ -120,7 +120,7 @@ def test_partition_into_one_part(self, index_file, expected):
120
120
)
121
121
def test_partition_into_max_parts (self , index_file , num_expected , total_records ):
122
122
indexed_vcf = self .get_instance (index_file )
123
- regions = indexed_vcf .partition_into_regions (num_parts = 1000 )
123
+ regions = list ( indexed_vcf .partition_into_regions (num_parts = 1000 ) )
124
124
assert all (isinstance (r , vcf_utils .Region ) for r in regions )
125
125
# print(regions)
126
126
assert len (regions ) == num_expected
@@ -151,7 +151,7 @@ def test_partition_into_max_parts(self, index_file, num_expected, total_records)
151
151
@pytest .mark .parametrize ("num_parts" , [2 , 3 , 4 , 5 , 16 , 33 ])
152
152
def test_partition_into_n_parts (self , index_file , total_records , num_parts ):
153
153
indexed_vcf = self .get_instance (index_file )
154
- regions = indexed_vcf .partition_into_regions (num_parts = num_parts )
154
+ regions = list ( indexed_vcf .partition_into_regions (num_parts = num_parts ) )
155
155
assert all (isinstance (r , vcf_utils .Region ) for r in regions )
156
156
part_variant_counts = np .array (
157
157
[indexed_vcf .count_variants (region ) for region in regions ]
@@ -161,7 +161,7 @@ def test_partition_into_n_parts(self, index_file, total_records, num_parts):
161
161
162
162
def test_tabix_multi_chrom_bug (self ):
163
163
indexed_vcf = self .get_instance ("multi_contig.vcf.gz.tbi" )
164
- regions = indexed_vcf .partition_into_regions (num_parts = 10 )
164
+ regions = list ( indexed_vcf .partition_into_regions (num_parts = 10 ) )
165
165
# An earlier version of the code returned this, i.e. with a duplicate
166
166
# for 4 with end coord of 0
167
167
# ["0:1-", "1", "2", "3", "4:1-0", "4:1-"]
@@ -185,7 +185,9 @@ def test_tabix_multi_chrom_bug(self):
185
185
)
186
186
def test_target_part_size (self , target_part_size , filename ):
187
187
indexed_vcf = self .get_instance (filename )
188
- regions = indexed_vcf .partition_into_regions (target_part_size = target_part_size )
188
+ regions = list (
189
+ indexed_vcf .partition_into_regions (target_part_size = target_part_size )
190
+ )
189
191
assert len (regions ) == 5
190
192
part_variant_counts = [indexed_vcf .count_variants (region ) for region in regions ]
191
193
assert part_variant_counts == [3450 , 3869 , 4525 , 7041 , 1025 ]
@@ -197,7 +199,7 @@ def test_partition_invalid_arguments(self):
197
199
with pytest .raises (
198
200
ValueError , match = r"One of num_parts or target_part_size must be specified"
199
201
):
200
- indexed_vcf .partition_into_regions ()
202
+ list ( indexed_vcf .partition_into_regions () )
201
203
202
204
with pytest .raises (
203
205
ValueError ,
0 commit comments