Subject: port to python3
Description: fix to port to python3,
 upstream not maintained nor porting to py3.
Author: Olivier Sallou <osallou@debian.org>
Last-Updated: 2020-02-09
Forwarded: no
--- a/distutils.ext/obidistutils/core.py
+++ b/distutils.ext/obidistutils/core.py
@@ -75,6 +75,7 @@
             except IOError:
                 pass
             pyrexs[-1].sources.extend(glob.glob(os.path.splitext(pyrex)[0]+'.ext.*.c'))
+            pyrexs[-1].cython_directives = {'language_level': "3"}
             print(pyrexs[-1].sources)
             # Main.compile([pyrex],timestamps=True)
             
--- a/src/obitools/_obitools.pyx
+++ b/src/obitools/_obitools.pyx
@@ -1,7 +1,7 @@
 # cython: profile=True
 
 
-from _obitools cimport *
+from obitools._obitools cimport *
 
 #from cython.parallel import parallel, prange
 
@@ -207,7 +207,8 @@
         raise TypeError,'key must be a Location, an integer or a slice'  
     
     cpdef object getKey(self, bytes key):
-                
+        if key.decode() in self._info:
+            return self._info[key.decode()]
         if key not in self._info:
             if self.__rawinfo is None:
                 if key==b'count':
@@ -256,18 +257,26 @@
         return v 
     
     def __str__(self):
-        return self.getStr()
+        return self.getStr().decode()
     
     def __getitem__(self,key):
         if isinstance(key, bytes):
             return self.getKey(key)
+        elif isinstance(key, str):
+            return self.getKey(key.encode())
         else:
             return self.getSubSeq(key)
         
     def __setitem__(self,key,value):
-        self.__contains__(key)
-        self._info[key]=value
-        if key=='taxid':
+        if isinstance(key, bytes):
+          self.__contains__(key)
+          self._info[key] = value
+          if key == u'taxid':
+              self._hasTaxid=value is not None
+        else:
+          self.__contains__(key.encode())
+          self._info[key.encode()]=value
+          if key=='taxid':
             self._hasTaxid=value is not None
         
     def __delitem__(self,key):
@@ -325,6 +334,8 @@
         '''
         if key=='taxid' and self._hasTaxid is None:
             self.extractTaxon()
+        if isinstance(key, str):
+            key = key.encode()
         return self.hasKey(key)
     
     def rawiteritems(self):
@@ -528,11 +539,13 @@
     cpdef object getKey(self,bytes key):
         if key in self._info:
             return self._info[key]
+        elif key.decode() in self._info:
+            return self._info[key.decode()]
         else:
             return self.wrapped.getKey(key)
         
     cpdef bint hasKey(self,bytes key):
-        return key in self._info or self.wrapped.hasKey(key)
+        return key in self._info or key.decode() in self._info or self.wrapped.hasKey(key)
             
     cpdef  getSymbolAt(self, int position):
         return self.wrapped.getSymbolAt(self.posInWrapped(position))
@@ -545,7 +558,7 @@
             
     
     cpdef bytes getStr(self):
-        return str(self.wrapped)
+        return str(self.wrapped).encode()
     
     cpdef object getRoot(self):
         return self.wrapped.getRoot()
@@ -736,7 +749,7 @@
     acgt   = 0
     notnuc = 0
     lltot  = len(text)
-    ltot   = lltot * 4 / 5
+    ltot   = int(lltot * 4 / 5)
     
     for c in text:
         if c in _nuc:
--- a/src/obitools/fastq/_fastq.pyx
+++ b/src/obitools/fastq/_fastq.pyx
@@ -193,7 +193,7 @@
         data = [data]
 
     for sequence in data:
-        seq = str(sequence)
+        seq = str(sequence).encode()
         if upper:
             seq=seq.upper()
         if sequence.definition is None:
--- a/src/obitools/fasta/_fasta.pyx
+++ b/src/obitools/fasta/_fasta.pyx
@@ -4,7 +4,7 @@
 
 
 """
-from _fasta cimport *
+from obitools.fasta._fasta cimport *
 
 from obitools._obitools cimport  _bioSeqGenerator,BioSequence,AASequence,NucSequence
 from obitools._obitools cimport  __default_raw_parser
@@ -41,8 +41,8 @@
     void regfree(regex_t *preg)
     
 #fastaEntryIterator=fastGenericEntryIteratorGenerator(startEntry='>')
-fastaEntryIterator=genericEntryIteratorGenerator(startEntry='>')
-rawFastaEntryIterator=genericEntryIteratorGenerator(startEntry='\s*>')
+fastaEntryIterator=genericEntryIteratorGenerator(startEntry='>'.encode())
+rawFastaEntryIterator=genericEntryIteratorGenerator(startEntry='\s*>'.encode())
 
 cdef bytes _fastaJoinSeq(list seqarray):
     return  b''.join([x.strip() for x in seqarray])
@@ -205,7 +205,7 @@
     >>> from obitools.format.sequence.fasta import fastFastaIterator
     >>> f = fastFastaIterator('monfichier')
     >>> s = f.next()
-    >>> print s
+    >>> print(s)
     gctagctagcatgctagcatgcta
     >>>
     '''
@@ -244,7 +244,7 @@
     >>> from obitools.format.sequence.fasta import fastaIterator
     >>> f = fastaIterator('monfichier')
     >>> s = f.next()
-    >>> print s
+    >>> print(s)
     gctagctagcatgctagcatgcta
     >>>
     '''
--- a/src/obitools/utils/_utils.pyx
+++ b/src/obitools/utils/_utils.pyx
@@ -1,6 +1,6 @@
 # cython: profile=True
 
-from _utils cimport *
+from obitools.utils._utils cimport *
 
 import sys
 
@@ -157,4 +157,4 @@
         cycle+=1
 
     step[0:3] = freq,cycle,arrow
-    
\ No newline at end of file
+
--- a/src/obitools/align/_codonnws.pyx
+++ b/src/obitools/align/_codonnws.pyx
@@ -5,8 +5,9 @@
 '''
 #@PydevCodeAnalysisIgnore
 
-from _codonnws cimport * 
-
+from obitools.align._codonnws cimport *
+from obitools.align._dynamic cimport *
+from obitools.align._nws cimport *
 
 #TODO: change functions for translation and BLOSUM scores
 
@@ -23,157 +24,160 @@
 #  -- Base3  TCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAGTCAG
 
 #TODO : fonction completement cablee en dure a changer vite !
-cdef char _translate(char c1, char c2, char c3):
+cdef char _translate(char c1i, char c2i, char c3i):
+    cdef Py_UNICODE c1 = c1i;
+    cdef Py_UNICODE c2 = c2i;
+    cdef Py_UNICODE c3 = c3i;
     if c1=='a':
         if c2=='a':
             if c3=='a':
