def process_fastq_rich(fastq, **kwargs):
    """Extract metrics from a richer fastq file.

    Extract information from fastq files generated by albacore or MinKNOW,
    containing richer information in the header (key-value pairs)
    read=<int> [72]
    ch=<int> [159]
    start_time=<timestamp> [2016-07-15T14:23:22Z]  # UTC ISO 8601 ISO 3339 timestamp
    Z indicates UTC time, T is the delimiter between date expression and time expression
    dateutil.parser.parse("2016-07-15T14:23:22Z") imported as dparse
    -> datetime.datetime(2016, 7, 15, 14, 23, 22, tzinfo=tzutc())
    """
    logging.info("Nanoget: Starting to collect statistics from rich fastq file.")
    inputfastq = handle_compressed_input(fastq)
    res = []
    for record in SeqIO.parse(inputfastq, "fastq"):
        try:
            read_info = info_to_dict(record.description)
            res.append(
                (nanomath.ave_qual(record.letter_annotations["phred_quality"]),
                 len(record),
                 read_info["ch"],
                 read_info["start_time"],
                 read_info["runid"]))
        except KeyError:
            logging.error("Nanoget: keyerror when processing record {}".format(record.description))
            sys.exit("Unexpected fastq identifier:\n{}\n\n \
            missing one or more of expected fields 'ch', 'start_time' or 'runid'".format(
                record.description))
    df = pd.DataFrame(
        data=res,
        columns=["quals", "lengths", "channelIDs", "timestamp", "runIDs"]).dropna()
    df["channelIDs"] = df["channelIDs"].astype("int64")
    return ut.reduce_memory_usage(df)
def process_fastq_rich ( fastq , ** kwargs ) : logging . info ( "Nanoget: Starting to collect statistics from rich fastq file." ) inputfastq = handle_compressed_input ( fastq ) res = [ ] for record in SeqIO . parse ( inputfastq , "fastq" ) : try : read_info = info_to_dict ( record . description ) res . append ( ( nanomath . ave_qual ( record . letter_annotations [ "phred_quality" ] ) , len ( record ) , read_info [ "ch" ] , read_info [ "start_time" ] , read_info [ "runid" ] ) ) except KeyError : logging . error ( "Nanoget: keyerror when processing record {}" . format ( record . description ) ) sys . exit ( "Unexpected fastq identifier:\n{}\n\n \
            missing one or more of expected fields 'ch', 'start_time' or 'runid'" . format ( record . description ) ) df = pd . DataFrame ( data = res , columns = [ "quals" , "lengths" , "channelIDs" , "timestamp" , "runIDs" ] ) . dropna ( ) df [ "channelIDs" ] = df [ "channelIDs" ] . astype ( "int64" ) return ut . reduce_memory_usage ( df )
Extract metrics from a richer fastq file.

    Extract information from fastq files generated by albacore or MinKNOW,
    containing richer information in the header (key-value pairs)
    read=<int> [72]
    ch=<int> [159]
    start_time=<timestamp> [2016-07-15T14:23:22Z]  # UTC ISO 8601 ISO 3339 timestamp
    Z indicates UTC time, T is the delimiter between date expression and time expression
    dateutil.parser.parse("2016-07-15T14:23:22Z") imported as dparse
    -> datetime.datetime(2016, 7, 15, 14, 23, 22, tzinfo=tzutc())