Commits

Kanwei Li committed 480f64c

Minor refactorings to bbi

Comments (0)

Files changed (4)

lib/bx/bbi/bbi_file.c

-/* Generated by Cython 0.13 on Thu Dec  9 16:01:34 2010 */
+/* Generated by Cython 0.13 on Thu Dec  9 17:09:42 2010 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 static CYTHON_INLINE void __Pyx_SafeReleaseBuffer(Py_buffer* info);
 
 static void __Pyx_RaiseBufferFallbackError(void); /*proto*/
+static void __Pyx_RaiseBufferIndexError(int axis); /*proto*/
+#define __Pyx_BufPtrStrided1d(type, buf, i0, s0) (type)((char*)buf + i0 * s0)
 
 static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
 static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
 
 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
 
-static int __Pyx_Print(PyObject*, PyObject *, int); /*proto*/
-#if PY_MAJOR_VERSION >= 3
-static PyObject* __pyx_print = 0;
-static PyObject* __pyx_print_kwargs = 0;
-#endif
-
-static int __Pyx_PrintOne(PyObject* stream, PyObject *o); /*proto*/
+static CYTHON_INLINE npy_uint64 __Pyx_PyInt_from_py_npy_uint64(PyObject *);
 
 #if CYTHON_CCOMPLEX
   #ifdef __cplusplus
  */
 
 static  PyObject *__pyx_f_2bx_3bbi_8bbi_file_9ZoomLevel__summarize(struct __pyx_obj_2bx_3bbi_8bbi_file_ZoomLevel *__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, int __pyx_v_summary_size) {
-  float __pyx_v_base_to_index_factor;
+  __pyx_t_2bx_3bbi_5types_bits32 __pyx_v_base_start;
+  __pyx_t_2bx_3bbi_5types_bits32 __pyx_v_base_end;
+  __pyx_t_2bx_3bbi_5types_bits32 __pyx_v_base_step;
   PyArrayObject *__pyx_v_valid_count;
   PyArrayObject *__pyx_v_min_val;
   PyArrayObject *__pyx_v_max_val;
   struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *__pyx_v_rval;
   PyObject *__pyx_v_reader;
   PyObject *__pyx_v_summaries;
-  PyObject *__pyx_v_base_start;
-  PyObject *__pyx_v_baseCount;
-  PyObject *__pyx_v_i;
-  PyObject *__pyx_v_base_end;
+  int __pyx_v_i;
+  Py_buffer __pyx_bstruct_sum_squares;
+  Py_ssize_t __pyx_bstride_0_sum_squares = 0;
+  Py_ssize_t __pyx_bshape_0_sum_squares = 0;
   Py_buffer __pyx_bstruct_valid_count;
   Py_ssize_t __pyx_bstride_0_valid_count = 0;
   Py_ssize_t __pyx_bshape_0_valid_count = 0;
+  Py_buffer __pyx_bstruct_min_val;
+  Py_ssize_t __pyx_bstride_0_min_val = 0;
+  Py_ssize_t __pyx_bshape_0_min_val = 0;
+  Py_buffer __pyx_bstruct_sum_data;
+  Py_ssize_t __pyx_bstride_0_sum_data = 0;
+  Py_ssize_t __pyx_bshape_0_sum_data = 0;
   Py_buffer __pyx_bstruct_max_val;
   Py_ssize_t __pyx_bstride_0_max_val = 0;
   Py_ssize_t __pyx_bshape_0_max_val = 0;
-  Py_buffer __pyx_bstruct_min_val;
-  Py_ssize_t __pyx_bstride_0_min_val = 0;
-  Py_ssize_t __pyx_bshape_0_min_val = 0;
-  Py_buffer __pyx_bstruct_sum_squares;
-  Py_ssize_t __pyx_bstride_0_sum_squares = 0;
-  Py_ssize_t __pyx_bshape_0_sum_squares = 0;
-  Py_buffer __pyx_bstruct_sum_data;
-  Py_ssize_t __pyx_bstride_0_sum_data = 0;
-  Py_ssize_t __pyx_bshape_0_sum_data = 0;
   PyObject *__pyx_r = NULL;
-  __pyx_t_2bx_3bbi_5types_bits32 __pyx_t_1;
-  float __pyx_t_2;
-  PyObject *__pyx_t_3 = NULL;
-  PyObject *__pyx_t_4 = NULL;
-  PyArrayObject *__pyx_t_5 = NULL;
-  int __pyx_t_6;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyArrayObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
   PyObject *__pyx_t_7 = NULL;
-  PyObject *__pyx_t_8 = NULL;
-  PyObject *__pyx_t_9 = NULL;
+  PyArrayObject *__pyx_t_8 = NULL;
+  PyArrayObject *__pyx_t_9 = NULL;
   PyArrayObject *__pyx_t_10 = NULL;
   PyArrayObject *__pyx_t_11 = NULL;
-  PyArrayObject *__pyx_t_12 = NULL;
-  PyArrayObject *__pyx_t_13 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
   PyObject *__pyx_t_14 = NULL;
-  PyObject *__pyx_t_15 = NULL;
-  PyObject *__pyx_t_16 = NULL;
-  Py_ssize_t __pyx_t_17;
+  __pyx_t_2bx_3bbi_5types_bits32 __pyx_t_15;
+  int __pyx_t_16;
+  int __pyx_t_17;
   int __pyx_t_18;
   int __pyx_t_19;
-  int __pyx_t_20;
-  __pyx_t_2bx_3bbi_5types_bits32 __pyx_t_21;
-  PyObject *__pyx_t_22 = NULL;
-  PyObject *__pyx_t_23 = NULL;
-  PyObject *__pyx_t_24 = NULL;
+  PyObject *__pyx_t_20 = NULL;
+  __pyx_t_5numpy_uint64_t __pyx_t_21;
+  __pyx_t_5numpy_float64_t __pyx_t_22;
+  __pyx_t_5numpy_float64_t __pyx_t_23;
+  __pyx_t_5numpy_float64_t __pyx_t_24;
+  __pyx_t_5numpy_float64_t __pyx_t_25;
+  int __pyx_t_26;
+  int __pyx_t_27;
+  int __pyx_t_28;
+  int __pyx_t_29;
+  int __pyx_t_30;
+  int __pyx_t_31;
+  PyObject *__pyx_t_32 = NULL;
+  int __pyx_t_33;
+  int __pyx_t_34;
+  int __pyx_t_35;
+  int __pyx_t_36;
+  int __pyx_t_37;
   __Pyx_RefNannySetupContext("_summarize");
   __pyx_v_valid_count = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_min_val = ((PyArrayObject *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_rval = ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)Py_None); __Pyx_INCREF(Py_None);
   __pyx_v_reader = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_summaries = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_base_start = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_baseCount = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_i = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_base_end = Py_None; __Pyx_INCREF(Py_None);
   __pyx_bstruct_valid_count.buf = NULL;
   __pyx_bstruct_min_val.buf = NULL;
   __pyx_bstruct_max_val.buf = NULL;
   __pyx_bstruct_sum_data.buf = NULL;
   __pyx_bstruct_sum_squares.buf = NULL;
 
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":295
- *         # Factor to map base positions to array indexes, also size in bases of
- *         # a single summary value
- *         cdef float base_to_index_factor = ( end - start ) / <float> summary_size             # <<<<<<<<<<<<<<
- *         cdef int overlap
- *         cdef double overlap_factor
- */
-  __pyx_t_1 = (__pyx_v_end - __pyx_v_start);
-  __pyx_t_2 = ((float)__pyx_v_summary_size);
-  if (unlikely(__pyx_t_2 == 0)) {
-    PyErr_Format(PyExc_ZeroDivisionError, "float division");
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  }
-  __pyx_v_base_to_index_factor = (__pyx_t_1 / __pyx_t_2);
-
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":305
- *         cdef numpy.ndarray[numpy.float64_t] sum_squares
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":298
+ * 
  *         # What we will load into
  *         rval = SummarizedData( summary_size )             # <<<<<<<<<<<<<<
  *         valid_count = rval.valid_count
  *         min_val = rval.min_val
  */
-  __pyx_t_3 = PyInt_FromLong(__pyx_v_summary_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
-  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
-  __Pyx_GIVEREF(__pyx_t_3);
-  __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_2bx_3bbi_8bbi_file_SummarizedData)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_summary_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __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 = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__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_8bbi_file_SummarizedData)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_v_rval));
-  __pyx_v_rval = ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_t_3);
-  __pyx_t_3 = 0;
-
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":306
+  __pyx_v_rval = ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":299
  *         # What we will load into
  *         rval = SummarizedData( summary_size )
  *         valid_count = rval.valid_count             # <<<<<<<<<<<<<<
  *         min_val = rval.min_val
  *         max_val = rval.max_val
  */
-  __pyx_t_5 = ((PyArrayObject *)__pyx_v_rval->valid_count);
+  __pyx_t_3 = ((PyArrayObject *)__pyx_v_rval->valid_count);
   {
     __Pyx_BufFmt_StackElem __pyx_stack[1];
     __Pyx_SafeReleaseBuffer(&__pyx_bstruct_valid_count);
-    __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_valid_count, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
-    if (unlikely(__pyx_t_6 < 0)) {
-      PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
-      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_valid_count, (PyObject*)__pyx_v_valid_count, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
-        Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
+    __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_valid_count, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
+    if (unlikely(__pyx_t_4 < 0)) {
+      PyErr_Fetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
+      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_valid_count, (PyObject*)__pyx_v_valid_count, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
+        Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7);
         __Pyx_RaiseBufferFallbackError();
       } else {
-        PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
+        PyErr_Restore(__pyx_t_5, __pyx_t_6, __pyx_t_7);
       }
     }
     __pyx_bstride_0_valid_count = __pyx_bstruct_valid_count.strides[0];
     __pyx_bshape_0_valid_count = __pyx_bstruct_valid_count.shape[0];
-    if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  }
-  __pyx_t_5 = 0;
+    if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_t_3 = 0;
   __Pyx_INCREF(((PyObject *)__pyx_v_rval->valid_count));
   __Pyx_DECREF(((PyObject *)__pyx_v_valid_count));
   __pyx_v_valid_count = ((PyArrayObject *)__pyx_v_rval->valid_count);
 
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":307
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":300
  *         rval = SummarizedData( summary_size )
  *         valid_count = rval.valid_count
  *         min_val = rval.min_val             # <<<<<<<<<<<<<<
  *         max_val = rval.max_val
  *         sum_data = rval.sum_data
  */