-                return 'k'
+                return <bytes>'k'
             elif c3=='c':
-                return 'n'
+                return <bytes>'n'
             elif c3=='g':
-                return 'k'
+                return <bytes>'k'
             elif c3=='t':
-                return 'n'
+                return <bytes>'n'
         elif c2=='c':
             if c3=='a':
-                return 't'
+                return <bytes>'t'
             elif c3=='c':
-                return 't'
+                return <bytes>'t'
             elif c3=='g':
-                return 't'
+                return <bytes>'t'
             elif c3=='t':
-                return 't'
+                return <bytes>'t'
         elif c2=='g':
             if c3=='a':
-                return 'r'
+                return <bytes>'r'
             elif c3=='c':
-                return 's'
+                return <bytes>'s'
             elif c3=='g':
-                return 'r'
+                return <bytes>'r'
             elif c3=='t':
-                return 's'
+                return <bytes>'s'
         elif c2=='t':
             if c3=='a':
-                return 'i'
+                return <bytes>'i'
             elif c3=='c':
-                return 'i'
+                return <bytes>'i'
             elif c3=='g':
-                return 'm'
+                return <bytes>'m'
             elif c3=='t':
-                return 'i'
+                return <bytes>'i'
     elif c1=='c':
         if c2=='a':
             if c3=='a':
-                return 'q'
+                return <bytes>'q'
             elif c3=='c':
-                return 'h'
+                return <bytes>'h'
             elif c3=='g':
-                return 'q'
+                return <bytes>'q'
             elif c3=='t':
-                return 'h'
+                return <bytes>'h'
         elif c2=='c':
             if c3=='a':
-                return 'p'
+                return <bytes>'p'
             elif c3=='c':
-                return 'p'
+                return <bytes>'p'
             elif c3=='g':
-                return 'p'
+                return <bytes>'p'
             elif c3=='t':
-                return 'p'
+                return <bytes>'p'
         elif c2=='g':
             if c3=='a':
-                return 'r'
+                return <bytes>'r'
             elif c3=='c':
-                return 'r'
+                return <bytes>'r'
             elif c3=='g':
-                return 'r'
+                return <bytes>'r'
             elif c3=='t':
-                return 'r'
+                return <bytes>'r'
         elif c2=='g':
             if c3=='a':
-                return 'l'
+                return <bytes>'l'
             elif c3=='c':
-                return 'l'
+                return <bytes>'l'
             elif c3=='g':
-                return 'l'
+                return <bytes>'l'
             elif c3=='t':
-                return 'l'
+                return <bytes>'l'
     elif c1=='g':
         if c2=='a':
             if c3=='a':
-                return 'e'
+                return <bytes>'e'
             elif c3=='c':
-                return 'd'
+                return <bytes>'d'
             elif c3=='g':
-                return 'e'
+                return <bytes>'e'
             elif c3=='t':
-                return 'd'
+                return <bytes>'d'
         elif c2=='c':
             if c3=='a':
-                return 'a'
+                return <bytes>'a'
             elif c3=='c':
-                return 'a'
+                return <bytes>'a'
             elif c3=='g':
-                return 'a'
+                return <bytes>'a'
             elif c3=='t':
-                return 'a'
+                return <bytes>'a'
         elif c2=='g':
             if c3=='a':
-                return 'g'
+                return <bytes>'g'
             elif c3=='c':
-                return 'g'
+                return <bytes>'g'
             elif c3=='g':
-                return 'g'
+                return <bytes>'g'
             elif c3=='t':
-                return 'g'
+                return <bytes>'g'
         elif c2=='t':
             if c3=='a':
-                return 'v'
+                return <bytes>'v'
             elif c3=='c':
-                return 'v'
+                return <bytes>'v'
             elif c3=='g':
-                return 'v'
+                return <bytes>'v'
             elif c3=='t':
-                return 'v'
+                return <bytes>'v'
     elif c1=='t':
         if c2=='a':
             if c3=='a':
-                return '*'
+                return <bytes>'*'
             elif c3=='c':
-                return 'y'
+                return <bytes>'y'
             elif c3=='g':
-                return '*'
+                return <bytes>'*'
             elif c3=='t':
-                return 'y'
+                return <bytes>'y'
         elif c2=='c':
             if c3=='a':
-                return 's'
+                return <bytes>'s'
             elif c3=='c':
-                return 's'
+                return <bytes>'s'
             elif c3=='g':
-                return 's'
+                return <bytes>'s'
             elif c3=='t':
-                return 's'
+                return <bytes>'s'
         elif c2=='g':
             if c3=='a':
-                return '*'
+                return <bytes>'*'
             elif c3=='c':
-                return 'c'
+                return <bytes>'c'
             elif c3=='g':
-                return 'w'
+                return <bytes>'w'
             elif c3=='t':
-                return 'c'
+                return <bytes>'c'
         elif c2=='t':
             if c3=='a':
-                return 'l'
+                return <bytes>'l'
             elif c3=='c':
-                return 'f'
+                return <bytes>'f'
             elif c3=='g':
-                return 'l'
+                return <bytes>'l'
             elif c3=='t':
-                return 'f'
+                return <bytes>'f'
 
-    return '*'
+    return <bytes>'*'
 
 #http://www.ncbi.nlm.nih.gov/Class/FieldGuide/BLOSUM62.txt
 #
@@ -212,8 +216,8 @@
 
 cdef double _blosum62(char c1_1, char c1_2, char c1_3, char c2_1, char c2_2, char c2_3):
 
-    cdef char aa1 = _translate(c1_1, c1_2, c1_3)
-    cdef char aa2 = _translate(c2_1, c2_2, c2_3)
+    cdef Py_UNICODE aa1 = _translate(c1_1, c1_2, c1_3)
+    cdef Py_UNICODE aa2 = _translate(c2_1, c2_2, c2_3)
 
     if aa1=="a" and aa2=="a":
         return 4
@@ -1399,10 +1403,10 @@
         return score
 
     cdef inline int colindex(self, int idx):
-        return idx%(self._hlen()+1)
+        return int(idx%(self._hlen()+1))
         
     cdef inline int rowindex(self, int idx):
-        return idx/(self._hlen()+1)
+        return int(idx/(self._hlen()+1))
 
 
     #on change la signification des infos dans la matrice path
@@ -1554,7 +1558,7 @@
                 #print 'on passe par un gap'
                 p = -(i-ori_i)
             else:
-                print "badaboum !"
+                print("badaboum !")
  
             i = ori_i
             j = ori_j
--- a/src/obitools/align/_dynamic.pyx
+++ b/src/obitools/align/_dynamic.pyx
@@ -17,7 +17,7 @@
 #
 #
 
-from _dynamic cimport * 
+from obitools.align._dynamic cimport *
     
 cdef AlignMatrix* allocateMatrix(int hsize, int vsize,AlignMatrix *matrix=NULL):
     
