Commits

Anonymous committed 19a56ca Merge

updated to current bx-python trunk

Comments (0)

Files changed (15)

File contents unchanged.

doc/source/conf.py

 master_doc = 'index'
 
 # General information about the project.
-project = u'BxPython'
+project = u'bx-python'
 copyright = u'2009, James Taylor'
 
 # The version info for the project you're documenting, acts as replacement for
 # The style sheet to use for HTML and HTML Help pages. A file of that name
 # must exist either in Sphinx' static/ path, or in one of the custom paths
 # given in html_static_path.
-html_style = 'bxdoc.css'
+html_style = 'base.css'
 
 # The name for this set of Sphinx documents.  If None, it defaults to
 # "<project> v<release> documentation".
 #html_file_suffix = ''
 
 # Output file base name for HTML help builder.
-htmlhelp_basename = 'BxDoc'
+htmlhelp_basename = 'bx-doc'
 
 
 # Options for LaTeX output
 # Grouping the document tree into LaTeX files. List of tuples
 # (source start file, target name, title, author, document class [howto/manual]).
 latex_documents = [
-  ('index', 'BxPython.tex', ur'BxPython Documentation',
+  ('index', 'bx-python.tex', ur'bx-python Documentation',
    ur'James Taylor', 'manual'),
 ]
 

doc/source/contents.rst

 
 
-BX documentation contents
-===========================
+bx-python documentation contents
+================================
 
 Browse the Python API `class documentation <apidoc/index.html>`_ 
 

doc/source/index.rst

    You can adapt this file completely to your liking, but it should at least
    contain the root `toctree` directive.
 
-Welcome to BxPython's documentation!
+Welcome to bx-python's documentation
 ====================================
 
 Contents:

doc/source/static/base.css

+@import url(tripoli.base.css);
+
+html {
+    font-family: 'Verdana', sans-serif;
+    color: #333333;
+}
+body {
+    padding: 3em 3em;
+}
+
+h1.pageheader {
+    font-variant: small-caps;
+    margin-top: 0;
+    border-top: solid 1px;
+    padding-top: 2px;
+    border-bottom: solid 1px;
+    border-color: #CCCCCC;
+    margin-bottom: 1em;
+}
+
+h1.pageheader a {
+    color: inherit;
+    text-decoration: inherit;
+    border: none;
+}
+
+.content h1, .content h2, .content h3, .content h4, .content h5, .content h6 {
+    font-family: 'Hoefler Text', 'Georgia', serif;
+    font-weight: normal;
+    color: #666666;
+    /* border-bottom: solid #666666 1px; */
+}
+
+.content h1.pagetitle {
+    color: #c33;
+}
+
+#main {
+}
+
+.colpad {
+    padding: 0 2em;
+}
+
+#main > .inner {
+    min-width: 70em;
+    max-width: 90em;
+    margin: auto;
+    height: 100%;
+}
+
+#left {
+    background: white;
+    margin-right: 36%; /* 31em; */
+    padding-right: 3%;
+    height: 100%;
+}
+
+#right {
+    float: right;
+    width: 33%; /* 28em; */
+    padding-left: 3%; 
+    border-left: solid #CCCCCC 1px;
+}
+
+.sidebar {
+    font-size: 1em;
+}
+
+.sidebar ul {
+    margin-left: 0;
+}
+
+.sidebar ul li {
+    list-style-type: none;
+    margin-bottom: 0.6em;
+}
+
+.sidebar ul.pages {
+    margin-left: 5px;
+    margin-top: 0.6em;
+}
+
+.sidebar ul.pages li {
+    background: url(hbullet.png) 0 0.4em no-repeat;
+    padding-left: 25px;
+    list-style-type: none;
+}
+
+.sidebar ul.pages li {
+}
+
+.sidebar h1 {
+    clear: both;
+}
+
+.sidebar .publications .info {
+    color: #666666;
+}
+
+.postinfo {
+    color: #666666;
+    font-size: 92%;
+    margin-top: -1em;
+}
+
+.postreadlink {
+    margin-top: -1em;
+}
+
+.sidebar .posts .info {
+    color: #666666;
+}
+
+.comments_title {
+    margin-top: 2em;
+}
+
+label {
+    display: block;
+}
+
+#footer {
+    clear: both;
+}
+
+a, a:link, a:visited {
+    text-decoration: none;
+    border-bottom: dotted #666666 1px;
+    color: black;
+}
+
+a:hover {
+ color: #CC3333;
+}
+
+li {
+    list-style: square;
+}
+
+table.layout td {
+    vertical-align: top;
+    padding-left: 2em;
+    padding-right: 2em;
+    border-left: solid #999999 1px
+}
+
+hr {
+    border: none;
+    height: 1px;
+    background: #999999; 
+}	

doc/source/static/tripoli.base.css

