def testConvertRegion(self):
        ngsutils.bam.convertregion.bam_convertregion(infname, outfname, chromsizes, quiet=True)

        bam = ngsutils.bam.bam_open(outfname)
        for read in ngsutils.bam.bam_iter(bam):
            if read.qname == 'A':
                self.assertEqual(bam.getrname(read.tid), 'chr1')
                self.assertEqual(read.pos, 109)  # 0-based in BAM, 1-based in SAM
                self.assertEqual(read.cigar, ngsutils.bam.cigar_fromstr('50M'))
            elif read.qname == 'B':
                self.assertEqual(bam.getrname(read.tid), 'chr1')
                self.assertEqual(read.pos, 174)
                self.assertEqual(read.cigar, ngsutils.bam.cigar_fromstr('26M100N24M'))
            elif read.qname == 'C':
                self.assertEqual(bam.getrname(read.tid), 'chr1')
                self.assertEqual(read.pos, 197)
                self.assertEqual(read.cigar, ngsutils.bam.cigar_fromstr('3M100N47M'))
            elif read.qname == 'Z':
                self.assertTrue(read.is_unmapped)
Convert region/junction coordinates
dataset/ETHPy150Open ngsutils/ngsutils/ngsutils/bam/t/test_convertregion.py/ConvertRegionTest.testConvertRegion