@@ -128,7 +128,7 @@
         cdef long j
         
         j=path.length
-        for i in range(path.length/2):
+        for i in range(int(path.length/2)):
             j-=1
             path.path[i],path.path[j]=path.path[j],path.path[i]
 
@@ -362,4 +362,4 @@
 for i in range(26):
     _basecode[i]=__basecode[i]
                
-        
\ No newline at end of file
+
--- a/src/obitools/align/_nws.pyx
+++ b/src/obitools/align/_nws.pyx
@@ -5,7 +5,8 @@
 '''
 #@PydevCodeAnalysisIgnore
 
-from _nws cimport * 
+from obitools.align._nws cimport *
+from obitools.align._dynamic cimport *
 
 
 cdef class NWS(DynamicProgramming):
--- a/src/obitools/align/_nws.pxd
+++ b/src/obitools/align/_nws.pxd
@@ -1,4 +1,4 @@
-from _dynamic cimport *
+from obitools.align._dynamic cimport *
 
 cdef class NWS(DynamicProgramming):
     cdef double _match
--- a/src/obitools/align/_codonnws.pxd
+++ b/src/obitools/align/_codonnws.pxd
@@ -1,4 +1,4 @@
-from _nws cimport *
+from obitools.align._nws cimport *
 
 cdef class CodonNWS(NWS):
     #cdef double* _aamatrix
--- a/src/obitools/align/_freeendgap.pyx
+++ b/src/obitools/align/_freeendgap.pyx
@@ -5,7 +5,7 @@
 '''
 #@PydevCodeAnalysisIgnore
 
-from _freeendgap cimport *  
+from obitools.align._freeendgap cimport *
 
 
 cdef class FreeEndGap(NWS):
--- a/src/obitools/align/_freeendgap.pxd
+++ b/src/obitools/align/_freeendgap.pxd
@@ -1,4 +1,4 @@
-from _nws cimport *  
+from obitools.align._nws cimport *
 
 cdef class FreeEndGap(NWS):
     cdef double xsmax
--- a/src/obitools/align/_gprofilenws.pxd
+++ b/src/obitools/align/_gprofilenws.pxd
@@ -1,8 +1,8 @@
-from _profilenws cimport *
+from obitools.align._profilenws cimport *
 
 cdef class GProfileNWS(ProfileNWS):
 
     cdef double matchScore(self,int h, int v)
     cdef object alignment1
     cdef object alignment2
-    #cdef double doAlignment(self) except? 0
\ No newline at end of file
+    #cdef double doAlignment(self) except? 0
--- a/src/obitools/align/_gprofilenws.pyx
+++ b/src/obitools/align/_gprofilenws.pyx
@@ -5,7 +5,7 @@
 '''
 #@PydevCodeAnalysisIgnore
 
-from _gprofilenws cimport *
+from obitools.align._gprofilenws cimport *
 
 
 cdef class GProfileNWS(ProfileNWS):
--- a/src/obitools/align/_profilenws.pxd
+++ b/src/obitools/align/_profilenws.pxd
@@ -1,4 +1,4 @@
-from _nws cimport *
+from obitools.align._nws cimport *
 from obitools.profile._profile cimport *
 
 cdef struct alignProfile:
@@ -20,4 +20,4 @@
     
     cdef int _vlen(self)
     cdef int _hlen(self)
-    cdef double doAlignment(self) except? 0
\ No newline at end of file
+    cdef double doAlignment(self) except? 0
--- a/src/obitools/align/_upperbond.pyx
+++ b/src/obitools/align/_upperbond.pyx
@@ -5,10 +5,10 @@
 '''
 #@PydevCodeAnalysisIgnore
 
-from _dynamic cimport *
+from obitools.align._dynamic cimport *
 
 from obitools import BioSequence
-from _upperbond cimport *
+from obitools.align._upperbond cimport *
 #from libupperbond import buildTable
 
 cdef array.array[unsigned char] newtable():
--- a/src/obitools/align/_rassemble.pxd
+++ b/src/obitools/align/_rassemble.pxd
@@ -1,4 +1,4 @@
-from _nws cimport *  
+from obitools.align._nws cimport *
 
 cdef class RightDirectAssemble(NWS):
     cdef double xsmax
@@ -7,4 +7,4 @@
     cdef double doAlignment(self) except? 0
     
 cdef class RightReverseAssemble(RightDirectAssemble):    
-    pass
\ No newline at end of file
+    pass
--- a/src/obitools/align/_rassemble.pyx
+++ b/src/obitools/align/_rassemble.pyx
@@ -5,7 +5,7 @@
 @author: coissac
 '''
 
-from _rassemble cimport *  
+from obitools.align._rassemble cimport *
 
 
 cdef class RightDirectAssemble(NWS):
--- a/src/obitools/align/_assemble.pxd
+++ b/src/obitools/align/_assemble.pxd
@@ -1,4 +1,4 @@
-from _nws cimport *  
+from obitools.align._nws cimport *
 
 cdef class DirectAssemble(NWS):
     cdef double ysmax
@@ -7,4 +7,4 @@
     cdef double doAlignment(self) except? 0
     
 cdef class ReverseAssemble(DirectAssemble):    
-    pass
\ No newline at end of file
+    pass
--- a/src/obitools/align/_assemble.pyx
+++ b/src/obitools/align/_assemble.pyx
@@ -5,7 +5,7 @@
 '''
 #@PydevCodeAnalysisIgnore
 
-from _assemble cimport *  
+from obitools.align._assemble cimport *
 
 
 cdef class DirectAssemble(NWS):
--- a/src/obitools/align/_nwsdnabyprot.pxd
+++ b/src/obitools/align/_nwsdnabyprot.pxd
@@ -1,4 +1,4 @@
-from _dynamic cimport *
+from obitools.align._dynamic cimport *
 
 cdef struct CodonAlignCell :
     double score
--- a/src/obitools/align/_nwsdnabyprot.pyx
+++ b/src/obitools/align/_nwsdnabyprot.pyx
@@ -7,7 +7,7 @@
 
 import sys
 
-from _nwsdnabyprot cimport * 
+from obitools.align._nwsdnabyprot cimport *
 
 from obitools.sequenceencoder.geneticcode import TranslationEncoder
 from obitools.translate import GeneticCode
@@ -90,7 +90,7 @@
         self._sframe = startingFrame
         
     cdef double aaScore(self,char aa1,char aa2):
-        if aa1==aa2 or aa1=='X' or aa2=='X':
+        if aa1==aa2 or aa1==<bytes>'X' or aa2==<bytes>'X':
             return self._match
         else:
             return self._mismatch
@@ -113,11 +113,11 @@
             if v < (self.vSeq.length):
                 codon[1]=self.vSeq.sequence[v]
             else:
