Commits

James Taylor committed ca1390b

refactor bigwig support, add more tests

Comments (0)

Files changed (10)

lib/bx/bbi/bbi_file.c

-/* Generated by Cython 0.14.1 on Fri Feb 11 18:47:56 2011 */
+/* Generated by Cython 0.14.1 on Wed Mar 23 16:39:30 2011 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
   double sum_squares;
 };
 
+/* "bx/bbi/bbi_file.pxd":37
+ * cdef class BBIFile
+ * 
+ * cdef class BlockHandler:             # <<<<<<<<<<<<<<
+ *     """
+ *     Callback for `BBIFile.visit_blocks_in_region`
+ */
+
+struct __pyx_obj_2bx_3bbi_8bbi_file_BlockHandler {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_2bx_3bbi_8bbi_file_BlockHandler *__pyx_vtab;
+};
+
 /* "cirtree_file.pxd":3
  * from types cimport *
  * 
 
 struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData {
   PyObject_HEAD
+  __pyx_t_2bx_3bbi_5types_bits32 start;
+  __pyx_t_2bx_3bbi_5types_bits32 end;
   int size;
   PyArrayObject *valid_count;
   PyArrayObject *min_val;
   PyArrayObject *sum_squares;
 };
 
-/* "bx/bbi/bbi_file.pyx":210
+/* "bx/bbi/bbi_file.pyx":261
  *         return closest_level
  * 
  * cdef class ZoomLevel:             # <<<<<<<<<<<<<<
   int item_count;
 };
 
-/* "bx/bbi/bbi_file.pxd":33
+/* "bx/bbi/bbi_file.pxd":35
  *     cdef public numpy.ndarray sum_squares
  * 
- * cdef class BBIFile:             # <<<<<<<<<<<<<<
- *     """
- *     A "big binary indexed" file. Stores blocks of raw data and numeric
+ * cdef class BBIFile             # <<<<<<<<<<<<<<
+ * 
+ * cdef class BlockHandler:
  */
 
 struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile {
 };
 
 
-/* "bx/bbi/bbi_file.pyx":62
- *         self.sum_squares = numpy.zeros( self.size, dtype=numpy.float64 )
+/* "bx/bbi/bbi_file.pyx":95
+ *         pass
  * 
  * cdef class BBIFile:             # <<<<<<<<<<<<<<
  *     """
  */
 
 struct __pyx_vtabstruct_2bx_3bbi_8bbi_file_BBIFile {
+  PyObject *(*visit_blocks_in_region)(struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *, __pyx_t_2bx_3bbi_5types_bits32, __pyx_t_2bx_3bbi_5types_bits32, __pyx_t_2bx_3bbi_5types_bits32, struct __pyx_obj_2bx_3bbi_8bbi_file_BlockHandler *);
   PyObject *(*_get_chrom_id_and_size)(struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *, char *);
   PyObject *(*_best_zoom_level)(struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *, int);
   PyObject *(*summarize)(struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *, char *, __pyx_t_2bx_3bbi_5types_bits32, __pyx_t_2bx_3bbi_5types_bits32, int, int __pyx_skip_dispatch);
 static struct __pyx_vtabstruct_2bx_3bbi_8bbi_file_BBIFile *__pyx_vtabptr_2bx_3bbi_8bbi_file_BBIFile;
 
 
-/* "bx/bbi/bbi_file.pyx":210
+/* "bx/bbi/bbi_file.pyx":88
+ *                     self.min_val[j] = val
+ * 
+ * cdef class BlockHandler:             # <<<<<<<<<<<<<<
+ *     """
+ *     Callback for `BBIFile.visit_blocks_in_region`
+ */
+
+struct __pyx_vtabstruct_2bx_3bbi_8bbi_file_BlockHandler {
+  PyObject *(*handle_block)(struct __pyx_obj_2bx_3bbi_8bbi_file_BlockHandler *, PyObject *, struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *);
+};
+static struct __pyx_vtabstruct_2bx_3bbi_8bbi_file_BlockHandler *__pyx_vtabptr_2bx_3bbi_8bbi_file_BlockHandler;
+
+
+/* "bx/bbi/bbi_file.pyx":261
  *         return closest_level
  * 
  * cdef class ZoomLevel:             # <<<<<<<<<<<<<<
 
 static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
 
+static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
+    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
+
 static void __Pyx_RaiseDoubleKeywordsError(
     const char* func_name, PyObject* kw_name); /*proto*/
 
 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
 
-static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
-    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
-
 static CYTHON_INLINE int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
 
 static CYTHON_INLINE PyObject* __Pyx_PyObject_Append(PyObject* L, PyObject* x) {
 static PyTypeObject *__pyx_ptype_2bx_3bbi_8bbi_file_SummaryBlock = 0;
 static PyTypeObject *__pyx_ptype_2bx_3bbi_8bbi_file_SummarizedData = 0;
 static PyTypeObject *__pyx_ptype_2bx_3bbi_8bbi_file_BBIFile = 0;
+static PyTypeObject *__pyx_ptype_2bx_3bbi_8bbi_file_BlockHandler = 0;
 static PyTypeObject *__pyx_ptype_2bx_3bbi_8bbi_file_ZoomLevel = 0;
 DL_EXPORT(int) big_wig_sig;
 DL_EXPORT(int) big_bed_sig;
 static char __pyx_k_1[] = "unzoomed_data_offset";
 static char __pyx_k_2[] = "unzoomed_index_offset";
 static char __pyx_k_3[] = "total_summary_offset";
-static char __pyx_k_5[] = "_get_chrom_id_and_size";
-static char __pyx_k_6[] = "_summarize_from_full";
-static char __pyx_k_8[] = "find_overlapping_blocks";
+static char __pyx_k_5[] = "find_overlapping_blocks";
+static char __pyx_k_6[] = "_get_chrom_id_and_size";
+static char __pyx_k_7[] = "_summarize_from_full";
 static char __pyx_k_9[] = "_summary_blocks_in_region";
 static char __pyx_k_10[] = "ndarray is not C contiguous";
 static char __pyx_k_12[] = "ndarray is not Fortran contiguous";
 static char __pyx_k__Q[] = "Q";
 static char __pyx_k__b[] = "b";
 static char __pyx_k__d[] = "d";
+static char __pyx_k__e[] = "e";
 static char __pyx_k__f[] = "f";
 static char __pyx_k__g[] = "g";
 static char __pyx_k__h[] = "h";
 static char __pyx_k__i[] = "i";
 static char __pyx_k__l[] = "l";
 static char __pyx_k__q[] = "q";
+static char __pyx_k__s[] = "s";
 static char __pyx_k__II[] = "II";
 static char __pyx_k__Zd[] = "Zd";
 static char __pyx_k__Zf[] = "Zf";
 static char __pyx_k__min[] = "min";
 static char __pyx_k__nan[] = "nan";
 static char __pyx_k__obj[] = "obj";
+static char __pyx_k__val[] = "val";
 static char __pyx_k__base[] = "base";
 static char __pyx_k__file[] = "file";
 static char __pyx_k__find[] = "find";
 static char __pyx_k__zoom_levels[] = "zoom_levels";
 static char __pyx_k__RuntimeError[] = "RuntimeError";
 static char __pyx_k__expected_sig[] = "expected_sig";
+static char __pyx_k__handle_block[] = "handle_block";
 static char __pyx_k__index_offset[] = "index_offset";
 static char __pyx_k__summary_size[] = "summary_size";
 static char __pyx_k__is_byteswapped[] = "is_byteswapped";
 static PyObject *__pyx_n_s_3;
 static PyObject *__pyx_n_s_5;
 static PyObject *__pyx_n_s_6;
-static PyObject *__pyx_n_s_8;
+static PyObject *__pyx_n_s_7;
 static PyObject *__pyx_n_s_9;
 static PyObject *__pyx_n_s__BinaryFileReader;
 static PyObject *__pyx_n_s__II;
 static PyObject *__pyx_n_s__deque;
 static PyObject *__pyx_n_s__descr;
 static PyObject *__pyx_n_s__dtype;
+static PyObject *__pyx_n_s__e;
 static PyObject *__pyx_n_s__end;
 static PyObject *__pyx_n_s__expected_sig;
 static PyObject *__pyx_n_s__field_count;
 static PyObject *__pyx_n_s__find;
 static PyObject *__pyx_n_s__float64;
 static PyObject *__pyx_n_s__format;
+static PyObject *__pyx_n_s__handle_block;
 static PyObject *__pyx_n_s__index_offset;
 static PyObject *__pyx_n_s__is_byteswapped;
 static PyObject *__pyx_n_s__is_little_endian;
 static PyObject *__pyx_n_s__readonly;
 static PyObject *__pyx_n_s__reduction_level;
 static PyObject *__pyx_n_s__reserved;
+static PyObject *__pyx_n_s__s;
 static PyObject *__pyx_n_s__seek;
 static PyObject *__pyx_n_s__shape;
 static PyObject *__pyx_n_s__size;
 static PyObject *__pyx_n_s__type_num;
 static PyObject *__pyx_n_s__uncompress_buf_size;
 static PyObject *__pyx_n_s__unpack;
+static PyObject *__pyx_n_s__val;
 static PyObject *__pyx_n_s__valid_count;
 static PyObject *__pyx_n_s__version;
 static PyObject *__pyx_n_s__zeros;
 static PyObject *__pyx_int_32;
 static PyObject *__pyx_int_64;
 static PyObject *__pyx_k_tuple_4;
-static PyObject *__pyx_k_tuple_7;
+static PyObject *__pyx_k_tuple_8;
 static PyObject *__pyx_k_tuple_11;
 static PyObject *__pyx_k_tuple_13;
 static PyObject *__pyx_k_tuple_15;
 /* "bx/bbi/bbi_file.pyx":54
  *     aggregation over a particular range and resolution
  *     """
- *     def __init__( self, int size ):             # <<<<<<<<<<<<<<
- *         self.size = size
- *         self.valid_count = numpy.zeros( self.size, dtype=numpy.float64 )
+ *     def __init__( self, bits32 start, bits32 end, int size ):             # <<<<<<<<<<<<<<
+ *         self.start = start
+ *         self.end = end
  */
 
 static int __pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
 static int __pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  __pyx_t_2bx_3bbi_5types_bits32 __pyx_v_start;
+  __pyx_t_2bx_3bbi_5types_bits32 __pyx_v_end;
   int __pyx_v_size;
   int __pyx_r;
   PyObject *__pyx_t_1 = NULL;
   PyObject *__pyx_t_3 = NULL;
   PyObject *__pyx_t_4 = NULL;
   PyObject *__pyx_t_5 = NULL;
-  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__size,0};
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__size,0};
   __Pyx_RefNannySetupContext("__init__");
   if (unlikely(__pyx_kwds)) {
     Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
-    PyObject* values[1] = {0};
+    PyObject* values[3] = {0,0,0};
     switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
       case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
       case  0: break;
       default: goto __pyx_L5_argtuple_error;
     }
     switch (PyTuple_GET_SIZE(__pyx_args)) {
       case  0:
-      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__size);
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__start);
       if (likely(values[0])) kw_args--;
       else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__size);
