@@ -424,7 +424,6 @@ def sanitise_value_float_1d(shape, value):
424424 value = drop_empty_second_dim (value )
425425 result = np .full (shape , constants .FLOAT32_FILL , dtype = np .float32 )
426426 result [: value .shape [0 ]] = value
427- print (result )
428427 return result
429428
430429
@@ -435,7 +434,6 @@ def sanitise_value_float_2d(shape, value):
435434 value = np .array (value , ndmin = 2 , dtype = np .float32 , copy = True )
436435 result = np .full (shape , constants .FLOAT32_FILL , dtype = np .float32 )
437436 result [:, : value .shape [1 ]] = value
438- print (result )
439437 return result
440438
441439
@@ -943,6 +941,19 @@ def iter_filters(self, start, stop):
943941 ) from None
944942 yield filters
945943
944+ def iter_contig (self , start , stop ):
945+ source_field = self .fields ["CHROM" ]
946+ lookup = {
947+ contig .id : index for index , contig in enumerate (self .metadata .contigs )
948+ }
949+
950+ for value in source_field .iter_values (start , stop ):
951+ # Note: because we are using the indexes to define the lookups
952+ # and we always have an index, it seems that we the contig lookup
953+ # will always succeed. However, if anyone ever does hit a KeyError
954+ # here, please do open an issue with a reproducible example!
955+ yield lookup [value [0 ]]
956+
946957 def iter_field (self , field_name , shape , start , stop ):
947958 source_field = self .fields [field_name ]
948959 sanitiser = source_field .sanitiser_factory (shape )
0 commit comments