-                codon[1]='*'
+                codon[1]=<bytes>'*'
             if v < (self.vSeq.length-1):
                 codon[2]=self.vSeq.sequence[v+1]
             else:
-                codon[2]='*'
+                codon[2]=<bytes>'*'
             
         elif frame==1 :
             vv=v
@@ -132,12 +132,12 @@
                     path   = smatrix[self.index(h,vv)].path
                 codon[0]=self.vSeq.sequence[vv-1]
             else:
-                codon[0]='*'
+                codon[0]=<bytes>'*'
             codon[1]=self.vSeq.sequence[v-1]
             if v < (self.vSeq.length):
                 codon[2]=self.vSeq.sequence[v]
             else:
-                codon[2]='*'
+                codon[2]=<bytes>'*'
         else:
             vv=v
             if v>1:
@@ -154,7 +154,7 @@
                 h-=1
                 path   = smatrix[self.index(h,vv)].path
             else:
-                codon[1]='*'
+                codon[1]=<bytes>'*'
             if v>2:
                 if path==0:
                     vv-=1
@@ -167,7 +167,7 @@
                 codon[0]=self.vSeq.sequence[vv-1]
                 codon[0]=self.vSeq.sequence[v-3]
             else:
-                codon[0]='*'
+                codon[0]=<bytes>'*'
             codon[2]=self.vSeq.sequence[v-1]
 
         
@@ -188,30 +188,30 @@
             if h < (self.hSeq.length):
                 codon[1]=self.hSeq.sequence[h]
             else:
-                codon[1]='*'
+                codon[1]=<bytes>'*'
             if h < (self.hSeq.length-1):
                 codon[2]=self.hSeq.sequence[h+1]
             else:
-                codon[2]='*'
+                codon[2]=<bytes>'*'
         elif frame==1 :
             if h>1:
                 codon[0]=self.hSeq.sequence[h-2]
             else:
-                codon[0]='*'
+                codon[0]=<bytes>'*'
             codon[1]=self.hSeq.sequence[h-1]
             if h < (self.hSeq.length):
                 codon[2]=self.hSeq.sequence[h]
             else:
-                codon[2]='*'
+                codon[2]=<bytes>'*'
         else:
             if h>2:
                 codon[0]=self.hSeq.sequence[h-3]
             else:
-                codon[0]='*'
+                codon[0]=<bytes>'*'
             if h>1:
                 codon[1]=self.hSeq.sequence[h-2]
             else:
-                codon[1]='*'
+                codon[1]=<bytes>'*'
             codon[2]=self.hSeq.sequence[h-1]
             
         aa=ord(self._gc[str(codon)])
--- a/src/obitools/align/_profilenws.pyx
+++ b/src/obitools/align/_profilenws.pyx
@@ -5,7 +5,7 @@
 '''
 #@PydevCodeAnalysisIgnore
 
-from _profilenws cimport *
+from obitools.align._profilenws cimport *
 from obitools.profile._profile import DNAProfile
 
 
--- a/src/obitools/align/_freeendgapfm.pxd
+++ b/src/obitools/align/_freeendgapfm.pxd
@@ -1,4 +1,4 @@
-from _freeendgap cimport *  
+from obitools.align._freeendgap cimport *
 
 cdef class FreeEndGapFullMatch(FreeEndGap):
     cdef double matchScore(self,int h, int v)
--- a/src/obitools/align/_freeendgapfm.pyx
+++ b/src/obitools/align/_freeendgapfm.pyx
@@ -5,7 +5,7 @@
 '''
 #@PydevCodeAnalysisIgnore
 
-from _freeendgapfm cimport *  
+from obitools.align._freeendgapfm cimport *
 
 
 cdef class FreeEndGapFullMatch(FreeEndGap):
--- a/src/obitools/profile/_profile.pyx
+++ b/src/obitools/profile/_profile.pyx
@@ -1,6 +1,6 @@
 from obitools import NucSequence
 from math import log
-from _profile cimport *
+from obitools.profile._profile cimport *
 
 
 cdef dnaprofile_t* allocateDNAProfile(int size):
@@ -224,16 +224,16 @@
         
         for i in range(lseq):
             nuc = seq[i]
-            if nuc=='a':
+            if nuc==<bytes>'a':
                 A[i]=1
-            elif nuc=='c':
+            elif nuc==<bytes>'c':
                 C[i]=1
-            elif nuc=='g':
+            elif nuc==<bytes>'g':
                 G[i]=1
-            elif nuc=='t':
+            elif nuc==<bytes>'t':
                 T[i]=1
-            elif nuc=='-':
-                if i > 0 and seq[i-1]=='-':
+            elif nuc==<bytes>'-':
+                if i > 0 and seq[i-1]==<bytes>'-':
                     Eg[i]=1
                 else:
                     Og[i]=1
--- a/src/obitools/word/_readindex.pyx
+++ b/src/obitools/word/_readindex.pyx
@@ -62,13 +62,13 @@
 
 cdef obinuc encodeobinuc(char nuc):    
     nuc&=0b11011111
-    if nuc=='A':
+    if nuc==<bytes>'A':
         return A
-    elif nuc=='C':
+    elif nuc==<bytes>'C':
         return C
-    elif nuc=='G':
+    elif nuc==<bytes>'G':
         return G
-    elif nuc=='T':
+    elif nuc==<bytes>'T':
         return T
     else:
         return N
@@ -261,7 +261,7 @@
         assert f!=NULL,"cannot open file Ms" % filename
         
         if verbose:
-            print >>sys.stderr,"Writing header..."
+            print("Writing header...",file=sys.stderr)
             
         transfered = fwrite(&(self._size),sizeof(int),1,f)
         assert transfered==1,"Error during size writing"
@@ -278,7 +278,7 @@
         transfered = fwrite(&(self._buffer),sizeof(pobinuc),1,f)
         assert transfered==1,"Error during buffer address writing"
         
-        print >> sys.stderr,self._endofreads
+        print(self._endofreads, file=sys.stderr)
         transfered = fwrite(&(self._endofreads),sizeof(long long),1,f)
         assert transfered==1,"Error during endofread writing"
         
@@ -292,12 +292,12 @@
         assert transfered==1,"Error during lindex writing"
         
         if verbose:
-            print >>sys.stderr,"Writing sequences..."
+            print("Writing sequences...", file=sys.stderr)
 
         fwrite(self._buffer,1,self._buffer_size,f)
         
         if verbose:
-            print >>sys.stderr,"Writing %d words index..." % self._wordlist_size
+            print("Writing %d words index..." % self._wordlist_size, file=sys.stderr)
 
 #        for i in range(self._wordlist_size):    
 #            print >>sys.stderr,'--> %d %d' % (i,<long long>self._wordlist[i]),
@@ -312,13 +312,13 @@
 #            print " %d" % <long long>self._wordlist[i]
        
         if verbose:
