Ejemplo n.º 1
0
 def test_build_exon_overlap_cluster_with_lnc_in_intron(self):
     # read1: ++++....................++++
     # read2:         ++++....++++
     read1 = make_read(0, "read1", 100, [(0, 100), (3, 500), (0, 100)])
     read2 = make_read(0, "read2", 300, [(0, 100), (3, 100), (0, 100)])
     read_list = [read1, read2]
     clusterlist = GeneLinkageFinder.build_exon_overlap_cluster(read_list)
     self.assertEqual(len(clusterlist), 2)
Ejemplo n.º 2
0
 def test_split_cluster_by_overlap_with_same_cluster(self):
     # read1: ++++....++++
     # read2: ++++....+
     # read3: ++++....++++....++++
     read1 = make_read(0, "read1", 100, [(0, 100), (3, 100), (0, 100)])
     read2 = make_read(0, "read2", 100, [(0, 100), (3, 100), (0, 10)])
     read3 = make_read(0, "read3", 100, [(0, 100), (3, 100), (0, 100),
                                         (3, 100), (0, 100)])
     cluster = [read1, read2, read3]
     clusterlist = GeneLinkageFinder.split_cluster_by_overlap(cluster)
     self.assertEqual(len(clusterlist), 1)
Ejemplo n.º 3
0
 def test_build_exon_overlap_cluster_with_no_overlap_iso(self):
     # read1: ++++....++++
     # read2:                     ++++....+
     # read3: ++++....++++....++++
     read1 = make_read(0, "read1", 100, [(0, 100), (3, 100), (0, 100)])
     read2 = make_read(0, "read2", 600, [(0, 100), (3, 100), (0, 10)])
     read3 = make_read(0, "read3", 100, [(0, 100), (3, 100), (0, 100),
                                         (3, 100), (0, 100)])
     read_list = [read1, read2, read3]
     clusterlist = GeneLinkageFinder.build_exon_overlap_cluster(read_list)
     self.assertEqual(len(clusterlist), 2)
Ejemplo n.º 4
0
 def test_filter_cluster_by_strand_with_diff_intron(self):
     # read1: ++++....++++
     # read2:   ----....-
     read1 = make_read(0, "read1", 100, [(0, 100), (3, 100), (0, 100)])
     read2 = make_read(0, "read2", 150, [(0, 100), (3, 100), (0, 10)])
     read2.is_reverse = True
     read1.setTag("FL", 100)
     read2.setTag("FL", 1000)
     clusterlist = [[read1], [read2]]
     res = GeneLinkageFinder.filter_cluster_by_strand(clusterlist)
     self.assertEqual(len(res), 2)
Ejemplo n.º 5
0
 def test_build_exon_overlap_cluster_with_diff_strand(self):
     # read1: ++++....++++
     # read2: ----....-
     # read3: ++++....++++....++++
     read1 = make_read(0, "read1", 100, [(0, 100), (3, 100), (0, 100)])
     read2 = make_read(0, "read2", 100, [(0, 100), (3, 100), (0, 10)])
     read3 = make_read(0, "read3", 100, [(0, 100), (3, 100), (0, 100),
                                         (3, 100), (0, 100)])
     read2.is_reverse = True
     read_list = [read1, read2, read3]
     clusterlist = GeneLinkageFinder.build_exon_overlap_cluster(read_list)
     self.assertEqual(len(clusterlist), 2)
Ejemplo n.º 6
0
 def test_filter_cluster_by_strand_both_without_intron_1(self):
     # read1: ++++
     # read2: ----
     read1 = make_read(0, "read1", 100, [(0, 100)])
     read2 = make_read(0, "read2", 100, [(0, 100)])
     read2.is_reverse = True
     read1.setTag("FL", 1000)
     read2.setTag("FL", 100)
     clusterlist = [[read1], [read2]]
     res = GeneLinkageFinder.filter_cluster_by_strand(clusterlist)
     self.assertEqual(len(res), 1)
     self.assertFalse(res[0][0].is_reverse)
Ejemplo n.º 7
0
 def test_find_junction(self):
     read = make_read(0, "test", 100, [(0, 20), (3, 20), (0, 20), (1, 1),
                                       (3, 20), (0, 20), (2, 10), (0, 5),
                                       (3, 20), (0, 20)])
     junctions = JunctionGraph._find_junction(read, 10)
     self.assertEqual(len(junctions), 1)
     self.assertEqual(junctions[0],
                      (("chr1", 120, '+', 'EI'), ("chr1", 140, '+', 'IE')))
Ejemplo n.º 8
0
    def test_adjust_intron_position(self):
        read = make_read(0, "test", 100, [(0, 100), (3, 100), (0, 100)])
        intron = Intron(read.reference_name, 190, 310, "+")
        ElementDiscover.adjust_intron_position(read, intron)
        self.assertListEqual(read.blocks, [(100, 190), (310, 400)])

        read = make_read(0, "test", 100, [(0, 100), (3, 100), (0, 100)])
        intron = Intron(read.reference_name, 210, 290, "+")
        ElementDiscover.adjust_intron_position(read, intron)
        self.assertListEqual(read.blocks, [(100, 210), (290, 400)])

        # Difference chrom
        read = make_read(0, "test", 100, [(0, 100), (3, 100), (0, 100)])
        intron = Intron("DiffChrom", 190, 310, "+")
        ElementDiscover.adjust_intron_position(read, intron)
        self.assertListEqual(read.blocks, [(100, 200), (300, 400)])

        # Difference strand
        read = make_read(0, "test", 100, [(0, 100), (3, 100), (0, 100)])
        intron = Intron("DiffChrom", 190, 310, "-")
        ElementDiscover.adjust_intron_position(read, intron)
        self.assertListEqual(read.blocks, [(100, 200), (300, 400)])
Ejemplo n.º 9
0
 def test_blocks2cigar(self):
     blocks = ((0, 20), (3, 80), (0, 75), (3, 42), (0, 30))
     read = make_read(0, "test", 100, blocks)
     self.assertEqual(ElementDiscover.blocks2cigar(read.blocks), blocks)