コード例 #1
0
    def testTwoPathsTwoRoots(self):
        db = {}
        clusters = []
        exons1 = [self.a1, self.c1, self.d1, self.f1]
        exons2 = [self.b2, self.c2, self.e2, self.g2]

        comp.addExon(db, clusters, exons1)
        comp.addExon(db, clusters, exons2)

        allPath = comp.getPath(self.a1.cluster)

        self.assertEqual(len(allPath), 4)
        self.assertEqual(len(allPath[0]), 4)
        self.assertEqual(len(allPath[1]), 4)

        allPath = comp.getPath(self.b2.cluster)

        self.assertEqual(len(allPath), 4)
        self.assertEqual(len(allPath[0]), 4)
        self.assertEqual(len(allPath[1]), 4)

        allPath = comp.getPath(self.c1.cluster)

        self.assertEqual(len(allPath), 4)
        self.assertEqual(len(allPath[0]), 4)
        self.assertEqual(len(allPath[1]), 4)

        allPath = comp.getPath(self.d1.cluster)

        self.assertEqual(len(allPath), 4)
        self.assertEqual(len(allPath[0]), 4)
        self.assertEqual(len(allPath[1]), 4)
コード例 #2
0
    def testTwoPathsTwoRoots(self):
        db = {}
        clusters = []
        exons1 = [self.a1, self.c1, self.d1, self.f1]
        exons2 = [self.b2, self.c2, self.e2, self.g2]

        comp.addExon(db, clusters, exons1)
        comp.addExon(db, clusters, exons2)

        allPath = comp.getPath(self.a1.cluster)

        self.assertEqual(len(allPath), 4)
        self.assertEqual(len(allPath[0]), 4)
        self.assertEqual(len(allPath[1]), 4)

        allPath = comp.getPath(self.b2.cluster)

        self.assertEqual(len(allPath), 4)
        self.assertEqual(len(allPath[0]), 4)
        self.assertEqual(len(allPath[1]), 4)

        allPath = comp.getPath(self.c1.cluster)

        self.assertEqual(len(allPath), 4)
        self.assertEqual(len(allPath[0]), 4)
        self.assertEqual(len(allPath[1]), 4)

        allPath = comp.getPath(self.d1.cluster)

        self.assertEqual(len(allPath), 4)
        self.assertEqual(len(allPath[0]), 4)
        self.assertEqual(len(allPath[1]), 4)
コード例 #3
0
    def testTwoPathsTwoBubbles(self):
        db = {}
        clusters = []
        exons1 = [self.a1, self.b1, self.d1, self.f1, self.g1]
        exons2 = [self.a2, self.c2, self.d2, self.e2, self.g2]
        comp.addExon(db, clusters, exons1)
        comp.addExon(db, clusters, exons2)

        path = []
        allPaths = []

        comp.walkDown(self.a1.coord, path, allPaths, self.a1.cluster)
        self.assertEqual(len(allPaths), 4)

        expectedAllPaths = [[self.b1.coord,
                                self.d1.coord,
                                self.f1.coord,
                                self.g1.coord],
                            [self.b1.coord,
                                self.d1.coord,
                                self.e2.coord,
                                self.g1.coord],
                            [self.c2.coord,
                                self.d1.coord,
                                self.f1.coord,
                                self.g1.coord],
                            [self.c2.coord,
                                self.d1.coord,
                                self.e2.coord,
                                self.g1.coord]]

        self.assertListEqual(expectedAllPaths, allPaths)
コード例 #4
0
    def testTwoPaths(self):
        db = {}
        clusters = []
        exons1 = [self.a1, self.b1, self.c1, self.d1]
        exons2 = [self.a2, self.b2, self.c2, self.e2]
        comp.addExon(db, clusters, exons1)
        comp.addExon(db, clusters, exons2)

        path = []
        allPath = []

        comp.walkDown(self.c2.coord, path, allPath, self.c2.cluster)
        self.assertEqual(len(allPath), 2)

        path = []
        allPath = []

        comp.walkDown(self.a2.coord, path, allPath, self.a2.cluster)
        self.assertEqual(len(allPath), 2)
        self.assertEqual(
            allPath[0],
            [str(self.b1), str(self.c1),
             str(self.d1)])
        self.assertEqual(
            allPath[1],
            [str(self.b2), str(self.c2),
             str(self.e2)])
