INNER CODE UNIT · Python

outputBam

timoast/sinto · sinto/addtags.py:20

    outputBam = pysam.AlignmentFile(output + ident, outfmt, header=newhead)
    for i in intervals:
        for r in inputBam.fetch(i[0], i[1], i[2]):
            if mode == "tag":
                cell_barcode, _ = utils.scan_tags(r.tags)
            elif mode == "readname":
                cell_barcode = r.qname.split(":")[0]
            else:
                raise Exception("Unknown mode. Use either tag or readname")
            if cell_barcode is not None:
                if trim_suffix:
                    cell_barcode = cell_barcode[:-2]
                if cell_barcode in cb.keys():
                    r.tags += cb[cell_barcode]
            outputBam.write(r)
    outputBam.close()
    inputBam.close()
    return output + ident

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…