-  __pyx_t_10 = ((PyArrayObject *)__pyx_v_rval->min_val);
+  __pyx_t_8 = ((PyArrayObject *)__pyx_v_rval->min_val);
   {
     __Pyx_BufFmt_StackElem __pyx_stack[1];
     __Pyx_SafeReleaseBuffer(&__pyx_bstruct_min_val);
-    __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_min_val, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
-    if (unlikely(__pyx_t_6 < 0)) {
-      PyErr_Fetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
-      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_min_val, (PyObject*)__pyx_v_min_val, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
-        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7);
+    __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_min_val, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
+    if (unlikely(__pyx_t_4 < 0)) {
+      PyErr_Fetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5);
+      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_min_val, (PyObject*)__pyx_v_min_val, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
+        Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_5);
         __Pyx_RaiseBufferFallbackError();
       } else {
-        PyErr_Restore(__pyx_t_9, __pyx_t_8, __pyx_t_7);
+        PyErr_Restore(__pyx_t_7, __pyx_t_6, __pyx_t_5);
       }
     }
     __pyx_bstride_0_min_val = __pyx_bstruct_min_val.strides[0];
     __pyx_bshape_0_min_val = __pyx_bstruct_min_val.shape[0];
-    if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  }
-  __pyx_t_10 = 0;
+    if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_t_8 = 0;
   __Pyx_INCREF(((PyObject *)__pyx_v_rval->min_val));
   __Pyx_DECREF(((PyObject *)__pyx_v_min_val));
   __pyx_v_min_val = ((PyArrayObject *)__pyx_v_rval->min_val);
 
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":308
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":301
  *         valid_count = rval.valid_count
  *         min_val = rval.min_val
  *         max_val = rval.max_val             # <<<<<<<<<<<<<<
  *         sum_data = rval.sum_data
  *         sum_squares = rval.sum_squares
  */
-  __pyx_t_11 = ((PyArrayObject *)__pyx_v_rval->max_val);
+  __pyx_t_9 = ((PyArrayObject *)__pyx_v_rval->max_val);
   {
     __Pyx_BufFmt_StackElem __pyx_stack[1];
     __Pyx_SafeReleaseBuffer(&__pyx_bstruct_max_val);
-    __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_max_val, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
-    if (unlikely(__pyx_t_6 < 0)) {
-      PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
-      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_max_val, (PyObject*)__pyx_v_max_val, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
-        Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
+    __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_max_val, (PyObject*)__pyx_t_9, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
+    if (unlikely(__pyx_t_4 < 0)) {
+      PyErr_Fetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
+      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_max_val, (PyObject*)__pyx_v_max_val, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
+        Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7);
         __Pyx_RaiseBufferFallbackError();
       } else {
-        PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
+        PyErr_Restore(__pyx_t_5, __pyx_t_6, __pyx_t_7);
       }
     }
     __pyx_bstride_0_max_val = __pyx_bstruct_max_val.strides[0];
     __pyx_bshape_0_max_val = __pyx_bstruct_max_val.shape[0];
-    if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  }
-  __pyx_t_11 = 0;
+    if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_t_9 = 0;
   __Pyx_INCREF(((PyObject *)__pyx_v_rval->max_val));
   __Pyx_DECREF(((PyObject *)__pyx_v_max_val));
   __pyx_v_max_val = ((PyArrayObject *)__pyx_v_rval->max_val);
 
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":309
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":302
  *         min_val = rval.min_val
  *         max_val = rval.max_val
  *         sum_data = rval.sum_data             # <<<<<<<<<<<<<<
  *         sum_squares = rval.sum_squares
  *         # First, load up summaries
  */
-  __pyx_t_12 = ((PyArrayObject *)__pyx_v_rval->sum_data);
+  __pyx_t_10 = ((PyArrayObject *)__pyx_v_rval->sum_data);
   {
     __Pyx_BufFmt_StackElem __pyx_stack[1];
     __Pyx_SafeReleaseBuffer(&__pyx_bstruct_sum_data);
-    __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_sum_data, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
-    if (unlikely(__pyx_t_6 < 0)) {
-      PyErr_Fetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
-      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_sum_data, (PyObject*)__pyx_v_sum_data, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
-        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7);
+    __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_sum_data, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
+    if (unlikely(__pyx_t_4 < 0)) {
+      PyErr_Fetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5);
+      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_sum_data, (PyObject*)__pyx_v_sum_data, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
+        Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_5);
         __Pyx_RaiseBufferFallbackError();
       } else {
-        PyErr_Restore(__pyx_t_9, __pyx_t_8, __pyx_t_7);
+        PyErr_Restore(__pyx_t_7, __pyx_t_6, __pyx_t_5);
       }
     }
     __pyx_bstride_0_sum_data = __pyx_bstruct_sum_data.strides[0];
     __pyx_bshape_0_sum_data = __pyx_bstruct_sum_data.shape[0];
-    if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  }
-  __pyx_t_12 = 0;
+    if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_t_10 = 0;
   __Pyx_INCREF(((PyObject *)__pyx_v_rval->sum_data));
   __Pyx_DECREF(((PyObject *)__pyx_v_sum_data));
   __pyx_v_sum_data = ((PyArrayObject *)__pyx_v_rval->sum_data);
 
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":310
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":303
  *         max_val = rval.max_val
  *         sum_data = rval.sum_data
  *         sum_squares = rval.sum_squares             # <<<<<<<<<<<<<<
  *         # First, load up summaries
  *         reader = self.bbi_file.reader
  */
-  __pyx_t_13 = ((PyArrayObject *)__pyx_v_rval->sum_squares);
+  __pyx_t_11 = ((PyArrayObject *)__pyx_v_rval->sum_squares);
   {
     __Pyx_BufFmt_StackElem __pyx_stack[1];
     __Pyx_SafeReleaseBuffer(&__pyx_bstruct_sum_squares);
-    __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_sum_squares, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
-    if (unlikely(__pyx_t_6 < 0)) {
-      PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
-      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_sum_squares, (PyObject*)__pyx_v_sum_squares, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
-        Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
+    __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_sum_squares, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack);
+    if (unlikely(__pyx_t_4 < 0)) {
+      PyErr_Fetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
+      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_sum_squares, (PyObject*)__pyx_v_sum_squares, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES| PyBUF_WRITABLE, 1, 0, __pyx_stack) == -1)) {
+        Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7);
         __Pyx_RaiseBufferFallbackError();
       } else {
-        PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
+        PyErr_Restore(__pyx_t_5, __pyx_t_6, __pyx_t_7);
       }
     }
     __pyx_bstride_0_sum_squares = __pyx_bstruct_sum_squares.strides[0];
     __pyx_bshape_0_sum_squares = __pyx_bstruct_sum_squares.shape[0];
-    if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  }
-  __pyx_t_13 = 0;
+    if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_t_11 = 0;
   __Pyx_INCREF(((PyObject *)__pyx_v_rval->sum_squares));
   __Pyx_DECREF(((PyObject *)__pyx_v_sum_squares));
   __pyx_v_sum_squares = ((PyArrayObject *)__pyx_v_rval->sum_squares);
 
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":312
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":305
  *         sum_squares = rval.sum_squares
  *         # First, load up summaries
  *         reader = self.bbi_file.reader             # <<<<<<<<<<<<<<
   __Pyx_DECREF(__pyx_v_reader);
   __pyx_v_reader = __pyx_v_self->bbi_file->reader;
 
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":313
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":306
  *         # First, load up summaries
  *         reader = self.bbi_file.reader
  *         reader.seek( self.index_offset )             # <<<<<<<<<<<<<<
  *         summaries = self._summary_blocks_in_region(chrom_id, start, end)
  * 
  */
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__seek); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyLong_FromUnsignedLongLong(__pyx_v_self->index_offset); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_14);
-  PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_4);
-  __Pyx_GIVEREF(__pyx_t_4);
-  __pyx_t_4 = 0;
-  __pyx_t_4 = PyObject_Call(__pyx_t_3, __pyx_t_14, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
-  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":314
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__seek); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyLong_FromUnsignedLongLong(__pyx_v_self->index_offset); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_12);
+  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, __pyx_t_12, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":307
  *         reader = self.bbi_file.reader
  *         reader.seek( self.index_offset )
  *         summaries = self._summary_blocks_in_region(chrom_id, start, end)             # <<<<<<<<<<<<<<
  * 
+ *         base_step = (end - start) / summary_size
+ */
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s_7); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_12 = PyLong_FromUnsignedLong(__pyx_v_chrom_id); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_12);
+  __pyx_t_1 = PyLong_FromUnsignedLong(__pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_13 = PyLong_FromUnsignedLong(__pyx_v_end); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
+  __pyx_t_14 = PyTuple_New(3); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_14);
+  PyTuple_SET_ITEM(__pyx_t_14, 0, __pyx_t_12);
+  __Pyx_GIVEREF(__pyx_t_12);
+  PyTuple_SET_ITEM(__pyx_t_14, 1, __pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_14, 2, __pyx_t_13);
+  __Pyx_GIVEREF(__pyx_t_13);
+  __pyx_t_12 = 0;
+  __pyx_t_1 = 0;
+  __pyx_t_13 = 0;
+  __pyx_t_13 = PyObject_Call(__pyx_t_2, __pyx_t_14, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_13);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
+  __Pyx_DECREF(__pyx_v_summaries);
+  __pyx_v_summaries = __pyx_t_13;
+  __pyx_t_13 = 0;
+
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":309
+ *         summaries = self._summary_blocks_in_region(chrom_id, start, end)
+ * 
+ *         base_step = (end - start) / summary_size             # <<<<<<<<<<<<<<
  *         base_start = start
