INNER CODE UNIT · Python

stream_fastq

linsalrob/ComputationalGenomicsManual · Python/countfastq.py:16

def stream_fastq(fqfile):
    """Read a fastq file and provide an iterable of the sequence ID, the
    full header, the sequence, and the quaity scores.

    Note that the sequence ID is the header up until the first space,
    while the header is the whole header.
    """

    if fqfile.endswith('.gz'):
        qin = gzip.open(fqfile, 'rt')
    else:
        qin = open(fqfile, 'r')

    linecounter = 0
    while True:
        header = qin.readline()
        linecounter += 1
        if not header:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…