コード例 #5
0
    def testAddOneClusterWithOneExon(self):
        db = {}
        clusters = []
        exons1 = [self.a1]

        comp.addExon(db, clusters, exons1)
        self.assertEqual(len(db), 1)
        self.assertEqual(len(self.a1.cluster.nodes()), 1)
        self.assertEqual(self.a1.cluster.edges(), [])
コード例 #6
0
    def testSinglePath(self):
        db = {}
        clusters = []
        exons1 = [self.a1, self.b1, self.c1, self.d1, self.e1, self.f1, self.g1]
        comp.addExon(db, clusters, exons1)

        allPath = comp.getPath(self.e1.cluster)
        self.assertEqual(len(allPath), 1)
        self.assertEqual(len(allPath[0]), 7)
コード例 #7
0
    def testAddOneClusterWithOneExon(self):
        db = {}
        clusters = []
        exons1 = [self.a1]

        comp.addExon(db, clusters, exons1)
        self.assertEqual(len(db), 1)
        self.assertEqual(len(self.a1.cluster.nodes()), 1)
        self.assertEqual(self.a1.cluster.edges(), [])
コード例 #8
0
    def testTwoPathsTwoBubbles(self):
        db = {}
        clusters = []
        exons1 = [self.a1, self.b1, self.d1, self.f1, self.g1]
        exons2 = [self.a2, self.c2, self.d2, self.e2, self.g2]
        comp.addExon(db, clusters, exons1)
        comp.addExon(db, clusters, exons2)

        allPath = comp.getPath(self.d1.cluster)
        self.assertEqual(len(allPath), 4)
コード例 #9
0
    def testTwoPathsTwoBubbles(self):
        db = {}
        clusters = []
        exons1 = [self.a1, self.b1, self.d1, self.f1, self.g1]
        exons2 = [self.a2, self.c2, self.d2, self.e2, self.g2]
        comp.addExon(db, clusters, exons1)
        comp.addExon(db, clusters, exons2)

        allPath = comp.getPath(self.d1.cluster) 
        self.assertEqual(len(allPath), 4)
コード例 #10
0
    def testSinglePath(self):
        db = {}
        clusters = []
        exons1 = [
            self.a1, self.b1, self.c1, self.d1, self.e1, self.f1, self.g1
        ]
        comp.addExon(db, clusters, exons1)

        allPath = comp.getPath(self.e1.cluster)
        self.assertEqual(len(allPath), 1)
        self.assertEqual(len(allPath[0]), 7)
コード例 #11
0
    def testSingleNodePath(self):
        db = {}
        clusters = []
        exons1 = [self.a1]
        comp.addExon(db, clusters, exons1)

        self.assertEqual(len(self.a1.cluster.nodes()), 1)

        allPath = comp.getPath(self.a1.cluster)
        self.assertEqual(len(allPath), 1)
        self.assertEqual(len(allPath[0]), 1)
        self.assertEqual(allPath[0][0], self.a1.coord)
コード例 #12
0
    def testSingleExonPath(self):
        db = {}
        clusters = []
        exons1 = [self.a1]
        comp.addExon(db, clusters, exons1)

        path = []
        allPath = []

        comp.walkDown(self.a1.coord, path, allPath, self.a1.cluster)
        self.assertEqual(len(allPath), 1)
        self.assertEqual(allPath, [[]])
コード例 #13
0
    def testSingleExonPath(self):
        db = {}
        clusters = []
        exons1 = [self.a1]
        comp.addExon(db, clusters, exons1)

        path = []
        allPath = []

        comp.walkDown(self.a1.coord, path, allPath, self.a1.cluster) 
        self.assertEqual(len(allPath), 1)
        self.assertEqual(allPath, [[]])
コード例 #14
0
    def testSingleNodePath(self):
        db = {}
        clusters = []
        exons1 = [self.a1]
        comp.addExon(db, clusters, exons1)

        self.assertEqual(len(self.a1.cluster.nodes()), 1)

        allPath = comp.getPath(self.a1.cluster)
        self.assertEqual(len(allPath), 1)
        self.assertEqual(len(allPath[0]), 1)
        self.assertEqual(allPath[0][0], self.a1.coord)
