def process_ubam(bam, **kwargs):
logging.info("<STR_LIT>".format(bam))<EOL>samfile = pysam.AlignmentFile(bam, "<STR_LIT:rb>", check_sq=False)<EOL>if not samfile.has_index():<EOL><INDENT>pysam.index(bam)<EOL>samfile = pysam.AlignmentFile(bam, "<STR_LIT:rb>")<EOL>logging.info("<STR_LIT>")<EOL><DEDENT>datadf = pd.DataFrame(<EOL>data=[(read.query_name, nanomath.ave_qual(read.query_qualities), read.query_length)<EOL>for read in samfile.fetch(until_eof=True)],<EOL>columns=["<STR_LIT>", "<STR_LIT>", "<STR_LIT>"]).dropna(axis='<STR_LIT>', how='<STR_LIT:all>').dropna(axis='<STR_LIT:index>', how='<STR_LIT>')<EOL>logging.info("<STR_LIT>".format(<EOL>bam, datadf["<STR_LIT>"].size))<EOL>return ut.reduce_memory_usage(datadf)<EOL>
Extracting metrics from unaligned bam format
    Extracting lengths