+      if (likely(values[2])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
     }
     if (unlikely(kw_args > 0)) {
       if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
-    __pyx_v_size = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-  } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
+    __pyx_v_start = __Pyx_PyInt_AsUnsignedInt(values[0]); if (unlikely((__pyx_v_start == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_end = __Pyx_PyInt_AsUnsignedInt(values[1]); if (unlikely((__pyx_v_end == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_size = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
     goto __pyx_L5_argtuple_error;
   } else {
-    __pyx_v_size = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_start = __Pyx_PyInt_AsUnsignedInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_start == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_end = __Pyx_PyInt_AsUnsignedInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_end == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_size = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__init__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__init__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 54; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("bx.bbi.bbi_file.SummarizedData.__init__");
   __Pyx_RefNannyFinishContext();
 
   /* "bx/bbi/bbi_file.pyx":55
  *     """
- *     def __init__( self, int size ):
+ *     def __init__( self, bits32 start, bits32 end, int size ):
+ *         self.start = start             # <<<<<<<<<<<<<<
+ *         self.end = end
+ *         self.size = size
+ */
+  ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->start = __pyx_v_start;
+
+  /* "bx/bbi/bbi_file.pyx":56
+ *     def __init__( self, bits32 start, bits32 end, int size ):
+ *         self.start = start
+ *         self.end = end             # <<<<<<<<<<<<<<
+ *         self.size = size
+ *         self.valid_count = numpy.zeros( self.size, dtype=numpy.float64 )
+ */
+  ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->end = __pyx_v_end;
+
+  /* "bx/bbi/bbi_file.pyx":57
+ *         self.start = start
+ *         self.end = end
  *         self.size = size             # <<<<<<<<<<<<<<
  *         self.valid_count = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.min_val = numpy.zeros( self.size, dtype=numpy.float64 )
  */
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size = __pyx_v_size;
 
-  /* "bx/bbi/bbi_file.pyx":56
- *     def __init__( self, int size ):
+  /* "bx/bbi/bbi_file.pyx":58
+ *         self.end = end
  *         self.size = size
  *         self.valid_count = numpy.zeros( self.size, dtype=numpy.float64 )             # <<<<<<<<<<<<<<
  *         self.min_val = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.max_val = numpy.zeros( self.size, dtype=numpy.float64 )
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_3));
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-  __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GIVEREF(__pyx_t_5);
   __Pyx_GOTREF(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->valid_count);
   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->valid_count));
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->valid_count = ((PyArrayObject *)__pyx_t_5);
   __pyx_t_5 = 0;
 
-  /* "bx/bbi/bbi_file.pyx":57
+  /* "bx/bbi/bbi_file.pyx":59
  *         self.size = size
  *         self.valid_count = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.min_val = numpy.zeros( self.size, dtype=numpy.float64 )             # <<<<<<<<<<<<<<
  *         self.max_val = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.sum_data = numpy.zeros( self.size, dtype=numpy.float64 )
  */
-  __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__zeros); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__zeros); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-  __pyx_t_5 = PyInt_FromLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyInt_FromLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_3));
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_5);
   __Pyx_GIVEREF(__pyx_t_5);
   __pyx_t_5 = 0;
-  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyDict_New(); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__float64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__float64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__dtype), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __pyx_t_4 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyEval_CallObjectWithKeywords(__pyx_t_1, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
-  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 57; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(((__pyx_t_4) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GIVEREF(__pyx_t_4);
   __Pyx_GOTREF(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->min_val);
   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->min_val));
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->min_val = ((PyArrayObject *)__pyx_t_4);
   __pyx_t_4 = 0;
 
-  /* "bx/bbi/bbi_file.pyx":58
+  /* "bx/bbi/bbi_file.pyx":60
  *         self.valid_count = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.min_val = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.max_val = numpy.zeros( self.size, dtype=numpy.float64 )             # <<<<<<<<<<<<<<
  *         self.sum_data = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.sum_squares = numpy.zeros( self.size, dtype=numpy.float64 )
  */
-  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__zeros); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__zeros); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __pyx_t_4 = PyInt_FromLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyInt_FromLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_3));
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4);
   __Pyx_GIVEREF(__pyx_t_4);
   __pyx_t_4 = 0;
-  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__float64); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__float64); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__dtype), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyEval_CallObjectWithKeywords(__pyx_t_5, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyEval_CallObjectWithKeywords(__pyx_t_5, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
-  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GIVEREF(__pyx_t_2);
   __Pyx_GOTREF(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->max_val);
   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->max_val));
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->max_val = ((PyArrayObject *)__pyx_t_2);
   __pyx_t_2 = 0;
 
