Commits

Daniel Blankenberg committed 465f234

Add an iterator to AbstractIndexedAccess and AbstractMultiIndexedAccess which returns the index and offset along with the value contained at the offset.

Comments (0)

Files changed (1)

lib/bx/interval_index_file.py

     def get( self, src, start, end ):
         return [block for block in self.get_as_iterator( src, start, end )]
     def get_as_iterator( self, src, start, end ):
+        for block, index, offset in self.get_as_iterator_with_index_and_offset( src, start, end ):
+            yield block
+    def get_as_iterator_with_index_and_offset( self, src, start, end ):
         for index in self.indexes:
-            for block in index.get_as_iterator( src, start, end ):
-                yield block
+            for block, idx, offset in index.get_as_iterator_with_index_and_offset( src, start, end ):
+                yield block, idx, offset
     def close( self ):
         for index in self.indexes:
             index.close()
     def get( self, src, start, end ):
         return [ val for val in self.get_as_iterator( src, start, end ) ]
     def get_as_iterator( self, src, start, end ):
+        for val, index, offset in self.get_as_iterator_with_index_and_offset( src, start, end ):
+            yield val
+    def get_as_iterator_with_index_and_offset( self, src, start, end ):
         for val_start, val_end, val in self.indexes.find( src, start, end ):
-            yield self.get_at_offset( val )
+            yield self.get_at_offset( val ), self, val
 
     def get_at_offset( self, offset ):
         if self.f: