Commits

Kanwei Li  committed 9872019

Fix string padding in bbi.bpt_file. Fix edge case when valid_count was less than 1, causing a division by zero

  • Participants
  • Parent commits 480f64c

Comments (0)

Files changed (6)

File lib/bx/bbi/bbi_file.c

-/* Generated by Cython 0.13 on Thu Dec  9 17:09:42 2010 */
+/* Generated by Cython 0.13 on Fri Dec 10 12:38:56 2010 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 
 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
 
-static CYTHON_INLINE npy_uint64 __Pyx_PyInt_from_py_npy_uint64(PyObject *);
-
 #if CYTHON_CCOMPLEX
   #ifdef __cplusplus
     #define __Pyx_CREAL(z) ((z).real())
 static CYTHON_INLINE int __pyx_f_2bx_3bbi_8bbi_file_range_intersection(int, int, int, int); /*proto*/
 static CYTHON_INLINE int __pyx_f_2bx_3bbi_8bbi_file_imax(int, int); /*proto*/
 static CYTHON_INLINE int __pyx_f_2bx_3bbi_8bbi_file_imin(int, int); /*proto*/
-static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_uint64_t = { "uint64_t", NULL, sizeof(__pyx_t_5numpy_uint64_t), 'U' };
 static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t = { "float64_t", NULL, sizeof(__pyx_t_5numpy_float64_t), 'R' };
 #define __Pyx_MODULE_NAME "bx.bbi.bbi_file"
 int __pyx_module_is_main_bx__bbi__bbi_file = 0;
 static char __pyx_k__fields[] = "fields";
 static char __pyx_k__format[] = "format";
 static char __pyx_k__reader[] = "reader";
-static char __pyx_k__uint64[] = "uint64";
 static char __pyx_k__unpack[] = "unpack";
 static char __pyx_k__BBIFile[] = "BBIFile";
 static char __pyx_k__float64[] = "float64";
 static PyObject *__pyx_n_s__summary_size;
 static PyObject *__pyx_n_s__type_name;
 static PyObject *__pyx_n_s__type_num;
-static PyObject *__pyx_n_s__uint64;
 static PyObject *__pyx_n_s__uncompress_buf_size;
 static PyObject *__pyx_n_s__unpack;
 static PyObject *__pyx_n_s__valid_count;
  *     """
  *     def __init__( self, int size ):             # <<<<<<<<<<<<<<
  *         self.size = size
- *         self.valid_count = numpy.zeros( self.size, dtype=numpy.uint64 )
+ *         self.valid_count = numpy.zeros( self.size, dtype=numpy.float64 )
  */
 
 static int __pyx_pf_2bx_3bbi_8bbi_file_14SummarizedData___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
  *     """
  *     def __init__( self, int size ):
  *         self.size = size             # <<<<<<<<<<<<<<
- *         self.valid_count = numpy.zeros( self.size, dtype=numpy.uint64 )
+ *         self.valid_count = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.min_val = numpy.zeros( self.size, dtype=numpy.float64 )
  */
   ((struct __pyx_obj_2bx_3bbi_8bbi_file_SummarizedData *)__pyx_v_self)->size = __pyx_v_size;
   /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":56
  *     def __init__( self, int size ):
  *         self.size = size
- *         self.valid_count = numpy.zeros( self.size, dtype=numpy.uint64 )             # <<<<<<<<<<<<<<
+ *         self.valid_count = numpy.zeros( self.size, dtype=numpy.float64 )             # <<<<<<<<<<<<<<
  *         self.min_val = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.max_val = numpy.zeros( self.size, dtype=numpy.float64 )
  */
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
   __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__numpy); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__uint64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__float64); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__dtype), __pyx_t_5) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
   /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":57
  *         self.size = size
- *         self.valid_count = numpy.zeros( self.size, dtype=numpy.uint64 )
+ *         self.valid_count = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.min_val = numpy.zeros( self.size, dtype=numpy.float64 )             # <<<<<<<<<<<<<<
  *         self.max_val = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.sum_data = numpy.zeros( self.size, dtype=numpy.float64 )
   __pyx_t_4 = 0;
 
   /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":58
- *         self.valid_count = numpy.zeros( self.size, dtype=numpy.uint64 )
+ *         self.valid_count = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.min_val = numpy.zeros( self.size, dtype=numpy.float64 )
  *         self.max_val = numpy.zeros( self.size, dtype=numpy.float64 )             # <<<<<<<<<<<<<<
  *         self.sum_data = numpy.zeros( self.size, dtype=numpy.float64 )
  *         return rval
  * 
  *     cdef _get_summary_slice( self, bits32 base_start, bits32 base_end, summaries ):             # <<<<<<<<<<<<<<
- *         cdef float valid_count = 0
+ *         cdef float valid_count = 0.0
  *         cdef float sum_data = 0.0
  */
 
   /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":246
  * 
  *     cdef _get_summary_slice( self, bits32 base_start, bits32 base_end, summaries ):
- *         cdef float valid_count = 0             # <<<<<<<<<<<<<<
+ *         cdef float valid_count = 0.0             # <<<<<<<<<<<<<<
  *         cdef float sum_data = 0.0
  *         cdef float sum_squares = 0.0
  */
 
   /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":247
  *     cdef _get_summary_slice( self, bits32 base_start, bits32 base_end, summaries ):
- *         cdef float valid_count = 0
+ *         cdef float valid_count = 0.0
  *         cdef float sum_data = 0.0             # <<<<<<<<<<<<<<
  *         cdef float sum_squares = 0.0
  *         cdef float min_val = numpy.nan
   __pyx_v_sum_data = 0.0;
 
   /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":248
- *         cdef float valid_count = 0
+ *         cdef float valid_count = 0.0
  *         cdef float sum_data = 0.0
  *         cdef float sum_squares = 0.0             # <<<<<<<<<<<<<<
  *         cdef float min_val = numpy.nan
   int __pyx_t_18;
   int __pyx_t_19;
   PyObject *__pyx_t_20 = NULL;
-  __pyx_t_5numpy_uint64_t __pyx_t_21;
+  __pyx_t_5numpy_float64_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_BufFmt_StackElem __pyx_stack[1];
     __Pyx_SafeReleaseBuffer(&__pyx_bstruct_valid_count);
