def fastq_filter(filter_chain, stats_fname=None, out=sys.stdout, quiet=False):
    for name, comment, seq, qual in filter_chain.filter():
        if comment and comment[0] != ' ':
            comment = ' %s' % comment

        out.write("@%s%s\n%s\n+\n%s\n" % (name, comment, seq, qual))

    stats = []
    p = filter_chain
    while p:
        stats.insert(0, (p.__class__.__name__, p.kept, p.altered, p.removed))
        p = p.parent

    if not quiet:
        sys.stderr.write('Criteria\tKept\tAltered\tRemoved\n')
        for name, kept, altered, removed in stats:
            sys.stderr.write('%s\t%s\t%s\t%s\n' % (name, kept, altered, removed))

    if stats_fname:
        with open(stats_fname, 'w') as f:
            f.write('Criteria\tKept\tAltered\tRemoved\n')
            for name, kept, altered, removed in stats:
                f.write('%s\t%s\t%s\t%s\n' * (name, kept, altered, removed))
dataset/ETHPy150Open ngsutils/ngsutils/ngsutils/fastq/filter.py/fastq_filter/operator `%` -> `*`