def test_to_cigar_unit(self, length, opstr, expected): # Check we can convert a tuple and list of length and opstr. self.assertEqual(cigar.to_cigar_unit((length, opstr)), expected) self.assertEqual(cigar.to_cigar_unit([length, opstr]), expected) # Check that we can convert a string version len+opstr. self.assertEqual(cigar.to_cigar_unit(str(length) + opstr), expected) # Check that we can pass a CigarUnit through without modification. self.assertEqual(cigar.to_cigar_unit(expected), expected) # Check that we can pass length as a string. self.assertEqual(cigar.to_cigar_unit((str(length), opstr)), expected)
def test_no_bad_soft_clipping(self): self.skipTest('Enable when b/63143285 global alignment is fixed') common = 'CTA' read_seq = common + 'GA' ref_seq = 'N' + common + 'CA' + 'N' alt_seq = 'A' + ref_seq targets = [ref_seq, alt_seq] region = ranges.make_range('ref', 0, len(ref_seq)) align_reads = self.make_test_aligner(ref_seq, region) read = test_utils.make_read( read_seq, chrom='ref', start=0, cigar=[(len(read_seq), 'M')], quals=[35] * len(read_seq), name='read') realigned = align_reads.align_reads(targets, [read])[0] # redacted # 5M as we'd expect for this read: # read_seq: -CTAGA- # ref_seq : NCGTCAN # But the current algorithm produces a local alignment of the read against # the haplotypes, and the G <=> C mismatch causes the local aligner to # simply skip those bases instead of incurring the mismatch penalty for it, # resulting in a 3M2S read (GA clipped off) instead of the better 5M result. self.assertEqual([_cigar.to_cigar_unit(len(read_seq), 'M')], list(realigned.alignment.cigar))
def test_to_cigar_unit_detects_bad_args(self, bad): with self.assertRaises(ValueError): cigar.to_cigar_unit(bad)