Skip to content

Instantly share code, notes, and snippets.

@alimanfoo
Last active August 29, 2015 14:00
Show Gist options
  • Save alimanfoo/11271034 to your computer and use it in GitHub Desktop.
Save alimanfoo/11271034 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "",
"signature": "sha256:e7a95ff96eced6e3e0f91b11410c2548433f07afeb21c4bd5ca668d482dba258"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"from bx.intervals.intersection import Interval, IntervalTree"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 2
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"tree = IntervalTree()"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 3
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"tree.insert(5, 7, 'foo')\n",
"tree.insert(9, 12, 'bar')"
],
"language": "python",
"metadata": {},
"outputs": [],
"prompt_number": 4
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"tree.find(6, 8)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"metadata": {},
"output_type": "pyout",
"prompt_number": 5,
"text": [
"['foo']"
]
}
],
"prompt_number": 5
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"tree.before(14)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "'str' object has no attribute 'end'",
"output_type": "pyerr",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-11-3370fddbaf8e>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mtree\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbefore\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m14\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;32m/home/aliman/pyenv/scientific/local/lib/python2.7/site-packages/bx/intervals/intersection.so\u001b[0m in \u001b[0;36mbx.intervals.intersection.IntervalTree.before (lib/bx/intervals/intersection.c:4529)\u001b[1;34m()\u001b[0m\n",
"\u001b[1;32m/home/aliman/pyenv/scientific/local/lib/python2.7/site-packages/bx/intervals/intersection.so\u001b[0m in \u001b[0;36mbx.intervals.intersection.IntervalNode.left (lib/bx/intervals/intersection.c:2732)\u001b[1;34m()\u001b[0m\n",
"\u001b[1;31mAttributeError\u001b[0m: 'str' object has no attribute 'end'"
]
}
],
"prompt_number": 11
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"tree.before_interval(Interval(14, 16))"
],
"language": "python",
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "'str' object has no attribute 'end'",
"output_type": "pyerr",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-12-ddc5a057c3db>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mtree\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mbefore_interval\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mInterval\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m14\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m16\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;32m/home/aliman/pyenv/scientific/local/lib/python2.7/site-packages/bx/intervals/intersection.so\u001b[0m in \u001b[0;36mbx.intervals.intersection.IntervalTree.before_interval (lib/bx/intervals/intersection.c:4877)\u001b[1;34m()\u001b[0m\n",
"\u001b[1;32m/home/aliman/pyenv/scientific/local/lib/python2.7/site-packages/bx/intervals/intersection.so\u001b[0m in \u001b[0;36mbx.intervals.intersection.IntervalNode.left (lib/bx/intervals/intersection.c:2732)\u001b[1;34m()\u001b[0m\n",
"\u001b[1;31mAttributeError\u001b[0m: 'str' object has no attribute 'end'"
]
}
],
"prompt_number": 12
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"tree.after(4)"
],
"language": "python",
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "'str' object has no attribute 'start'",
"output_type": "pyerr",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-7-896a39c1ddb7>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mtree\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mafter\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m4\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;32m/home/aliman/pyenv/scientific/local/lib/python2.7/site-packages/bx/intervals/intersection.so\u001b[0m in \u001b[0;36mbx.intervals.intersection.IntervalTree.after (lib/bx/intervals/intersection.c:4668)\u001b[1;34m()\u001b[0m\n",
"\u001b[1;32m/home/aliman/pyenv/scientific/local/lib/python2.7/site-packages/bx/intervals/intersection.so\u001b[0m in \u001b[0;36mbx.intervals.intersection.IntervalNode.right (lib/bx/intervals/intersection.c:3020)\u001b[1;34m()\u001b[0m\n",
"\u001b[1;31mAttributeError\u001b[0m: 'str' object has no attribute 'start'"
]
}
],
"prompt_number": 7
},
{
"cell_type": "code",
"collapsed": false,
"input": [
"tree.after_interval(Interval(2, 4))"
],
"language": "python",
"metadata": {},
"outputs": [
{
"ename": "AttributeError",
"evalue": "'str' object has no attribute 'start'",
"output_type": "pyerr",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mAttributeError\u001b[0m Traceback (most recent call last)",
"\u001b[1;32m<ipython-input-10-abd657fa9fc5>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[1;33m \u001b[0mtree\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mafter_interval\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mInterval\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;36m2\u001b[0m\u001b[1;33m,\u001b[0m \u001b[1;36m4\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[1;32m/home/aliman/pyenv/scientific/local/lib/python2.7/site-packages/bx/intervals/intersection.so\u001b[0m in \u001b[0;36mbx.intervals.intersection.IntervalTree.after_interval (lib/bx/intervals/intersection.c:5021)\u001b[1;34m()\u001b[0m\n",
"\u001b[1;32m/home/aliman/pyenv/scientific/local/lib/python2.7/site-packages/bx/intervals/intersection.so\u001b[0m in \u001b[0;36mbx.intervals.intersection.IntervalNode.right (lib/bx/intervals/intersection.c:3020)\u001b[1;34m()\u001b[0m\n",
"\u001b[1;31mAttributeError\u001b[0m: 'str' object has no attribute 'start'"
]
}
],
"prompt_number": 10
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment