Beispiel #1
0
    def test_global_revcomp(self):
        er = EdlibRunner("global", revcomp=True)

        aln = er.align(revcomp_seq(self.y), self.x)
        self.assertEqual(aln.strand, 1)
        self.assertEqual(aln.cigar, self.cigar_x2y_global.revcomp())
        self.assertEqual(aln.a_start, 0)
        self.assertEqual(aln.b_start, 0)
        self.assertEqual(aln.a_end, len(self.y))
        self.assertEqual(aln.b_end, len(self.x))
        self.assertEqual(aln.a_aligned_seq, revcomp_seq(self.y))
        self.assertEqual(aln.b_aligned_seq, revcomp_seq(self.x))

        aln = er.align(self.y, revcomp_seq(self.x))
        self.assertEqual(aln.strand, 1)
        self.assertEqual(aln.cigar, self.cigar_x2y_global)
        self.assertEqual(aln.a_start, 0)
        self.assertEqual(aln.b_start, 0)
        self.assertEqual(aln.a_end, len(self.y))
        self.assertEqual(aln.b_end, len(self.x))
        self.assertEqual(aln.a_aligned_seq, self.y)
        self.assertEqual(aln.b_aligned_seq, self.x)

        aln = er.align(self.x, revcomp_seq(self.y))
        self.assertEqual(aln.strand, 1)
        self.assertEqual(aln.cigar, self.cigar_x2y_global.swap())
        self.assertEqual(aln.a_start, 0)
        self.assertEqual(aln.b_start, 0)
        self.assertEqual(aln.a_end, len(self.x))
        self.assertEqual(aln.b_end, len(self.y))
        self.assertEqual(aln.a_aligned_seq, self.x)
        self.assertEqual(aln.b_aligned_seq, self.y)
Beispiel #2
0
    def test_glocal_revcomp(self):
        er = EdlibRunner("glocal", revcomp=True)

        aln = er.align(revcomp_seq(self.y), self.x)
        self.assertEqual(aln.strand, 1)
        self.assertEqual(aln.cigar, self.cigar_x2y_glocal.revcomp())
        self.assertEqual(aln.a_start, 0)
        self.assertEqual(aln.b_start, self.x_glocal_start)
        self.assertEqual(aln.a_end, len(self.y))
        self.assertEqual(aln.b_end, self.x_glocal_end)  # position is forward
        self.assertEqual(aln.a_aligned_seq, revcomp_seq(self.y))
        self.assertEqual(aln.b_aligned_seq,
                         revcomp_seq(self.x_glocal))  # seq is revcomp

        aln = er.align(self.y, revcomp_seq(self.x))
        self.assertEqual(aln.strand, 1)
        self.assertEqual(aln.cigar, self.cigar_x2y_glocal)
        self.assertEqual(aln.a_start, 0)
        self.assertEqual(aln.b_start, len(self.x) - self.x_glocal_end)
        self.assertEqual(aln.a_end, len(self.y))
        self.assertEqual(aln.b_end,
                         len(self.x) - self.x_glocal_start)  # rc(x) is forward
        self.assertEqual(aln.a_aligned_seq, self.y)
        self.assertEqual(aln.b_aligned_seq, self.x_glocal)  # seq is forward

        # inappropriate use-case (mapped seq is shorter)
        aln = er.align(self.x, revcomp_seq(self.y))
        self.assertEqual(aln.strand, 1)
        self.assertEqual(aln.cigar, self.cigar_x2y_global.swap())
        self.assertEqual(aln.a_start, 0)
        self.assertEqual(aln.b_start, 0)
        self.assertEqual(aln.a_end, len(self.x))
        self.assertEqual(aln.b_end, len(self.y))
        self.assertEqual(aln.a_aligned_seq, self.x)
        self.assertEqual(aln.b_aligned_seq, self.y)
Beispiel #3
0
    def test_global_forward(self):
        er = EdlibRunner("global", revcomp=False)

        aln = er.align(self.y, self.x)
        self.assertEqual(aln.cigar, self.cigar_x2y_global)
        self.assertEqual(aln.a_aligned_seq, self.y)
        self.assertEqual(aln.b_aligned_seq, self.x)

        aln = er.align(self.x, self.y)
        self.assertEqual(aln.cigar, self.cigar_x2y_global.swap())
        self.assertEqual(aln.a_aligned_seq, self.x)
        self.assertEqual(aln.b_aligned_seq, self.y)