コード例 #15
0
    def testSinglePath(self):
        db = {}
        clusters = []
        exons1 = [self.a1, self.b1, self.c1, self.d1, self.e1]
        comp.addExon(db, clusters, exons1)

        path = []
        allPath = []

        comp.walkDown(self.a1.coord, path, allPath, self.a1.cluster) 
        self.assertEqual(len(allPath), 1)
        self.assertEqual(allPath, [[str(self.b1), str(self.c1),
                                    str(self.d1), str(self.e1)]])
コード例 #16
0
    def testSinglePath(self):
        db = {}
        clusters = []
        exons1 = [self.a1, self.b1, self.c1, self.d1, self.e1]
        comp.addExon(db, clusters, exons1)

        path = []
        allPath = []

        comp.walkDown(self.a1.coord, path, allPath, self.a1.cluster)
        self.assertEqual(len(allPath), 1)
        self.assertEqual(
            allPath, [[str(self.b1),
                       str(self.c1),
                       str(self.d1),
                       str(self.e1)]])
コード例 #17
0
    def testOneMissingPath(self):
        db1 = {}
        db2 = {}
        clusters = []

        exons1 = [self.g1]
        exons2 = [self.a2, self.b2, self.c2, self.d2, self.e2, self.f2]

        comp.addExon(db1, clusters, exons1)
        comp.addExon(db2, clusters, exons2)

        missingPaths, alteredPaths = comp.findPathDiff(db1, db2)

        self.assertEqual(len(missingPaths), 1)
        self.assertEqual(len(alteredPaths), 0)

        missingPaths, alteredPaths = comp.findPathDiff(db2, db1)

        self.assertEqual(len(missingPaths), 1)
        self.assertEqual(len(alteredPaths), 0)
コード例 #18
0
    def testOneMissingPath(self):
        db1 = {}
        db2 = {}
        clusters = []

        exons1 = [self.g1]
        exons2 = [self.a2, self.b2, self.c2, self.d2, self.e2, self.f2]

        comp.addExon(db1, clusters, exons1)
        comp.addExon(db2, clusters, exons2)

        missingPaths, alteredPaths = comp.findPathDiff(db1, db2)

        self.assertEqual(len(missingPaths), 1)
        self.assertEqual(len(alteredPaths), 0)

        missingPaths, alteredPaths = comp.findPathDiff(db2, db1)

        self.assertEqual(len(missingPaths), 1)
        self.assertEqual(len(alteredPaths), 0)
コード例 #19
0
    def testTwoPaths(self):
        db = {}
        clusters = []
        exons1 = [self.a1, self.b1, self.c1, self.d1]
        exons2 = [self.a2, self.b2, self.c2, self.e2]
        comp.addExon(db, clusters, exons1)
        comp.addExon(db, clusters, exons2)

        path = []
        allPath = []

        comp.walkDown(self.c2.coord, path, allPath, self.c2.cluster)
        self.assertEqual(len(allPath), 2)

        path = []
        allPath = []

        comp.walkDown(self.a2.coord, path, allPath, self.a2.cluster)
        self.assertEqual(len(allPath), 2)
        self.assertEqual(allPath[0], [str(self.b1), str(self.c1), str(self.d1)])
        self.assertEqual(allPath[1], [str(self.b2), str(self.c2), str(self.e2)])
コード例 #20
0
    def testOnePathDiff(self):
        db1 = {}
        db2 = {}
        clusters = []

        exons1 = [self.a1, self.c1, self.d1, self.e1, self.f1]
        exons2 = [self.a2, self.c2, self.d2, self.e2, self.f2, self.g2]

        comp.addExon(db1, clusters, exons1)
        comp.addExon(db2, clusters, exons2)

        self.assertEqual(len(db1), 5)
        self.assertEqual(len(db2), 6)

        self.assertEqual(len(db1[self.a1.coord].cluster.nodes()), 5)
        self.assertEqual(len(db2[self.a1.coord].cluster.nodes()), 6)

        missingPaths, alteredPaths = comp.findPathDiff(db2, db1)

        self.assertEqual(len(missingPaths), 0)
        self.assertEqual(len(alteredPaths), 1)
