@@ -0,0 +1,1674 @@
+# source: https://github.com/lh3/readfq%0A%0Adef readfq(fp): # this is a generator function%0A    last = None # this is a buffer keeping the last unprocessed line%0A    while True: # mimic closure; is it a bad idea?%0A        if not last: # the first record or a record following a fastq%0A            for l in fp: # search for the start of the next record%0A                if l%5B0%5D in '%3E@': # fasta/q header line%0A                    last = l%5B:-1%5D # save this line%0A                    break%0A        if not last: break%0A        name, seqs, last = last%5B1:%5D.partition(%22 %22)%5B0%5D, %5B%5D, None%0A        for l in fp: # read the sequence%0A            if l%5B0%5D in '@+%3E':%0A                last = l%5B:-1%5D%0A                break%0A            seqs.append(l%5B:-1%5D)%0A        if not last or last%5B0%5D != '+': # this is a fasta record%0A            yield name, ''.join(seqs), None # yield a fasta record%0A            if not last: break%0A        else: # this is a fastq record%0A            seq, leng, seqs = ''.join(seqs), 0, %5B%5D%0A            for l in fp: # read the quality%0A                seqs.append(l%5B:-1%5D)%0A                leng += len(l) - 1%0A                if leng %3E= len(seq): # have read enough quality%0A                    last = None%0A                    yield name, seq, ''.join(seqs); # yield a fastq record%0A                    break%0A            if last: # reach EOF before reading enough quality%0A                yield name, seq, None # yield a fasta record instead%0A                break%0A%0Aif __name__ == %22__main__%22:%0A    import sys%0A    n, slen, qlen = 0, 0, 0%0A    for name, seq, qual in readfq(sys.stdin):%0A        n += 1%0A        slen += len(seq)%0A        qlen += qual and len(qual) or 0%0A    print n, '%5Ct', slen, '%5Ct', qlen%0A

Add Heng Li's readfq.py