def __init__(self): # given self.query = "GTAGGCGAGATGACGCCAT" self.targets = ["GTAGGCGAGTCCCGTTTATA", "CCACAGAAGATGACGCCATT"] # when self.t = Tesserae(mem_limit=False) self.p = self.t.align(self.query, self.targets)
def test_mosaic_alignment_on_medium_queries_and_two_templates(self): random.seed(0) # given for total_len in [100, 200, 500]: partial_len = int(total_len / 2) query = random_dna_string(total_len) targets = ["".join(query[0:partial_len]) + random_dna_string(partial_len), random_dna_string(partial_len) + "".join(query[partial_len:total_len])] # when t = Tesserae() p = t.align(query, targets) # then assert len(p) == 3 assert p[1][0] == 'template0' assert p[1][1] == "".join(targets[0][0:partial_len]) assert p[1][2] == 0 assert p[1][3] == partial_len - 1 assert p[2][0] == 'template1' assert p[2][1] == repeat(" ", partial_len) + targets[1][partial_len:total_len] assert p[2][2] == partial_len assert p[2][3] == total_len - 1
def test_mosaic_alignment_on_medium_queries_and_two_templates(self): # given for total_len, (query, targets) in self.samples.items(): # when t = Tesserae(mem_limit=False) p = t.align(query, targets) # then self.__assertions__(p, targets, total_len)
def test_mosaic_alignment_on_medium_queries_and_two_templates_reduced_memory_usage( self): # given for total_len, (query, targets) in self.samples.items(): # when t = Tesserae(mem_limit=True) p = t.align(query, targets) max_mem_limit = sqrt(total_len) + 2 # then self.__assertions__(p, targets, total_len) assert t.traceback_limit <= max_mem_limit assert t.states_to_save <= max_mem_limit
def test_mosaic_alignment_on_short_query_and_two_templates_reduced_memory_usage( self): # when t = Tesserae(mem_limit=True) p = t.align(self.query, self.targets) max_mem_limit = sqrt(len(self.query)) + 1 # then assert p == self.p assert t.llk >= -27 assert t.llk <= -26 assert t.traceback_limit <= max_mem_limit assert t.states_to_save <= max_mem_limit
def test_mosaic_alignment_on_short_query_and_two_templates(self): # given query = "GTAGGCGAGATGACGCCAT" targets = ["GTAGGCGAGTCCCGTTTATA", "CCACAGAAGATGACGCCATT"] # when t = Tesserae() p = t.align(query, targets) # then assert len(p) == 3 assert p[1][0] == 'template0' assert p[1][1] == 'GTAGGCG' assert p[1][2] == 0 assert p[1][3] == 6 assert p[2][0] == 'template1' assert p[2][1] == ' AGATGACGCCAT' assert p[2][2] == 7 assert p[2][3] == 18
class TestTesserae: def __init__(self): # given self.query = "GTAGGCGAGATGACGCCAT" self.targets = ["GTAGGCGAGTCCCGTTTATA", "CCACAGAAGATGACGCCATT"] # when self.t = Tesserae(mem_limit=False) self.p = self.t.align(self.query, self.targets) def test_mosaic_alignment_on_short_query_and_two_templates(self): # then assert len(self.p) == 3 assert self.p[1][0] == 'template0' assert self.p[1][1] == 'GTAGGCG' assert self.p[1][2] == 0 assert self.p[1][3] == 6 assert self.p[2][0] == 'template1' assert self.p[2][1] == ' AGATGACGCCAT' assert self.p[2][2] == 7 assert self.p[2][3] == 18 assert self.t.llk >= -27 assert self.t.llk <= -26 def test_mosaic_alignment_on_short_query_and_two_templates_reduced_memory_usage( self): # when t = Tesserae(mem_limit=True) p = t.align(self.query, self.targets) max_mem_limit = sqrt(len(self.query)) + 1 # then assert p == self.p assert t.llk >= -27 assert t.llk <= -26 assert t.traceback_limit <= max_mem_limit assert t.states_to_save <= max_mem_limit