コード例 #21
0
    def testOnePathDiff(self):
        db1 = {}
        db2 = {}
        clusters = []

        exons1 = [self.a1, self.c1, self.d1, self.e1, self.f1]
        exons2 = [self.a2, self.c2, self.d2, self.e2, self.f2, self.g2]

        comp.addExon(db1, clusters, exons1)
        comp.addExon(db2, clusters, exons2)

        self.assertEqual(len(db1), 5)
        self.assertEqual(len(db2), 6)
        
        self.assertEqual(len(db1[self.a1.coord].cluster.nodes()), 5)
        self.assertEqual(len(db2[self.a1.coord].cluster.nodes()), 6)

        missingPaths, alteredPaths = comp.findPathDiff(db2, db1)

        self.assertEqual(len(missingPaths), 0)
        self.assertEqual(len(alteredPaths), 1)
コード例 #22
0
    def testTwoPathsTwoBubbles(self):
        db = {}
        clusters = []
        exons1 = [self.a1, self.b1, self.d1, self.f1, self.g1]
        exons2 = [self.a2, self.c2, self.d2, self.e2, self.g2]
        comp.addExon(db, clusters, exons1)
        comp.addExon(db, clusters, exons2)

        path = []
        allPaths = []

        comp.walkDown(self.a1.coord, path, allPaths, self.a1.cluster)
        self.assertEqual(len(allPaths), 4)

        expectedAllPaths = [
            [self.b1.coord, self.d1.coord, self.f1.coord, self.g1.coord],
            [self.b1.coord, self.d1.coord, self.e2.coord, self.g1.coord],
            [self.c2.coord, self.d1.coord, self.f1.coord, self.g1.coord],
            [self.c2.coord, self.d1.coord, self.e2.coord, self.g1.coord]
        ]

        self.assertListEqual(expectedAllPaths, allPaths)
コード例 #23
0
    def testLeftRightExtension(self):
        db1 = {}
        db2 = {}
        clusters = []

        exons1 = [self.aa2, self.c1, self.d1, self.e1, self.f1, self.gg1]
        exons2 = [self.aa1, self.c2, self.d2, self.e2, self.f2, self.gg2]

        comp.addExon(db1, clusters, exons1)
        comp.addExon(db2, clusters, exons2)

        missingPaths, alteredPaths = comp.findPathDiff(db1, db2)

        self.assertEqual(len(missingPaths), 0)
        self.assertEqual(len(alteredPaths), 1)

        cluster1 = self.gg1.cluster
        cluster2 = self.gg2.cluster

        leftExtension, rightExtension = \
                comp.findExtendedEnd(cluster1, cluster2, db1, db2)

        self.assertEqual(len(leftExtension), 1)
        self.assertEqual(len(rightExtension), 1)
コード例 #24
0
    def testAddExonOneCluster(self):
        db = {}
        clusters = []
        exons1 = [self.a1, self.b1, self.c1, self.d1]
        exons2 = [self.a2, self.b2, self.c2, self.e2]

        comp.addExon(db, clusters, exons1)
        self.assertEqual(len(db), 4)

        comp.addExon(db, clusters, exons2)
        self.assertEqual(len(db), 5)

        self.assertEqual(len(clusters), 1)

        cl = clusters[0]

        self.assertEqual(len(cl.neighbors(self.c1.coord)), 2)
        self.assertIn(self.d1.coord, cl.nodes())
        self.assertIn(self.e1.coord, cl.nodes())
        self.assertEqual(len(cl.predecessors(self.c1.coord)), 1)
        self.assertIn(self.b1.coord, cl.predecessors(self.c1.coord))
        self.assertIn(self.a1.coord, cl.predecessors(self.b1.coord))
        self.assertEqual(cl.predecessors(self.a1.coord), [])
        self.assertEqual(cl.successors(self.d1.coord), [])
コード例 #25
0
    def testAddExonOneCluster(self):
        db = {}
        clusters = []
        exons1 = [self.a1, self.b1, self.c1, self.d1]
        exons2 = [self.a2, self.b2, self.c2, self.e2]

        comp.addExon(db, clusters, exons1)
        self.assertEqual(len(db), 4)

        comp.addExon(db, clusters, exons2)
        self.assertEqual(len(db), 5)

        self.assertEqual(len(clusters), 1)

        cl = clusters[0]

        self.assertEqual(len(cl.neighbors(self.c1.coord)), 2)
        self.assertIn(self.d1.coord, cl.nodes())
        self.assertIn(self.e1.coord, cl.nodes())
        self.assertEqual(len(cl.predecessors(self.c1.coord)), 1)
        self.assertIn(self.b1.coord, cl.predecessors(self.c1.coord))
        self.assertIn(self.a1.coord, cl.predecessors(self.b1.coord))
        self.assertEqual(cl.predecessors(self.a1.coord), [])
        self.assertEqual(cl.successors(self.d1.coord), [])
