def suffix(args):
    """
    %prog suffix fastqfile CAG

    Filter reads based on suffix.
    """
    p = OptionParser(suffix.__doc__)
    p.set_outfile()
    opts, args = p.parse_args(args)

    if len(args) != 2:
        sys.exit(not p.print_help())

    fastqfile, sf = args
    fw = must_open(opts.outfile, "w")
    nreads = nselected = 0
    for rec in iter_fastq(fastqfile):
        nreads += 1
        if rec is None:
            break
        if rec.seq.endswith(sf):
            print(rec, file=fw)
            nselected += 1
    logging.debug("Selected reads with suffix {0}: {1}".\
                  format(sf, percentage(nselected, nreads)))
def suffix ( args ) : p = OptionParser ( suffix . __doc__ ) p . set_outfile ( ) opts , args = p . parse_args ( args ) if len ( args ) != 2 : sys . exit ( not p . print_help ( ) ) fastqfile , sf = args fw = must_open ( opts . outfile , "w" ) nreads = nselected = 0 for rec in iter_fastq ( fastqfile ) : nreads += 1 if rec is None : break if rec . seq . endswith ( sf ) : print ( rec , file = fw ) nselected += 1 logging . debug ( "Selected reads with suffix {0}: {1}" . format ( sf , percentage ( nselected , nreads ) ) )
%prog suffix fastqfile CAG

    Filter reads based on suffix.