+/*
+ *   Tripoli is a generic CSS standard for HTML rendering. 
+ *   Copyright (C) 2007 David Hellsing
+ *   
+ *   http://devkick.com/lab/tripoli/
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
+**/
+
+/*
+_______________________________
+RESET */
+
+*
+{
+	text-decoration:none;
+	font-size:1em;
+	outline:none;
+	margin:0;
+	padding:0;
+}
+
+code,kbd,samp,pre,tt,var,textarea,input,select,isindex,listing,xmp,plaintext
+{
+	font:inherit;
+	white-space:normal;
+}
+
+a,img,a img,iframe,form,abbr,acronym,object,applet,table,a abbr,a acronym
+{
+	border-width:0;
+}
+
+dfn,i,cite,var,address,em
+{
+	font-style:normal;
+}
+
+th,b,strong,h1,h2,h3,h4,h5,h6,dt
+{
+	font-weight:normal;
+}
+
+caption,th,td
+{
+	text-align:left;
+}
+
+html
+{
+	background:white;
+	color:black;
+	line-height:1;
+	font-family:arial, sans-serif;
+}
+
+/* \*/
+
+html
+{
+	font-family:sans-serif;
+}
+
+/* */
+
+q
+{
+	quotes:"\201C""\201D""\2018""\2019";
+}
+
+ul,ol,dir,menu
+{
+	list-style:none;
+}
+
+sub,sup
+{
+	vertical-align:baseline;
+}
+
+a
+{
+	color:inherit;
+}
+
+/*
+_______________________________
+DISABLE DEPRECATED HTML */
+
+font,basefont
+{
+	color:inherit;
+	font:inherit;
+	font-size:100%;
+}
+
+
+center,*[align]
+{
+	text-align:inherit;
+}
+
+s,strike,u
+{
+	text-decoration:inherit;
+}
+
+img
+{
+	border:none;
+	margin:0;
+}
+
+ol
+{
+	list-style-type:decimal;
+}
+
+body
+{
+	background-color:transparent;
+}
+
+tr,th,td
+{
+	width:auto;
+	height:auto;
+	background-color:transparent;
+	vertical-align:inherit;
+	border:none;
+}
+
+table[border],.content table[border]
+{
+	border-collapse:separate;
+	border-spacing:0;
+}
+
+nobr
+{
+	white-space:normal;
+}
+
+marquee
+{
+	overflow:visible;
+	-moz-binding:none;
+}
+
+blink
+{
+	text-decoration:none;
+}
+
+/*
+_______________________________
+GENERAL */
+
+html
+{
+	font-size:125%;
+}
+
+body
+{
+	font-size:50%;
+}
+
+a
+{
+	text-decoration:underline;
+}
+
+strong,th,thead td,h1,h2,h3,h4,h5,h6,dt
+{
+	font-weight:bold;
+}
+
+cite,em,dfn
+{
+	font-style:italic;
+}
+
+code,kbd,samp,pre,tt,var,input[type='text'],input[type='password'],textarea
+{
+	font-size:100%;
+	font-family:mono-space,monospace;
+}
+
+pre
+{
+	white-space:pre;
+}
+
+pre *
+{
+	font-size:100%;
+	white-space:pre;
+}
+
+del
+{
+	text-decoration:line-through;
+}
+
+ins,dfn
+{
+	border-bottom:1px solid black;
+}
+
+small,sup,sub
+{
+	font-size:85%;
+}
+
+big
+{
+	font-size:125%;
+	line-height:80%;
+}
+
+abbr,acronym
+{
+	text-transform:uppercase;
+	font-size:85%;
+	letter-spacing:.1em;
+}
+
+abbr[title],acronym[title],dfn[title]
+{
+	cursor:help;
+	border-bottom:1px dotted black;
+}
+
+sup
+{
+	vertical-align:super;
+}
+
+sub
+{
+	vertical-align:sub;
+}
+
+blockquote
+{
+	padding-left:2.2em;
+}
+
+hr
+{
+	display:none; /* We will re-reset it later for content */
+}
+
+:lang(af),:lang(nl),:lang(pl)
+{
+	quotes:'\201E' '\201D' '\201A' '\2019';
+}
+
+:lang(bg),:lang(cs),:lang(de),:lang(is),:lang(lt),:lang(sk),:lang(sr),:lang(ro)
+{
+	quotes:'\201E' '\201C' '\201A' '\2018';
+}
+
+:lang(da),:lang(hr)
+{
+	quotes:'\00BB' '\00AB' '\203A' '\2039';
+}
+
+:lang(el),:lang(es),:lang(sq),:lang(tr)
+{
+	quotes:'\00AB' '\00BB' '\2039' '\203A';
+}
+
+:lang(en-GB)
+{
+	quotes:'\2018' '\2019' '\201C' '\201D';
+}
+
+:lang(fi),:lang(sv)
+{
+	quotes:'\201D' '\201D' '\2019' '\2019';
+}
+
+:lang(fr)
+{
+	quotes:'\ab\2005' '\2005\bb' '\2039\2005' '\2005\203a';
+}
+
+*[lang|='en'] q:before
+{
+	content:'\201C';
+}
+
+*[lang|='en'] q:after
+{
+	content:'\201D';
+}
+
+*[lang|='en'] q q:before
+{
+	content:'\2018';
+}
+
+*[lang|='en'] q q:after
+{
+	content:'\2019';
+}
+
+input,select,button
+{
+	cursor:pointer;
+}
+
+input[type='text'],input[type='password']
+{
+	cursor:text;
+}
+
+input[type='hidden']
+{
+	display:none;
+}
+
+/*
+_______________________________
+CONTENT */
+
+.content
+{
+	font-size:1.2em;
+	line-height:1.6em;
+}
+
+.content h1
+{
+	font-size:1.6em;
+	line-height:1;
+	margin:1em 0 .5em;
+}
+
+.content h2
+{
+	font-size:1.5em;
+	line-height:1;
+	margin:1.07em 0 .535em;
+}
+
+.content h3
+{
+	font-size:1.4em;
+	line-height:1;
+	margin:1.14em 0 .57em;
+}
+
+.content h4
+{
+	font-size:1.3em;
+	line-height:1;
+	margin:1.23em 0 .615em;
+}
+
+.content h5
+{
+	font-size:1.2em;
+	line-height:1;
+	margin:1.33em 0 .67em;
+}
+
+.content h6
+{
+	font-size:1em;
+	line-height:1;
+	margin:1.6em 0 .8em;
+}
+
+.content hr
+{
+	display:block;
+	background:black;
+	color:black;
+	width:100%;
+	height:1px;
+	border:none;
+}
+
+.content ul
+{
+	list-style:disc outside;
+}
+
+.content ol
+{
+	list-style:decimal outside;
+}
+
+.content table
+{
+	border-collapse:collapse;
+}
+
+.content hr,.content p,.content ul,.content ol,.content dl,.content pre, .content address,.content table,.content form
+{
+	margin-bottom:1.6em;
+}
+
+.content p+p
+{
+	margin-top:-.8em;
+}
+
+.content fieldset
+{
+	margin:1.6em 0;
+	padding:1.6em;
+}
+
+/* \*/
+
+.content legend
+{
+	padding-left:.8em;
+	padding-right:.8em;
+}
+
+/* */
+
+@media all and (min-width: 0px) /* for Opera 8 */
+{ 
+	.content legend
+	{
+		margin-bottom:1.6em;
+	}
+	.content fieldset
+	{
+		margin-top:0;
+	}
+	.content[class^='content'] fieldset
+	{
+		margin-top:1.6em;
+	}
+}
+
+.content fieldset>*:first-child
+{
+	margin-top:0;
+}
+
+.content textarea,.content input[type='text']
+{
+	padding:.1em .2em;
+}
+
+.content input
+{
+	padding:.2em .1em;
+}
+
+.content select
+{
+	padding:.2em .1em 0;
+}
+
+.content select[multiple]
+{
+	margin-bottom:.8em;
+}
+
+.content option
+{
+	padding:0 .4em .1em;
+}
+
+.content button
+{
+	padding:.3em .5em;
+}
+
+.content input[type='radio']
+{
+	position:relative;
+	bottom:-.2em;
+}
+
+.content dt
+{
+	margin-top:.8em;
+	margin-bottom:.4em;
+}
+
+.content ul,.content ol
+{
+	margin-left:2.2em;
+}
+
+.content caption,.content form div
+{
+	padding-bottom:.8em;
+}
+
+.content ul ul,content ol ul,.content ul ol,content ol ol
+{
+	margin-bottom:0;
+}
+
+/*
+_______________________________
+END */

doc/source/templates/layout.html

 {% extends "!layout.html" %}
 
-{% block rootrellink %}
-        <li><a href="{{ pathto('index') }}">BX home</a> |&nbsp;</li>
-        <li><a href="{{ pathto('contents') }}">Table of contents</a> &raquo;</li>
+{%- block document %}
+    <div id="main">
+        <div class="inner">
+            <div id="title" class="content">
+                <h1 class="pageheader">
+                    <a href="{{pathto('index')}}">bx-python</a>
+                </h1>
+            </div>	
+            <div id="right">
+                <div class="content secondary sidebar">
+                    {{ relbar() }}
+                    {{ sidebar() }}
+                </div>
+            </div>
+            <div id="left" class="document">
+                <div class="documentwrapper">
+                    {%- if builder != 'htmlhelp' %}
+                      <div class="bodywrapper">
+                    {%- endif %}
+                    <div class="body content">
+                        {% block body %} {% endblock %}
+                    </div>
+                    {%- if builder != 'htmlhelp' %}
+                      </div>
+                    {%- endif %}
+                </div>
+            </div>
+        </div>
+    </div>
+{%- endblock %}
+
+{% block doctype %}
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 {% endblock %}
 
-{% block relbar1 %}
-<div style="background-color: white; text-align: left; padding: 10px 10px 10px 10px">
-<img src="{{ pathto("_static/bx-logo.png", 1) }}" alt="BX logo" />
-</div>
-{{ super() }}
+{% block rootrellink %}
+        <li><a href="{{ pathto('index') }}">bx-python home</a></li>
+        <li><a href="{{ pathto('contents') }}">Table of contents</a></li>
 {% endblock %}
 
