Ejemplo n.º 1
0
 def test_merging_correct(self):
     # two BGEdges can be merged together into a third, separate BGEdge
     # that would contain information from both supplied BGEdges in terms of colors and multiplicities
     # such merge is allowed only if a pair of vertices in both BGEdges is the same
     # ordering of vertices if not a concern, since edges in BreakpointGraph are not directed
     v1 = BlockVertex("v1")
     v2 = BlockVertex("v2")
     multicolor = Multicolor(self.genome3)
     multicolor1 = Multicolor(self.genome2)
     edge1 = BGEdge(vertex1=v1, vertex2=v2, multicolor=multicolor)
     edge2 = BGEdge(vertex1=v1, vertex2=v2, multicolor=multicolor1)
     merged_edge = BGEdge.merge(edge1, edge2)
     self.assertEqual(merged_edge.vertex1, v1)
     self.assertEqual(merged_edge.vertex2, v2)
     self.assertEqual(merged_edge.multicolor, multicolor + multicolor1)
Ejemplo n.º 2
0
 def test_merging_incorrect(self):
     # cases when vertices in two supplied for the merging edges are not consistent
     v1 = BlockVertex("v1")
     v2 = BlockVertex("v2")
     v3 = BlockVertex("v3")
     v4 = BlockVertex("v4")
     multicolor = Multicolor(self.genome3)
     multicolor1 = Multicolor(self.genome2)
     edge1 = BGEdge(vertex1=v1, vertex2=v2, multicolor=multicolor)
     edge2 = BGEdge(vertex1=v1, vertex2=v3, multicolor=multicolor1)
     with self.assertRaises(ValueError):
         BGEdge.merge(edge1, edge2)
     edge2 = BGEdge(vertex1=v3, vertex2=v2, multicolor=multicolor1)
     with self.assertRaises(ValueError):
         BGEdge.merge(edge1, edge2)
     edge2 = BGEdge(vertex1=v3, vertex2=v4, multicolor=multicolor1)
     with self.assertRaises(ValueError):
         BGEdge.merge(edge1, edge2)
     edge2 = BGEdge(vertex1=v1, vertex2=v1, multicolor=multicolor1)
     with self.assertRaises(ValueError):
         BGEdge.merge(edge1, edge2)
     edge2 = BGEdge(vertex1=v2, vertex2=v2, multicolor=multicolor1)
     with self.assertRaises(ValueError):
         BGEdge.merge(edge1, edge2)
     edge2 = BGEdge(vertex1=v3, vertex2=v1, multicolor=multicolor1)
     with self.assertRaises(ValueError):
         BGEdge.merge(edge1, edge2)