-            print >>sys.stderr,"Writing sequence identifiers..."
+            print("Writing sequence identifiers...", file=sys.stderr)
 
         tbuffer=dumps(self._ids)
         tcbuffer=tbuffer
         ltbuffer=strlen(tcbuffer)
         if verbose:
-            print >>sys.stderr,"  identifier size = %d" % ltbuffer
+            print("  identifier size = %d" % ltbuffer, file=sys.stderr)
         fwrite(&ltbuffer,sizeof(size_t),1,f)
         fwrite(tcbuffer,1,ltbuffer,f)
         
@@ -329,15 +329,15 @@
 #            fwrite(&(ltitle),sizeof(int),1,f)
 #            fwrite(title,1,ltitle,f)
             
-        print >>sys.stderr
+        print('', file=sys.stderr)
 
         if verbose:
-            print >>sys.stderr,"Save done"
+            print("Save done", file=sys.stderr)
 
         fclose(f)
             
         if verbose:
-            print >>sys.stderr,"File closed"
+            print("File closed", file=sys.stderr)
             
     def load(self,bytes filename, bint verbose=False):
         cdef char* cfile=filename
@@ -356,39 +356,39 @@
         assert f!=NULL,"cannot open file Ms" % filename
 
         if verbose:
-            print >>sys.stderr,"Reading header..."
+            print("Reading header...", file=sys.stderr)
             
         transfered = fread(&(self._size),sizeof(int),1,f)
         assert transfered==1,"Error during size reading"
         if verbose:
-            print >>sys.stderr,"  index contains %d sequence pairs" % self._size
+            print("  index contains %d sequence pairs" % self._size, file=sys.stderr)
         
         transfered = fread(&(self._readsize),sizeof(int),1,f)
         assert transfered==1,"Error during read size reading"
         if verbose:
-            print >>sys.stderr,"  read size is %d pb" % self._readsize
+            print("  read size is %d pb" % self._readsize, file=sys.stderr)
         
         transfered = fread(&(self._seqsize),sizeof(int),1,f)
         assert transfered==1,"Error during seqsize reading"
         if verbose:
-            print >>sys.stderr,"  sequence size is %d bytes" % self._seqsize
+            print("  sequence size is %d bytes" % self._seqsize, file=sys.stderr)
         
         transfered = fread(&(self._buffer_size),sizeof(long long),1,f)
         assert transfered==1,"Error during buffer size reading"
         if verbose:
-            print >>sys.stderr,"  buffer size is %d bytes" % self._buffer_size
+            print("  buffer size is %d bytes" % self._buffer_size, file=sys.stderr)
         
         transfered = fread(&(oldbuf),sizeof(pobinuc),1,f)
         assert transfered==1,"Error during buffer address reading"
         transfered = fread(&(self._endofreads),sizeof(long long),1,f)
         assert transfered==1,"Error during endofread reading"
         if verbose:
-            print >>sys.stderr,"  end of reads is %d" % self._endofreads
+            print("  end of reads is %d" % self._endofreads, file=sys.stderr)
             
         transfered = fread(&(self._wordlist_size),sizeof(long long),1,f)
         assert transfered==1,"Error during word list size reading"
         if verbose:
-            print >>sys.stderr,"  index contains %d words" % self._wordlist_size
+            print("  index contains %d words" % self._wordlist_size, file=sys.stderr)
         
         transfered = fread(&(self._wordlength),sizeof(int),1,f)
         assert transfered==1,"Error during word length reading"
@@ -397,7 +397,7 @@
         assert transfered==1,"Error during lindex reading"
         
         if verbose:
-            print >>sys.stderr,"Reading sequences..."
+            print("Reading sequences...", file=sys.stderr)
             
         if (self._buffer!=NULL):
             free(self._buffer)
@@ -407,7 +407,7 @@
         transfered = fread(self._buffer,1,self._buffer_size,f)
 
         if verbose:
-            print >>sys.stderr,"Reading %d words index..." % self._wordlist_size
+            print("Reading %d words index..." % self._wordlist_size, file=sys.stderr)
             
         if (self._wordlist!=NULL):
             free(self._wordlist)
@@ -418,7 +418,7 @@
  
 
         if verbose:
-            print >>sys.stderr,"Patching word index..."
+            print("Patching word index...", file=sys.stderr)
             
 
         for i in range(self._wordlist_size):    
@@ -427,11 +427,11 @@
         self._ids=[]
         
         if verbose:
-            print >>sys.stderr,"Reading sequence ids..."
+            print("Reading sequence ids...", file=sys.stderr)
             
         fread(&ltbuffer,sizeof(size_t),1,f)
         if verbose:
-            print >>sys.stderr,"  identifier size = %d" % ltbuffer
+            print("  identifier size = %d" % ltbuffer, file=sys.stderr)
         tcbuffer = <char*>malloc(ltbuffer)
         fread(tcbuffer,1,ltbuffer,f)
         self._ids=loads(PyBytes_FromStringAndSize(tcbuffer,ltbuffer))
@@ -442,7 +442,7 @@
         self._lindex=6 if self._wordlength >=6 else self._wordlength
         
         if verbose:
-            print >>sys.stderr,"Hashing word prefix..."
+            print("Hashing word prefix...", file=sys.stderr)
 
         for i in range(4096):
             self._index[i]=-1
@@ -469,7 +469,7 @@
         assert lword <= self._readsize,"words cannot be longer than reads"
         
         if verbose:
-            print >>sys.stderr,"Indexing words from %d sequences..." % len(self)
+            print("Indexing words from %d sequences..." % len(self), file=sys.stderr)
         
         if self._wordlist!=NULL:
             free(self._wordlist)
@@ -501,7 +501,7 @@
         self._wordlength=lword
 
         if verbose:
-            print >>sys.stderr,"Sorting %d words..." % i
+            print("Sorting %d words..." % i, file=sys.stderr)
         
         cmpwordlengthLock.acquire()
         self._globalwordlength[0]=lword
@@ -511,7 +511,7 @@
         self._lindex=6 if lword >=6 else lword
         
         if verbose:
-            print >>sys.stderr,"Hashing word prefix..."
+            print("Hashing word prefix...", file=sys.stderr)
 
         for i in range(4096):
             self._index[i]=-1
@@ -530,7 +530,7 @@
         
         for i in range(self._size):
             start1=self._buffer+ i * self._seqsize
-            start2=start1 + self._seqsize / 2
+            start2=start1 + <long>(self._seqsize / 2)
             if GET_SEQUSED(start1[0])==1 and GET_SEQUSED(start2[0])==1:
                 yield self.getSeqPairAt(start1,False)
         
@@ -541,7 +541,7 @@
         
         for i in range(self._size):
             start1=self._buffer+ i * self._seqsize
