def fastq_info(path):
    """ Found some info about how to ignore warnings in code blocks here:
      - http://stackoverflow.com/questions/14463277/how-to-disable-python-warnings
    """
    numBases = 0
    numReads = 0
    readLengths = Counter()
    GCTot = 0
    with warnings.catch_warnings():
        warnings.simplefilter("ignore")
        handle = gzip.open(path, "rt")
        for record in SeqIO.parse(handle, "fastq"):
            numBases += len(record)
            numReads += 1
            readLengths[len(record)] += 1
            GCTot += sum(record.seq.count(x) for x in ['G', 'C', 'g', 'c', 'S', 's'])
        handle.close()
    GCPer = (GCTot/numBases)
    avgReadLen = (sum(value*count for value,count in readLengths.items())/numReads)
    return {"numBases": numBases,
            "numReads": numReads,
            "numGCBases": GCTot,
            "portionGC": GCPer,
            "avgReadLen": avgReadLen}
def fastq_info ( path ) : numBases = 0 numReads = 0 readLengths = Counter ( ) GCTot = 0 with warnings . catch_warnings ( ) : warnings . simplefilter ( "ignore" ) handle = gzip . open ( path , "rt" ) for record in SeqIO . parse ( handle , "fastq" ) : numBases += len ( record ) numReads += 1 readLengths [ len ( record ) ] += 1 GCTot += sum ( record . seq . count ( x ) for x in [ 'G' , 'C' , 'g' , 'c' , 'S' , 's' ] ) handle . close ( ) GCPer = ( GCTot / numBases ) avgReadLen = ( sum ( value * count for value , count in readLengths . items ( ) ) / numReads ) return { "numBases" : numBases , "numReads" : numReads , "numGCBases" : GCTot , "portionGC" : GCPer , "avgReadLen" : avgReadLen }
Found some info about how to ignore warnings in code blocks here:
      - http://stackoverflow.com/questions/14463277/how-to-disable-python-warnings