-{# put the sidebar before the body #}
-{% block sidebar1 %}{{ sidebar() }}{% endblock %}
+{# Sidebar and already handled #}
+
+{% block relbar1 %}{% endblock %}
+{% block relbar2 %}{% endblock %}
+
+{% block sidebar1 %}{% endblock %}
 {% block sidebar2 %}{% endblock %}
+
+{% block footer %}{% endblock %}

lib/bx/__init__.py

 """
 Shamelessly ripped off of py.std
 """
-__version__ = '0.9.0'
+__version__ = '0.5.0'
 
 class Std( object ):
     def __init__( self ):

lib/bx/align/tools/chop.py

+"""
+Support for chopping a list of alignment blocks to only the portion that
+intersects a particular interval.
+"""
+
 def chop_list( blocks, src, start, end ):
+    """
+    For each alignment block in the sequence `blocks`, chop out the portion
+    of the block that overlaps the interval [`start`,`end`) in the
+    component/species named `src`.
+    """
     new_blocks = []
     for block in blocks: 
         ref = block.get_component_by_src( src )

lib/bx/arrays/__init__.py

+"""
+Classes for working with arrays of data.
+"""

lib/bx/arrays/array_tree.c

+/* Generated by Cython 0.11.1 on Thu May 14 17:22:27 2009 */
+
+#define PY_SSIZE_T_CLEAN
+#include "Python.h"
+#include "structmember.h"
+#ifndef Py_PYTHON_H
+    #error Python headers needed to compile C extensions, please install development version of Python.
+#endif
+#ifndef PY_LONG_LONG
+  #define PY_LONG_LONG LONG_LONG
+#endif
+#ifndef DL_EXPORT
+  #define DL_EXPORT(t) t
+#endif
+#if PY_VERSION_HEX < 0x02040000
+  #define METH_COEXIST 0
+  #define PyDict_CheckExact(op) (Py_TYPE(op) == &PyDict_Type)
+#endif
+#if PY_VERSION_HEX < 0x02050000
+  typedef int Py_ssize_t;
+  #define PY_SSIZE_T_MAX INT_MAX
+  #define PY_SSIZE_T_MIN INT_MIN
+  #define PY_FORMAT_SIZE_T ""
+  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
+  #define PyInt_AsSsize_t(o)   PyInt_AsLong(o)
+  #define PyNumber_Index(o)    PyNumber_Int(o)
+  #define PyIndex_Check(o)     PyNumber_Check(o)
+#endif
+#if PY_VERSION_HEX < 0x02060000
+  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
+  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
+  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
+  #define PyVarObject_HEAD_INIT(type, size) \
+          PyObject_HEAD_INIT(type) size,
+  #define PyType_Modified(t)
+
+  typedef struct {
+       void *buf;
+       PyObject *obj;
+       Py_ssize_t len;
+       Py_ssize_t itemsize;
+       int readonly;
+       int ndim;
+       char *format;
+       Py_ssize_t *shape;
+       Py_ssize_t *strides;
+       Py_ssize_t *suboffsets;
+       void *internal;
+  } Py_buffer;
+
+  #define PyBUF_SIMPLE 0
+  #define PyBUF_WRITABLE 0x0001
+  #define PyBUF_FORMAT 0x0004
+  #define PyBUF_ND 0x0008
+  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
+  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
+  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
+  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
+  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
+
+#endif
+#if PY_MAJOR_VERSION < 3
+  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
+#else
+  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define Py_TPFLAGS_CHECKTYPES 0
+  #define Py_TPFLAGS_HAVE_INDEX 0
+#endif
+#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
+  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyBaseString_Type            PyUnicode_Type
+  #define PyString_Type                PyBytes_Type
+  #define PyString_CheckExact          PyBytes_CheckExact
+  #define PyInt_Type                   PyLong_Type
+  #define PyInt_Check(op)              PyLong_Check(op)
+  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
+  #define PyInt_FromString             PyLong_FromString
+  #define PyInt_FromUnicode            PyLong_FromUnicode
+  #define PyInt_FromLong               PyLong_FromLong
+  #define PyInt_FromSize_t             PyLong_FromSize_t
+  #define PyInt_FromSsize_t            PyLong_FromSsize_t
+  #define PyInt_AsLong                 PyLong_AsLong
+  #define PyInt_AS_LONG                PyLong_AS_LONG
+  #define PyInt_AsSsize_t              PyLong_AsSsize_t
+  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
+  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
+#else
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
+  #define PyBytes_Type                 PyString_Type
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyMethod_New(func, self, klass) PyInstanceMethod_New(func)
+#endif
+#if !defined(WIN32) && !defined(MS_WINDOWS)
+  #ifndef __stdcall
+    #define __stdcall
+  #endif
+  #ifndef __cdecl
+    #define __cdecl
+  #endif
+#else
+  #define _USE_MATH_DEFINES
+#endif
+#if PY_VERSION_HEX < 0x02050000
+  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
+  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
+  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
+#else
+  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
+  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
+  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
+#endif
+#if PY_VERSION_HEX < 0x02050000
+  #define __Pyx_NAMESTR(n) ((char *)(n))
+  #define __Pyx_DOCSTR(n)  ((char *)(n))
+#else
+  #define __Pyx_NAMESTR(n) (n)
+  #define __Pyx_DOCSTR(n)  (n)
+#endif
+#ifdef __cplusplus
+#define __PYX_EXTERN_C extern "C"
+#else
+#define __PYX_EXTERN_C extern
+#endif
+#include <math.h>
+#define __PYX_HAVE_API__bx__arrays__array_tree
+#include "stdlib.h"
+#include "numpy/arrayobject.h"
+
+
+#ifdef __GNUC__
+#define INLINE __inline__
+#elif _WIN32
+#define INLINE __inline
+#else
+#define INLINE 
+#endif
+
+typedef struct {PyObject **p; char *s; long n; char is_unicode; char intern; char is_identifier;} __Pyx_StringTabEntry; /*proto*/
+
+
+
+static int __pyx_skip_dispatch = 0;
+
+
+/* Type Conversion Predeclarations */
+
+#if PY_MAJOR_VERSION < 3
+#define __Pyx_PyBytes_FromString          PyString_FromString
+#define __Pyx_PyBytes_FromStringAndSize   PyString_FromStringAndSize
+#define __Pyx_PyBytes_AsString            PyString_AsString
+#else
+#define __Pyx_PyBytes_FromString          PyBytes_FromString
+#define __Pyx_PyBytes_FromStringAndSize   PyBytes_FromStringAndSize
+#define __Pyx_PyBytes_AsString            PyBytes_AsString
+#endif
+
+#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
+static INLINE int __Pyx_PyObject_IsTrue(PyObject*);
+static INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
+
+#if !defined(T_PYSSIZET)
+#if PY_VERSION_HEX < 0x02050000
+#define T_PYSSIZET T_INT
+#elif !defined(T_LONGLONG)
+#define T_PYSSIZET \
+        ((sizeof(Py_ssize_t) == sizeof(int))  ? T_INT  : \
+        ((sizeof(Py_ssize_t) == sizeof(long)) ? T_LONG : -1))
+#else
+#define T_PYSSIZET \
+        ((sizeof(Py_ssize_t) == sizeof(int))          ? T_INT      : \
+        ((sizeof(Py_ssize_t) == sizeof(long))         ? T_LONG     : \
+        ((sizeof(Py_ssize_t) == sizeof(PY_LONG_LONG)) ? T_LONGLONG : -1)))
+#endif
+#endif
+
+#if !defined(T_SIZET)
+#if !defined(T_ULONGLONG)
+#define T_SIZET \
+        ((sizeof(size_t) == sizeof(unsigned int))  ? T_UINT  : \
+        ((sizeof(size_t) == sizeof(unsigned long)) ? T_ULONG : -1))
+#else
+#define T_SIZET \
+        ((sizeof(size_t) == sizeof(unsigned int))          ? T_UINT      : \
+        ((sizeof(size_t) == sizeof(unsigned long))         ? T_ULONG     : \
+        ((sizeof(size_t) == sizeof(unsigned PY_LONG_LONG)) ? T_ULONGLONG : -1)))
+#endif
+#endif
+
+static INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
+static INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
+static INLINE size_t __Pyx_PyInt_AsSize_t(PyObject*);
+
+#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
+
+
+#ifdef __GNUC__
+/* Test for GCC > 2.95 */
+#if __GNUC__ > 2 ||               (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)) 
+#define likely(x)   __builtin_expect(!!(x), 1)
+#define unlikely(x) __builtin_expect(!!(x), 0)
+#else /* __GNUC__ > 2 ... */
+#define likely(x)   (x)
+#define unlikely(x) (x)
+#endif /* __GNUC__ > 2 ... */
+#else /* __GNUC__ */
+#define likely(x)   (x)
+#define unlikely(x) (x)
+#endif /* __GNUC__ */
+    
+static PyObject *__pyx_m;
+static PyObject *__pyx_b;
+static PyObject *__pyx_empty_tuple;
+static int __pyx_lineno;
+static int __pyx_clineno = 0;
+static const char * __pyx_cfilenm= __FILE__;
+static const char *__pyx_filename;
+static const char **__pyx_f;
+
+#ifdef CYTHON_REFNANNY
+typedef struct {
+  void (*INCREF)(void*, PyObject*, int);
+  void (*DECREF)(void*, PyObject*, int);
+  void (*GOTREF)(void*, PyObject*, int);
+  void (*GIVEREF)(void*, PyObject*, int);
+  void* (*NewContext)(const char*, int, const char*);
+  void (*FinishContext)(void**);
+} __Pyx_RefnannyAPIStruct;
+static __Pyx_RefnannyAPIStruct *__Pyx_Refnanny = NULL;
+#define __Pyx_ImportRefcountAPI(name)   (__Pyx_RefnannyAPIStruct *) PyCObject_Import((char *)name, (char *)"RefnannyAPI")
+#define __Pyx_INCREF(r) __Pyx_Refnanny->INCREF(__pyx_refchk, (PyObject *)(r), __LINE__)
+#define __Pyx_DECREF(r) __Pyx_Refnanny->DECREF(__pyx_refchk, (PyObject *)(r), __LINE__)
+#define __Pyx_GOTREF(r) __Pyx_Refnanny->GOTREF(__pyx_refchk, (PyObject *)(r), __LINE__)
+#define __Pyx_GIVEREF(r) __Pyx_Refnanny->GIVEREF(__pyx_refchk, (PyObject *)(r), __LINE__)
+#define __Pyx_XDECREF(r) if((r) == NULL) ; else __Pyx_DECREF(r)
+#define __Pyx_SetupRefcountContext(name)   void* __pyx_refchk = __Pyx_Refnanny->NewContext((name), __LINE__, __FILE__)
+#define __Pyx_FinishRefcountContext()   __Pyx_Refnanny->FinishContext(&__pyx_refchk)
+#else
+#define __Pyx_INCREF(r) Py_INCREF(r)
+#define __Pyx_DECREF(r) Py_DECREF(r)
+#define __Pyx_GOTREF(r)
+#define __Pyx_GIVEREF(r)
+#define __Pyx_XDECREF(r) Py_XDECREF(r)
+#define __Pyx_SetupRefcountContext(name)
+#define __Pyx_FinishRefcountContext()
+#endif /* CYTHON_REFNANNY */
+#define __Pyx_XGIVEREF(r) if((r) == NULL) ; else __Pyx_GIVEREF(r)
+#define __Pyx_XGOTREF(r) if((r) == NULL) ; else __Pyx_GOTREF(r)
+
+static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/
+
+static void __Pyx_RaiseDoubleKeywordsError(
+    const char* func_name, PyObject* kw_name); /*proto*/
+
+static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
+    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
+
+static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],     PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,     const char* function_name); /*proto*/
+
+#define __Pyx_SetItemInt(o, i, v, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
+                                                    __Pyx_SetItemInt_Fast(o, i, v, size <= sizeof(long)) : \
+                                                    __Pyx_SetItemInt_Generic(o, to_py_func(i), v))
+
+static INLINE int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
+    int r;
+    if (!j) return -1;
+    r = PyObject_SetItem(o, j, v);
+    Py_DECREF(j);
+    return r;
+}
+
+static INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int fits_long) {
+    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
+        Py_INCREF(v);
+        Py_DECREF(PyList_GET_ITEM(o, i));
+        PyList_SET_ITEM(o, i, v);
+        return 1;
+    }
+    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_ass_item && (likely(i >= 0)))
+        return PySequence_SetItem(o, i, v);
+    else {
+        PyObject *j = fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i);
+        return __Pyx_SetItemInt_Generic(o, j, v);
+    }
+}
+
+
+static INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
+    PyObject *r;
+    if (!j) return NULL;
+    r = PyObject_GetItem(o, j);
+    Py_DECREF(j);
+    return r;
+}
+
+
+#define __Pyx_GetItemInt_List(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
+                                                    __Pyx_GetItemInt_List_Fast(o, i, size <= sizeof(long)) : \
+                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
+
+static INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
+    if (likely(o != Py_None)) {
+        if (likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
+            PyObject *r = PyList_GET_ITEM(o, i);
+            Py_INCREF(r);
+            return r;
+        }
+        else if ((-PyList_GET_SIZE(o) <= i) & (i < 0)) {
+            PyObject *r = PyList_GET_ITEM(o, PyList_GET_SIZE(o) + i);
+            Py_INCREF(r);
+            return r;
+        }
+    }
+    return __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
+}
+
+#define __Pyx_GetItemInt_Tuple(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
+                                                    __Pyx_GetItemInt_Tuple_Fast(o, i, size <= sizeof(long)) : \
+                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
+
+static INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
+    if (likely(o != Py_None)) {
+        if (likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
+            PyObject *r = PyTuple_GET_ITEM(o, i);
+            Py_INCREF(r);
+            return r;
+        }
+        else if ((-PyTuple_GET_SIZE(o) <= i) & (i < 0)) {
+            PyObject *r = PyTuple_GET_ITEM(o, PyTuple_GET_SIZE(o) + i);
+            Py_INCREF(r);
+            return r;
+        }
+    }
+    return __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
+}
+
+
+#define __Pyx_GetItemInt(o, i, size, to_py_func) ((size <= sizeof(Py_ssize_t)) ? \
+                                                    __Pyx_GetItemInt_Fast(o, i, size <= sizeof(long)) : \
+                                                    __Pyx_GetItemInt_Generic(o, to_py_func(i)))
+
+static INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int fits_long) {
+    PyObject *r;
+    if (PyList_CheckExact(o) && ((0 <= i) & (i < PyList_GET_SIZE(o)))) {
+        r = PyList_GET_ITEM(o, i);
+        Py_INCREF(r);
+    }
+    else if (PyTuple_CheckExact(o) && ((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
+        r = PyTuple_GET_ITEM(o, i);
+        Py_INCREF(r);
+    }
+    else if (Py_TYPE(o)->tp_as_sequence && Py_TYPE(o)->tp_as_sequence->sq_item && (likely(i >= 0))) {
+        r = PySequence_GetItem(o, i);
+    }
+    else {
+        r = __Pyx_GetItemInt_Generic(o, fits_long ? PyInt_FromLong(i) : PyLong_FromLongLong(i));
+    }
+    return r;
+}
+
+static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
+    const char *name, int exact); /*proto*/
+
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/
+
+static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/
+
+#include "descrobject.h"
+static PyObject* __Pyx_Method_ClassMethod(PyObject *method); /*proto*/
+
+static INLINE long __Pyx_pow_long(long, long); /* proto */
+
+static INLINE int __Pyx_pow_int(int, int); /* proto */
+
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+
+static INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb); /*proto*/
+static INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb); /*proto*/
+
+static INLINE int __Pyx_StrEq(const char *, const char *); /*proto*/
+
+static INLINE unsigned char __Pyx_PyInt_AsUnsignedChar(PyObject *);
+
+static INLINE unsigned short __Pyx_PyInt_AsUnsignedShort(PyObject *);
+
+static INLINE unsigned int __Pyx_PyInt_AsUnsignedInt(PyObject *);
+
+static INLINE char __Pyx_PyInt_AsChar(PyObject *);
+
+static INLINE short __Pyx_PyInt_AsShort(PyObject *);
+
+static INLINE int __Pyx_PyInt_AsInt(PyObject *);
+
+static INLINE signed char __Pyx_PyInt_AsSignedChar(PyObject *);
+
+static INLINE signed short __Pyx_PyInt_AsSignedShort(PyObject *);
+
+static INLINE signed int __Pyx_PyInt_AsSignedInt(PyObject *);
+
+static INLINE unsigned long __Pyx_PyInt_AsUnsignedLong(PyObject *);
+
+static INLINE unsigned PY_LONG_LONG __Pyx_PyInt_AsUnsignedLongLong(PyObject *);
+
+static INLINE long __Pyx_PyInt_AsLong(PyObject *);
+
+static INLINE PY_LONG_LONG __Pyx_PyInt_AsLongLong(PyObject *);
+
+static INLINE signed long __Pyx_PyInt_AsSignedLong(PyObject *);
+
+static INLINE signed PY_LONG_LONG __Pyx_PyInt_AsSignedLongLong(PyObject *);
+
+static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/
+
+static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, long size);  /*proto*/
+
+static PyObject *__Pyx_ImportModule(const char *name); /*proto*/
+
+static void __Pyx_AddTraceback(const char *funcname); /*proto*/
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
+
+/* Type declarations */
+
+typedef npy_int8 __pyx_t_5numpy_int8_t;
+
+typedef npy_int16 __pyx_t_5numpy_int16_t;
+
+typedef npy_int32 __pyx_t_5numpy_int32_t;
+
+typedef npy_int64 __pyx_t_5numpy_int64_t;
+
+typedef npy_uint8 __pyx_t_5numpy_uint8_t;
+
+typedef npy_uint16 __pyx_t_5numpy_uint16_t;
+
+typedef npy_uint32 __pyx_t_5numpy_uint32_t;
+
+typedef npy_uint64 __pyx_t_5numpy_uint64_t;
+
+typedef npy_float32 __pyx_t_5numpy_float32_t;
+
+typedef npy_float64 __pyx_t_5numpy_float64_t;
+
+typedef npy_long __pyx_t_5numpy_int_t;
+
+typedef npy_longlong __pyx_t_5numpy_long_t;
+
+typedef npy_ulong __pyx_t_5numpy_uint_t;
+
+typedef npy_ulonglong __pyx_t_5numpy_ulong_t;
+
+typedef npy_double __pyx_t_5numpy_float_t;
+
+typedef npy_double __pyx_t_5numpy_double_t;
+
+typedef npy_longdouble __pyx_t_5numpy_longdouble_t;
+
+typedef npy_cfloat __pyx_t_5numpy_cfloat_t;
+
+typedef npy_cdouble __pyx_t_5numpy_cdouble_t;
+
+typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
+
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":69
+ *     cdef public object sumsquares
+ * 
+ * cdef class ArrayTreeNode             # <<<<<<<<<<<<<<
+ * cdef class ArrayTreeLeaf
+ * 
+ */
+
+struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTreeNode {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_2bx_6arrays_10array_tree_ArrayTreeNode *__pyx_vtab;
+  struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *tree;
+  int min;
+  int max;
+  int block_size;
+  int level;
+  int child_size;
+  PyObject *children;
+  struct __pyx_obj_2bx_6arrays_10array_tree_Summary *summary;
+  long start_offset;
+};
+
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":58
+ * VERSION = 0
+ * 
+ * cdef class Summary( object ):             # <<<<<<<<<<<<<<
+ *     """
+ *     Summary for a non-leaf level of the tree, contains arrays of the min, max,
+ */
+
+struct __pyx_obj_2bx_6arrays_10array_tree_Summary {
+  PyObject_HEAD
+  PyObject *counts;
+  PyObject *mins;
+  PyObject *maxs;
+  PyObject *sums;
+  PyObject *sumsquares;
+};
+
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":72
+ * cdef class ArrayTreeLeaf
+ * 
+ * cdef class ArrayTree:             # <<<<<<<<<<<<<<
+ *     """
+ *     Stores a sparse array of data as a tree.
+ */
+
+struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree {
+  PyObject_HEAD
+  int max;
+  int block_size;
+  PyObject *dtype;
+  int levels;
+  struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTreeNode *root;
+};
+
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":70
+ * 
+ * cdef class ArrayTreeNode
+ * cdef class ArrayTreeLeaf             # <<<<<<<<<<<<<<
+ * 
+ * cdef class ArrayTree:
+ */
+
+struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTreeLeaf {
+  PyObject_HEAD
+  struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *tree;
+  int min;
+  int max;
+  PyArrayObject *values;
+  long start_offset;
+};
+
+
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":152
+ *         return tree
+ * 
+ * cdef class ArrayTreeNode:             # <<<<<<<<<<<<<<
+ *     """
+ *     Internal node of an ArrayTree. Contains summary data and pointers to
+ */
+
+struct __pyx_vtabstruct_2bx_6arrays_10array_tree_ArrayTreeNode {
+  PyObject *(*init_bin)(struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTreeNode *, int);
+  PyObject *(*build_summary)(struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTreeNode *, int __pyx_skip_dispatch);
+};
+static struct __pyx_vtabstruct_2bx_6arrays_10array_tree_ArrayTreeNode *__pyx_vtabptr_2bx_6arrays_10array_tree_ArrayTreeNode;
+/* Module declarations from python_buffer */
+
+/* Module declarations from stdlib */
+
+/* Module declarations from numpy */
+
+/* Module declarations from numpy */
+
+static PyTypeObject *__pyx_ptype_5numpy_dtype = 0;
+static PyTypeObject *__pyx_ptype_5numpy_ndarray = 0;
+static INLINE char *__pyx_f_5numpy__util_dtypestring(PyArray_Descr *, char *, char *); /*proto*/
+/* Module declarations from bx.arrays.array_tree */
+
+static PyTypeObject *__pyx_ptype_2bx_6arrays_10array_tree_Summary = 0;
+static PyTypeObject *__pyx_ptype_2bx_6arrays_10array_tree_ArrayTreeNode = 0;
+static PyTypeObject *__pyx_ptype_2bx_6arrays_10array_tree_ArrayTreeLeaf = 0;
+static PyTypeObject *__pyx_ptype_2bx_6arrays_10array_tree_ArrayTree = 0;
+static PyObject *__pyx_k_27 = 0;
+
+const char *__pyx_modulename = "bx.arrays.array_tree";
+
+/* Implementation of bx.arrays.array_tree */
+static PyObject *__pyx_int_0x310ec7dc;
+static PyObject *__pyx_int_0;
+static PyObject *__pyx_int_1000;
+static PyObject *__pyx_int_neg_1;
+static PyObject *__pyx_int_1;
+static PyObject *__pyx_int_3;
+static PyObject *__pyx_int_2;
+static PyObject *__pyx_int_5;
+static char __pyx_k___init__[] = "__init__";
+static PyObject *__pyx_kp___init__;
+static char __pyx_k___setitem__[] = "__setitem__";
+static PyObject *__pyx_kp___setitem__;
+static char __pyx_k___getitem__[] = "__getitem__";
+static PyObject *__pyx_kp___getitem__;
+static char __pyx_k_to_file[] = "to_file";
+static PyObject *__pyx_kp_to_file;
+static char __pyx_k_from_file[] = "from_file";
+static PyObject *__pyx_kp_from_file;
+static char __pyx_k_from_sequence[] = "from_sequence";
+static PyObject *__pyx_kp_from_sequence;
+static char __pyx_k_set[] = "set";
+static PyObject *__pyx_kp_set;
+static char __pyx_k_get[] = "get";
+static PyObject *__pyx_kp_get;
+static char __pyx_k_build_summary[] = "build_summary";
+static PyObject *__pyx_kp_build_summary;
+static char __pyx_k_to_file_data_pass[] = "to_file_data_pass";
+static PyObject *__pyx_kp_to_file_data_pass;
+static char __pyx_k_to_file_offset_pass[] = "to_file_offset_pass";
+static PyObject *__pyx_kp_to_file_offset_pass;
+static char __pyx_k_value[] = "value";
+static PyObject *__pyx_kp_value;
+static char __pyx_k_max[] = "max";
+static PyObject *__pyx_kp_max;
+static char __pyx_k_block_size[] = "block_size";
+static PyObject *__pyx_kp_block_size;
+static char __pyx_k_dtype[] = "dtype";
+static PyObject *__pyx_kp_dtype;
+static char __pyx_k_index[] = "index";
+static PyObject *__pyx_kp_index;
+static char __pyx_k_f[] = "f";
+static PyObject *__pyx_kp_f;
+static char __pyx_k_s[] = "s";
+static PyObject *__pyx_kp_s;
+static char __pyx_k_tree[] = "tree";
+static PyObject *__pyx_kp_tree;
+static char __pyx_k_min[] = "min";
+static PyObject *__pyx_kp_min;
+static char __pyx_k_level[] = "level";
+static PyObject *__pyx_kp_level;
+static char __pyx_k_io[] = "io";
+static PyObject *__pyx_kp_io;
+static char __pyx_k_23[] = "ArrayTree";
+static PyObject *__pyx_kp_23;
+static char __pyx_k___all__[] = "__all__";
+static PyObject *__pyx_kp___all__;
+static char __pyx_k_numpy[] = "numpy";
+static PyObject *__pyx_kp_numpy;
+static char __pyx_k_24[] = "*";
+static PyObject *__pyx_kp_24;
+static char __pyx_k_25[] = "bx.misc.binary_file";
+static PyObject *__pyx_kp_25;
+static char __pyx_k_BinaryFileWriter[] = "BinaryFileWriter";
+static PyObject *__pyx_kp_BinaryFileWriter;
+static char __pyx_k_BinaryFileReader[] = "BinaryFileReader";
+static PyObject *__pyx_kp_BinaryFileReader;
+static char __pyx_k_MAGIC[] = "MAGIC";
+static PyObject *__pyx_kp_MAGIC;
+static char __pyx_k_VERSION[] = "VERSION";
+static PyObject *__pyx_kp_VERSION;
+static char __pyx_k_26[] = "float32";
+static PyObject *__pyx_kp_26;
+static char __pyx_k_magic[] = "magic";
+static PyObject *__pyx_kp_magic;
+static char __pyx_k_29[] = "write_uint32";
+static PyObject *__pyx_kp_29;
+static char __pyx_k_write[] = "write";
+static PyObject *__pyx_kp_write;
+static char __pyx_k_char[] = "char";
+static PyObject *__pyx_kp_char;
+static char __pyx_k_range[] = "range";
+static PyObject *__pyx_kp_range;
+static char __pyx_k_31[] = "read_uint32";
+static PyObject *__pyx_kp_31;
+static char __pyx_k_read[] = "read";
+static PyObject *__pyx_kp_read;
+static char __pyx_k_root[] = "root";
+static PyObject *__pyx_kp_root;
+static char __pyx_k_nan[] = "nan";
+static PyObject *__pyx_kp_nan;
+static char __pyx_k_empty[] = "empty";
+static PyObject *__pyx_kp_empty;
+static char __pyx_k_values[] = "values";
+static PyObject *__pyx_kp_values;
+static char __pyx_k_sum[] = "sum";
+static PyObject *__pyx_kp_sum;
+static char __pyx_k_isnan[] = "isnan";
+static PyObject *__pyx_kp_isnan;
+static char __pyx_k_nanmin[] = "nanmin";
+static PyObject *__pyx_kp_nanmin;
+static char __pyx_k_nanmax[] = "nanmax";
+static PyObject *__pyx_kp_nanmax;
+static char __pyx_k_nansum[] = "nansum";
+static PyObject *__pyx_kp_nansum;
+static char __pyx_k_summary[] = "summary";
+static PyObject *__pyx_kp_summary;
+static char __pyx_k_counts[] = "counts";
+static PyObject *__pyx_kp_counts;
+static char __pyx_k_mins[] = "mins";
+static PyObject *__pyx_kp_mins;
+static char __pyx_k_maxs[] = "maxs";
+static PyObject *__pyx_kp_maxs;
+static char __pyx_k_sums[] = "sums";
+static PyObject *__pyx_kp_sums;
+static char __pyx_k_sumsquares[] = "sumsquares";
+static PyObject *__pyx_kp_sumsquares;
+static char __pyx_k_tell[] = "tell";
+static PyObject *__pyx_kp_tell;
+static char __pyx_k_write_raw_array[] = "write_raw_array";
+static PyObject *__pyx_kp_write_raw_array;
+static char __pyx_k_skip[] = "skip";
+static PyObject *__pyx_kp_skip;
+static char __pyx_k_itemsize[] = "itemsize";
+static PyObject *__pyx_kp_itemsize;
+static char __pyx_k_seek[] = "seek";
+static PyObject *__pyx_kp_seek;
+static char __pyx_k_33[] = "write_uint64";
+static PyObject *__pyx_kp_33;
+static char __pyx_k_start_offset[] = "start_offset";
+static PyObject *__pyx_kp_start_offset;
+static char __pyx_k_read_raw_array[] = "read_raw_array";
+static PyObject *__pyx_kp_read_raw_array;
+static char __pyx_k_34[] = "read_uint64";
+static PyObject *__pyx_kp_34;
+static PyObject *__pyx_builtin_range;
+static PyObject *__pyx_builtin_sum;
+static PyObject *__pyx_kp_28;
+static char __pyx_k_28[] = "max < block_size not yet handled";
+static PyObject *__pyx_kp_30;
+static char __pyx_k_30[] = "\000\000\000";
+static PyObject *__pyx_kp_32;
+static char __pyx_k_32[] = "Writing without summaries is currently not supported";
+static char __pyx_k___getbuffer__[] = "__getbuffer__";
+static PyObject *__pyx_kp___getbuffer__;
+static char __pyx_k___releasebuffer__[] = "__releasebuffer__";
+static PyObject *__pyx_kp___releasebuffer__;
+static char __pyx_k_info[] = "info";
+static PyObject *__pyx_kp_info;
+static char __pyx_k_flags[] = "flags";
+static PyObject *__pyx_kp_flags;
+static char __pyx_k_ValueError[] = "ValueError";
+static PyObject *__pyx_kp_ValueError;
+static char __pyx_k_itervalues[] = "itervalues";
+static PyObject *__pyx_kp_itervalues;
+static char __pyx_k_RuntimeError[] = "RuntimeError";
+static PyObject *__pyx_kp_RuntimeError;
+static PyObject *__pyx_kp_1;
+static PyObject *__pyx_kp_2;
+static PyObject *__pyx_kp_20;
+static PyObject *__pyx_builtin_ValueError;
+static PyObject *__pyx_builtin_RuntimeError;
+static char __pyx_k_1[] = "ndarray is not C contiguous";
+static char __pyx_k_2[] = "ndarray is not Fortran contiguous";
+static char __pyx_k_3[] = "b";
+static char __pyx_k_4[] = "B";
+static char __pyx_k_5[] = "h";
+static char __pyx_k_6[] = "H";
+static char __pyx_k_7[] = "i";
+static char __pyx_k_8[] = "I";
+static char __pyx_k_9[] = "l";
+static char __pyx_k_10[] = "L";
+static char __pyx_k_11[] = "q";
+static char __pyx_k_12[] = "Q";
+static char __pyx_k_13[] = "f";
+static char __pyx_k_14[] = "d";
+static char __pyx_k_15[] = "g";
+static char __pyx_k_16[] = "Zf";
+static char __pyx_k_17[] = "Zd";
+static char __pyx_k_18[] = "Zg";
+static char __pyx_k_19[] = "O";
+static char __pyx_k_20[] = "unknown dtype code in numpy.pxd (%d)";
+static PyObject *__pyx_kp_21;
+static PyObject *__pyx_kp_22;
+static char __pyx_k_21[] = "Format string allocated too short.";
+static char __pyx_k_22[] = "unknown dtype code in numpy.pxd (%d)";
+
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":91
+ *     cdef object dtype
+ *     cdef int levels
+ *     cdef public ArrayTreeNode root             # <<<<<<<<<<<<<<
+ * 
+ *     def __init__( self, int max, int block_size, dtype=float32 ):
+ */
+
+static PyObject *__pyx_pf_2bx_6arrays_10array_tree_9ArrayTree_4root___get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pf_2bx_6arrays_10array_tree_9ArrayTree_4root___get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_SetupRefcountContext("__get__");
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->root));
+  __pyx_r = ((PyObject *)((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->root);
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_2bx_6arrays_10array_tree_9ArrayTree_4root___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pf_2bx_6arrays_10array_tree_9ArrayTree_4root___set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  __Pyx_SetupRefcountContext("__set__");
+  if (!(__Pyx_TypeTest(__pyx_v_value, __pyx_ptype_2bx_6arrays_10array_tree_ArrayTreeNode))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_INCREF(__pyx_v_value);
+  __Pyx_GIVEREF(__pyx_v_value);
+  __Pyx_GOTREF(((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->root);
+  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->root));
+  ((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->root = ((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTreeNode *)__pyx_v_value);
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("bx.arrays.array_tree.ArrayTree.root.__set__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_FinishRefcountContext();
+  return __pyx_r;
+}
+
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":93
+ *     cdef public ArrayTreeNode root
+ * 
+ *     def __init__( self, int max, int block_size, dtype=float32 ):             # <<<<<<<<<<<<<<
+ *         """
+ *         Create a new array tree of size `max`
+ */
+
+static int __pyx_pf_2bx_6arrays_10array_tree_9ArrayTree___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_2bx_6arrays_10array_tree_9ArrayTree___init__[] = "\n        Create a new array tree of size `max` \n        ";
+static int __pyx_pf_2bx_6arrays_10array_tree_9ArrayTree___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  int __pyx_v_max;
+  int __pyx_v_block_size;
+  PyObject *__pyx_v_dtype = 0;
+  int __pyx_r;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  static PyObject **__pyx_pyargnames[] = {&__pyx_kp_max,&__pyx_kp_block_size,&__pyx_kp_dtype,0};
+  __Pyx_SetupRefcountContext("__init__");
+  if (unlikely(__pyx_kwds)) {
+    Py_ssize_t kw_args = PyDict_Size(__pyx_kwds);
+    PyObject* values[3] = {0,0,0};
+    values[2] = __pyx_k_27;
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+      case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+      case  0: break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  0:
+      values[0] = PyDict_GetItem(__pyx_kwds, __pyx_kp_max);
+      if (likely(values[0])) kw_args--;
+      else goto __pyx_L5_argtuple_error;
+      case  1:
+      values[1] = PyDict_GetItem(__pyx_kwds, __pyx_kp_block_size);
+      if (likely(values[1])) kw_args--;
+      else {
+        __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+      case  2:
+      if (kw_args > 1) {
+        PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_kp_dtype);
+        if (unlikely(value)) { values[2] = value; kw_args--; }
+      }
+    }
+    if (unlikely(kw_args > 0)) {
+      if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, PyTuple_GET_SIZE(__pyx_args), "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    }
+    __pyx_v_max = __Pyx_PyInt_AsInt(values[0]); if (unlikely((__pyx_v_max == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_block_size = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_block_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_dtype = values[2];
+  } else {
+    __pyx_v_dtype = __pyx_k_27;
+    switch (PyTuple_GET_SIZE(__pyx_args)) {
+      case  3:
+      __pyx_v_dtype = PyTuple_GET_ITEM(__pyx_args, 2);
+      case  2:
+      __pyx_v_block_size = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 1)); if (unlikely((__pyx_v_block_size == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_max = __Pyx_PyInt_AsInt(PyTuple_GET_ITEM(__pyx_args, 0)); if (unlikely((__pyx_v_max == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      break;
+      default: goto __pyx_L5_argtuple_error;
+    }
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("bx.arrays.array_tree.ArrayTree.__init__");
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":97
+ *         Create a new array tree of size `max`
+ *         """
+ *         self.max = max             # <<<<<<<<<<<<<<
+ *         self.block_size = block_size
+ *         # Force the dtype argument to its canonical dtype object
+ */
+  ((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->max = __pyx_v_max;
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":98
+ *         """
+ *         self.max = max
+ *         self.block_size = block_size             # <<<<<<<<<<<<<<
+ *         # Force the dtype argument to its canonical dtype object
+ *         self.dtype = numpy.dtype( dtype )
+ */
+  ((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->block_size = __pyx_v_block_size;
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":100
+ *         self.block_size = block_size
+ *         # Force the dtype argument to its canonical dtype object
+ *         self.dtype = numpy.dtype( dtype )             # <<<<<<<<<<<<<<
+ *         # How many levels are needed to cover the entire range?
+ *         self.levels = 0
+ */
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __Pyx_INCREF(__pyx_v_dtype);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_dtype);
+  __Pyx_GIVEREF(__pyx_v_dtype);
+  __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5numpy_dtype)), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+  __Pyx_GIVEREF(__pyx_t_2);
+  __Pyx_GOTREF(((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->dtype);
+  __Pyx_DECREF(((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->dtype);
+  ((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->dtype = __pyx_t_2;
+  __pyx_t_2 = 0;
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":102
+ *         self.dtype = numpy.dtype( dtype )
+ *         # How many levels are needed to cover the entire range?
+ *         self.levels = 0             # <<<<<<<<<<<<<<
+ *         while self.block_size ** ( self.levels + 1 ) < self.max:
+ *             self.levels += 1
+ */
+  ((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->levels = 0;
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":103
+ *         # How many levels are needed to cover the entire range?
+ *         self.levels = 0
+ *         while self.block_size ** ( self.levels + 1 ) < self.max:             # <<<<<<<<<<<<<<
+ *             self.levels += 1
+ *         # Not yet dealing with the case where the root is a Leaf
+ */
+  while (1) {
+    __pyx_t_3 = (__Pyx_pow_long(((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->block_size, (((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->levels + 1)) < ((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->max);
+    if (!__pyx_t_3) break;
+
+    /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":104
+ *         self.levels = 0
+ *         while self.block_size ** ( self.levels + 1 ) < self.max:
+ *             self.levels += 1             # <<<<<<<<<<<<<<
+ *         # Not yet dealing with the case where the root is a Leaf
+ *         assert self.levels > 0, "max < block_size not yet handled"
+ */
+    ((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->levels += 1;
+  }
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":106
+ *             self.levels += 1
+ *         # Not yet dealing with the case where the root is a Leaf
+ *         assert self.levels > 0, "max < block_size not yet handled"             # <<<<<<<<<<<<<<
+ *         # Create the root node
+ *         self.root = ArrayTreeNode( self, 0, max, block_size, self.levels )
+ */
+  #ifndef PYREX_WITHOUT_ASSERTIONS
+  if (unlikely(!(((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->levels > 0))) {
+    PyErr_SetObject(PyExc_AssertionError, __pyx_kp_28);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  #endif
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":108
+ *         assert self.levels > 0, "max < block_size not yet handled"
+ *         # Create the root node
+ *         self.root = ArrayTreeNode( self, 0, max, block_size, self.levels )             # <<<<<<<<<<<<<<
+ * 
+ *     def __setitem__( self, int index, value ):
+ */
+  __pyx_t_2 = PyInt_FromLong(__pyx_v_max); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_block_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_4 = PyInt_FromLong(((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->levels); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_5));
+  __Pyx_INCREF(__pyx_v_self);
+  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_self);
+  __Pyx_GIVEREF(__pyx_v_self);
+  __Pyx_INCREF(__pyx_int_0);
+  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_int_0);
+  __Pyx_GIVEREF(__pyx_int_0);
+  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_t_4);
+  __Pyx_GIVEREF(__pyx_t_4);
+  __pyx_t_2 = 0;
+  __pyx_t_1 = 0;
+  __pyx_t_4 = 0;
+  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_2bx_6arrays_10array_tree_ArrayTreeNode)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
+  if (!(__Pyx_TypeTest(__pyx_t_4, __pyx_ptype_2bx_6arrays_10array_tree_ArrayTreeNode))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GIVEREF(__pyx_t_4);
+  __Pyx_GOTREF(((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->root);
+  __Pyx_DECREF(((PyObject *)((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->root));
+  ((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->root = ((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTreeNode *)__pyx_t_4);
+  __pyx_t_4 = 0;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("bx.arrays.array_tree.ArrayTree.__init__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_FinishRefcountContext();
+  return __pyx_r;
+}
+
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":110
+ *         self.root = ArrayTreeNode( self, 0, max, block_size, self.levels )
+ * 
+ *     def __setitem__( self, int index, value ):             # <<<<<<<<<<<<<<
+ *         self.root.set( index, value )
+ * 
+ */
+
+static int __pyx_pf_2bx_6arrays_10array_tree_9ArrayTree___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pf_2bx_6arrays_10array_tree_9ArrayTree___setitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index, PyObject *__pyx_v_value) {
+  int __pyx_v_index;
+  int __pyx_r;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_SetupRefcountContext("__setitem__");
+  assert(__pyx_arg_index); {
+    __pyx_v_index = __Pyx_PyInt_AsInt(__pyx_arg_index); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("bx.arrays.array_tree.ArrayTree.__setitem__");
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":111
+ * 
+ *     def __setitem__( self, int index, value ):
+ *         self.root.set( index, value )             # <<<<<<<<<<<<<<
+ * 
+ *     def __getitem__( self, int index ):
+ */
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->root), __pyx_kp_set); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyInt_FromLong(__pyx_v_index); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_v_value);
+  PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_value);
+  __Pyx_GIVEREF(__pyx_v_value);
+  __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __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_t_3)); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("bx.arrays.array_tree.ArrayTree.__setitem__");
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_FinishRefcountContext();
+  return __pyx_r;
+}
+
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":113
+ *         self.root.set( index, value )
+ * 
+ *     def __getitem__( self, int index ):             # <<<<<<<<<<<<<<
+ *         return self.root.get( index )
+ * 
+ */
+
+static PyObject *__pyx_pf_2bx_6arrays_10array_tree_9ArrayTree___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index); /*proto*/
+static PyObject *__pyx_pf_2bx_6arrays_10array_tree_9ArrayTree___getitem__(PyObject *__pyx_v_self, PyObject *__pyx_arg_index) {
+  int __pyx_v_index;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  __Pyx_SetupRefcountContext("__getitem__");
+  assert(__pyx_arg_index); {
+    __pyx_v_index = __Pyx_PyInt_AsInt(__pyx_arg_index); if (unlikely((__pyx_v_index == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 113; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("bx.arrays.array_tree.ArrayTree.__getitem__");
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":114
+ * 
+ *     def __getitem__( self, int index ):
+ *         return self.root.get( index )             # <<<<<<<<<<<<<<
+ * 
+ *     def to_file( self, f ):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->root), __pyx_kp_get); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyInt_FromLong(__pyx_v_index); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("bx.arrays.array_tree.ArrayTree.__getitem__");
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_FinishRefcountContext();
+  return __pyx_r;
+}
+
+/* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":116
+ *         return self.root.get( index )
+ * 
+ *     def to_file( self, f ):             # <<<<<<<<<<<<<<
+ *         io = BinaryFileWriter( f, magic=MAGIC )
+ *         io.write_uint32( VERSION )
+ */
+
+static PyObject *__pyx_pf_2bx_6arrays_10array_tree_9ArrayTree_to_file(PyObject *__pyx_v_self, PyObject *__pyx_v_f); /*proto*/
+static PyObject *__pyx_pf_2bx_6arrays_10array_tree_9ArrayTree_to_file(PyObject *__pyx_v_self, PyObject *__pyx_v_f) {
+  PyObject *__pyx_v_io;
+  PyObject *__pyx_v_level;
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_1 = 0;
+  PyObject *__pyx_2 = 0;
+  PyObject *__pyx_3 = 0;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  Py_ssize_t __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  __Pyx_SetupRefcountContext("to_file");
+  __pyx_v_io = Py_None; __Pyx_INCREF(Py_None);
+  __pyx_v_level = Py_None; __Pyx_INCREF(Py_None);
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":117
+ * 
+ *     def to_file( self, f ):
+ *         io = BinaryFileWriter( f, magic=MAGIC )             # <<<<<<<<<<<<<<
+ *         io.write_uint32( VERSION )
+ *         io.write_uint32( self.max )
+ */
+  __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_kp_BinaryFileWriter); if (unlikely(!__pyx_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_1);
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __Pyx_INCREF(__pyx_v_f);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_f);
+  __Pyx_GIVEREF(__pyx_v_f);
+  __pyx_2 = PyDict_New(); if (unlikely(!__pyx_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_2));
+  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_MAGIC); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_3);
+  if (PyDict_SetItem(__pyx_2, __pyx_kp_magic, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_3); __pyx_3 = 0;
+  __pyx_t_2 = PyEval_CallObjectWithKeywords(__pyx_1, ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_2)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_1); __pyx_1 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_2)); __pyx_2 = 0;
+  __Pyx_DECREF(__pyx_v_io);
+  __pyx_v_io = __pyx_t_2;
+  __pyx_t_2 = 0;
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":118
+ *     def to_file( self, f ):
+ *         io = BinaryFileWriter( f, magic=MAGIC )
+ *         io.write_uint32( VERSION )             # <<<<<<<<<<<<<<
+ *         io.write_uint32( self.max )
+ *         io.write_uint32( self.block_size )
+ */
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_io, __pyx_kp_29); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_kp_VERSION); if (unlikely(!__pyx_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_3);
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_3);
+  __Pyx_GIVEREF(__pyx_3);
+  __pyx_3 = 0;
+  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":119
+ *         io = BinaryFileWriter( f, magic=MAGIC )
+ *         io.write_uint32( VERSION )
+ *         io.write_uint32( self.max )             # <<<<<<<<<<<<<<
+ *         io.write_uint32( self.block_size )
+ *         io.write( self.dtype.char )
+ */
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_io, __pyx_kp_29); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->max); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __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 = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":120
+ *         io.write_uint32( VERSION )
+ *         io.write_uint32( self.max )
+ *         io.write_uint32( self.block_size )             # <<<<<<<<<<<<<<
+ *         io.write( self.dtype.char )
+ *         io.write( "\0\0\0" )
+ */
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_io, __pyx_kp_29); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyInt_FromLong(((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->block_size); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+  PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __pyx_t_2 = 0;
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 120; __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_t_3)); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":121
+ *         io.write_uint32( self.max )
+ *         io.write_uint32( self.block_size )
+ *         io.write( self.dtype.char )             # <<<<<<<<<<<<<<
+ *         io.write( "\0\0\0" )
+ *         # Data pass, level order
+ */
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_io, __pyx_kp_write); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = PyObject_GetAttr(((struct __pyx_obj_2bx_6arrays_10array_tree_ArrayTree *)__pyx_v_self)->dtype, __pyx_kp_char); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_3);
+  __pyx_t_3 = 0;
+  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "/Users/james/projects/bx-python/code/bx-python-central/lib/bx/arrays/array_tree.pyx":122
+ *         io.write_uint32( self.block_size )
+ *         io.write( self.dtype.char )
+ *         io.write( "\0\0\0" )             # <<<<<<<<<<<<<<
+ *         # Data pass, level order
+ *         for level in range( self.levels, -1, -1 ):
+ */
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_io, __pyx_kp_write); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __Pyx_INCREF(__pyx_kp_30);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_kp_30);
+  __Pyx_GIVEREF(__pyx_kp_30);
+  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 122; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;