-            start2=start1 + self._seqsize / 2
+            start2=start1 + <long>(self._seqsize / 2)
             if (GET_SEQUSED(start1[0])==1 or GET_SEQUSED(start2[0])==1) \
                and not (GET_SEQUSED(start1[0])==1 and GET_SEQUSED(start2[0])==1):
                 if GET_SEQUSED(start1[0])==1:
@@ -715,7 +715,7 @@
         delta/= self._seqsize
         
         start1=self._buffer+ delta * self._seqsize
-        start2=start1 + self._seqsize / 2
+        start2=start1 + <long>(self._seqsize / 2)
         
         if word >= start2:
             start1=start2
@@ -754,7 +754,7 @@
         delta/= self._seqsize
         
         start1=self._buffer+ delta * self._seqsize
-        start2=start1 + self._seqsize / 2
+        start2=start1 + <long>(self._seqsize / 2)
         
         if lock:
             if GET_SEQUSED(start1[0])==1:
--- a/src/obitools/word/_binary.pyx
+++ b/src/obitools/word/_binary.pyx
@@ -248,7 +248,7 @@
         rep = 0
         for i in range(self._errors):
             rep |= 1 << self._errorpos[i]
-            print bin2str(rep)
+            print(bin2str(rep))
             
         move=False
         i=0
@@ -257,7 +257,7 @@
                  self._errorpos[i]+=1
                  move=True
                  i=0
-                 print "pos %d/%d moved" % (i,self._wsize)
+                 print("pos %d/%d moved" % (i,self._wsize))
             else:
                 self._errorpos[i]=i
                 i+=1
@@ -266,4 +266,4 @@
                 move=True
                 
         return rep
-    
\ No newline at end of file
+ 
--- a/src/obitools/__init__.py
+++ b/src/obitools/__init__.py
@@ -20,7 +20,7 @@
 
 '''
 
-from _obitools import BioSequence,NucSequence,AASequence, \
+from obitools._obitools import BioSequence,NucSequence,AASequence, \
                       WrappedBioSequence,SubSequence, \
                       DNAComplementSequence,_default_raw_parser, \
                       _isNucSeq,bioSeqGenerator
--- a/src/obitools/utils/__init__.py
+++ b/src/obitools/utils/__init__.py
@@ -12,8 +12,8 @@
 from obitools.zipfile import ZipFile
 import os.path
 
-from _utils import FakeFile     # @UnresolvedImport
-from _utils import progressBar  # @UnresolvedImport
+from obitools.utils._utils import FakeFile     # @UnresolvedImport
+from obitools.utils._utils import progressBar  # @UnresolvedImport
 import zlib
 
 try:
@@ -61,9 +61,11 @@
     
     @return: an iterator on text lines.
     '''
+    if isinstance(file, bytes):
+        file = file.decode()
     if isinstance(file,str):
         try:
-            if urllib2.urlparse.urlparse(file)[0]=='':
+            if urllib.parse.urlparse(file)[0]=='':
                 rep = open(file)
             else:
                 rep  = urllib.request.urlopen(file,timeout=15)
@@ -99,7 +101,11 @@
     '''
     
     if hasattr(file, "tell"):
-        return file.tell()
+        try:
+            t = file.tell()
+            return t
+        except Exception:
+            return None
     else:
         return None
 
--- a/src/obitools/word/__init__.py
+++ b/src/obitools/word/__init__.py
@@ -1,5 +1,5 @@
 
-from _binary import *
+from obitools.word._binary import *
 from functools import reduce
 
 def wordCount(liste):
--- a/src/obitools/fasta/__init__.py
+++ b/src/obitools/fasta/__init__.py
@@ -4,7 +4,7 @@
 
 """
 
-from _fasta import parseFastaDescription, \
+from obitools.fasta._fasta import parseFastaDescription, \
                    fastaParser, fastaNucParser,fastaAAParser, fastFastaParser, \
                    fastaIterator,fastFastaIterator, rawFastaIterator, \
                    fastaNucIterator, fastaAAIterator, \
--- a/src/obitools/format/genericparser/__init__.py
+++ b/src/obitools/format/genericparser/__init__.py
@@ -5,7 +5,7 @@
 
 from obitools.utils import universalOpen
 
-from _genericparser import genericEntryIteratorGenerator
+from obitools.format.genericparser._genericparser import genericEntryIteratorGenerator
 
 #def genericEntryIteratorGenerator(startEntry=None,endEntry=None,
 #                                  head=False,tail=False,
@@ -216,4 +216,4 @@
             yield pe
             
             
-    
\ No newline at end of file
+    
--- a/src/obitools/unit/obitools/__init__.py
+++ b/src/obitools/unit/obitools/__init__.py
@@ -2,18 +2,25 @@
 
 import obitools
 
-from utils import tests_group as utils_tests_group
+#from utils import tests_group as utils_tests_group
 
 class BioseqTest(unittest.TestCase):
+    '''
+    Base test class
+    '''
+
 
     sequenceId = 'id1'
     sequenceDefinition = 'sequence definition'
     sequenceQualifier = {'extra':3}
+    bioseqClass = obitools.AASequence
+    sequenceString = 'MLKCVT' * 5
+
 
     def setUp(self):
-        self.bioseq = self.bioseqClass(self.sequenceId,
-                                       self.sequenceString,
-                                       self.sequenceDefinition,
+        self.bioseq = self.bioseqClass(self.sequenceId.encode(),
+                                       self.sequenceString.encode(),
+                                       self.sequenceDefinition.encode(),
                                        **self.sequenceQualifier)
         
         title = self.__doc__.strip()
@@ -35,7 +42,7 @@
         '''
         test if id attribute value is 'id1'
         '''
-        self.assertEqual(self.bioseq.id, 'id1', 
+        self.assertEqual(self.bioseq.id, 'id1'.encode(),
                              'identifier is created with good value')
         
     def testDefinitionAttribute(self):
@@ -88,4 +95,5 @@
 
 
 
-tests_group = utils_tests_group + [NucBioseqTest,AABioseqTest] 
\ No newline at end of file
+#tests_group = utils_tests_group + [NucBioseqTest,AABioseqTest]
+tests_group = [NucBioseqTest,AABioseqTest]
--- a/src/obitools/align/__init__.py
+++ b/src/obitools/align/__init__.py
@@ -1,15 +1,15 @@
 
 
-from _nws import NWS
-from _upperbond import indexSequences
-from _lcs import LCS,lenlcs,ALILEN,MAXLEN,MINLEN
-from _assemble import DirectAssemble, ReverseAssemble
-from _qsassemble import QSolexaDirectAssemble,QSolexaReverseAssemble 
-from _rassemble import RightDirectAssemble as RightReverseAssemble
-from _qsrassemble import QSolexaRightDirectAssemble,QSolexaRightReverseAssemble 
-from _freeendgap import FreeEndGap
-from _freeendgapfm import FreeEndGapFullMatch
-from _upperbond import isLCSReachable
-from _codonnws import CodonNWS
+from obitools.align._nws import NWS
+from obitools.align._upperbond import indexSequences
+from obitools.align._lcs import LCS,lenlcs,ALILEN,MAXLEN,MINLEN
+from obitools.align._assemble import DirectAssemble, ReverseAssemble
+from obitools.align._qsassemble import QSolexaDirectAssemble,QSolexaReverseAssemble
+from obitools.align._rassemble import RightDirectAssemble as RightReverseAssemble
+from obitools.align._qsrassemble import QSolexaRightDirectAssemble,QSolexaRightReverseAssemble
+from obitools.align._freeendgap import FreeEndGap
+from obitools.align._freeendgapfm import FreeEndGapFullMatch
+from obitools.align._upperbond import isLCSReachable
+from obitools.align._codonnws import CodonNWS
 
 
--- a/src/obitools/fastq/__init__.py
+++ b/src/obitools/fastq/__init__.py
@@ -4,15 +4,15 @@
 @author: coissac
 '''
 
