def filter_stream(fq, args):
if args.quality:<EOL><INDENT>quality_check = ave_qual<EOL><DEDENT>else:<EOL><INDENT>quality_check = silent_quality_check<EOL><DEDENT>minlen = args.length + int(args.headcrop or <NUM_LIT:0>) - (int(args.tailcrop or <NUM_LIT:0>))<EOL>for rec in SeqIO.parse(fq, "<STR_LIT>"):<EOL><INDENT>if args.GC_filter:<EOL><INDENT>gc = (rec.seq.upper().count("<STR_LIT:C>") + rec.seq.upper().count("<STR_LIT>")) / len(rec)<EOL><DEDENT>else:<EOL><INDENT>gc = <NUM_LIT>  <EOL><DEDENT>if quality_check(rec.letter_annotations["<STR_LIT>"]) > args.qualityand minlen <= len(rec) <= args.maxlengthand args.minGC <= gc <= args.maxGC:<EOL><INDENT>print(rec[args.headcrop:args.tailcrop].format("<STR_LIT>"), end="<STR_LIT>")<EOL><DEDENT><DEDENT>
Filter a fastq file on stdin.

    Print fastq record to stdout if it passes
    - quality filter (optional)
    - length filter (optional)
    - min/maxGC filter (optional)
    Optionally trim a number of nucleotides from beginning and end.
    Record has to be longer than args.length (default 1) after trimming
    Use a faster silent quality_check if no filtering on quality is required