-  /* "bx/bbi/bbi_file.pyx":59
+  /* "bx/bbi/bbi_file.pyx":61
  *         self.min_val = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.max_val = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.sum_data = numpy.zeros( self.size, dtype=numpy.float64 )             # <<<<<<<<<<<<<<
  *         self.sum_squares = numpy.zeros( self.size, dtype=numpy.float64 )
- * 
- */
-  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ *     def accumulate_interval_value( self, bits32 s, bits32 e, float val ):
+ */
+  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__zeros); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_3));
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
   __pyx_t_2 = 0;
-  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__float64); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__float64); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__dtype), __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_t_4, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyEval_CallObjectWithKeywords(__pyx_t_4, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(((__pyx_t_1) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GIVEREF(__pyx_t_1);
   __Pyx_GOTREF(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->sum_data);
   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->sum_data));
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->sum_data = ((PyArrayObject *)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "bx/bbi/bbi_file.pyx":60
+  /* "bx/bbi/bbi_file.pyx":62
  *         self.max_val = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.sum_data = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.sum_squares = numpy.zeros( self.size, dtype=numpy.float64 )             # <<<<<<<<<<<<<<
- * 
- * cdef class BBIFile:
- */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ *     def accumulate_interval_value( self, bits32 s, bits32 e, float val ):
+ *         # Trim interval down to region of interest
+ */
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__zeros); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_3));
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-  __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyEval_CallObjectWithKeywords(__pyx_t_2, ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(((__pyx_t_5) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_5, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GIVEREF(__pyx_t_5);
   __Pyx_GOTREF(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->sum_squares);
   __Pyx_DECREF(((PyObject *)((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->sum_squares));
   return __pyx_r;
 }
 
+/* "bx/bbi/bbi_file.pyx":63
+ *         self.sum_data = numpy.zeros( self.size, dtype=numpy.float64 )
+ *         self.sum_squares = numpy.zeros( self.size, dtype=numpy.float64 )
+ *     def accumulate_interval_value( self, bits32 s, bits32 e, float val ):             # <<<<<<<<<<<<<<
+ *         # Trim interval down to region of interest
+ *         if s < self.start:
+ */
+
+static PyObject *__pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData_1accumulate_interval_value(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyObject *__pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData_1accumulate_interval_value(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  __pyx_t_2bx_3bbi_5types_bits32 __pyx_v_s;
+  __pyx_t_2bx_3bbi_5types_bits32 __pyx_v_e;
+  float __pyx_v_val;
+  PyObject *__pyx_v_base_step;
+  PyObject *__pyx_v_j;
+  PyObject *__pyx_v_base_start;
+  PyObject *__pyx_v_base_end;
+  int __pyx_v_overlap;
+  PyObject *__pyx_v_interval_size;
+  PyObject *__pyx_v_overlap_factor;
+  PyObject *__pyx_v_interval_weight;
+  PyObject *__pyx_r = NULL;
+  int __pyx_t_1;
+  __pyx_t_2bx_3bbi_5types_bits32 __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  long __pyx_t_5;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  int __pyx_t_8;
+  int __pyx_t_9;
+  PyArrayObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__s,&__pyx_n_s__e,&__pyx_n_s__val,0};
+  __Pyx_RefNannySetupContext("accumulate_interval_value");
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[3] = {0,0,0};
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__s);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__e);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("accumulate_interval_value", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__val);
+      if (likely(values[2])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("accumulate_interval_value", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "accumulate_interval_value") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_s = __Pyx_PyInt_AsUnsignedInt(values[0]); if (unlikely((__pyx_v_s == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_e = __Pyx_PyInt_AsUnsignedInt(values[1]); if (unlikely((__pyx_v_e == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_val = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_val == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
+    goto __pyx_L5_argtuple_error;
+  } else {
+    __pyx_v_s = __Pyx_PyInt_AsUnsignedInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_s == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_e = __Pyx_PyInt_AsUnsignedInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_e == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_val = __pyx_PyFloat_AsDouble(PyTuple_GET_ITEM(__pyx_args, 2)); if (unlikely((__pyx_v_val == (float)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("accumulate_interval_value", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 63; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("bx.bbi.bbi_file.SummarizedData.accumulate_interval_value");
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_v_base_step = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_j = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_base_start = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_base_end = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_interval_size = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_overlap_factor = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_interval_weight = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "bx/bbi/bbi_file.pyx":65
+ *     def accumulate_interval_value( self, bits32 s, bits32 e, float val ):
+ *         # Trim interval down to region of interest
+ *         if s < self.start:             # <<<<<<<<<<<<<<
+ *             s = self.start
+ *         if e > self.end:
+ */
+  __pyx_t_1 = (__pyx_v_s < ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->start);
+  if (__pyx_t_1) {
+
+    /* "bx/bbi/bbi_file.pyx":66
+ *         # Trim interval down to region of interest
+ *         if s < self.start:
+ *             s = self.start             # <<<<<<<<<<<<<<
+ *         if e > self.end:
+ *             e = self.end
+ */
+    __pyx_v_s = ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->start;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "bx/bbi/bbi_file.pyx":67
+ *         if s < self.start:
+ *             s = self.start
+ *         if e > self.end:             # <<<<<<<<<<<<<<
+ *             e = self.end
+ *         if s >= e:
+ */
+  __pyx_t_1 = (__pyx_v_e > ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->end);
+  if (__pyx_t_1) {
+
+    /* "bx/bbi/bbi_file.pyx":68
+ *             s = self.start
+ *         if e > self.end:
+ *             e = self.end             # <<<<<<<<<<<<<<
+ *         if s >= e:
+ *             return
+ */
+    __pyx_v_e = ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->end;
+    goto __pyx_L7;
+  }
+  __pyx_L7:;
+
+  /* "bx/bbi/bbi_file.pyx":69
+ *         if e > self.end:
+ *             e = self.end
+ *         if s >= e:             # <<<<<<<<<<<<<<
+ *             return
+ *         base_step = ( self.end - self.start ) / self.size
+ */
+  __pyx_t_1 = (__pyx_v_s >= __pyx_v_e);
+  if (__pyx_t_1) {
+
+    /* "bx/bbi/bbi_file.pyx":70
+ *             e = self.end
+ *         if s >= e:
+ *             return             # <<<<<<<<<<<<<<
+ *         base_step = ( self.end - self.start ) / self.size
+ *         for j from 0 <= j < self.size:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+    goto __pyx_L0;
+    goto __pyx_L8;
+  }
+  __pyx_L8:;
+
+  /* "bx/bbi/bbi_file.pyx":71
+ *         if s >= e:
+ *             return
+ *         base_step = ( self.end - self.start ) / self.size             # <<<<<<<<<<<<<<
+ *         for j from 0 <= j < self.size:
+ *             base_start = self.start + ( base_step * j )
+ */
+  __pyx_t_2 = (((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->end - ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->start);
+  if (unlikely(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size == 0)) {
+    PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero");
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_t_3 = PyLong_FromUnsignedLong((__pyx_t_2 / ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_v_base_step);
+  __pyx_v_base_step = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "bx/bbi/bbi_file.pyx":72
+ *             return
+ *         base_step = ( self.end - self.start ) / self.size
+ *         for j from 0 <= j < self.size:             # <<<<<<<<<<<<<<
+ *             base_start = self.start + ( base_step * j )
+ *             base_end = base_start + base_step
+ */
+  __pyx_t_4 = ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size;
+  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5++) {
+    __pyx_t_3 = PyInt_FromLong(__pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_v_j);
+    __pyx_v_j = __pyx_t_3;
+    __pyx_t_3 = 0;
+
+    /* "bx/bbi/bbi_file.pyx":73
+ *         base_step = ( self.end - self.start ) / self.size
+ *         for j from 0 <= j < self.size:
+ *             base_start = self.start + ( base_step * j )             # <<<<<<<<<<<<<<
+ *             base_end = base_start + base_step
+ *             overlap = range_intersection( base_start, base_end, s, e )
+ */
+    __pyx_t_3 = PyLong_FromUnsignedLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->start); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_6 = PyNumber_Multiply(__pyx_v_base_step, __pyx_v_j); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_7 = PyNumber_Add(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_v_base_start);
+    __pyx_v_base_start = __pyx_t_7;
+    __pyx_t_7 = 0;
+
+    /* "bx/bbi/bbi_file.pyx":74
+ *         for j from 0 <= j < self.size:
+ *             base_start = self.start + ( base_step * j )
+ *             base_end = base_start + base_step             # <<<<<<<<<<<<<<
+ *             overlap = range_intersection( base_start, base_end, s, e )
+ *             if overlap > 0:
+ */
+    __pyx_t_7 = PyNumber_Add(__pyx_v_base_start, __pyx_v_base_step); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_v_base_end);
+    __pyx_v_base_end = __pyx_t_7;
+    __pyx_t_7 = 0;
+
+    /* "bx/bbi/bbi_file.pyx":75
+ *             base_start = self.start + ( base_step * j )
+ *             base_end = base_start + base_step
+ *             overlap = range_intersection( base_start, base_end, s, e )             # <<<<<<<<<<<<<<
+ *             if overlap > 0:
+ *                 interval_size = e - s
+ */
+    __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_v_base_start); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_v_base_end); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_v_overlap = __pyx_f_2bx_3bbi_8bbi_file_range_intersection(__pyx_t_8, __pyx_t_9, __pyx_v_s, __pyx_v_e);
+
+    /* "bx/bbi/bbi_file.pyx":76
+ *             base_end = base_start + base_step
+ *             overlap = range_intersection( base_start, base_end, s, e )
+ *             if overlap > 0:             # <<<<<<<<<<<<<<
+ *                 interval_size = e - s
+ *                 overlap_factor = <double> overlap / interval_size
+ */
+    __pyx_t_1 = (__pyx_v_overlap > 0);
+    if (__pyx_t_1) {
+
+      /* "bx/bbi/bbi_file.pyx":77
+ *             overlap = range_intersection( base_start, base_end, s, e )
+ *             if overlap > 0:
+ *                 interval_size = e - s             # <<<<<<<<<<<<<<
+ *                 overlap_factor = <double> overlap / interval_size
+ *                 interval_weight = interval_size * overlap_factor
+ */
+      __pyx_t_7 = PyLong_FromUnsignedLong((__pyx_v_e - __pyx_v_s)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_v_interval_size);
+      __pyx_v_interval_size = __pyx_t_7;
+      __pyx_t_7 = 0;
+
+      /* "bx/bbi/bbi_file.pyx":78
+ *             if overlap > 0:
+ *                 interval_size = e - s
+ *                 overlap_factor = <double> overlap / interval_size             # <<<<<<<<<<<<<<
+ *                 interval_weight = interval_size * overlap_factor
+ *                 self.valid_count[j] += interval_weight
+ */
+      __pyx_t_7 = PyFloat_FromDouble(((double)__pyx_v_overlap)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_6 = __Pyx_PyNumber_Divide(__pyx_t_7, __pyx_v_interval_size); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_DECREF(__pyx_v_overlap_factor);
+      __pyx_v_overlap_factor = __pyx_t_6;
+      __pyx_t_6 = 0;
+
+      /* "bx/bbi/bbi_file.pyx":79
+ *                 interval_size = e - s
+ *                 overlap_factor = <double> overlap / interval_size
+ *                 interval_weight = interval_size * overlap_factor             # <<<<<<<<<<<<<<
+ *                 self.valid_count[j] += interval_weight
+ *                 self.sum_data[j] += val * interval_weight
+ */
+      __pyx_t_6 = PyNumber_Multiply(__pyx_v_interval_size, __pyx_v_overlap_factor); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_v_interval_weight);
+      __pyx_v_interval_weight = __pyx_t_6;
+      __pyx_t_6 = 0;
+
+      /* "bx/bbi/bbi_file.pyx":80
+ *                 overlap_factor = <double> overlap / interval_size
+ *                 interval_weight = interval_size * overlap_factor
+ *                 self.valid_count[j] += interval_weight             # <<<<<<<<<<<<<<
+ *                 self.sum_data[j] += val * interval_weight
+ *                 self.sum_squares[j] += val * val * interval_weight
+ */
+      __Pyx_INCREF(((PyObject *)((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->valid_count));
+      __pyx_t_10 = ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->valid_count;
+      __Pyx_INCREF(__pyx_v_j);
+      __pyx_t_6 = __pyx_v_j;
+      __pyx_t_7 = PyObject_GetItem(((PyObject *)__pyx_t_10), __pyx_t_6); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_v_interval_weight); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      if (PyObject_SetItem(((PyObject *)__pyx_t_10), __pyx_t_6, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
+
+      /* "bx/bbi/bbi_file.pyx":81
+ *                 interval_weight = interval_size * overlap_factor
+ *                 self.valid_count[j] += interval_weight
+ *                 self.sum_data[j] += val * interval_weight             # <<<<<<<<<<<<<<
+ *                 self.sum_squares[j] += val * val * interval_weight
+ *                 if self.max_val[j] < val:
+ */
+      __Pyx_INCREF(((PyObject *)((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->sum_data));
+      __pyx_t_10 = ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->sum_data;
+      __Pyx_INCREF(__pyx_v_j);
+      __pyx_t_6 = __pyx_v_j;
+      __pyx_t_3 = PyObject_GetItem(((PyObject *)__pyx_t_10), __pyx_t_6); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_7 = PyFloat_FromDouble(__pyx_v_val); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_11 = PyNumber_Multiply(__pyx_t_7, __pyx_v_interval_weight); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_t_11); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      if (PyObject_SetItem(((PyObject *)__pyx_t_10), __pyx_t_6, __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
+
+      /* "bx/bbi/bbi_file.pyx":82
+ *                 self.valid_count[j] += interval_weight
+ *                 self.sum_data[j] += val * interval_weight
+ *                 self.sum_squares[j] += val * val * interval_weight             # <<<<<<<<<<<<<<
+ *                 if self.max_val[j] < val:
+ *                     self.max_val[j] = val
+ */
+      __Pyx_INCREF(((PyObject *)((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->sum_squares));
+      __pyx_t_10 = ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->sum_squares;
+      __Pyx_INCREF(__pyx_v_j);
+      __pyx_t_6 = __pyx_v_j;
+      __pyx_t_7 = PyObject_GetItem(((PyObject *)__pyx_t_10), __pyx_t_6); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __pyx_t_11 = PyFloat_FromDouble((__pyx_v_val * __pyx_v_val)); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __pyx_t_3 = PyNumber_Multiply(__pyx_t_11, __pyx_v_interval_weight); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      __pyx_t_11 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_t_3); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      if (PyObject_SetItem(((PyObject *)__pyx_t_10), __pyx_t_6, __pyx_t_11) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
+
+      /* "bx/bbi/bbi_file.pyx":83
+ *                 self.sum_data[j] += val * interval_weight
+ *                 self.sum_squares[j] += val * val * interval_weight
+ *                 if self.max_val[j] < val:             # <<<<<<<<<<<<<<
+ *                     self.max_val[j] = val
+ *                 if self.min_val[j] > val:
+ */
+      __pyx_t_6 = PyObject_GetItem(((PyObject *)((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->max_val), __pyx_v_j); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __pyx_t_11 = PyFloat_FromDouble(__pyx_v_val); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __pyx_t_3 = PyObject_RichCompare(__pyx_t_6, __pyx_t_11, Py_LT); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      if (__pyx_t_1) {
+
+        /* "bx/bbi/bbi_file.pyx":84
+ *                 self.sum_squares[j] += val * val * interval_weight
+ *                 if self.max_val[j] < val:
+ *                     self.max_val[j] = val             # <<<<<<<<<<<<<<
+ *                 if self.min_val[j] > val:
+ *                     self.min_val[j] = val
+ */
+        __pyx_t_3 = PyFloat_FromDouble(__pyx_v_val); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_3);
+        if (PyObject_SetItem(((PyObject *)((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->max_val), __pyx_v_j, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+        goto __pyx_L12;
+      }
+      __pyx_L12:;
+
+      /* "bx/bbi/bbi_file.pyx":85
+ *                 if self.max_val[j] < val:
+ *                     self.max_val[j] = val
+ *                 if self.min_val[j] > val:             # <<<<<<<<<<<<<<
+ *                     self.min_val[j] = val
+ * 
+ */
+      __pyx_t_3 = PyObject_GetItem(((PyObject *)((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->min_val), __pyx_v_j); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_11 = PyFloat_FromDouble(__pyx_v_val); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_11);
+      __pyx_t_6 = PyObject_RichCompare(__pyx_t_3, __pyx_t_11, Py_GT); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
+      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      if (__pyx_t_1) {
+
+        /* "bx/bbi/bbi_file.pyx":86
+ *                     self.max_val[j] = val
+ *                 if self.min_val[j] > val:
+ *                     self.min_val[j] = val             # <<<<<<<<<<<<<<
+ * 
+ * cdef class BlockHandler:
+ */
+        __pyx_t_6 = PyFloat_FromDouble(__pyx_v_val); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
+        if (PyObject_SetItem(((PyObject *)((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->min_val), __pyx_v_j, __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        goto __pyx_L13;
+      }
+      __pyx_L13:;
+      goto __pyx_L11;
+    }
+    __pyx_L11:;
+    __pyx_t_5 = __Pyx_PyInt_AsLong(__pyx_v_j); if (unlikely((__pyx_t_5 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+
+  /* "bx/bbi/bbi_file.pyx":72
+ *             return
+ *         base_step = ( self.end - self.start ) / self.size
+ *         for j from 0 <= j < self.size:             # <<<<<<<<<<<<<<
+ *             base_start = self.start + ( base_step * j )
+ *             base_end = base_start + base_step
+ */
+  __pyx_t_6 = PyInt_FromLong(__pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_DECREF(__pyx_v_j);
+  __pyx_v_j = __pyx_t_6;
+  __pyx_t_6 = 0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(((PyObject *)__pyx_t_10));
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_AddTraceback("bx.bbi.bbi_file.SummarizedData.accumulate_interval_value");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_DECREF(__pyx_v_base_step);
+  __Pyx_DECREF(__pyx_v_j);
+  __Pyx_DECREF(__pyx_v_base_start);
+  __Pyx_DECREF(__pyx_v_base_end);
+  __Pyx_DECREF(__pyx_v_interval_size);
+  __Pyx_DECREF(__pyx_v_overlap_factor);
+  __Pyx_DECREF(__pyx_v_interval_weight);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
 /* "bx/bbi/bbi_file.pxd":26
  *     aggregation over a particular range and resolution
  *     """
+ *     cdef public bits32 start             # <<<<<<<<<<<<<<
+ *     cdef public bits32 end
+ *     cdef public int size
+ */
+
+static PyObject *__pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData_5start___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData_5start___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyLong_FromUnsignedLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("bx.bbi.bbi_file.SummarizedData.start.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData_5start_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData_5start_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  __pyx_t_2bx_3bbi_5types_bits32 __pyx_t_1;
+  __Pyx_RefNannySetupContext("__set__");
+  __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->start = __pyx_t_1;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("bx.bbi.bbi_file.SummarizedData.start.__set__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "bx/bbi/bbi_file.pxd":27
+ *     """
+ *     cdef public bits32 start
+ *     cdef public bits32 end             # <<<<<<<<<<<<<<
+ *     cdef public int size
+ *     cdef public numpy.ndarray valid_count
+ */
+
+static PyObject *__pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData_3end___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData_3end___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  __Pyx_RefNannySetupContext("__get__");
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyLong_FromUnsignedLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->end); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("bx.bbi.bbi_file.SummarizedData.end.__get__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData_3end_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData_3end_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  __pyx_t_2bx_3bbi_5types_bits32 __pyx_t_1;
+  __Pyx_RefNannySetupContext("__set__");
+  __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->end = __pyx_t_1;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("bx.bbi.bbi_file.SummarizedData.end.__set__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "bx/bbi/bbi_file.pxd":28
+ *     cdef public bits32 start
+ *     cdef public bits32 end
  *     cdef public int size             # <<<<<<<<<<<<<<
  *     cdef public numpy.ndarray valid_count
  *     cdef public numpy.ndarray min_val
   PyObject *__pyx_t_1 = NULL;
   __Pyx_RefNannySetupContext("__get__");
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
   int __pyx_r;
   int __pyx_t_1;
   __Pyx_RefNannySetupContext("__set__");
-  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size = __pyx_t_1;
 
   __pyx_r = 0;
   return __pyx_r;
 }
 
-/* "bx/bbi/bbi_file.pxd":27
- *     """
+/* "bx/bbi/bbi_file.pxd":29
+ *     cdef public bits32 end
  *     cdef public int size
  *     cdef public numpy.ndarray valid_count             # <<<<<<<<<<<<<<
  *     cdef public numpy.ndarray min_val
 static int __pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData_11valid_count_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
   int __pyx_r;
   __Pyx_RefNannySetupContext("__set__");
-  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_INCREF(__pyx_v_value);
   __Pyx_GIVEREF(__pyx_v_value);
   __Pyx_GOTREF(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->valid_count);
   return __pyx_r;
 }
 
-/* "bx/bbi/bbi_file.pxd":28
+/* "bx/bbi/bbi_file.pxd":30
  *     cdef public int size
  *     cdef public numpy.ndarray valid_count
  *     cdef public numpy.ndarray min_val             # <<<<<<<<<<<<<<
 static int __pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData_7min_val_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
   int __pyx_r;
   __Pyx_RefNannySetupContext("__set__");
-  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_INCREF(__pyx_v_value);
   __Pyx_GIVEREF(__pyx_v_value);
   __Pyx_GOTREF(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->min_val);
   return __pyx_r;
 }
 
-/* "bx/bbi/bbi_file.pxd":29
+/* "bx/bbi/bbi_file.pxd":31
  *     cdef public numpy.ndarray valid_count
  *     cdef public numpy.ndarray min_val
  *     cdef public numpy.ndarray max_val             # <<<<<<<<<<<<<<
 static int __pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData_7max_val_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
   int __pyx_r;
   __Pyx_RefNannySetupContext("__set__");
-  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_INCREF(__pyx_v_value);
   __Pyx_GIVEREF(__pyx_v_value);
   __Pyx_GOTREF(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->max_val);
   return __pyx_r;
 }
 
-/* "bx/bbi/bbi_file.pxd":30
+/* "bx/bbi/bbi_file.pxd":32
  *     cdef public numpy.ndarray min_val
  *     cdef public numpy.ndarray max_val
  *     cdef public numpy.ndarray sum_data             # <<<<<<<<<<<<<<
 static int __pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData_8sum_data_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
   int __pyx_r;
   __Pyx_RefNannySetupContext("__set__");
-  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_INCREF(__pyx_v_value);
   __Pyx_GIVEREF(__pyx_v_value);
   __Pyx_GOTREF(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->sum_data);
   return __pyx_r;
 }
 
-/* "bx/bbi/bbi_file.pxd":31
+/* "bx/bbi/bbi_file.pxd":33
  *     cdef public numpy.ndarray max_val
  *     cdef public numpy.ndarray sum_data
  *     cdef public numpy.ndarray sum_squares             # <<<<<<<<<<<<<<
  * 
- * cdef class BBIFile:
+ * cdef class BBIFile
  */
 
 static PyObject *__pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData_11sum_squares___get__(PyObject *__pyx_v_self); /*proto*/
 static int __pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData_11sum_squares_1__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
   int __pyx_r;
   __Pyx_RefNannySetupContext("__set__");
-  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 31; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(((__pyx_v_value) == Py_None) || likely(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_5numpy_ndarray))))) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_INCREF(__pyx_v_value);
   __Pyx_GIVEREF(__pyx_v_value);
   __Pyx_GOTREF(((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->sum_squares);
   return __pyx_r;
 }
 
-/* "bx/bbi/bbi_file.pyx":69
+/* "bx/bbi/bbi_file.pyx":92
+ *     Callback for `BBIFile.visit_blocks_in_region`
+ *     """
+ *     cdef handle_block( self, str block_data, BBIFile bbi_file ):             # <<<<<<<<<<<<<<
+ *         pass
+ * 
+ */
+
+static  PyObject *__pyx_f_2bx_3bbi_8bbi_file_12BlockHandler_handle_block(struct __pyx_obj_2bx_3bbi_8bbi_file_BlockHandler *__pyx_v_self, PyObject *__pyx_v_block_data, struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *__pyx_v_bbi_file) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannySetupContext("handle_block");
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "bx/bbi/bbi_file.pyx":102
  *     """
  * 
  *     def __init__( self, file=None, expected_sig=None, type_name=None ):             # <<<<<<<<<<<<<<
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_file = values[0];
     __pyx_v_expected_sig = values[1];
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__init__", 0, 0, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("bx.bbi.bbi_file.BBIFile.__init__");
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "bx/bbi/bbi_file.pyx":70
+  /* "bx/bbi/bbi_file.pyx":103
  * 
  *     def __init__( self, file=None, expected_sig=None, type_name=None ):
  *         if file is not None:             # <<<<<<<<<<<<<<
   __pyx_t_1 = (__pyx_v_file != Py_None);
   if (__pyx_t_1) {
 
-    /* "bx/bbi/bbi_file.pyx":71
+    /* "bx/bbi/bbi_file.pyx":104
  *     def __init__( self, file=None, expected_sig=None, type_name=None ):
  *         if file is not None:
  *             self.open( file, expected_sig, type_name )             # <<<<<<<<<<<<<<
  * 
  *     def open( self, file, expected_sig, type_name ):
  */
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__open); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__open); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyTuple_New(3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
     __Pyx_INCREF(__pyx_v_file);
     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_file);
     __Pyx_INCREF(__pyx_v_type_name);
     PyTuple_SET_ITEM(__pyx_t_3, 2, __pyx_v_type_name);
     __Pyx_GIVEREF(__pyx_v_type_name);
-    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
   return __pyx_r;
 }
 
-/* "bx/bbi/bbi_file.pyx":73
+/* "bx/bbi/bbi_file.pyx":106
  *             self.open( file, expected_sig, type_name )
  * 
  *     def open( self, file, expected_sig, type_name ):             # <<<<<<<<<<<<<<
       values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__expected_sig);
       if (likely(values[1])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("open", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("open", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
       case  2:
       values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__type_name);
       if (likely(values[2])) kw_args--;
       else {
-        __Pyx_RaiseArgtupleInvalid("open", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        __Pyx_RaiseArgtupleInvalid("open", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     }
     if (unlikely(kw_args > 0)) {
-      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "open") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "open") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     }
     __pyx_v_file = values[0];
     __pyx_v_expected_sig = values[1];
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("open", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("open", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("bx.bbi.bbi_file.BBIFile.open");
   __Pyx_RefNannyFinishContext();
   __pyx_v_reader = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_level = ((struct __pyx_obj_2bx_3bbi_8bbi_file_ZoomLevel *)Py_None); __Pyx_INCREF(Py_None);
 
-  /* "bx/bbi/bbi_file.pyx":78
+  /* "bx/bbi/bbi_file.pyx":111
  *         in since this is generic.
  *         """
  *         assert expected_sig is not None             # <<<<<<<<<<<<<<
   __pyx_t_1 = (__pyx_v_expected_sig != Py_None);
   if (unlikely(!__pyx_t_1)) {
     PyErr_SetNone(PyExc_AssertionError);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  }
-  #endif
-
-  /* "bx/bbi/bbi_file.pyx":79
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  #endif
+
+  /* "bx/bbi/bbi_file.pyx":112
  *         """
  *         assert expected_sig is not None
  *         self.file = file             # <<<<<<<<<<<<<<
   __Pyx_DECREF(((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->file);
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->file = __pyx_v_file;
 
-  /* "bx/bbi/bbi_file.pyx":81
+  /* "bx/bbi/bbi_file.pyx":114
  *         self.file = file
  *         # Open the file in a BinaryFileReader, handles magic and byteswapping
  *         self.reader = reader = BinaryFileReader( file, expected_sig )             # <<<<<<<<<<<<<<
  *         self.magic = expected_sig
  *         self.is_byteswapped = self.reader.byteswap_needed
  */
-  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__BinaryFileReader); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__BinaryFileReader); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_3));
   __Pyx_INCREF(__pyx_v_file);
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_file);
   __Pyx_INCREF(__pyx_v_expected_sig);
   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_expected_sig);
   __Pyx_GIVEREF(__pyx_v_expected_sig);
-  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
   __pyx_v_reader = __pyx_t_4;
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-  /* "bx/bbi/bbi_file.pyx":82
+  /* "bx/bbi/bbi_file.pyx":115
  *         # Open the file in a BinaryFileReader, handles magic and byteswapping
  *         self.reader = reader = BinaryFileReader( file, expected_sig )
  *         self.magic = expected_sig             # <<<<<<<<<<<<<<
  *         self.is_byteswapped = self.reader.byteswap_needed
  *         # Read header stuff
  */
-  __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_expected_sig); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_expected_sig); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->magic = __pyx_t_5;
 
-  /* "bx/bbi/bbi_file.pyx":83
+  /* "bx/bbi/bbi_file.pyx":116
  *         self.reader = reader = BinaryFileReader( file, expected_sig )
  *         self.magic = expected_sig
  *         self.is_byteswapped = self.reader.byteswap_needed             # <<<<<<<<<<<<<<
  *         # Read header stuff
  *         self.version = reader.read_uint16()
  */
-  __pyx_t_4 = PyObject_GetAttr(((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->reader, __pyx_n_s__byteswap_needed); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->reader, __pyx_n_s__byteswap_needed); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->is_byteswapped = __pyx_t_6;
 
-  /* "bx/bbi/bbi_file.pyx":85
+  /* "bx/bbi/bbi_file.pyx":118
  *         self.is_byteswapped = self.reader.byteswap_needed
  *         # Read header stuff
  *         self.version = reader.read_uint16()             # <<<<<<<<<<<<<<
  *         self.zoom_levels = reader.read_uint16()
  *         self.chrom_tree_offset = reader.read_uint64()
  */
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint16); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint16); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __pyx_t_7 = __Pyx_PyInt_AsUnsignedShort(__pyx_t_3); if (unlikely((__pyx_t_7 == (unsigned short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = __Pyx_PyInt_AsUnsignedShort(__pyx_t_3); if (unlikely((__pyx_t_7 == (unsigned short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->version = __pyx_t_7;
 
-  /* "bx/bbi/bbi_file.pyx":86
+  /* "bx/bbi/bbi_file.pyx":119
  *         # Read header stuff
  *         self.version = reader.read_uint16()
  *         self.zoom_levels = reader.read_uint16()             # <<<<<<<<<<<<<<
  *         self.chrom_tree_offset = reader.read_uint64()
  *         self.unzoomed_data_offset = reader.read_uint64()
  */
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint16); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint16); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_7 = __Pyx_PyInt_AsUnsignedShort(__pyx_t_4); if (unlikely((__pyx_t_7 == (unsigned short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = __Pyx_PyInt_AsUnsignedShort(__pyx_t_4); if (unlikely((__pyx_t_7 == (unsigned short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->zoom_levels = __pyx_t_7;
 
-  /* "bx/bbi/bbi_file.pyx":87
+  /* "bx/bbi/bbi_file.pyx":120
  *         self.version = reader.read_uint16()
  *         self.zoom_levels = reader.read_uint16()
  *         self.chrom_tree_offset = reader.read_uint64()             # <<<<<<<<<<<<<<
  *         self.unzoomed_data_offset = reader.read_uint64()
  *         self.unzoomed_index_offset = reader.read_uint64()
  */
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __pyx_t_8 = __Pyx_PyInt_AsUnsignedLongLong(__pyx_t_3); if (unlikely((__pyx_t_8 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 87; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = __Pyx_PyInt_AsUnsignedLongLong(__pyx_t_3); if (unlikely((__pyx_t_8 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->chrom_tree_offset = __pyx_t_8;
 
-  /* "bx/bbi/bbi_file.pyx":88
+  /* "bx/bbi/bbi_file.pyx":121
  *         self.zoom_levels = reader.read_uint16()
  *         self.chrom_tree_offset = reader.read_uint64()
  *         self.unzoomed_data_offset = reader.read_uint64()             # <<<<<<<<<<<<<<
  *         self.unzoomed_index_offset = reader.read_uint64()
  *         self.field_count = reader.read_uint16()
  */
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint64); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint64); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_8 = __Pyx_PyInt_AsUnsignedLongLong(__pyx_t_4); if (unlikely((__pyx_t_8 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = __Pyx_PyInt_AsUnsignedLongLong(__pyx_t_4); if (unlikely((__pyx_t_8 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->unzoomed_data_offset = __pyx_t_8;
 
-  /* "bx/bbi/bbi_file.pyx":89
+  /* "bx/bbi/bbi_file.pyx":122
  *         self.chrom_tree_offset = reader.read_uint64()
  *         self.unzoomed_data_offset = reader.read_uint64()
  *         self.unzoomed_index_offset = reader.read_uint64()             # <<<<<<<<<<<<<<
  *         self.field_count = reader.read_uint16()
  *         self.defined_field_count = reader.read_uint16()
  */
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __pyx_t_8 = __Pyx_PyInt_AsUnsignedLongLong(__pyx_t_3); if (unlikely((__pyx_t_8 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = __Pyx_PyInt_AsUnsignedLongLong(__pyx_t_3); if (unlikely((__pyx_t_8 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->unzoomed_index_offset = __pyx_t_8;
 
-  /* "bx/bbi/bbi_file.pyx":90
+  /* "bx/bbi/bbi_file.pyx":123
  *         self.unzoomed_data_offset = reader.read_uint64()
  *         self.unzoomed_index_offset = reader.read_uint64()
  *         self.field_count = reader.read_uint16()             # <<<<<<<<<<<<<<
  *         self.defined_field_count = reader.read_uint16()
  *         self.as_offset = reader.read_uint64()
  */
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint16); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint16); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_7 = __Pyx_PyInt_AsUnsignedShort(__pyx_t_4); if (unlikely((__pyx_t_7 == (unsigned short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = __Pyx_PyInt_AsUnsignedShort(__pyx_t_4); if (unlikely((__pyx_t_7 == (unsigned short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->field_count = __pyx_t_7;
 
-  /* "bx/bbi/bbi_file.pyx":91
+  /* "bx/bbi/bbi_file.pyx":124
  *         self.unzoomed_index_offset = reader.read_uint64()
  *         self.field_count = reader.read_uint16()
  *         self.defined_field_count = reader.read_uint16()             # <<<<<<<<<<<<<<
  *         self.as_offset = reader.read_uint64()
  *         self.total_summary_offset = reader.read_uint64()
  */
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint16); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint16); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __pyx_t_7 = __Pyx_PyInt_AsUnsignedShort(__pyx_t_3); if (unlikely((__pyx_t_7 == (unsigned short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = __Pyx_PyInt_AsUnsignedShort(__pyx_t_3); if (unlikely((__pyx_t_7 == (unsigned short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->defined_field_count = __pyx_t_7;
 
-  /* "bx/bbi/bbi_file.pyx":92
+  /* "bx/bbi/bbi_file.pyx":125
  *         self.field_count = reader.read_uint16()
  *         self.defined_field_count = reader.read_uint16()
  *         self.as_offset = reader.read_uint64()             # <<<<<<<<<<<<<<
  *         self.total_summary_offset = reader.read_uint64()
  *         self.uncompress_buf_size = reader.read_uint32()
  */
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint64); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint64); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_8 = __Pyx_PyInt_AsUnsignedLongLong(__pyx_t_4); if (unlikely((__pyx_t_8 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = __Pyx_PyInt_AsUnsignedLongLong(__pyx_t_4); if (unlikely((__pyx_t_8 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->as_offset = __pyx_t_8;
 
-  /* "bx/bbi/bbi_file.pyx":93
+  /* "bx/bbi/bbi_file.pyx":126
  *         self.defined_field_count = reader.read_uint16()
  *         self.as_offset = reader.read_uint64()
  *         self.total_summary_offset = reader.read_uint64()             # <<<<<<<<<<<<<<
  *         self.uncompress_buf_size = reader.read_uint32()
  *         # Skip reserved
  */
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __pyx_t_8 = __Pyx_PyInt_AsUnsignedLongLong(__pyx_t_3); if (unlikely((__pyx_t_8 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = __Pyx_PyInt_AsUnsignedLongLong(__pyx_t_3); if (unlikely((__pyx_t_8 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->total_summary_offset = __pyx_t_8;
 
-  /* "bx/bbi/bbi_file.pyx":94
+  /* "bx/bbi/bbi_file.pyx":127
  *         self.as_offset = reader.read_uint64()
  *         self.total_summary_offset = reader.read_uint64()
  *         self.uncompress_buf_size = reader.read_uint32()             # <<<<<<<<<<<<<<
  *         # Skip reserved
  *         reader.seek( 64 )
  */
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint32); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint32); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_4); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_4); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->uncompress_buf_size = __pyx_t_5;
 
-  /* "bx/bbi/bbi_file.pyx":96
+  /* "bx/bbi/bbi_file.pyx":129
  *         self.uncompress_buf_size = reader.read_uint32()
  *         # Skip reserved
  *         reader.seek( 64 )             # <<<<<<<<<<<<<<
  *         # Read zoom headers
  *         self.level_list = []
  */
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__seek); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__seek); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_k_tuple_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-  /* "bx/bbi/bbi_file.pyx":98
+  /* "bx/bbi/bbi_file.pyx":131
  *         reader.seek( 64 )
  *         # Read zoom headers
  *         self.level_list = []             # <<<<<<<<<<<<<<
  *         for i from 0 <= i < self.zoom_levels:
  *             level = ZoomLevel()
  */
-  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_3));
   __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
   __Pyx_GOTREF(((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->level_list);
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->level_list = ((PyObject *)__pyx_t_3);
   __pyx_t_3 = 0;
 
-  /* "bx/bbi/bbi_file.pyx":99
+  /* "bx/bbi/bbi_file.pyx":132
  *         # Read zoom headers
  *         self.level_list = []
  *         for i from 0 <= i < self.zoom_levels:             # <<<<<<<<<<<<<<
   __pyx_t_7 = ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->zoom_levels;
   for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {
 
-    /* "bx/bbi/bbi_file.pyx":100
+    /* "bx/bbi/bbi_file.pyx":133
  *         self.level_list = []
  *         for i from 0 <= i < self.zoom_levels:
  *             level = ZoomLevel()             # <<<<<<<<<<<<<<
  *             level.bbi_file = self
  *             level.reduction_level = reader.read_uint32()
  */
-    __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_2bx_3bbi_8bbi_file_ZoomLevel)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_2bx_3bbi_8bbi_file_ZoomLevel)), ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(((PyObject *)__pyx_v_level));
     __pyx_v_level = ((struct __pyx_obj_2bx_3bbi_8bbi_file_ZoomLevel *)__pyx_t_3);
     __pyx_t_3 = 0;
 
-    /* "bx/bbi/bbi_file.pyx":101
+    /* "bx/bbi/bbi_file.pyx":134
  *         for i from 0 <= i < self.zoom_levels:
  *             level = ZoomLevel()
  *             level.bbi_file = self             # <<<<<<<<<<<<<<
     __Pyx_DECREF(((PyObject *)__pyx_v_level->bbi_file));
     __pyx_v_level->bbi_file = ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self);
 
-    /* "bx/bbi/bbi_file.pyx":102
+    /* "bx/bbi/bbi_file.pyx":135
  *             level = ZoomLevel()
  *             level.bbi_file = self
  *             level.reduction_level = reader.read_uint32()             # <<<<<<<<<<<<<<
  *             level.reserved = reader.read_uint32()
  *             level.data_offset = reader.read_uint64()
  */
-    __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint32); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint32); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_4); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_4); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __pyx_v_level->reduction_level = __pyx_t_5;
 
-    /* "bx/bbi/bbi_file.pyx":103
+    /* "bx/bbi/bbi_file.pyx":136
  *             level.bbi_file = self
  *             level.reduction_level = reader.read_uint32()
  *             level.reserved = reader.read_uint32()             # <<<<<<<<<<<<<<
  *             level.data_offset = reader.read_uint64()
  *             level.index_offset = reader.read_uint64()
  */
-    __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint32); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint32); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = __Pyx_PyInt_AsUnsignedInt(__pyx_t_3); if (unlikely((__pyx_t_5 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_v_level->reserved = __pyx_t_5;
 
-    /* "bx/bbi/bbi_file.pyx":104
+    /* "bx/bbi/bbi_file.pyx":137
  *             level.reduction_level = reader.read_uint32()
  *             level.reserved = reader.read_uint32()
  *             level.data_offset = reader.read_uint64()             # <<<<<<<<<<<<<<
  *             level.index_offset = reader.read_uint64()
  *             self.level_list.append( level )
  */
-    __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint64); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint64); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_8 = __Pyx_PyInt_AsUnsignedLongLong(__pyx_t_4); if (unlikely((__pyx_t_8 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = __Pyx_PyInt_AsUnsignedLongLong(__pyx_t_4); if (unlikely((__pyx_t_8 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __pyx_v_level->data_offset = __pyx_t_8;
 
-    /* "bx/bbi/bbi_file.pyx":105
+    /* "bx/bbi/bbi_file.pyx":138
  *             level.reserved = reader.read_uint32()
  *             level.data_offset = reader.read_uint64()
  *             level.index_offset = reader.read_uint64()             # <<<<<<<<<<<<<<
  *             self.level_list.append( level )
  *         # Initialize and attach embedded BPTFile containing chromosome names and ids
  */
-    __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__read_uint64); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __pyx_t_8 = __Pyx_PyInt_AsUnsignedLongLong(__pyx_t_3); if (unlikely((__pyx_t_8 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = __Pyx_PyInt_AsUnsignedLongLong(__pyx_t_3); if (unlikely((__pyx_t_8 == (unsigned PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_v_level->index_offset = __pyx_t_8;
 
-    /* "bx/bbi/bbi_file.pyx":106
+    /* "bx/bbi/bbi_file.pyx":139
  *             level.data_offset = reader.read_uint64()
  *             level.index_offset = reader.read_uint64()
  *             self.level_list.append( level )             # <<<<<<<<<<<<<<
  *         # Initialize and attach embedded BPTFile containing chromosome names and ids
  *         reader.seek( self.chrom_tree_offset )
  */
-    __pyx_t_3 = __Pyx_PyObject_Append(((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->level_list, ((PyObject *)__pyx_v_level)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyObject_Append(((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->level_list, ((PyObject *)__pyx_v_level)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   }
 
-  /* "bx/bbi/bbi_file.pyx":108
+  /* "bx/bbi/bbi_file.pyx":141
  *             self.level_list.append( level )
  *         # Initialize and attach embedded BPTFile containing chromosome names and ids
  *         reader.seek( self.chrom_tree_offset )             # <<<<<<<<<<<<<<
  *         self.chrom_bpt = BPTFile( file=self.file )
  * 
  */
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__seek); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__seek); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyLong_FromUnsignedLongLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->chrom_tree_offset); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyLong_FromUnsignedLongLong(((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->chrom_tree_offset); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_4);
   __Pyx_GIVEREF(__pyx_t_4);
   __pyx_t_4 = 0;
-  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-  /* "bx/bbi/bbi_file.pyx":109
+  /* "bx/bbi/bbi_file.pyx":142
  *         # Initialize and attach embedded BPTFile containing chromosome names and ids
  *         reader.seek( self.chrom_tree_offset )
  *         self.chrom_bpt = BPTFile( file=self.file )             # <<<<<<<<<<<<<<
  * 
- *     cpdef summarize( self, char * chrom, bits32 start, bits32 end, int summary_size ):
- */
-  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+ *     cdef visit_blocks_in_region( self, bits32 chrom_id, bits32 start, bits32 end, BlockHandler handler ):
+ */
+  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__file), ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->file) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_2bx_3bbi_8bpt_file_BPTFile)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__file), ((struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *)__pyx_v_self)->file) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyEval_CallObjectWithKeywords(((PyObject *)((PyObject*)__pyx_ptype_2bx_3bbi_8bpt_file_BPTFile)), ((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
   __Pyx_GIVEREF(__pyx_t_2);
   return __pyx_r;
 }
 
-/* "bx/bbi/bbi_file.pyx":111
+/* "bx/bbi/bbi_file.pyx":144
  *         self.chrom_bpt = BPTFile( file=self.file )
  * 
+ *     cdef visit_blocks_in_region( self, bits32 chrom_id, bits32 start, bits32 end, BlockHandler handler ):             # <<<<<<<<<<<<<<
+ *         """
+ *         Visit each block from the full data that overlaps a specific region
+ */
+
+static  PyObject *__pyx_f_2bx_3bbi_8bbi_file_7BBIFile_visit_blocks_in_region(struct __pyx_obj_2bx_3bbi_8bbi_file_BBIFile *__pyx_v_self, __pyx_t_2bx_3bbi_5types_bits32 __pyx_v_chrom_id, __pyx_t_2bx_3bbi_5types_bits32 __pyx_v_start, __pyx_t_2bx_3bbi_5types_bits32 __pyx_v_end, struct __pyx_obj_2bx_3bbi_8bbi_file_BlockHandler *__pyx_v_handler) {
+  struct __pyx_obj_2bx_3bbi_12cirtree_file_CIRTreeFile *__pyx_v_ctf;
+  PyObject *__pyx_v_reader;
+  PyObject *__pyx_v_block_list;
+  PyObject *__pyx_v_offset;
+  PyObject *__pyx_v_size;
+  PyObject *__pyx_v_block_data;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  Py_ssize_t __pyx_t_6;
+  int __pyx_t_7;
+  __Pyx_RefNannySetupContext("visit_blocks_in_region");
+  __pyx_v_ctf = ((struct __pyx_obj_2bx_3bbi_12cirtree_file_CIRTreeFile *)Py_None); __Pyx_INCREF(Py_None);
+  __pyx_v_reader = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_block_list = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_offset = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_size = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_block_data = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "bx/bbi/bbi_file.pyx":149
+ *         """
+ *         cdef CIRTreeFile ctf
+ *         reader = self.reader             # <<<<<<<<<<<<<<
+ *         ctf = CIRTreeFile( reader.file )
+ *         block_list = ctf.find_overlapping_blocks( chrom_id, start, end )
+ */
+  __Pyx_INCREF(__pyx_v_self->reader);
+  __Pyx_DECREF(__pyx_v_reader);
+  __pyx_v_reader = __pyx_v_self->reader;
+
+  /* "bx/bbi/bbi_file.pyx":150
+ *         cdef CIRTreeFile ctf
+ *         reader = self.reader
+ *         ctf = CIRTreeFile( reader.file )             # <<<<<<<<<<<<<<
+ *         block_list = ctf.find_overlapping_blocks( chrom_id, start, end )
+ *         for offset, size in block_list:
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__file); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_2bx_3bbi_12cirtree_file_CIRTreeFile)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_v_ctf));
+  __pyx_v_ctf = ((struct __pyx_obj_2bx_3bbi_12cirtree_file_CIRTreeFile *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "bx/bbi/bbi_file.pyx":151
+ *         reader = self.reader
+ *         ctf = CIRTreeFile( reader.file )
+ *         block_list = ctf.find_overlapping_blocks( chrom_id, start, end )             # <<<<<<<<<<<<<<
+ *         for offset, size in block_list:
+ *             # Seek to and read all data for the block
+ */
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_ctf), __pyx_n_s_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_chrom_id); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_start); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_end); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);