-from _fastq import fastqQualitySangerDecoder,fastqQualitySolexaDecoder
-from _fastq import qualityToSangerError,qualityToSolexaError
-from _fastq import errorToSangerFastQStr
-from _fastq import formatFastq
-from _fastq import fastqParserGenetator
-from _fastq import fastqAAIterator,fastqIlluminaIterator,fastqSolexaIterator, \
+from obitools.fastq._fastq import fastqQualitySangerDecoder,fastqQualitySolexaDecoder
+from obitools.fastq._fastq import qualityToSangerError,qualityToSolexaError
+from obitools.fastq._fastq import errorToSangerFastQStr
+from obitools.fastq._fastq import formatFastq
+from obitools.fastq._fastq import fastqParserGenetator
+from obitools.fastq._fastq import fastqAAIterator,fastqIlluminaIterator,fastqSolexaIterator, \
                    fastqSangerIterator, fastqIterator, fastqEntryIterator
-from _fastq import fastFastqParserGenetator
-from _fastq import fastFastqIlluminaIterator,fastFastqSolexaIterator, \
+from obitools.fastq._fastq import fastFastqParserGenetator
+from obitools.fastq._fastq import fastFastqIlluminaIterator,fastFastqSolexaIterator, \
                    fastFastqSangerIterator, fastFastqIterator
 
 
--- a/src/obitools/unit/__init__.py
+++ b/src/obitools/unit/__init__.py
@@ -1,6 +1,6 @@
 import unittest
 
-from .obitools import tests_group as obitools_tests_group
+from obitools.unit.obitools import tests_group as obitools_tests_group
 
 tests_group=obitools_tests_group
 
--- a/src/obitools/seqdb/__init__.py
+++ b/src/obitools/seqdb/__init__.py
@@ -81,8 +81,8 @@
         
 
            
-nucEntryIterator=genericEntryIteratorGenerator(endEntry='^//')
-aaEntryIterator=genericEntryIteratorGenerator(endEntry='^//')
+nucEntryIterator=genericEntryIteratorGenerator(endEntry='^//'.encode())
+aaEntryIterator=genericEntryIteratorGenerator(endEntry='^//'.encode())
 
 
 
--- a/src/obitools/table/__init__.py
+++ b/src/obitools/table/__init__.py
@@ -2,9 +2,9 @@
 
 '''
 
-from itertools importcount,chain
+from itertools import count,chain
 
-from itertools importcount,chain
+from itertools import count,chain
 from functools import reduce
 
 class Table(list):
@@ -625,4 +625,4 @@
     
     headers = property(_getHeaders,None,None)
     types   = property(_getTypes,None,None)
-     
\ No newline at end of file
+     
--- a/src/obitools/options/__init__.py
+++ b/src/obitools/options/__init__.py
@@ -17,12 +17,12 @@
     autoEntriesIterator
 import time
     
-from _options import fileWithProgressBar        # @UnresolvedImport 
-from _options import currentInputFileName       # @UnresolvedImport 
-from _options import currentInputFile           # @UnresolvedImport 
-from _options import currentFileSize            # @UnresolvedImport 
-from _options import currentFileTell            # @UnresolvedImport 
-from _options import allEntryIterator           # @UnresolvedImport
+from obitools.options._options import fileWithProgressBar        # @UnresolvedImport 
+from obitools.options._options import currentInputFileName       # @UnresolvedImport 
+from obitools.options._options import currentInputFile           # @UnresolvedImport 
+from obitools.options._options import currentFileSize            # @UnresolvedImport 
+from obitools.options._options import currentFileTell            # @UnresolvedImport 
+from obitools.options._options import allEntryIterator           # @UnresolvedImport
 
 from obitools.ecopcr.sequence import EcoPCRDBSequenceIterator
 
@@ -98,4 +98,4 @@
     return commandLineAnalyzer
 
 
-        
\ No newline at end of file
+        
--- a/src/obitools/blast/__init__.py
+++ b/src/obitools/blast/__init__.py
@@ -1,5 +1,6 @@
-from os import popen2
-from itertools importcount
+#from os import popen2
+from subprocess import Popen, PIPE
+from itertools import count
 
 from obitools.table import iTableIterator,TableRow,Table,SelectionIterator
 from obitools.utils import ColumnFile
@@ -55,10 +56,12 @@
         '''
         cmd = self._blastcmd()
         
-        (blast_in,blast_out) = popen2(cmd)
+        #(blast_in,blast_out) = popen2(cmd)
+        s = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
+        blast_out, errs = s.communicate(formatFasta(sequence).encode())
         
-        print(formatFasta(sequence), file=blast_in)
-        blast_in.close()
+        #print(formatFasta(sequence), file=blast_in)
+        #blast_in.close()
         
         blast  = BlastResultIterator(blast_out)
         
@@ -204,4 +207,4 @@
         return self._covMinPredicat(row) and SelectionIterator._checkCondition(self, row)
     
     
-    
\ No newline at end of file
+    
--- a/src/obitools/align/_lcs.pyx
+++ b/src/obitools/align/_lcs.pyx
@@ -8,11 +8,11 @@
 from cpython cimport array
 
 from obitools import BioSequence
-from _lcs cimport *
-from _upperbond cimport *
-from _dynamic cimport *
+from obitools.align._lcs cimport *
+from obitools.align._upperbond cimport *
+from obitools.align._dynamic cimport *
 
-from _upperbond import *
+from obitools.align._upperbond import *
 
 cdef class LCS(DynamicProgramming):
 
