def test_extract(self): """LocationList extract should return correct sequence""" l = Location(3) l2_a = Location(5) l2_b = Location(7) l2 = Location([l2_a, l2_b], Strand=-1) l3_a = Location(10) l3_b = Location(12) l3 = Location([l3_a, l3_b]) ll = LocationList([l, l2, l3]) s = ll.extract("ACGTGCAGTCAGTAGCAT") # 123456789012345678 self.assertEqual(s, "G" + "TGC" + "CAG") # check a case where it wraps around l5_a = Location(16) l5_b = Location(4) l5 = Location([l5_a, l5_b]) ll = LocationList([l5]) s = ll.extract("ACGTGCAGTCAGTAGCAT") self.assertEqual(s, "CATACGT")
def test_init(self): """Location should init with 1 or 2 values, plus params.""" l = Location(37) self.assertEqual(str(l), "37") l = Location(37, Ambiguity=">") self.assertEqual(str(l), ">37") l = Location(37, Ambiguity="<") self.assertEqual(str(l), "<37") l = Location(37, Accession="AB123") self.assertEqual(str(l), "AB123:37") l = Location(37, Accession="AB123", Db="Kegg") self.assertEqual(str(l), "Kegg::AB123:37") l1 = Location(37) l2 = Location(42) l = Location([l1, l2]) self.assertEqual(str(l), "37..42") l3 = Location([l1, l2], IsBounds=True) self.assertEqual(str(l3), "(37.42)") l4 = Location([l1, l2], IsBetween=True) self.assertEqual(str(l4), "37^42") l5 = Location([l4, l3]) self.assertEqual(str(l5), "37^42..(37.42)") l5 = Location([l4, l3], Strand=-1) self.assertEqual(str(l5), "complement(37^42..(37.42))")