Beispiel #4
0
    def test_prefix(self):
        er = EdlibRunner("prefix", revcomp=False)

        aln = er.align(self.y, self.x)
        self.assertEqual(aln.cigar, self.cigar_x2y_prefix)
        self.assertEqual(aln.a_aligned_seq, self.y)
        self.assertEqual(aln.b_aligned_seq, self.x_prefix)

        # inappropriate use-case (mapped seq is shorter)
        aln = er.align(self.x, self.y)
        self.assertEqual(aln.cigar, self.cigar_x2y_global.swap())
        self.assertEqual(aln.a_aligned_seq, self.x)
        self.assertEqual(aln.b_aligned_seq, self.y)
Beispiel #5
0
    def test_global_forward_cyclic(self):
        er = EdlibRunner("global", revcomp=False, cyclic=True)

        aln = er.align(self.z, self.x)  # z vs xx
        self.assertIn(aln.cigar, self.cigar_xx2z)
        self.assertEqual(aln.a_start, 0)
        self.assertEqual(aln.a_end, len(self.z))
        self.assertIn(aln.b_start, self.x_cyclic_start)
        self.assertEqual(aln.b_start, aln.b_end)
        self.assertEqual(aln.a_aligned_seq, self.z)
        self.assertIn(aln.b_aligned_seq, self.x_cyclic)

        aln = er.align(self.x, self.z)  # x vs zz
        self.assertIn(aln.cigar, self.cigar_zz2x)
        self.assertEqual(aln.a_start, 0)
        self.assertEqual(aln.a_end, len(self.x))
        self.assertIn(aln.b_start, self.z_cyclic_start)
        self.assertEqual(aln.b_start, aln.b_end)
        self.assertEqual(aln.a_aligned_seq, self.x)
        self.assertIn(aln.b_aligned_seq, self.z_cyclic)
Beispiel #6
0
    def test_global_revcomp_cyclic(self):
        er = EdlibRunner("global", revcomp=True, cyclic=True)

        aln = er.align(revcomp_seq(self.z), self.x)  # rc(z) vs xx
        self.assertEqual(aln.strand, 1)
        self.assertIn(aln.cigar, [x.revcomp() for x in self.cigar_xx2z])
        self.assertEqual(aln.a_start, 0)
        self.assertEqual(aln.a_end, len(self.z))
        self.assertIn(aln.b_start, self.x_cyclic_start)
        self.assertEqual(aln.b_start, aln.b_end)
        self.assertEqual(aln.a_aligned_seq, revcomp_seq(self.z))
        self.assertIn(aln.b_aligned_seq,
                      [revcomp_seq(x) for x in self.x_cyclic])

        aln = er.align(self.z, revcomp_seq(self.x))  # z vs rc(xx)
        self.assertEqual(aln.strand, 1)
        self.assertIn(aln.cigar, self.cigar_xx2z)
        self.assertEqual(aln.a_start, 0)
        self.assertEqual(aln.a_end, len(self.z))
        self.assertIn(aln.b_start,
                      [len(self.x) - x for x in self.x_cyclic_start])
        self.assertEqual(aln.b_start, aln.b_end)
        self.assertEqual(aln.a_aligned_seq, self.z)
        self.assertIn(aln.b_aligned_seq, self.x_cyclic)

        aln = er.align(revcomp_seq(self.x), self.z)  # rc(x) vs zz
        self.assertEqual(aln.strand, 1)
        self.assertIn(aln.cigar, [x.revcomp() for x in self.cigar_zz2x])
        self.assertEqual(aln.a_start, 0)
        self.assertEqual(aln.a_end, len(self.x))
        self.assertIn(aln.b_start, self.z_cyclic_start)
        self.assertEqual(aln.b_start, aln.b_end)
        self.assertEqual(aln.a_aligned_seq, revcomp_seq(self.x))
        self.assertIn(aln.b_aligned_seq,
                      [revcomp_seq(x) for x in self.z_cyclic])

        aln = er.align(self.x, revcomp_seq(self.z))  # x vs rc(zz)
        self.assertEqual(aln.strand, 1)
        self.assertIn(aln.cigar, self.cigar_zz2x)
        self.assertEqual(aln.a_start, 0)
        self.assertEqual(aln.a_end, len(self.x))
        self.assertIn(aln.b_start,
                      [len(self.z) - x for x in self.z_cyclic_start])
        self.assertEqual(aln.b_start, aln.b_end)
        self.assertEqual(aln.a_aligned_seq, self.x)
        self.assertIn(aln.b_aligned_seq, self.z_cyclic)