--- a/src/obitools/align/_qsassemble.pyx
+++ b/src/obitools/align/_qsassemble.pyx
@@ -5,8 +5,8 @@
 @author: coissac
 '''
 
-from _dynamic cimport * 
-from _assemble cimport DirectAssemble
+from obitools.align._dynamic cimport *
+from obitools.align._assemble cimport DirectAssemble
 
 
 cdef class QSolexaDirectAssemble(DirectAssemble):
--- a/src/obitools/align/_qsrassemble.pyx
+++ b/src/obitools/align/_qsrassemble.pyx
@@ -5,8 +5,8 @@
 @author: coissac
 '''
 
-from _dynamic cimport * 
-from _rassemble cimport RightDirectAssemble
+from obitools.align._dynamic cimport *
+from obitools.align._rassemble cimport RightDirectAssemble
 
 cdef class QSolexaRightDirectAssemble(RightDirectAssemble):             
  
--- a/src/obitools/SVGdraw.py
+++ b/src/obitools/SVGdraw.py
@@ -70,22 +70,18 @@
 use_dom_implementation=0
 
 
-import exceptions
+import builtins
 if use_dom_implementation!=0:
     try:
         from xml.dom import implementation
         from xml.dom.ext import PrettyPrint
     except:
-        raise exceptions.ImportError("PyXML is required for using the dom implementation")
+        raise ImportError("PyXML is required for using the dom implementation")
 #The implementation is used for the creating the XML document.
 #The prettyprint module is used for converting the xml document object to a xml file
 
 import sys
-assert sys.version_info[0]>=2
-if sys.version_info[1]<2:
-    True=1
-    False=0
-    file=open
+assert sys.version_info[0]>=3
     
 sys.setrecursionlimit=50
 #The recursion limit is set conservative so mistakes like s=svg() s.addElement(s)
--- a/src/obitools/distances/phylip.py
+++ b/src/obitools/distances/phylip.py
@@ -1,6 +1,6 @@
 import sys
 
-from itertools importcount
+from itertools import count
 
 def writePhylipMatrix(matrix):
     names = [x.id for x in matrix.aligment]
@@ -32,4 +32,4 @@
     
             
     
-    
\ No newline at end of file
+    
--- a/src/obitools/distances/r.py
+++ b/src/obitools/distances/r.py
@@ -1,6 +1,6 @@
 import sys
 
-from itertools importcount
+from itertools import count
 
 def writeRMatrix(matrix):
     names = [x.id for x in matrix.aligment]
@@ -22,4 +22,4 @@
     return '\n'.join(rep)
         
     
-            
\ No newline at end of file
+            
--- a/src/obitools/obischemas/kb/extern.py
+++ b/src/obitools/obischemas/kb/extern.py
@@ -26,16 +26,15 @@
         self.db = psycopg2.connect(**(self.connectParam))
 
     def restart(self):
-	ok=1
-	while (ok and ok < 1000):
-	  try:	
-	    self.db = psycopg2.connect(**self.connectParam)
-	  except:
-            ok+=1
-	  else:
-            ok=0
+        ok=1
+        while (ok and ok < 1000):
+            try:
+                self.db = psycopg2.connect(**self.connectParam)
+            except:
+                ok+=1
+            else:
+                ok=0
 
-	    
     def cursor(self):
         curs = Cursor(self.db)
         if hasattr(self,'autocommit') and self.autocommit:
@@ -56,7 +55,7 @@
 class Cursor(kb.Cursor):
 
     def __init__(self,db):
-	self.db   = db
+        self.db   = db
         self.curs = db.cursor()
         
     def execute(self,query):
--- a/src/obitools/options/_options.pyx
+++ b/src/obitools/options/_options.pyx
@@ -50,12 +50,13 @@
         cdef str l
         
         pos=1
-        progressBar(pos, size, True,cfs.currentInputFileName)
+        # python3 port fails with this, disable progress bar
+        #progressBar(pos, size, True,cfs.currentInputFileName)
         for l in file:
-            progressBar(currentFileTell,size, False,
-                        cfs.currentInputFileName)
+            #progressBar(currentFileTell,size, False,
+            #            cfs.currentInputFileName)
             yield l 
-        print >>sys.stderr,''   
+        print('', file=sys.stderr)
          
     if size < 0:
         return file
@@ -70,14 +71,14 @@
         for f in files:
             if (entryIterator != EcoPCRDBSequenceIterator) :
                           
-                cfs.currentInputFileName=f
+                cfs.currentInputFileName=f.encode()
                 try:
                     f = universalOpen(f,noError=True)
                 except Exception as e:    
                     if glob('%s_[0-9][0-9][0-9].sdx' % f):
                         entryIterator=EcoPCRDBSequenceIterator
                     else:
-                        print >>sys.stderr, e
+                        print(e, file=sys.stderr)
                         sys.exit();
                 else:
                     cfs.currentFile=f
@@ -118,7 +119,7 @@
             elif stat.S_ISREG(mode):
                 pass
             else:
-                print>>sys.stderr, "No Entry to process"
+                print("No Entry to process", file=sys.stderr)
                 sys.exit()
             for entry in entryIterator(sys.stdin):
                 yield entry
--- a/src/obitools/format/genericparser/_genericparser.pyx
+++ b/src/obitools/format/genericparser/_genericparser.pyx
@@ -67,40 +67,46 @@
         if not hasattr(file, 'next'):
             file = universalOpen(file)
 
-        line = file.next()
+        #line = file.next()
+        line = next(file).encode()
         started = head or isBeginning(line,c_startEntry)
-        
         try:
             while 1:
                 while not started:
-                    line = file.next()
+                    #line = file.next()
+                    line = next(file).encode()
                     started = isBeginning(line,c_startEntry)
                     
                 if endEntry is None:
-                    entry.append(line)
-                    line = file.next()
+                    entry.append(line.decode())
+                    #line = file.next()
+                    line = next(file).encode()
                     
                 while started:
                     end = isEnding(line,c_startEntry,c_endEntry)
                     if end:
                         if endEntry is not None:
-                            entry.append(line)
+                            entry.append(line.decode())
                         if join:
                             e = ''.join(entry)
                             if strip:
                                 e=e.strip()
+                            e = e.encode()
                         else:
                             e=entry
                             if strip:
                                 e=[x.strip() for x in e]
+                            e = [x.encode() for x in e]
                         entry=[]
                         yield e
                         started=False
                         if endEntry is not None:
-                            line = file.next()
+                            #line = file.next()
+                            line = next(file).encode()
                     else:
-                        entry.append(line)
-                        line = file.next()
+                        entry.append(line.decode())
+                        #line = file.next()
+                        line = next(file).encode()
                         
                 started = isBeginning(line,c_startEntry) 
                        
@@ -110,10 +116,12 @@
                     e = ''.join(entry)
                     if strip:
                         e=e.strip()
+                    e = e.encode()
                 else:
                     e=entry
                     if strip:
                         e=[x.strip() for x in e]
+                    e = [x.encode() for x in e]
                 yield e
 
                             