- */
-  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s_7); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_14 = PyLong_FromUnsignedLong(__pyx_v_chrom_id); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_14);
-  __pyx_t_3 = PyLong_FromUnsignedLong(__pyx_v_start); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_15 = PyLong_FromUnsignedLong(__pyx_v_end); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_15);
-  __pyx_t_16 = PyTuple_New(3); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_16);
-  PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_14);
-  __Pyx_GIVEREF(__pyx_t_14);
-  PyTuple_SET_ITEM(__pyx_t_16, 1, __pyx_t_3);
-  __Pyx_GIVEREF(__pyx_t_3);
-  PyTuple_SET_ITEM(__pyx_t_16, 2, __pyx_t_15);
-  __Pyx_GIVEREF(__pyx_t_15);
-  __pyx_t_14 = 0;
-  __pyx_t_3 = 0;
-  __pyx_t_15 = 0;
-  __pyx_t_15 = PyObject_Call(__pyx_t_4, __pyx_t_16, NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_15);
-  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
-  __Pyx_DECREF(__pyx_v_summaries);
-  __pyx_v_summaries = __pyx_t_15;
-  __pyx_t_15 = 0;
-
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":316
- *         summaries = self._summary_blocks_in_region(chrom_id, start, end)
- * 
+ *         base_end = start
+ */
+  __pyx_t_15 = (__pyx_v_end - __pyx_v_start);
+  if (unlikely(__pyx_v_summary_size == 0)) {
+    PyErr_Format(PyExc_ZeroDivisionError, "integer division or modulo by zero");
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_v_base_step = (__pyx_t_15 / __pyx_v_summary_size);
+
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":310
+ * 
+ *         base_step = (end - start) / summary_size
  *         base_start = start             # <<<<<<<<<<<<<<
- *         baseCount = end - start
- * 
- */
-  __pyx_t_15 = PyLong_FromUnsignedLong(__pyx_v_start); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_15);
-  __Pyx_DECREF(__pyx_v_base_start);
-  __pyx_v_base_start = __pyx_t_15;
-  __pyx_t_15 = 0;
-
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":317
- * 
+ *         base_end = start
+ * 
+ */
+  __pyx_v_base_start = __pyx_v_start;
+
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":311
+ *         base_step = (end - start) / summary_size
  *         base_start = start
- *         baseCount = end - start             # <<<<<<<<<<<<<<
+ *         base_end = start             # <<<<<<<<<<<<<<
  * 
  *         for i in range(summary_size):
  */
-  __pyx_t_15 = PyLong_FromUnsignedLong((__pyx_v_end - __pyx_v_start)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_15);
-  __Pyx_DECREF(__pyx_v_baseCount);
-  __pyx_v_baseCount = __pyx_t_15;
-  __pyx_t_15 = 0;
-
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":319
- *         baseCount = end - start
+  __pyx_v_base_end = __pyx_v_start;
+
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":313
+ *         base_end = start
  * 
  *         for i in range(summary_size):             # <<<<<<<<<<<<<<