コード例 #26
0
    def testLeftRightExtension(self):
        db1 = {}
        db2 = {}
        clusters = []

        exons1 = [self.aa2, self.c1, self.d1, self.e1, self.f1, self.gg1]
        exons2 = [self.aa1, self.c2, self.d2, self.e2, self.f2, self.gg2]

        comp.addExon(db1, clusters, exons1)
        comp.addExon(db2, clusters, exons2)

        missingPaths, alteredPaths = comp.findPathDiff(db1, db2)

        self.assertEqual(len(missingPaths), 0)
        self.assertEqual(len(alteredPaths), 1)

        cluster1 = self.gg1.cluster
        cluster2 = self.gg2.cluster

        leftExtension, rightExtension = \
                comp.findExtendedEnd(cluster1, cluster2, db1, db2)

        self.assertEqual(len(leftExtension), 1)
        self.assertEqual(len(rightExtension), 1)
コード例 #27
0
    def testAddExonTwoClusters(self):
        db = {}
        clusters = []
        exons1 = [self.a1, self.b1, self.c1, self.d1]
        exons2 = [self.a2, self.b2, self.c2, self.e2]
        exons3 = [self.g3, self.f3]

        comp.addExon(db, clusters, exons1)
        self.assertEqual(len(db), 4)

        comp.addExon(db, clusters, exons2)
        self.assertEqual(len(db), 5)

        comp.addExon(db, clusters, exons3)
        self.assertEqual(len(db), 7)

        self.assertEqual(len(clusters), 2)

        self.assertEqual(len(clusters[0].nodes()), 5)
        self.assertEqual(len(clusters[1].nodes()), 2)
コード例 #28
0
    def testAddExonTwoClusters(self):
        db = {}
        clusters = []
        exons1 = [self.a1, self.b1, self.c1, self.d1]
        exons2 = [self.a2, self.b2, self.c2, self.e2]
        exons3 = [self.g3, self.f3]

        comp.addExon(db, clusters, exons1)
        self.assertEqual(len(db), 4)

        comp.addExon(db, clusters, exons2)
        self.assertEqual(len(db), 5)

        comp.addExon(db, clusters, exons3)
        self.assertEqual(len(db), 7)

        self.assertEqual(len(clusters), 2)

        self.assertEqual(len(clusters[0].nodes()), 5)
        self.assertEqual(len(clusters[1].nodes()), 2)
コード例 #29
0
    def testTwoPathDiff(self):
        db1 = {}
        db2 = {}
        clusters = []

        exons1 = [self.a1, self.b1, self.c1, self.d1, self.f1]
        exons2 = [self.a2, self.b2, self.c2, self.d2, self.e2, self.f2]
        exons3 = [self.a3, self.b3, self.c3, self.d3, self.e3, self.g3]

        comp.addExon(db1, clusters, exons1)
        comp.addExon(db2, clusters, exons2)
        comp.addExon(db2, clusters, exons3)

        missingPaths, alteredPaths = comp.findPathDiff(db1, db2)

        self.assertEqual(len(missingPaths), 0)
        self.assertEqual(len(alteredPaths), 1)

        missingPaths, alteredPaths = comp.findPathDiff(db2, db1)

        self.assertEqual(len(missingPaths), 0)
        self.assertEqual(len(alteredPaths), 2)
コード例 #30
0
    def testTwoPathDiff(self):
        db1 = {}
        db2 = {}
        clusters = []

        exons1 = [self.a1, self.b1, self.c1, self.d1, self.f1]
        exons2 = [self.a2, self.b2, self.c2, self.d2, self.e2, self.f2]
        exons3 = [self.a3, self.b3, self.c3, self.d3, self.e3, self.g3]

        comp.addExon(db1, clusters, exons1)
        comp.addExon(db2, clusters, exons2)
        comp.addExon(db2, clusters, exons3)

        missingPaths, alteredPaths = comp.findPathDiff(db1, db2)

        self.assertEqual(len(missingPaths), 0)
        self.assertEqual(len(alteredPaths), 1)

        missingPaths, alteredPaths = comp.findPathDiff(db2, db1)

        self.assertEqual(len(missingPaths), 0)
        self.assertEqual(len(alteredPaths), 2)