41 lines
921 B
Cython
41 lines
921 B
Cython
#cython: language_level=3
|
|
|
|
'''
|
|
Created on 30 mars 2016
|
|
|
|
@author: coissac
|
|
'''
|
|
|
|
|
|
|
|
def fastqIterator(lineiterator, int buffersize=100000000):
|
|
cdef LineBuffer lb
|
|
cdef str ident
|
|
cdef str definition
|
|
cdef dict tags
|
|
|
|
if isinstance(lineiterator,(str,bytes)):
|
|
lineiterator=uopen(lineiterator)
|
|
|
|
if isinstance(lineiterator, LineBuffer):
|
|
lb=lineiterator
|
|
else:
|
|
lb=LineBuffer(lineiterator,buffersize)
|
|
|
|
i = iter(lb)
|
|
for line in i:
|
|
ident,tags,definition = parseHeader(line)
|
|
sequence = next(i)[0:-1]
|
|
next(i)
|
|
quality = next(i)[0:-1]
|
|
|
|
yield { "id" : ident,
|
|
"definition" : definition,
|
|
"sequence" : sequence,
|
|
"quality" : quality,
|
|
"tags" : tags,
|
|
"annotation" : {}
|
|
}
|
|
|
|
|
|
|