- *             print i
- *             base_end = start + baseCount*(i+1)/summary_size
- */
-  __pyx_t_15 = PyInt_FromLong(__pyx_v_summary_size); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_15);
-  __pyx_t_16 = PyTuple_New(1); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_16);
-  PyTuple_SET_ITEM(__pyx_t_16, 0, __pyx_t_15);
-  __Pyx_GIVEREF(__pyx_t_15);
-  __pyx_t_15 = 0;
-  __pyx_t_15 = PyObject_Call(__pyx_builtin_range, __pyx_t_16, NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_15);
-  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
-  if (PyList_CheckExact(__pyx_t_15) || PyTuple_CheckExact(__pyx_t_15)) {
-    __pyx_t_17 = 0; __pyx_t_16 = __pyx_t_15; __Pyx_INCREF(__pyx_t_16);
-  } else {
-    __pyx_t_17 = -1; __pyx_t_16 = PyObject_GetIter(__pyx_t_15); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_16);
-  }
-  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
-  for (;;) {
-    if (likely(PyList_CheckExact(__pyx_t_16))) {
-      if (__pyx_t_17 >= PyList_GET_SIZE(__pyx_t_16)) break;
-      __pyx_t_15 = PyList_GET_ITEM(__pyx_t_16, __pyx_t_17); __Pyx_INCREF(__pyx_t_15); __pyx_t_17++;
-    } else if (likely(PyTuple_CheckExact(__pyx_t_16))) {
-      if (__pyx_t_17 >= PyTuple_GET_SIZE(__pyx_t_16)) break;
-      __pyx_t_15 = PyTuple_GET_ITEM(__pyx_t_16, __pyx_t_17); __Pyx_INCREF(__pyx_t_15); __pyx_t_17++;
-    } else {
-      __pyx_t_15 = PyIter_Next(__pyx_t_16);
-      if (!__pyx_t_15) {
-        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        break;
-      }
-      __Pyx_GOTREF(__pyx_t_15);
-    }
-    __Pyx_DECREF(__pyx_v_i);
-    __pyx_v_i = __pyx_t_15;
-    __pyx_t_15 = 0;
-
-    /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":320
+ *             base_end += base_step
+ * 
+ */
+  __pyx_t_4 = __pyx_v_summary_size;
+  for (__pyx_t_16 = 0; __pyx_t_16 < __pyx_t_4; __pyx_t_16+=1) {
+    __pyx_v_i = __pyx_t_16;
+
+    /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":314
  * 
  *         for i in range(summary_size):
- *             print i             # <<<<<<<<<<<<<<
- *             base_end = start + baseCount*(i+1)/summary_size
- * 
- */
-    if (__Pyx_PrintOne(0, __pyx_v_i) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
-    /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":321
- *         for i in range(summary_size):
- *             print i
- *             base_end = start + baseCount*(i+1)/summary_size             # <<<<<<<<<<<<<<
+ *             base_end += base_step             # <<<<<<<<<<<<<<
  * 
  *             while summaries and summaries[0].end <= base_start:
  */
-    __pyx_t_15 = PyLong_FromUnsignedLong(__pyx_v_start); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_15);
-    __pyx_t_4 = PyNumber_Add(__pyx_v_i, __pyx_int_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_3 = PyNumber_Multiply(__pyx_v_baseCount, __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __pyx_t_4 = PyInt_FromLong(__pyx_v_summary_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_14 = __Pyx_PyNumber_Divide(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_14);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __pyx_t_4 = PyNumber_Add(__pyx_t_15, __pyx_t_14); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
-    __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
-    __Pyx_DECREF(__pyx_v_base_end);
-    __pyx_v_base_end = __pyx_t_4;
-    __pyx_t_4 = 0;
-
-    /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":323
- *             base_end = start + baseCount*(i+1)/summary_size
+    __pyx_v_base_end += __pyx_v_base_step;
+
+    /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":316
+ *             base_end += base_step
  * 
  *             while summaries and summaries[0].end <= base_start:             # <<<<<<<<<<<<<<
  *                 summaries.popleft()
  * 
  */
     while (1) {
-      __pyx_t_18 = __Pyx_PyObject_IsTrue(__pyx_v_summaries); if (unlikely(__pyx_t_18 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      if (__pyx_t_18) {
-        __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_summaries, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_4);
-        __pyx_t_14 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__end); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_17 = __Pyx_PyObject_IsTrue(__pyx_v_summaries); if (unlikely(__pyx_t_17 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__pyx_t_17) {
+        __pyx_t_13 = __Pyx_GetItemInt(__pyx_v_summaries, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_13) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_13);
+        __pyx_t_14 = PyObject_GetAttr(__pyx_t_13, __pyx_n_s__end); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_14);
-        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-        __pyx_t_4 = PyObject_RichCompare(__pyx_t_14, __pyx_v_base_start, Py_LE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_GOTREF(__pyx_t_4);
+        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+        __pyx_t_13 = PyLong_FromUnsignedLong(__pyx_v_base_start); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_13);
+        __pyx_t_2 = PyObject_RichCompare(__pyx_t_14, __pyx_t_13, Py_LE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
         __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
-        __pyx_t_19 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_19 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-        __pyx_t_20 = __pyx_t_19;
+        __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+        __pyx_t_18 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_18 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 316; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __pyx_t_19 = __pyx_t_18;
       } else {
-        __pyx_t_20 = __pyx_t_18;
+        __pyx_t_19 = __pyx_t_17;
       }
-      if (!__pyx_t_20) break;
-
-      /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":324
+      if (!__pyx_t_19) break;
+
+      /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":317
  * 
  *             while summaries and summaries[0].end <= base_start:
  *                 summaries.popleft()             # <<<<<<<<<<<<<<
  * 
  *             valid_count[i], sum_data[i], sum_squares[i], min_val[i], max_val[i] = self._get_summary_slice(base_start, base_end, summaries)
  */
-      __pyx_t_4 = PyObject_GetAttr(__pyx_v_summaries, __pyx_n_s__popleft); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_4);
-      __pyx_t_14 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_14);
-      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
-    }
-
-    /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":326
+      __pyx_t_2 = PyObject_GetAttr(__pyx_v_summaries, __pyx_n_s__popleft); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_13 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_13);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+    }
+
+    /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":319
  *                 summaries.popleft()
  * 
  *             valid_count[i], sum_data[i], sum_squares[i], min_val[i], max_val[i] = self._get_summary_slice(base_start, base_end, summaries)             # <<<<<<<<<<<<<<
  *             base_start = base_end
  * 
  */
-    __pyx_t_1 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_base_start); if (unlikely((__pyx_t_1 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_21 = __Pyx_PyInt_AsUnsignedInt(__pyx_v_base_end); if (unlikely((__pyx_t_21 == (unsigned int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_14 = ((struct __pyx_vtabstruct_2bx_3bbi_8bbi_file_ZoomLevel *)__pyx_v_self->__pyx_vtab)->_get_summary_slice(__pyx_v_self, __pyx_t_1, __pyx_t_21, __pyx_v_summaries); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_14);
-    if (PyTuple_CheckExact(__pyx_t_14) && likely(PyTuple_GET_SIZE(__pyx_t_14) == 5)) {
-      PyObject* tuple = __pyx_t_14;
-      __pyx_t_4 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_4);
-      __pyx_t_15 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_15);
-      __pyx_t_3 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_3);
-      __pyx_t_22 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_22);
-      __pyx_t_23 = PyTuple_GET_ITEM(tuple, 4); __Pyx_INCREF(__pyx_t_23);
+    __pyx_t_13 = ((struct __pyx_vtabstruct_2bx_3bbi_8bbi_file_ZoomLevel *)__pyx_v_self->__pyx_vtab)->_get_summary_slice(__pyx_v_self, __pyx_v_base_start, __pyx_v_base_end, __pyx_v_summaries); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_13);
+    if (PyTuple_CheckExact(__pyx_t_13) && likely(PyTuple_GET_SIZE(__pyx_t_13) == 5)) {
+      PyObject* tuple = __pyx_t_13;
+      __pyx_t_2 = PyTuple_GET_ITEM(tuple, 0); __Pyx_INCREF(__pyx_t_2);
+      __pyx_t_21 = __Pyx_PyInt_from_py_npy_uint64(__pyx_t_2); if (unlikely((__pyx_t_21 == (npy_uint64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_14 = PyTuple_GET_ITEM(tuple, 1); __Pyx_INCREF(__pyx_t_14);
+      __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_t_14); if (unlikely((__pyx_t_22 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
-      if (PyObject_SetItem(((PyObject *)__pyx_v_valid_count), __pyx_v_i, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      if (PyObject_SetItem(((PyObject *)__pyx_v_sum_data), __pyx_v_i, __pyx_t_15) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
-      if (PyObject_SetItem(((PyObject *)__pyx_v_sum_squares), __pyx_v_i, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      if (PyObject_SetItem(((PyObject *)__pyx_v_min_val), __pyx_v_i, __pyx_t_22) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
-      if (PyObject_SetItem(((PyObject *)__pyx_v_max_val), __pyx_v_i, __pyx_t_23) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
+      __pyx_t_1 = PyTuple_GET_ITEM(tuple, 2); __Pyx_INCREF(__pyx_t_1);
+      __pyx_t_23 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_23 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_12 = PyTuple_GET_ITEM(tuple, 3); __Pyx_INCREF(__pyx_t_12);
+      __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_12); if (unlikely((__pyx_t_24 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+      __pyx_t_20 = PyTuple_GET_ITEM(tuple, 4); __Pyx_INCREF(__pyx_t_20);
+      __pyx_t_25 = __pyx_PyFloat_AsDouble(__pyx_t_20); if (unlikely((__pyx_t_25 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
+      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+      __pyx_t_26 = __pyx_v_i;
+      __pyx_t_27 = -1;
+      if (__pyx_t_26 < 0) {
+        __pyx_t_26 += __pyx_bshape_0_valid_count;
+        if (unlikely(__pyx_t_26 < 0)) __pyx_t_27 = 0;
+      } else if (unlikely(__pyx_t_26 >= __pyx_bshape_0_valid_count)) __pyx_t_27 = 0;
+      if (unlikely(__pyx_t_27 != -1)) {
+        __Pyx_RaiseBufferIndexError(__pyx_t_27);
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_uint64_t *, __pyx_bstruct_valid_count.buf, __pyx_t_26, __pyx_bstride_0_valid_count) = __pyx_t_21;
+      __pyx_t_27 = __pyx_v_i;
+      __pyx_t_28 = -1;
+      if (__pyx_t_27 < 0) {
+        __pyx_t_27 += __pyx_bshape_0_sum_data;
+        if (unlikely(__pyx_t_27 < 0)) __pyx_t_28 = 0;
+      } else if (unlikely(__pyx_t_27 >= __pyx_bshape_0_sum_data)) __pyx_t_28 = 0;
+      if (unlikely(__pyx_t_28 != -1)) {
+        __Pyx_RaiseBufferIndexError(__pyx_t_28);
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_sum_data.buf, __pyx_t_27, __pyx_bstride_0_sum_data) = __pyx_t_22;
+      __pyx_t_28 = __pyx_v_i;
+      __pyx_t_29 = -1;
+      if (__pyx_t_28 < 0) {
+        __pyx_t_28 += __pyx_bshape_0_sum_squares;
+        if (unlikely(__pyx_t_28 < 0)) __pyx_t_29 = 0;
+      } else if (unlikely(__pyx_t_28 >= __pyx_bshape_0_sum_squares)) __pyx_t_29 = 0;
+      if (unlikely(__pyx_t_29 != -1)) {
+        __Pyx_RaiseBufferIndexError(__pyx_t_29);
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_sum_squares.buf, __pyx_t_28, __pyx_bstride_0_sum_squares) = __pyx_t_23;
+      __pyx_t_29 = __pyx_v_i;
+      __pyx_t_30 = -1;
+      if (__pyx_t_29 < 0) {
+        __pyx_t_29 += __pyx_bshape_0_min_val;
+        if (unlikely(__pyx_t_29 < 0)) __pyx_t_30 = 0;
+      } else if (unlikely(__pyx_t_29 >= __pyx_bshape_0_min_val)) __pyx_t_30 = 0;
+      if (unlikely(__pyx_t_30 != -1)) {
+        __Pyx_RaiseBufferIndexError(__pyx_t_30);
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_min_val.buf, __pyx_t_29, __pyx_bstride_0_min_val) = __pyx_t_24;
+      __pyx_t_30 = __pyx_v_i;
+      __pyx_t_31 = -1;
+      if (__pyx_t_30 < 0) {
+        __pyx_t_30 += __pyx_bshape_0_max_val;
+        if (unlikely(__pyx_t_30 < 0)) __pyx_t_31 = 0;
+      } else if (unlikely(__pyx_t_30 >= __pyx_bshape_0_max_val)) __pyx_t_31 = 0;
+      if (unlikely(__pyx_t_31 != -1)) {
+        __Pyx_RaiseBufferIndexError(__pyx_t_31);
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_max_val.buf, __pyx_t_30, __pyx_bstride_0_max_val) = __pyx_t_25;
     } else {
-      __pyx_t_24 = PyObject_GetIter(__pyx_t_14); if (unlikely(!__pyx_t_24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_24);
+      __pyx_t_32 = PyObject_GetIter(__pyx_t_13); if (unlikely(!__pyx_t_32)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_32);
+      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+      __pyx_t_2 = __Pyx_UnpackItem(__pyx_t_32, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_21 = __Pyx_PyInt_from_py_npy_uint64(__pyx_t_2); if (unlikely((__pyx_t_21 == (npy_uint64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_14 = __Pyx_UnpackItem(__pyx_t_32, 1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_14);
+      __pyx_t_25 = __pyx_PyFloat_AsDouble(__pyx_t_14); if (unlikely((__pyx_t_25 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
-      __pyx_t_4 = __Pyx_UnpackItem(__pyx_t_24, 0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_4);
-      __pyx_t_15 = __Pyx_UnpackItem(__pyx_t_24, 1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_15);
-      __pyx_t_3 = __Pyx_UnpackItem(__pyx_t_24, 2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_22 = __Pyx_UnpackItem(__pyx_t_24, 3); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_22);
-      __pyx_t_23 = __Pyx_UnpackItem(__pyx_t_24, 4); if (unlikely(!__pyx_t_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_23);
-      if (__Pyx_EndUnpack(__pyx_t_24, 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_24); __pyx_t_24 = 0;
-      if (PyObject_SetItem(((PyObject *)__pyx_v_valid_count), __pyx_v_i, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      if (PyObject_SetItem(((PyObject *)__pyx_v_sum_data), __pyx_v_i, __pyx_t_15) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
-      if (PyObject_SetItem(((PyObject *)__pyx_v_sum_squares), __pyx_v_i, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      if (PyObject_SetItem(((PyObject *)__pyx_v_min_val), __pyx_v_i, __pyx_t_22) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_22); __pyx_t_22 = 0;
-      if (PyObject_SetItem(((PyObject *)__pyx_v_max_val), __pyx_v_i, __pyx_t_23) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_DECREF(__pyx_t_23); __pyx_t_23 = 0;
-    }
-
-    /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":327
+      __pyx_t_1 = __Pyx_UnpackItem(__pyx_t_32, 2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_1); if (unlikely((__pyx_t_24 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_12 = __Pyx_UnpackItem(__pyx_t_32, 3); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_12);
+      __pyx_t_23 = __pyx_PyFloat_AsDouble(__pyx_t_12); if (unlikely((__pyx_t_23 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+      __pyx_t_20 = __Pyx_UnpackItem(__pyx_t_32, 4); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_20);
+      __pyx_t_22 = __pyx_PyFloat_AsDouble(__pyx_t_20); if (unlikely((__pyx_t_22 == (npy_float64)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
+      if (__Pyx_EndUnpack(__pyx_t_32, 5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_32); __pyx_t_32 = 0;
+      __pyx_t_31 = __pyx_v_i;
+      __pyx_t_33 = -1;
+      if (__pyx_t_31 < 0) {
+        __pyx_t_31 += __pyx_bshape_0_valid_count;
+        if (unlikely(__pyx_t_31 < 0)) __pyx_t_33 = 0;
+      } else if (unlikely(__pyx_t_31 >= __pyx_bshape_0_valid_count)) __pyx_t_33 = 0;
+      if (unlikely(__pyx_t_33 != -1)) {
+        __Pyx_RaiseBufferIndexError(__pyx_t_33);
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_uint64_t *, __pyx_bstruct_valid_count.buf, __pyx_t_31, __pyx_bstride_0_valid_count) = __pyx_t_21;
+      __pyx_t_33 = __pyx_v_i;
+      __pyx_t_34 = -1;
+      if (__pyx_t_33 < 0) {
+        __pyx_t_33 += __pyx_bshape_0_sum_data;
+        if (unlikely(__pyx_t_33 < 0)) __pyx_t_34 = 0;
+      } else if (unlikely(__pyx_t_33 >= __pyx_bshape_0_sum_data)) __pyx_t_34 = 0;
+      if (unlikely(__pyx_t_34 != -1)) {
+        __Pyx_RaiseBufferIndexError(__pyx_t_34);
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_sum_data.buf, __pyx_t_33, __pyx_bstride_0_sum_data) = __pyx_t_25;
+      __pyx_t_34 = __pyx_v_i;
+      __pyx_t_35 = -1;
+      if (__pyx_t_34 < 0) {
+        __pyx_t_34 += __pyx_bshape_0_sum_squares;
+        if (unlikely(__pyx_t_34 < 0)) __pyx_t_35 = 0;
+      } else if (unlikely(__pyx_t_34 >= __pyx_bshape_0_sum_squares)) __pyx_t_35 = 0;
+      if (unlikely(__pyx_t_35 != -1)) {
+        __Pyx_RaiseBufferIndexError(__pyx_t_35);
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_sum_squares.buf, __pyx_t_34, __pyx_bstride_0_sum_squares) = __pyx_t_24;
+      __pyx_t_35 = __pyx_v_i;
+      __pyx_t_36 = -1;
+      if (__pyx_t_35 < 0) {
+        __pyx_t_35 += __pyx_bshape_0_min_val;
+        if (unlikely(__pyx_t_35 < 0)) __pyx_t_36 = 0;
+      } else if (unlikely(__pyx_t_35 >= __pyx_bshape_0_min_val)) __pyx_t_36 = 0;
+      if (unlikely(__pyx_t_36 != -1)) {
+        __Pyx_RaiseBufferIndexError(__pyx_t_36);
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_min_val.buf, __pyx_t_35, __pyx_bstride_0_min_val) = __pyx_t_23;
+      __pyx_t_36 = __pyx_v_i;
+      __pyx_t_37 = -1;
+      if (__pyx_t_36 < 0) {
+        __pyx_t_36 += __pyx_bshape_0_max_val;
+        if (unlikely(__pyx_t_36 < 0)) __pyx_t_37 = 0;
+      } else if (unlikely(__pyx_t_36 >= __pyx_bshape_0_max_val)) __pyx_t_37 = 0;
+      if (unlikely(__pyx_t_37 != -1)) {
+        __Pyx_RaiseBufferIndexError(__pyx_t_37);
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_max_val.buf, __pyx_t_36, __pyx_bstride_0_max_val) = __pyx_t_22;
+    }
+
+    /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":320
  * 
  *             valid_count[i], sum_data[i], sum_squares[i], min_val[i], max_val[i] = self._get_summary_slice(base_start, base_end, summaries)
  *             base_start = base_end             # <<<<<<<<<<<<<<
  * 
  *         return rval
  */
-    __Pyx_INCREF(__pyx_v_base_end);
-    __Pyx_DECREF(__pyx_v_base_start);
     __pyx_v_base_start = __pyx_v_base_end;
   }
-  __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
-
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":329
+
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":322
  *             base_start = base_end
  * 
  *         return rval             # <<<<<<<<<<<<<<
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_3);
-  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_12);
+  __Pyx_XDECREF(__pyx_t_13);
   __Pyx_XDECREF(__pyx_t_14);
-  __Pyx_XDECREF(__pyx_t_15);
-  __Pyx_XDECREF(__pyx_t_16);
-  __Pyx_XDECREF(__pyx_t_22);
-  __Pyx_XDECREF(__pyx_t_23);
-  __Pyx_XDECREF(__pyx_t_24);
+  __Pyx_XDECREF(__pyx_t_20);
+  __Pyx_XDECREF(__pyx_t_32);
   { PyObject *__pyx_type, *__pyx_value, *__pyx_tb;
     __Pyx_ErrFetch(&__pyx_type, &__pyx_value, &__pyx_tb);
+    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_sum_squares);
     __Pyx_SafeReleaseBuffer(&__pyx_bstruct_valid_count);
+    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_min_val);
+    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_sum_data);
     __Pyx_SafeReleaseBuffer(&__pyx_bstruct_max_val);
-    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_min_val);
-    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_sum_squares);
-    __Pyx_SafeReleaseBuffer(&__pyx_bstruct_sum_data);
   __Pyx_ErrRestore(__pyx_type, __pyx_value, __pyx_tb);}
   __Pyx_AddTraceback("bx.bbi.bbi_file.ZoomLevel._summarize");
   __pyx_r = 0;
   goto __pyx_L2;
   __pyx_L0:;
+  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_sum_squares);
   __Pyx_SafeReleaseBuffer(&__pyx_bstruct_valid_count);
+  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_min_val);
+  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_sum_data);
   __Pyx_SafeReleaseBuffer(&__pyx_bstruct_max_val);
-  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_min_val);
-  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_sum_squares);
-  __Pyx_SafeReleaseBuffer(&__pyx_bstruct_sum_data);
   __pyx_L2:;
   __Pyx_DECREF((PyObject *)__pyx_v_valid_count);
   __Pyx_DECREF((PyObject *)__pyx_v_min_val);
   __Pyx_DECREF((PyObject *)__pyx_v_rval);
   __Pyx_DECREF(__pyx_v_reader);
   __Pyx_DECREF(__pyx_v_summaries);
-  __Pyx_DECREF(__pyx_v_base_start);
-  __Pyx_DECREF(__pyx_v_baseCount);
-  __Pyx_DECREF(__pyx_v_i);
-  __Pyx_DECREF(__pyx_v_base_end);
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
      "Buffer acquisition failed on assignment; and then reacquiring the old buffer failed too!");
 }
 
+static void __Pyx_RaiseBufferIndexError(int axis) {
+  PyErr_Format(PyExc_IndexError,
+     "Out of bounds on buffer access (axis %d)", axis);
+}
+
 
 static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
     PyObject *tmp_type, *tmp_value, *tmp_tb;
 }
 #endif
 
-#if PY_MAJOR_VERSION < 3
-static PyObject *__Pyx_GetStdout(void) {
-    PyObject *f = PySys_GetObject((char *)"stdout");
-    if (!f) {
-        PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout");
-    }
-    return f;
-}
-
-static int __Pyx_Print(PyObject* f, PyObject *arg_tuple, int newline) {
-    PyObject* v;
-    int i;
-
-    if (!f) {
-        if (!(f = __Pyx_GetStdout()))
-            return -1;
-    }
-    for (i=0; i < PyTuple_GET_SIZE(arg_tuple); i++) {
-        if (PyFile_SoftSpace(f, 1)) {
-            if (PyFile_WriteString(" ", f) < 0)
-                return -1;
+static CYTHON_INLINE npy_uint64 __Pyx_PyInt_from_py_npy_uint64(PyObject* x) {
+    const npy_uint64 neg_one = (npy_uint64)-1, const_zero = (npy_uint64)0;
+    const int is_unsigned = const_zero < neg_one;
+    if (sizeof(npy_uint64) == sizeof(char)) {
+        if (is_unsigned)
+            return (npy_uint64)__Pyx_PyInt_AsUnsignedChar(x);
+        else
+            return (npy_uint64)__Pyx_PyInt_AsSignedChar(x);
+    } else if (sizeof(npy_uint64) == sizeof(short)) {
+        if (is_unsigned)
+            return (npy_uint64)__Pyx_PyInt_AsUnsignedShort(x);
+        else
+            return (npy_uint64)__Pyx_PyInt_AsSignedShort(x);
+    } else if (sizeof(npy_uint64) == sizeof(int)) {
+        if (is_unsigned)
+            return (npy_uint64)__Pyx_PyInt_AsUnsignedInt(x);
+        else
+            return (npy_uint64)__Pyx_PyInt_AsSignedInt(x);
+    } else if (sizeof(npy_uint64) == sizeof(long)) {
+        if (is_unsigned)
+            return (npy_uint64)__Pyx_PyInt_AsUnsignedLong(x);
+        else
+            return (npy_uint64)__Pyx_PyInt_AsSignedLong(x);
+    } else if (sizeof(npy_uint64) == sizeof(PY_LONG_LONG)) {
+        if (is_unsigned)
+            return (npy_uint64)__Pyx_PyInt_AsUnsignedLongLong(x);
+        else
+            return (npy_uint64)__Pyx_PyInt_AsSignedLongLong(x);
+    }  else {
+        npy_uint64 val;
+        PyObject *v = __Pyx_PyNumber_Int(x);
+        #if PY_VERSION_HEX < 0x03000000
+        if (likely(v) && !PyLong_Check(v)) {
+            PyObject *tmp = v;
+            v = PyNumber_Long(tmp);
+            Py_DECREF(tmp);
         }
-        v = PyTuple_GET_ITEM(arg_tuple, i);
-        if (PyFile_WriteObject(v, f, Py_PRINT_RAW) < 0)
-            return -1;
-        if (PyString_Check(v)) {
-            char *s = PyString_AsString(v);
-            Py_ssize_t len = PyString_Size(v);
-            if (len > 0 &&
-                isspace(Py_CHARMASK(s[len-1])) &&
-                s[len-1] != ' ')
-                    PyFile_SoftSpace(f, 0);
+        #endif
+        if (likely(v)) {
+            int one = 1; int is_little = (int)*(unsigned char *)&one;
+            unsigned char *bytes = (unsigned char *)&val;
+            int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                          bytes, sizeof(val),
+                                          is_little, !is_unsigned);
+            Py_DECREF(v);
+            if (likely(!ret))
+                return val;
         }
-    }
-    if (newline) {
-        if (PyFile_WriteString("\n", f) < 0)
-            return -1;
-        PyFile_SoftSpace(f, 0);
-    }
-    return 0;
-}
-
-#else /* Python 3 has a print function */
-
-static int __Pyx_Print(PyObject* stream, PyObject *arg_tuple, int newline) {
-    PyObject* kwargs = 0;
-    PyObject* result = 0;
-    PyObject* end_string;
-    if (unlikely(!__pyx_print)) {
-        __pyx_print = __Pyx_GetAttrString(__pyx_b, "print");
-        if (!__pyx_print)
-            return -1;
-    }
-    if (stream) {
-        kwargs = PyDict_New();
-        if (unlikely(!kwargs))
-            return -1;
-        if (unlikely(PyDict_SetItemString(kwargs, "file", stream) < 0))
-            goto bad;
-        if (!newline) {
-            end_string = PyUnicode_FromStringAndSize(" ", 1);
-            if (unlikely(!end_string))
-                goto bad;
-            if (PyDict_SetItemString(kwargs, "end", end_string) < 0) {
-                Py_DECREF(end_string);
-                goto bad;
-            }
-            Py_DECREF(end_string);
-        }
-    } else if (!newline) {
-        if (unlikely(!__pyx_print_kwargs)) {
-            __pyx_print_kwargs = PyDict_New();
-            if (unlikely(!__pyx_print_kwargs))
-                return -1;
-            end_string = PyUnicode_FromStringAndSize(" ", 1);
-            if (unlikely(!end_string))
-                return -1;
-            if (PyDict_SetItemString(__pyx_print_kwargs, "end", end_string) < 0) {
-                Py_DECREF(end_string);
-                return -1;
-            }
-            Py_DECREF(end_string);
-        }
-        kwargs = __pyx_print_kwargs;
-    }
-    result = PyObject_Call(__pyx_print, arg_tuple, kwargs);
-    if (unlikely(kwargs) && (kwargs != __pyx_print_kwargs))
-        Py_DECREF(kwargs);
-    if (!result)
-        return -1;
-    Py_DECREF(result);
-    return 0;
-bad:
-    if (kwargs != __pyx_print_kwargs)
-        Py_XDECREF(kwargs);
-    return -1;
-}
-
-#endif
-
-#if PY_MAJOR_VERSION < 3
-
-static int __Pyx_PrintOne(PyObject* f, PyObject *o) {
-    if (!f) {
-        if (!(f = __Pyx_GetStdout()))
-            return -1;
-    }
-    if (PyFile_SoftSpace(f, 0)) {
-        if (PyFile_WriteString(" ", f) < 0)
-            return -1;
-    }
-    if (PyFile_WriteObject(o, f, Py_PRINT_RAW) < 0)
-        return -1;
-    if (PyFile_WriteString("\n", f) < 0)
-        return -1;
-    return 0;
-    /* the line below is just to avoid compiler
-     * compiler warnings about unused functions */
-    return __Pyx_Print(f, NULL, 0);
-}
-
-#else /* Python 3 has a print function */
-
-static int __Pyx_PrintOne(PyObject* stream, PyObject *o) {
-    int res;
-    PyObject* arg_tuple = PyTuple_New(1);
-    if (unlikely(!arg_tuple))
-        return -1;
-    Py_INCREF(o);
-    PyTuple_SET_ITEM(arg_tuple, 0, o);
-    res = __Pyx_Print(stream, arg_tuple, 1);
-    Py_DECREF(arg_tuple);
-    return res;
-}
-
-#endif
+        return (npy_uint64)-1;
+    }
+}
 
 #if CYTHON_CCOMPLEX
   #ifdef __cplusplus

lib/bx/bbi/bbi_file.pyx

           - bbiSummarySlice is then used to aggregate over the subset of those 
             summaries that overlap a single summary element
         """
-        cdef CIRTreeFile ctf
-        cdef bits32 b_chrom_id, b_start, b_end, b_valid_count
-        cdef bits32 s_start, s_end, s_valid_count
-        cdef bits32 p_start, p_end
-        cdef float b_min_val, b_max_val, b_sum_data, b_sum_squares
-        # Factor to map base positions to array indexes, also size in bases of 
-        # a single summary value
-        cdef float base_to_index_factor = ( end - start ) / <float> summary_size
-        cdef int overlap
-        cdef double overlap_factor
+        cdef bits32 base_start, base_end, base_step
+        
         # We locally cdef the arrays so all indexing will be at C speeds
         cdef numpy.ndarray[numpy.uint64_t] valid_count
         cdef numpy.ndarray[numpy.float64_t] min_val
         cdef numpy.ndarray[numpy.float64_t] max_val
         cdef numpy.ndarray[numpy.float64_t] sum_data
         cdef numpy.ndarray[numpy.float64_t] sum_squares
+        
         # What we will load into
         rval = SummarizedData( summary_size )
         valid_count = rval.valid_count
         reader.seek( self.index_offset )
         summaries = self._summary_blocks_in_region(chrom_id, start, end)
         
+        base_step = (end - start) / summary_size
         base_start = start
-        baseCount = end - start
+        base_end = start
         
         for i in range(summary_size):
-            print i
-            base_end = start + baseCount*(i+1)/summary_size
+            base_end += base_step
             
             while summaries and summaries[0].end <= base_start:
                 summaries.popleft()

lib/bx/bbi/bigwig_file.c

-/* Generated by Cython 0.13 on Thu Dec  9 16:03:02 2010 */
+/* Generated by Cython 0.13 on Thu Dec  9 17:09:53 2010 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
   __pyx_t_2bx_3bbi_5types_UBYTE __pyx_v_b_type;
   __pyx_t_2bx_3bbi_5types_bits32 __pyx_v_base_start;
   __pyx_t_2bx_3bbi_5types_bits32 __pyx_v_base_end;
+  __pyx_t_2bx_3bbi_5types_bits32 __pyx_v_base_step;
   __pyx_t_2bx_3bbi_5types_bits32 __pyx_v_end1;
   int __pyx_v_s;
   int __pyx_v_e;
   float __pyx_v_val;
-  float __pyx_v_base_to_index_factor;
   PyArrayObject *__pyx_v_valid_count;
   PyArrayObject *__pyx_v_min_val;
   PyArrayObject *__pyx_v_max_val;
   PyObject *__pyx_v_block_data;
   Py_ssize_t __pyx_v_block_size;
   PyObject *__pyx_v_block_reader;
-  PyObject *__pyx_v_baseCount;
+  Py_buffer __pyx_bstruct_valid_count;
+  Py_ssize_t __pyx_bstride_0_valid_count = 0;
+  Py_ssize_t __pyx_bshape_0_valid_count = 0;
   Py_buffer __pyx_bstruct_sum_squares;
   Py_ssize_t __pyx_bstride_0_sum_squares = 0;
   Py_ssize_t __pyx_bshape_0_sum_squares = 0;
-  Py_buffer __pyx_bstruct_valid_count;
-  Py_ssize_t __pyx_bstride_0_valid_count = 0;
-  Py_ssize_t __pyx_bshape_0_valid_count = 0;
   Py_buffer __pyx_bstruct_max_val;
   Py_ssize_t __pyx_bstride_0_max_val = 0;
   Py_ssize_t __pyx_bshape_0_max_val = 0;
   Py_ssize_t __pyx_bstride_0_sum_data = 0;
   Py_ssize_t __pyx_bshape_0_sum_data = 0;
   PyObject *__pyx_r = NULL;
-  __pyx_t_2bx_3bbi_5types_bits32 __pyx_t_1;
-  float __pyx_t_2;
-  PyObject *__pyx_t_3 = NULL;
-  PyObject *__pyx_t_4 = NULL;
-  PyArrayObject *__pyx_t_5 = NULL;
-  int __pyx_t_6;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyArrayObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
   PyObject *__pyx_t_7 = NULL;
-  PyObject *__pyx_t_8 = NULL;
-  PyObject *__pyx_t_9 = NULL;
-  PyArrayObject *__pyx_t_10 = NULL;
-  Py_ssize_t __pyx_t_11;
-  PyObject *__pyx_t_12 = NULL;
+  PyArrayObject *__pyx_t_8 = NULL;
+  Py_ssize_t __pyx_t_9;
+  PyObject *__pyx_t_10 = NULL;
+  PyArrayObject *__pyx_t_11 = NULL;
+  PyArrayObject *__pyx_t_12 = NULL;
   PyArrayObject *__pyx_t_13 = NULL;
-  PyArrayObject *__pyx_t_14 = NULL;
-  PyArrayObject *__pyx_t_15 = NULL;
-  PyObject *__pyx_t_16 = NULL;
-  PyObject *__pyx_t_17 = NULL;
-  int __pyx_t_18;
-  Py_ssize_t __pyx_t_19;
-  __pyx_t_2bx_3bbi_5types_UBYTE __pyx_t_20;
-  __pyx_t_2bx_3bbi_5types_bits16 __pyx_t_21;
-  long __pyx_t_22;
+  PyObject *__pyx_t_14 = NULL;
+  PyObject *__pyx_t_15 = NULL;
+  int __pyx_t_16;
+  Py_ssize_t __pyx_t_17;
+  __pyx_t_2bx_3bbi_5types_bits32 __pyx_t_18;
+  __pyx_t_2bx_3bbi_5types_UBYTE __pyx_t_19;
+  __pyx_t_2bx_3bbi_5types_bits16 __pyx_t_20;
+  long __pyx_t_21;
+  float __pyx_t_22;
   int __pyx_t_23;
   int __pyx_t_24;
   PyObject *__pyx_t_25 = NULL;
   __pyx_v_size = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_block_data = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_block_reader = Py_None; __Pyx_INCREF(Py_None);
-  __pyx_v_baseCount = Py_None; __Pyx_INCREF(Py_None);
   __pyx_bstruct_valid_count.buf = NULL;
   __pyx_bstruct_min_val.buf = NULL;
   __pyx_bstruct_max_val.buf = NULL;
   __pyx_bstruct_sum_data.buf = NULL;
   __pyx_bstruct_sum_squares.buf = NULL;
 
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":81
- *         # Factor to map base positions to array indexes, also size in bases of
- *         # a single summary value
- *         cdef float base_to_index_factor = ( end - start ) / <float> summary_size             # <<<<<<<<<<<<<<
- *         # We locally cdef the arrays so all indexing will be at C speeds
- *         cdef numpy.ndarray[numpy.uint64_t] valid_count
- */
-  __pyx_t_1 = (__pyx_v_end - __pyx_v_start);
-  __pyx_t_2 = ((float)__pyx_v_summary_size);
-  if (unlikely(__pyx_t_2 == 0)) {
-    PyErr_Format(PyExc_ZeroDivisionError, "float division");
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  }
-  __pyx_v_base_to_index_factor = (__pyx_t_1 / __pyx_t_2);
-
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":88
- *         cdef numpy.ndarray[numpy.float64_t] sum_data
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":86
  *         cdef numpy.ndarray[numpy.float64_t] sum_squares
+ * 
  *         intervals = deque()             # <<<<<<<<<<<<<<
  *         # What we will load into
  *         rval = SummarizedData( summary_size )
  */
-  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__deque); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __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_GOTREF(__pyx_t_4);
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__deque); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_v_intervals);
-  __pyx_v_intervals = __pyx_t_4;
-  __pyx_t_4 = 0;
-
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":90
+  __pyx_v_intervals = __pyx_t_2;
+  __pyx_t_2 = 0;
+
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":88
  *         intervals = deque()
  *         # What we will load into
  *         rval = SummarizedData( summary_size )             # <<<<<<<<<<<<<<
  *         valid_count = rval.valid_count
  * 
  */
-  __pyx_t_4 = PyInt_FromLong(__pyx_v_summary_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __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 = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__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 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_2bx_3bbi_8bbi_file_SummarizedData)), __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_2 = PyInt_FromLong(__pyx_v_summary_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_2bx_3bbi_8bbi_file_SummarizedData)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_v_rval));
-  __pyx_v_rval = ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_t_4);
-  __pyx_t_4 = 0;
-
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":91
+  __pyx_v_rval = ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":89
  *         # What we will load into
  *         rval = SummarizedData( summary_size )
  *         valid_count = rval.valid_count             # <<<<<<<<<<<<<<
  * 
  *         min_val = rval.min_val
  */
-  __pyx_t_5 = ((PyArrayObject *)__pyx_v_rval->valid_count);
+  __pyx_t_3 = ((PyArrayObject *)__pyx_v_rval->valid_count);
   {
     __Pyx_BufFmt_StackElem __pyx_stack[1];
     __Pyx_SafeReleaseBuffer(&__pyx_bstruct_valid_count);
-    __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_valid_count, (PyObject*)__pyx_t_5, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
-    if (unlikely(__pyx_t_6 < 0)) {
-      PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
+    __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_valid_count, (PyObject*)__pyx_t_3, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
+    if (unlikely(__pyx_t_4 < 0)) {
+      PyErr_Fetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
       if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_valid_count, (PyObject*)__pyx_v_valid_count, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
-        Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
+        Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7);
         __Pyx_RaiseBufferFallbackError();
       } else {
-        PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
+        PyErr_Restore(__pyx_t_5, __pyx_t_6, __pyx_t_7);
       }
     }
     __pyx_bstride_0_valid_count = __pyx_bstruct_valid_count.strides[0];
     __pyx_bshape_0_valid_count = __pyx_bstruct_valid_count.shape[0];
-    if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
-  __pyx_t_5 = 0;
+  __pyx_t_3 = 0;
   __Pyx_INCREF(((PyObject *)__pyx_v_rval->valid_count));
   __Pyx_DECREF(((PyObject *)__pyx_v_valid_count));
   __pyx_v_valid_count = ((PyArrayObject *)__pyx_v_rval->valid_count);
 
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":93
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":91
  *         valid_count = rval.valid_count
  * 
  *         min_val = rval.min_val             # <<<<<<<<<<<<<<
  *         for i in range(summary_size):
  *             min_val[i] = +numpy.inf
  */
-  __pyx_t_10 = ((PyArrayObject *)__pyx_v_rval->min_val);
+  __pyx_t_8 = ((PyArrayObject *)__pyx_v_rval->min_val);
   {
     __Pyx_BufFmt_StackElem __pyx_stack[1];
     __Pyx_SafeReleaseBuffer(&__pyx_bstruct_min_val);
-    __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_min_val, (PyObject*)__pyx_t_10, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
-    if (unlikely(__pyx_t_6 < 0)) {
-      PyErr_Fetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
+    __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_min_val, (PyObject*)__pyx_t_8, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
+    if (unlikely(__pyx_t_4 < 0)) {
+      PyErr_Fetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5);
       if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_min_val, (PyObject*)__pyx_v_min_val, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
-        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7);
+        Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_5);
         __Pyx_RaiseBufferFallbackError();
       } else {
-        PyErr_Restore(__pyx_t_9, __pyx_t_8, __pyx_t_7);
+        PyErr_Restore(__pyx_t_7, __pyx_t_6, __pyx_t_5);
       }
     }
     __pyx_bstride_0_min_val = __pyx_bstruct_min_val.strides[0];
     __pyx_bshape_0_min_val = __pyx_bstruct_min_val.shape[0];
-    if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
-  __pyx_t_10 = 0;
+  __pyx_t_8 = 0;
   __Pyx_INCREF(((PyObject *)__pyx_v_rval->min_val));
   __Pyx_DECREF(((PyObject *)__pyx_v_min_val));
   __pyx_v_min_val = ((PyArrayObject *)__pyx_v_rval->min_val);
 
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":94
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":92
  * 
  *         min_val = rval.min_val
  *         for i in range(summary_size):             # <<<<<<<<<<<<<<
  *             min_val[i] = +numpy.inf
  * 
  */
-  __pyx_t_4 = PyInt_FromLong(__pyx_v_summary_size); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __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 = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__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 = PyObject_Call(__pyx_builtin_range, __pyx_t_3, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  if (PyList_CheckExact(__pyx_t_4) || PyTuple_CheckExact(__pyx_t_4)) {
-    __pyx_t_11 = 0; __pyx_t_3 = __pyx_t_4; __Pyx_INCREF(__pyx_t_3);
+  __pyx_t_2 = PyInt_FromLong(__pyx_v_summary_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_Call(__pyx_builtin_range, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
+    __pyx_t_9 = 0; __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1);
   } else {
-    __pyx_t_11 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_9 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
   }
-  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   for (;;) {
-    if (likely(PyList_CheckExact(__pyx_t_3))) {
-      if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_3)) break;
-      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_11); __Pyx_INCREF(__pyx_t_4); __pyx_t_11++;
-    } else if (likely(PyTuple_CheckExact(__pyx_t_3))) {
-      if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
-      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_11); __Pyx_INCREF(__pyx_t_4); __pyx_t_11++;
+    if (likely(PyList_CheckExact(__pyx_t_1))) {
+      if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_1)) break;
+      __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_1))) {
+      if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+      __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_2); __pyx_t_9++;
     } else {
-      __pyx_t_4 = PyIter_Next(__pyx_t_3);
-      if (!__pyx_t_4) {
-        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyIter_Next(__pyx_t_1);
+      if (!__pyx_t_2) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         break;
       }
-      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_GOTREF(__pyx_t_2);
     }
     __Pyx_DECREF(__pyx_v_i);
-    __pyx_v_i = __pyx_t_4;
-    __pyx_t_4 = 0;
-
-    /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":95
+    __pyx_v_i = __pyx_t_2;
+    __pyx_t_2 = 0;
+
+    /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":93
  *         min_val = rval.min_val
  *         for i in range(summary_size):
  *             min_val[i] = +numpy.inf             # <<<<<<<<<<<<<<
  * 
  *         max_val = rval.max_val
  */
-    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_12 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__inf); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_12);
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __pyx_t_4 = PyNumber_Positive(__pyx_t_12); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
-    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-    if (PyObject_SetItem(((PyObject *)__pyx_v_min_val), __pyx_v_i, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_10 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__inf); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_2 = PyNumber_Positive(__pyx_t_10); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    if (PyObject_SetItem(((PyObject *)__pyx_v_min_val), __pyx_v_i, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   }
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":97
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":95
  *             min_val[i] = +numpy.inf
  * 
  *         max_val = rval.max_val             # <<<<<<<<<<<<<<
  *         for i in range(summary_size):
  *             max_val[i] = -numpy.inf
  */
-  __pyx_t_13 = ((PyArrayObject *)__pyx_v_rval->max_val);
+  __pyx_t_11 = ((PyArrayObject *)__pyx_v_rval->max_val);
   {
     __Pyx_BufFmt_StackElem __pyx_stack[1];
     __Pyx_SafeReleaseBuffer(&__pyx_bstruct_max_val);
-    __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_max_val, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
-    if (unlikely(__pyx_t_6 < 0)) {
-      PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
+    __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_max_val, (PyObject*)__pyx_t_11, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
+    if (unlikely(__pyx_t_4 < 0)) {
+      PyErr_Fetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
       if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_max_val, (PyObject*)__pyx_v_max_val, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
-        Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
+        Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7);
         __Pyx_RaiseBufferFallbackError();
       } else {
-        PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
+        PyErr_Restore(__pyx_t_5, __pyx_t_6, __pyx_t_7);
       }
     }
     __pyx_bstride_0_max_val = __pyx_bstruct_max_val.strides[0];
     __pyx_bshape_0_max_val = __pyx_bstruct_max_val.shape[0];
-    if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
-  __pyx_t_13 = 0;
+  __pyx_t_11 = 0;
   __Pyx_INCREF(((PyObject *)__pyx_v_rval->max_val));
   __Pyx_DECREF(((PyObject *)__pyx_v_max_val));
   __pyx_v_max_val = ((PyArrayObject *)__pyx_v_rval->max_val);
 
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":98
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":96
  * 
  *         max_val = rval.max_val
  *         for i in range(summary_size):             # <<<<<<<<<<<<<<
  *             max_val[i] = -numpy.inf
  * 
  */
-  __pyx_t_3 = PyInt_FromLong(__pyx_v_summary_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
-  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
-  __Pyx_GIVEREF(__pyx_t_3);
-  __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_Call(__pyx_builtin_range, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  if (PyList_CheckExact(__pyx_t_3) || PyTuple_CheckExact(__pyx_t_3)) {
-    __pyx_t_11 = 0; __pyx_t_4 = __pyx_t_3; __Pyx_INCREF(__pyx_t_4);
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_summary_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __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 = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__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(__pyx_builtin_range, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
+    __pyx_t_9 = 0; __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2);
   } else {
-    __pyx_t_11 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_9 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
   }
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   for (;;) {
-    if (likely(PyList_CheckExact(__pyx_t_4))) {
-      if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_4)) break;
-      __pyx_t_3 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_3); __pyx_t_11++;
-    } else if (likely(PyTuple_CheckExact(__pyx_t_4))) {
-      if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
-      __pyx_t_3 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_11); __Pyx_INCREF(__pyx_t_3); __pyx_t_11++;
+    if (likely(PyList_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_2))) {
+      if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++;
     } else {
-      __pyx_t_3 = PyIter_Next(__pyx_t_4);
-      if (!__pyx_t_3) {
-        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyIter_Next(__pyx_t_2);
+      if (!__pyx_t_1) {
+        if (unlikely(PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         break;
       }
-      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_GOTREF(__pyx_t_1);
     }
     __Pyx_DECREF(__pyx_v_i);
-    __pyx_v_i = __pyx_t_3;
-    __pyx_t_3 = 0;
-
-    /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":99
+    __pyx_v_i = __pyx_t_1;
+    __pyx_t_1 = 0;
+
+    /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":97
  *         max_val = rval.max_val
  *         for i in range(summary_size):
  *             max_val[i] = -numpy.inf             # <<<<<<<<<<<<<<
  * 
  *         sum_data = rval.sum_data
  */
-    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_12 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__inf); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_12);
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyNumber_Negative(__pyx_t_12); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
-    if (PyObject_SetItem(((PyObject *)__pyx_v_max_val), __pyx_v_i, __pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_10 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__inf); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __pyx_t_1 = PyNumber_Negative(__pyx_t_10); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    if (PyObject_SetItem(((PyObject *)__pyx_v_max_val), __pyx_v_i, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 97; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   }
-  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":101
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":99
  *             max_val[i] = -numpy.inf
  * 
  *         sum_data = rval.sum_data             # <<<<<<<<<<<<<<
  *         sum_squares = rval.sum_squares
  *         # First, load up summaries
  */
-  __pyx_t_14 = ((PyArrayObject *)__pyx_v_rval->sum_data);
+  __pyx_t_12 = ((PyArrayObject *)__pyx_v_rval->sum_data);
   {
     __Pyx_BufFmt_StackElem __pyx_stack[1];
     __Pyx_SafeReleaseBuffer(&__pyx_bstruct_sum_data);
-    __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_sum_data, (PyObject*)__pyx_t_14, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
-    if (unlikely(__pyx_t_6 < 0)) {
-      PyErr_Fetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
+    __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_sum_data, (PyObject*)__pyx_t_12, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
+    if (unlikely(__pyx_t_4 < 0)) {
+      PyErr_Fetch(&__pyx_t_7, &__pyx_t_6, &__pyx_t_5);
       if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_sum_data, (PyObject*)__pyx_v_sum_data, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
-        Py_XDECREF(__pyx_t_9); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_7);
+        Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_5);
         __Pyx_RaiseBufferFallbackError();
       } else {
-        PyErr_Restore(__pyx_t_9, __pyx_t_8, __pyx_t_7);
+        PyErr_Restore(__pyx_t_7, __pyx_t_6, __pyx_t_5);
       }
     }
     __pyx_bstride_0_sum_data = __pyx_bstruct_sum_data.strides[0];
     __pyx_bshape_0_sum_data = __pyx_bstruct_sum_data.shape[0];
-    if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
-  __pyx_t_14 = 0;
+  __pyx_t_12 = 0;
   __Pyx_INCREF(((PyObject *)__pyx_v_rval->sum_data));
   __Pyx_DECREF(((PyObject *)__pyx_v_sum_data));
   __pyx_v_sum_data = ((PyArrayObject *)__pyx_v_rval->sum_data);
 
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":102
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":100
  * 
  *         sum_data = rval.sum_data
  *         sum_squares = rval.sum_squares             # <<<<<<<<<<<<<<
  *         # First, load up summaries
  *         reader = self.reader
  */
-  __pyx_t_15 = ((PyArrayObject *)__pyx_v_rval->sum_squares);
+  __pyx_t_13 = ((PyArrayObject *)__pyx_v_rval->sum_squares);
   {
     __Pyx_BufFmt_StackElem __pyx_stack[1];
     __Pyx_SafeReleaseBuffer(&__pyx_bstruct_sum_squares);
-    __pyx_t_6 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_sum_squares, (PyObject*)__pyx_t_15, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
-    if (unlikely(__pyx_t_6 < 0)) {
-      PyErr_Fetch(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
+    __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_sum_squares, (PyObject*)__pyx_t_13, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack);
+    if (unlikely(__pyx_t_4 < 0)) {
+      PyErr_Fetch(&__pyx_t_5, &__pyx_t_6, &__pyx_t_7);
       if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_sum_squares, (PyObject*)__pyx_v_sum_squares, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
-        Py_XDECREF(__pyx_t_7); Py_XDECREF(__pyx_t_8); Py_XDECREF(__pyx_t_9);
+        Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7);
         __Pyx_RaiseBufferFallbackError();
       } else {
-        PyErr_Restore(__pyx_t_7, __pyx_t_8, __pyx_t_9);
+        PyErr_Restore(__pyx_t_5, __pyx_t_6, __pyx_t_7);
       }
     }
     __pyx_bstride_0_sum_squares = __pyx_bstruct_sum_squares.strides[0];
     __pyx_bshape_0_sum_squares = __pyx_bstruct_sum_squares.shape[0];
-    if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
-  __pyx_t_15 = 0;
+  __pyx_t_13 = 0;
   __Pyx_INCREF(((PyObject *)__pyx_v_rval->sum_squares));
   __Pyx_DECREF(((PyObject *)__pyx_v_sum_squares));
   __pyx_v_sum_squares = ((PyArrayObject *)__pyx_v_rval->sum_squares);
 
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":104
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":102
  *         sum_squares = rval.sum_squares
  *         # First, load up summaries
  *         reader = self.reader             # <<<<<<<<<<<<<<
   __Pyx_DECREF(__pyx_v_reader);
   __pyx_v_reader = __pyx_v_self->__pyx_base.reader;
 
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":105
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":103
  *         # First, load up summaries
  *         reader = self.reader
  *         reader.seek( self.unzoomed_index_offset )             # <<<<<<<<<<<<<<
  *         ctf = CIRTreeFile( reader.file )
  *         block_list = ctf.find_overlapping_blocks( chrom_id, start, end )
  */
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__seek); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_3 = PyLong_FromUnsignedLongLong(__pyx_v_self->__pyx_base.unzoomed_index_offset); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_12);
-  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3);
-  __Pyx_GIVEREF(__pyx_t_3);
-  __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_Call(__pyx_t_4, __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __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_12); __pyx_t_12 = 0;
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":106
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__seek); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = PyLong_FromUnsignedLongLong(__pyx_v_self->__pyx_base.unzoomed_index_offset); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 103; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":104
  *         reader = self.reader
  *         reader.seek( self.unzoomed_index_offset )
  *         ctf = CIRTreeFile( reader.file )             # <<<<<<<<<<<<<<
  *         block_list = ctf.find_overlapping_blocks( chrom_id, start, end )
  *         for offset, size in block_list:
  */
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__file); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_12);
-  PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_3);
-  __Pyx_GIVEREF(__pyx_t_3);
-  __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_2bx_3bbi_12cirtree_file_CIRTreeFile)), __pyx_t_12, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_reader, __pyx_n_s__file); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  PyTuple_SET_ITEM(__pyx_t_10, 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)), __pyx_t_10, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_v_ctf));
-  __pyx_v_ctf = ((struct __pyx_obj_2bx_3bbi_12cirtree_file_CIRTreeFile *)__pyx_t_3);
-  __pyx_t_3 = 0;
-
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":107
+  __pyx_v_ctf = ((struct __pyx_obj_2bx_3bbi_12cirtree_file_CIRTreeFile *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":105
  *         reader.seek( self.unzoomed_index_offset )
  *         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_3 = PyObject_GetAttr(((PyObject *)__pyx_v_ctf), __pyx_n_s_2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_12 = PyLong_FromUnsignedLong(__pyx_v_chrom_id); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_12);
-  __pyx_t_4 = PyLong_FromUnsignedLong(__pyx_v_start); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_16 = PyLong_FromUnsignedLong(__pyx_v_end); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_16);
-  __pyx_t_17 = PyTuple_New(3); if (unlikely(!__pyx_t_17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_17);
-  PyTuple_SET_ITEM(__pyx_t_17, 0, __pyx_t_12);
-  __Pyx_GIVEREF(__pyx_t_12);
-  PyTuple_SET_ITEM(__pyx_t_17, 1, __pyx_t_4);
-  __Pyx_GIVEREF(__pyx_t_4);
-  PyTuple_SET_ITEM(__pyx_t_17, 2, __pyx_t_16);
-  __Pyx_GIVEREF(__pyx_t_16);
-  __pyx_t_12 = 0;
-  __pyx_t_4 = 0;
-  __pyx_t_16 = 0;
-  __pyx_t_16 = PyObject_Call(__pyx_t_3, __pyx_t_17, NULL); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 107; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_16);
-  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __Pyx_DECREF(__pyx_t_17); __pyx_t_17 = 0;
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_ctf), __pyx_n_s_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_10 = PyLong_FromUnsignedLong(__pyx_v_chrom_id); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  __pyx_t_2 = PyLong_FromUnsignedLong(__pyx_v_start); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_14 = PyLong_FromUnsignedLong(__pyx_v_end); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_14);
+  __pyx_t_15 = PyTuple_New(3); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_15);
+  PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_10);
+  __Pyx_GIVEREF(__pyx_t_10);
+  PyTuple_SET_ITEM(__pyx_t_15, 1, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_15, 2, __pyx_t_14);
+  __Pyx_GIVEREF(__pyx_t_14);
+  __pyx_t_10 = 0;
+  __pyx_t_2 = 0;
+  __pyx_t_14 = 0;
+  __pyx_t_14 = PyObject_Call(__pyx_t_1, __pyx_t_15, NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 105; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_14);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
   __Pyx_DECREF(__pyx_v_block_list);
-  __pyx_v_block_list = __pyx_t_16;
-  __pyx_t_16 = 0;
-
-  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":108
+  __pyx_v_block_list = __pyx_t_14;
+  __pyx_t_14 = 0;
+
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bigwig_file.pyx":106
  *         ctf = CIRTreeFile( reader.file )
  *         block_list = ctf.find_overlapping_blocks( chrom_id, start, end )
  *         for offset, size in block_list:             # <<<<<<<<<<<<<<
  *             reader.seek( offset )
  */
   if (PyList_CheckExact(__pyx_v_block_list) || PyTuple_CheckExact(__pyx_v_block_list)) {
-    __pyx_t_11 = 0; __pyx_t_16 = __pyx_v_block_list; __Pyx_INCREF(__pyx_t_16);
+    __pyx_t_9 = 0; __pyx_t_14 = __pyx_v_block_list; __Pyx_INCREF(__pyx_t_14);
   } else {
-    __pyx_t_11 = -1; __pyx_t_16 = PyObject_GetIter(__pyx_v_block_list); if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_16);
+    __pyx_t_9 = -1; __pyx_t_14 = PyObject_GetIter(__pyx_v_block_list); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_14);
   }
   for (;;) {
-    if (likely(PyList_CheckExact(__pyx_t_16))) {
-      if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_16)) break;
-      __pyx_t_17 = PyList_GET_ITEM(__pyx_t_16, __pyx_t_11); __Pyx_INCREF(__pyx_t_17); __pyx_t_11++;
-    } else if (likely(PyTuple_CheckExact(__pyx_t_16))) {
-      if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_16)) break;
-      __pyx_t_17 = PyTuple_GET_ITEM(__pyx_t_16, __pyx_t_11); __Pyx_INCREF(__pyx_t_17); __pyx_t_11++;
+    if (likely(PyList_CheckExact(__pyx_t_14))) {
+      if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_14)) break;
+      __pyx_t_15 = PyList_GET_ITEM(__pyx_t_14, __pyx_t_9); __Pyx_INCREF(__pyx_t_15); __pyx_t_9++;
+    } else if (likely(PyTuple_CheckExact(__pyx_t_14))) {