-    __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);
+    __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_valid_count, (PyObject*)__pyx_t_3, &__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_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)) {
+      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_valid_count, (PyObject*)__pyx_v_valid_count, &__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 {
     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_t_21 = __pyx_PyFloat_AsDouble(__pyx_t_2); if (unlikely((__pyx_t_21 == (npy_float64)-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_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_BufPtrStrided1d(__pyx_t_5numpy_float64_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_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_t_25 = __pyx_PyFloat_AsDouble(__pyx_t_2); 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_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_t_24 = __pyx_PyFloat_AsDouble(__pyx_t_14); 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_14); __pyx_t_14 = 0;
       __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_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 = __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_t_22 = __pyx_PyFloat_AsDouble(__pyx_t_12); 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_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_t_21 = __pyx_PyFloat_AsDouble(__pyx_t_20); if (unlikely((__pyx_t_21 == (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_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_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_valid_count.buf, __pyx_t_31, __pyx_bstride_0_valid_count) = __pyx_t_25;
       __pyx_t_33 = __pyx_v_i;
       __pyx_t_34 = -1;
       if (__pyx_t_33 < 0) {
         __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_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_sum_data.buf, __pyx_t_33, __pyx_bstride_0_sum_data) = __pyx_t_24;
       __pyx_t_34 = __pyx_v_i;
       __pyx_t_35 = -1;
       if (__pyx_t_34 < 0) {
         __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_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_sum_squares.buf, __pyx_t_34, __pyx_bstride_0_sum_squares) = __pyx_t_23;
       __pyx_t_35 = __pyx_v_i;
       __pyx_t_36 = -1;
       if (__pyx_t_35 < 0) {
         __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_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_min_val.buf, __pyx_t_35, __pyx_bstride_0_min_val) = __pyx_t_22;
       __pyx_t_36 = __pyx_v_i;
       __pyx_t_37 = -1;
       if (__pyx_t_36 < 0) {
         __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;
+      *__Pyx_BufPtrStrided1d(__pyx_t_5numpy_float64_t *, __pyx_bstruct_max_val.buf, __pyx_t_36, __pyx_bstride_0_max_val) = __pyx_t_21;
     }
 
     /* "/Users/kanwei/bx-python/lib/bx/bbi/bbi_file.pyx":320
   {&__pyx_n_s__summary_size, __pyx_k__summary_size, sizeof(__pyx_k__summary_size), 0, 0, 1, 1},
   {&__pyx_n_s__type_name, __pyx_k__type_name, sizeof(__pyx_k__type_name), 0, 0, 1, 1},
   {&__pyx_n_s__type_num, __pyx_k__type_num, sizeof(__pyx_k__type_num), 0, 0, 1, 1},
-  {&__pyx_n_s__uint64, __pyx_k__uint64, sizeof(__pyx_k__uint64), 0, 0, 1, 1},
   {&__pyx_n_s__uncompress_buf_size, __pyx_k__uncompress_buf_size, sizeof(__pyx_k__uncompress_buf_size), 0, 0, 1, 1},
   {&__pyx_n_s__unpack, __pyx_k__unpack, sizeof(__pyx_k__unpack), 0, 0, 1, 1},
   {&__pyx_n_s__valid_count, __pyx_k__valid_count, sizeof(__pyx_k__valid_count), 0, 0, 1, 1},
 }
 #endif
 
-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);
-        }
-        #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;
-        }
-        return (npy_uint64)-1;
-    }
-}
-
 #if CYTHON_CCOMPLEX
   #ifdef __cplusplus
     static CYTHON_INLINE __pyx_t_float_complex __pyx_t_float_complex_from_parts(float x, float y) {

File lib/bx/bbi/bbi_file.pyx

     """
     def __init__( self, int size ):
         self.size = size
-        self.valid_count = numpy.zeros( self.size, dtype=numpy.uint64 )
+        self.valid_count = numpy.zeros( self.size, dtype=numpy.float64 )
         self.min_val = numpy.zeros( self.size, dtype=numpy.float64 )
         self.max_val = numpy.zeros( self.size, dtype=numpy.float64 )
         self.sum_data = numpy.zeros( self.size, dtype=numpy.float64 )
         return rval
     
     cdef _get_summary_slice( self, bits32 base_start, bits32 base_end, summaries ):
-        cdef float valid_count = 0
+        cdef float valid_count = 0.0
         cdef float sum_data = 0.0
         cdef float sum_squares = 0.0
         cdef float min_val = numpy.nan
         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] 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

File lib/bx/bbi/bigwig_file.c

-/* Generated by Cython 0.13 on Thu Dec  9 17:09:53 2010 */
+/* Generated by Cython 0.13 on Fri Dec 10 12:39:07 2010 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 
 static PyTypeObject *__pyx_ptype_2bx_3bbi_11bigwig_file_BigWigFile = 0;
 static CYTHON_INLINE int __pyx_f_2bx_3bbi_11bigwig_file_range_intersection(int, int, int, int); /*proto*/
-static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_uint64_t = { "uint64_t", NULL, sizeof(__pyx_t_5numpy_uint64_t), 'U' };
 static __Pyx_TypeInfo __Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t = { "float64_t", NULL, sizeof(__pyx_t_5numpy_float64_t), 'R' };
 #define __Pyx_MODULE_NAME "bx.bbi.bigwig_file"
 int __pyx_module_is_main_bx__bbi__bigwig_file = 0;
   {
     __Pyx_BufFmt_StackElem __pyx_stack[1];
     __Pyx_SafeReleaseBuffer(&__pyx_bstruct_valid_count);
-    __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);
+    __pyx_t_4 = __Pyx_GetBufferAndValidate(&__pyx_bstruct_valid_count, (PyObject*)__pyx_t_3, &__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_valid_count, (PyObject*)__pyx_v_valid_count, &__Pyx_TypeInfo_nn___pyx_t_5numpy_uint64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
+      if (unlikely(__Pyx_GetBufferAndValidate(&__pyx_bstruct_valid_count, (PyObject*)__pyx_v_valid_count, &__Pyx_TypeInfo_nn___pyx_t_5numpy_float64_t, PyBUF_FORMAT| PyBUF_STRIDES, 1, 0, __pyx_stack) == -1)) {
         Py_XDECREF(__pyx_t_5); Py_XDECREF(__pyx_t_6); Py_XDECREF(__pyx_t_7);
         __Pyx_RaiseBufferFallbackError();
       } else {

File lib/bx/bbi/bigwig_file.pyx

         cdef float val
 
         # 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] 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

File lib/bx/bbi/bpt_file.c

-/* Generated by Cython 0.13 on Wed Oct 27 17:21:37 2010 */
+/* Generated by Cython 0.13 on Thu Dec  9 17:24:03 2010 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
 
 /* Type declarations */
 
-/* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pxd":5
+/* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pxd":5
  * from types cimport *
  * 
  * cdef class BPTFile:             # <<<<<<<<<<<<<<
 static PyObject *__pyx_int_8;
 static PyObject *__pyx_int_2026540177;
 
-/* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":13
+/* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":13
  *     """
  * 
  *     def __init__( self, file=None ):             # <<<<<<<<<<<<<<
   return -1;
   __pyx_L4_argument_unpacking_done:;
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":14
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":14
  * 
  *     def __init__( self, file=None ):
  *         if file is not None:             # <<<<<<<<<<<<<<
   __pyx_t_1 = (__pyx_v_file != Py_None);
   if (__pyx_t_1) {
 
-    /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":15
+    /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":15
  *     def __init__( self, file=None ):
  *         if file is not None:
  *             self.attach( file )             # <<<<<<<<<<<<<<
   return __pyx_r;
 }
 
-/* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":17
+/* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":17
  *             self.attach( file )
  * 
  *     def attach( self, file ):             # <<<<<<<<<<<<<<
   __Pyx_RefNannySetupContext("attach");
   __pyx_v_reader = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":21
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":21
  *         Attach to an open file
  *         """
  *         self.file = file             # <<<<<<<<<<<<<<
   __Pyx_DECREF(((struct __pyx_obj_2bx_3bbi_8bpt_file_BPTFile *)__pyx_v_self)->file);
   ((struct __pyx_obj_2bx_3bbi_8bpt_file_BPTFile *)__pyx_v_self)->file = __pyx_v_file;
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":22
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":22
  *         """
  *         self.file = file
  *         self.reader = reader = BinaryFileReader( file, bpt_sig )             # <<<<<<<<<<<<<<
   __pyx_v_reader = __pyx_t_3;
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":23
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":23
  *         self.file = file
  *         self.reader = reader = BinaryFileReader( file, bpt_sig )
  *         self.is_byteswapped = self.reader.byteswap_needed             # <<<<<<<<<<<<<<
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   ((struct __pyx_obj_2bx_3bbi_8bpt_file_BPTFile *)__pyx_v_self)->is_byteswapped = __pyx_t_4;
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":25
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":25
  *         self.is_byteswapped = self.reader.byteswap_needed
  *         # Read header stuff
  *         self.block_size = reader.read_uint32()             # <<<<<<<<<<<<<<
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   ((struct __pyx_obj_2bx_3bbi_8bpt_file_BPTFile *)__pyx_v_self)->block_size = __pyx_t_5;
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":26
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":26
  *         # Read header stuff
  *         self.block_size = reader.read_uint32()
  *         self.key_size = reader.read_uint32()             # <<<<<<<<<<<<<<
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   ((struct __pyx_obj_2bx_3bbi_8bpt_file_BPTFile *)__pyx_v_self)->key_size = __pyx_t_5;
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":27
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":27
  *         self.block_size = reader.read_uint32()
  *         self.key_size = reader.read_uint32()
  *         self.value_size = reader.read_uint32()             # <<<<<<<<<<<<<<
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   ((struct __pyx_obj_2bx_3bbi_8bpt_file_BPTFile *)__pyx_v_self)->value_size = __pyx_t_5;
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":28
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":28
  *         self.key_size = reader.read_uint32()
  *         self.value_size = reader.read_uint32()
  *         self.item_count = reader.read_uint64()             # <<<<<<<<<<<<<<
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   ((struct __pyx_obj_2bx_3bbi_8bpt_file_BPTFile *)__pyx_v_self)->item_count = __pyx_t_6;
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":29
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":29
  *         self.value_size = reader.read_uint32()
  *         self.item_count = reader.read_uint64()
  *         reader.skip( 8 )             # <<<<<<<<<<<<<<
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":30
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":30
  *         self.item_count = reader.read_uint64()
  *         reader.skip( 8 )
  *         self.root_offset = reader.tell()             # <<<<<<<<<<<<<<
   return __pyx_r;
 }
 
-/* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":32
+/* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":32
  *         self.root_offset = reader.tell()
  * 
  *     def r_find( self, bits64 block_start, key ):             # <<<<<<<<<<<<<<
   __pyx_v_node_key = Py_None; __Pyx_INCREF(Py_None);
   __pyx_v_node_value = Py_None; __Pyx_INCREF(Py_None);
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":40
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":40
  *         cdef bits16 child_count
  *         cdef bits64 offset
  *         self.reader.seek( block_start )             # <<<<<<<<<<<<<<
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":42
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":42
  *         self.reader.seek( block_start )
  *         # Block header
  *         is_leaf = self.reader.read_uint8()             # <<<<<<<<<<<<<<
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __pyx_v_is_leaf = __pyx_t_4;
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":43
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":43
  *         # Block header
  *         is_leaf = self.reader.read_uint8()
  *         self.reader.read_uint8()             # <<<<<<<<<<<<<<
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":44
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":44
  *         is_leaf = self.reader.read_uint8()
  *         self.reader.read_uint8()
  *         child_count = self.reader.read_uint16()             # <<<<<<<<<<<<<<
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __pyx_v_child_count = __pyx_t_5;
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":45
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":45
  *         self.reader.read_uint8()
  *         child_count = self.reader.read_uint16()
  *         if is_leaf:             # <<<<<<<<<<<<<<
  */
   if (__pyx_v_is_leaf) {
 
-    /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":46
+    /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":46
  *         child_count = self.reader.read_uint16()
  *         if is_leaf:
  *             for i from 0 <= i < child_count:             # <<<<<<<<<<<<<<
     __pyx_t_5 = __pyx_v_child_count;
     for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {
 
-      /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":47
+      /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":47
  *         if is_leaf:
  *             for i from 0 <= i < child_count:
  *                 node_key = self.reader.read( self.key_size )             # <<<<<<<<<<<<<<
       __pyx_v_node_key = __pyx_t_2;
       __pyx_t_2 = 0;
 
-      /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":48
+      /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":48
  *             for i from 0 <= i < child_count:
  *                 node_key = self.reader.read( self.key_size )
  *                 node_value = self.reader.read( self.value_size )             # <<<<<<<<<<<<<<
       __pyx_v_node_value = __pyx_t_1;
       __pyx_t_1 = 0;
 
-      /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":49
+      /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":49
  *                 node_key = self.reader.read( self.key_size )
  *                 node_value = self.reader.read( self.value_size )
  *                 if node_key == key:             # <<<<<<<<<<<<<<
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       if (__pyx_t_6) {
 
-        /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":50
+        /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":50
  *                 node_value = self.reader.read( self.value_size )
  *                 if node_key == key:
  *                     return node_value             # <<<<<<<<<<<<<<
       __pyx_L9:;
     }
 
-    /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":51
+    /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":51
  *                 if node_key == key:
  *                     return node_value
  *             return None             # <<<<<<<<<<<<<<
   }
   /*else*/ {
 
-    /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":54
+    /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":54
  *         else:
  *             # Read and discard first key, store offset
  *             self.reader.read( self.key_size )             # <<<<<<<<<<<<<<
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-    /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":55
+    /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":55
  *             # Read and discard first key, store offset
  *             self.reader.read( self.key_size )
  *             offset = self.reader.read_bits64()             # <<<<<<<<<<<<<<
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __pyx_v_offset = __pyx_t_7;
 
-    /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":57
+    /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":57
  *             offset = self.reader.read_bits64()
  *             # Loop until correct subtree is found
  *             for i from 0 <= i < child_count:             # <<<<<<<<<<<<<<
     __pyx_t_5 = __pyx_v_child_count;
     for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_5; __pyx_v_i++) {
 
-      /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":58
+      /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":58
  *             # Loop until correct subtree is found
  *             for i from 0 <= i < child_count:
  *                 node_key = self.reader.read( self.key_size )             # <<<<<<<<<<<<<<
       __pyx_v_node_key = __pyx_t_3;
       __pyx_t_3 = 0;
 
-      /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":59
+      /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":59
  *             for i from 0 <= i < child_count:
  *                 node_key = self.reader.read( self.key_size )
  *                 if node_key > key:             # <<<<<<<<<<<<<<
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       if (__pyx_t_6) {
 
-        /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":60
+        /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":60
  *                 node_key = self.reader.read( self.key_size )
  *                 if node_key > key:
  *                     break             # <<<<<<<<<<<<<<
       }
       __pyx_L12:;
 
-      /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":61
+      /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":61
  *                 if node_key > key:
  *                     break
  *                 offset = self.reader.read_bits64()             # <<<<<<<<<<<<<<
     }
     __pyx_L11_break:;
 
-    /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":62
+    /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":62
  *                     break
  *                 offset = self.reader.read_bits64()
  *             return self.r_find( offset, key )             # <<<<<<<<<<<<<<
   return __pyx_r;
 }
 
-/* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":64
+/* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":64
  *             return self.r_find( offset, key )
  * 
  *     def find( self, key ):             # <<<<<<<<<<<<<<
   __Pyx_RefNannySetupContext("find");
   __Pyx_INCREF(__pyx_v_key);
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":70
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":70
  *         """
  *         # Key is greater than key_size, must not be a match
- *         if len( key ) > self.key_size:             # <<<<<<<<<<<<<<
+ *         if len(key) > self.key_size:             # <<<<<<<<<<<<<<
  *             return None
  *         # Key is less than key_size, right pad with 0 bytes
  */
   __pyx_t_2 = (__pyx_t_1 > ((struct __pyx_obj_2bx_3bbi_8bpt_file_BPTFile *)__pyx_v_self)->key_size);
   if (__pyx_t_2) {
 
-    /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":71
+    /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":71
  *         # Key is greater than key_size, must not be a match
- *         if len( key ) > self.key_size:
+ *         if len(key) > self.key_size:
  *             return None             # <<<<<<<<<<<<<<
  *         # Key is less than key_size, right pad with 0 bytes
- *         if len( key ) < self.key_size:
+ *         if len(key) < self.key_size:
  */
     __Pyx_XDECREF(__pyx_r);
     __Pyx_INCREF(Py_None);
   }
   __pyx_L5:;
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":73
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":73
  *             return None
  *         # Key is less than key_size, right pad with 0 bytes
- *         if len( key ) < self.key_size:             # <<<<<<<<<<<<<<
- *             key += ( '\0' * self.key_size - len( key ) )
+ *         if len(key) < self.key_size:             # <<<<<<<<<<<<<<
+ *             key += ( '\0' * ( self.key_size - len(key) ) )
  *         # Call the recursive finder
  */
   __pyx_t_1 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_t_2 = (__pyx_t_1 < ((struct __pyx_obj_2bx_3bbi_8bpt_file_BPTFile *)__pyx_v_self)->key_size);
   if (__pyx_t_2) {
 
-    /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":74
+    /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":74
  *         # Key is less than key_size, right pad with 0 bytes
- *         if len( key ) < self.key_size:
- *             key += ( '\0' * self.key_size - len( key ) )             # <<<<<<<<<<<<<<
+ *         if len(key) < self.key_size:
+ *             key += ( '\0' * ( self.key_size - len(key) ) )             # <<<<<<<<<<<<<<
  *         # Call the recursive finder
  *         return self.r_find( self.root_offset, key )
  */
-    __pyx_t_3 = PyLong_FromUnsignedLong(((struct __pyx_obj_2bx_3bbi_8bpt_file_BPTFile *)__pyx_v_self)->key_size); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromSsize_t((((struct __pyx_obj_2bx_3bbi_8bpt_file_BPTFile *)__pyx_v_self)->key_size - __pyx_t_1)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_t_4 = PyNumber_Multiply(((PyObject *)__pyx_kp_s_1), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_1 = PyObject_Length(__pyx_v_key); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_3 = PyInt_FromSsize_t(__pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_key, ((PyObject *)__pyx_t_4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_5 = PyNumber_Subtract(((PyObject *)__pyx_t_4), __pyx_t_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
-    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_v_key, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __Pyx_GOTREF(__pyx_t_3);
-    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __Pyx_DECREF(__pyx_v_key);
     __pyx_v_key = __pyx_t_3;
     __pyx_t_3 = 0;
   }
   __pyx_L6:;
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":76
- *             key += ( '\0' * self.key_size - len( key ) )
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":76
+ *             key += ( '\0' * ( self.key_size - len(key) ) )
  *         # Call the recursive finder
  *         return self.r_find( self.root_offset, key )             # <<<<<<<<<<<<<<
  */
   __Pyx_XDECREF(__pyx_r);
   __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__r_find); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_5 = PyLong_FromUnsignedLongLong(((struct __pyx_obj_2bx_3bbi_8bpt_file_BPTFile *)__pyx_v_self)->root_offset); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyLong_FromUnsignedLongLong(((struct __pyx_obj_2bx_3bbi_8bpt_file_BPTFile *)__pyx_v_self)->root_offset); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
+  __Pyx_GIVEREF(__pyx_t_4);
+  __Pyx_INCREF(__pyx_v_key);
+  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_key);
+  __Pyx_GIVEREF(__pyx_v_key);
+  __pyx_t_4 = 0;
+  __pyx_t_4 = PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
-  __Pyx_GIVEREF(__pyx_t_5);
-  __Pyx_INCREF(__pyx_v_key);
-  PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_v_key);
-  __Pyx_GIVEREF(__pyx_v_key);
-  __pyx_t_5 = 0;
-  __pyx_t_5 = PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __pyx_r = __pyx_t_5;
-  __pyx_t_5 = 0;
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_r = __pyx_t_4;
+  __pyx_t_4 = 0;
   goto __pyx_L0;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   /*--- Function import code ---*/
   /*--- Execution code ---*/
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":1
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":1
  * from bx.misc.binary_file import BinaryFileReader             # <<<<<<<<<<<<<<
  * 
  * DEF bpt_sig = 0x78CA8C91
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":64
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":64
  *             return self.r_find( offset, key )
  * 
  *     def find( self, key ):             # <<<<<<<<<<<<<<
   __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
 
-  /* "/home/james/projects/bx-python/code/bx-python/lib/bx/bbi/bpt_file.pyx":1
+  /* "/Users/kanwei/bx-python/lib/bx/bbi/bpt_file.pyx":1
  * from bx.misc.binary_file import BinaryFileReader             # <<<<<<<<<<<<<<
  * 
  * DEF bpt_sig = 0x78CA8C91

File lib/bx/bbi/bpt_file.pyx

         value as a bytestring if found, or None
         """
         # Key is greater than key_size, must not be a match
-        if len( key ) > self.key_size:
+        if len(key) > self.key_size:
             return None
         # Key is less than key_size, right pad with 0 bytes
-        if len( key ) < self.key_size:
-            key += ( '\0' * self.key_size - len( key ) )
+        if len(key) < self.key_size:
+            key += ( '\0' * ( self.key_size - len(key) ) )
         # Call the recursive finder
         return self.r_find( self.root_offset, key )