class TestEventMapping(): def __init__(self): self.template_model = EventModel("models/template_model_5.model") self.complement_model = EventModel("models/complement_model_5.model") self.event_mapper = EventMapper() self.my_seq = Seq("CAAAACGTGT") self.forward_template_events = Seq2Events(self.my_seq, self.template_model).events self.reverse_template_events = Seq2Events(self.my_seq.reverse_complement(), self.template_model).events self.reverse_complement_events = Seq2Events(self.my_seq.reverse_complement(), self.complement_model).events self.forward_complement_events = Seq2Events(self.my_seq, self.complement_model).events self.complement_seq = self.my_seq.reverse_complement() def test_make_simple_reference(self): forward_template_mapping_results = self.event_mapper.map(self.forward_template_events, self.forward_template_events) reverse_template_mapping_results = self.event_mapper.map(self.reverse_template_events, self.forward_template_events) forward_complement_mapping_results = self.event_mapper.map(self.forward_complement_events, self.forward_template_events) reverse_complement_mapping_results = self.event_mapper.map(self.reverse_complement_events, self.forward_template_events) assert len(forward_template_mapping_results.path[0]) == 6 assert forward_template_mapping_results.path[0].tolist() == [0, 1, 2 ,3, 4, 5] assert forward_template_mapping_results.path[1].tolist() == [0, 1, 2 , 3 ,4, 5] assert min([sum(sum(forward_template_mapping_results.cost)), sum(sum(reverse_template_mapping_results.cost)), sum(sum(forward_complement_mapping_results.cost)), sum(sum(reverse_complement_mapping_results.cost))]) == sum(sum(forward_template_mapping_results.cost)) assert min([forward_template_mapping_results.dist, reverse_template_mapping_results.dist, forward_complement_mapping_results.dist, reverse_complement_mapping_results.dist]) == forward_template_mapping_results.dist def test_complement_mapping(self): forward_template_mapping_results = self.event_mapper.map(self.forward_template_events, self.forward_complement_events) reverse_template_mapping_results = self.event_mapper.map(self.reverse_template_events, self.forward_complement_events) forward_complement_mapping_results = self.event_mapper.map(self.forward_complement_events, self.forward_complement_events) reverse_complement_mapping_results = self.event_mapper.map(self.reverse_complement_events, self.forward_complement_events) assert len(forward_complement_mapping_results.path[0]) == 6 assert forward_complement_mapping_results.path[0].tolist() == [0, 1, 2 ,3, 4, 5] assert forward_complement_mapping_results.path[1].tolist() == [0, 1, 2 , 3 ,4, 5] assert min([sum(sum(forward_template_mapping_results.cost)), sum(sum(reverse_template_mapping_results.cost)), sum(sum(forward_complement_mapping_results.cost)), sum(sum(reverse_complement_mapping_results.cost))]) == sum(sum(forward_complement_mapping_results.cost)) assert min([forward_template_mapping_results.dist, reverse_template_mapping_results.dist, forward_complement_mapping_results.dist, reverse_complement_mapping_results.dist]) == forward_complement_mapping_results.dist
def __init__(self): self.template_model = EventModel("models/template_model_5.model") self.complement_model = EventModel("models/complement_model_5.model") self.event_mapper = EventMapper() self.my_seq = Seq("CAAAACGTGT") self.forward_template_events = Seq2Events(self.my_seq, self.template_model).events self.reverse_template_events = Seq2Events(self.my_seq.reverse_complement(), self.template_model).events self.reverse_complement_events = Seq2Events(self.my_seq.reverse_complement(), self.complement_model).events self.forward_complement_events = Seq2Events(self.my_seq, self.complement_model).events self.complement_seq = self.my_seq.reverse_complement()