bigfile support in python 3

Issue #57 new
Davide Cittaro
created an issue

I've successfully installed bx-python with easy_install (v 0.7.3), apparently bigwig and bigbed support is broken:

>>> import bx.bbi.bigwig_file
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "bx/bbi/bigwig_file.pyx", line 1, in init bx.bbi.bigwig_file (lib/bx/bbi/bigwig_file.c:7691)
  File "bx/bbi/bbi_file.pyx", line 25, in init bx.bbi.bbi_file (lib/bx/bbi/bbi_file.c:12911)
ImportError: No module named 'cStringIO'
>>> 

StringIO and cStringIO have been moved in python 3 (https://docs.python.org/3.0/whatsnew/3.0.html) and I've tried to patch accordingly bigwig_file.pyx and bigbed_file.pyx modifing

from cStringIO import StringIO

to

try:
    from io import StringIO
except ImportError:
    from cStringIO import StringIO

This solves the issue of loading module but the reader is broken anyway, as I try to load bigwig content like with "get_as_array()" function, I get a

TypeError: expected bytes, str found

error

Comments (6)

  1. Shiran Abadi

    Hi @Eran Rosenthal , Thanks for the fix! However, after recompiling it, I still get an error:

    bwh.get_as_array('chr1', 64941267, 64941289) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "lib/bx/bbi/bigwig_file.pyx", line 147, in bx.bbi.bigwig_file.BigWigFile.get_as_array (lib/bx/bbi/bigwig_file.c:5044) File "lib/bx/bbi/bigwig_file.pyx", line 154, in bx.bbi.bigwig_file.BigWigFile.get_as_array (lib/bx/bbi/bigwig_file.c:4797) File "lib/bx/bbi/bbi_file.pyx", line 249, in bx.bbi.bbi_file.BBIFile._get_chrom_id_and_size (lib/bx/bbi/bbi_file.c:7173) File "bpt_file.pyx", line 74, in bx.bbi.bpt_file.BPTFile.find (lib/bx/bbi/bpt_file.c:1444) TypeError: can't concat bytes to str

    Since you're familiar with the code, I was wondering if you have a clue. (I can't run tests, I'm not an admin of our systems).

    Thanks!

  2. Shiran Abadi

    Hi again, Our dear IT person, @Michail Chernogorsky downloaded your files and recompiled it, and still we get the same error.

    [GCC 4.8.0] on linux Type "help", "copyright", "credits" or "license" for more information.

    filepath = "....."

    import bx.bbi.bigwig_file

    BWH = bx.bbi.bigwig_file.BigWigFile(open(filepath , "rb"))

    BWH.get_as_array('chr1', 100741280, 100741300)

    Traceback (most recent call last):

    File "<stdin>", line 1, in <module>

    File "lib/bx/bbi/bigwig_file.pyx", line 147, in

    bx.bbi.bigwig_file.BigWigFile.get_as_array (lib/bx/bbi/bigwig_file.c:5044)

    cpdef get_as_array( self, chrom, bits32 start, bits32 end ):

    File "lib/bx/bbi/bigwig_file.pyx", line 154, in

    bx.bbi.bigwig_file.BigWigFile.get_as_array (lib/bx/bbi/bigwig_file.c:4797)

    chrom_id, chrom_size = self._get_chrom_id_and_size( chrom_b )

    File "lib/bx/bbi/bbi_file.pyx", line 249, in

    bx.bbi.bbi_file.BBIFile._get_chrom_id_and_size (lib/bx/bbi/bbi_file.c:7173)

    bytes = self.chrom_bpt.find( chrom )

    File "bpt_file.pyx", line 74, in bx.bbi.bpt_file.BPTFile.find

    (lib/bx/bbi/bpt_file.c:1444)

    TypeError: can't concat bytes to str

    I would really appreciate your help.

    Thanks a lot, Shiran

  3. Log in to comment