bxlab / bx-python

Tools for manipulating biological data, particularly multiple sequence alignments
MIT License
145 stars 53 forks source link

TypeError: write() argument must be str, not bytes when running maf_build_index.py with python3.6 #47

Closed mt1022 closed 4 years ago

mt1022 commented 5 years ago

I have latest release of bx-python (0.8.4) installed and came across the following error when index a small maf file using python 3.6:

Traceback (most recent call last):
  File "/home/mt1022/anaconda3/bin/maf_build_index.py", line 88, in <module>
    if __name__ == "__main__": main()
  File "/home/mt1022/anaconda3/bin/maf_build_index.py", line 85, in main
    indexes.write( out )
  File "/home/mt1022/anaconda3/lib/python3.6/site-packages/bx/interval_index_file.py", line 324, in write
    write_packed( f, ">3I", MAGIC, VERSION, len( self.indexes ) )
  File "/home/mt1022/anaconda3/lib/python3.6/site-packages/bx/interval_index_file.py", line 463, in write_packed
    f.write( pack( pattern, *vals ) )
TypeError: write() argument must be str, not bytes

The same file can be indexed successfully with python2.7. Could you help investigate what is causing the error?

mirahan commented 4 years ago

We are having the same issue with the conda version on python 3.6. bx-python 0.8.5 py36h9449cc1_0 bioconda

mt1022 commented 4 years ago

@mirahan , I finally used AlignIO.MafIO from biopython (version 1.73) instead. I find it works fine in python3 with even large MAF files such as that for the human genome against 99 vertebrates..