예제 #1
0
    def test_deletion_or_insertion(self):
        b = BreakpointPair(
            Breakpoint(1, 1, 2, strand=STRAND.POS, orient=ORIENT.LEFT),
            Breakpoint(1, 10, 11, strand=STRAND.POS, orient=ORIENT.RIGHT))
        self.assertEqual(sorted([SVTYPE.DEL, SVTYPE.INS]),
                         sorted(BreakpointPair.classify(b)))

        b = BreakpointPair(Breakpoint(1,
                                      1,
                                      2,
                                      strand=STRAND.POS,
                                      orient=ORIENT.LEFT),
                           Breakpoint(1,
                                      10,
                                      11,
                                      strand=STRAND.NS,
                                      orient=ORIENT.RIGHT),
                           opposing_strands=False)
        self.assertEqual(sorted([SVTYPE.DEL, SVTYPE.INS]),
                         sorted(BreakpointPair.classify(b)))

        b = BreakpointPair(
            Breakpoint(1, 1, 2, strand=STRAND.NEG, orient=ORIENT.LEFT),
            Breakpoint(1, 10, 11, strand=STRAND.NEG, orient=ORIENT.RIGHT))
        self.assertEqual(sorted([SVTYPE.DEL, SVTYPE.INS]),
                         sorted(BreakpointPair.classify(b)))

        b = BreakpointPair(Breakpoint(1,
                                      1,
                                      2,
                                      strand=STRAND.NEG,
                                      orient=ORIENT.LEFT),
                           Breakpoint(1,
                                      10,
                                      11,
                                      strand=STRAND.NS,
                                      orient=ORIENT.RIGHT),
                           opposing_strands=False)
        self.assertEqual(sorted([SVTYPE.DEL, SVTYPE.INS]),
                         sorted(BreakpointPair.classify(b)))

        b = BreakpointPair(Breakpoint(1,
                                      1,
                                      2,
                                      strand=STRAND.NS,
                                      orient=ORIENT.LEFT),
                           Breakpoint(1,
                                      10,
                                      11,
                                      strand=STRAND.POS,
                                      orient=ORIENT.RIGHT),
                           opposing_strands=False)
        self.assertEqual(sorted([SVTYPE.DEL, SVTYPE.INS]),
                         sorted(BreakpointPair.classify(b)))

        b = BreakpointPair(Breakpoint(1,
                                      1,
                                      2,
                                      strand=STRAND.NS,
                                      orient=ORIENT.LEFT),
                           Breakpoint(1,
                                      10,
                                      11,
                                      strand=STRAND.NEG,
                                      orient=ORIENT.RIGHT),
                           opposing_strands=False)
        self.assertEqual(sorted([SVTYPE.DEL, SVTYPE.INS]),
                         sorted(BreakpointPair.classify(b)))

        b = BreakpointPair(Breakpoint(1,
                                      1,
                                      2,
                                      strand=STRAND.NS,
                                      orient=ORIENT.LEFT),
                           Breakpoint(1,
                                      10,
                                      11,
                                      strand=STRAND.NS,
                                      orient=ORIENT.RIGHT),
                           opposing_strands=False)
        self.assertEqual(sorted([SVTYPE.DEL, SVTYPE.INS]),
                         sorted(BreakpointPair.classify(b)))
예제 #2
0
 def test_deletion_no_distance_error(self):
     bpp = BreakpointPair(Breakpoint('1', 7039, orient='L'),
                          Breakpoint('1', 7040, orient='R'),
                          opposing=False)
     self.assertEqual(sorted([SVTYPE.INS]),
                      sorted(BreakpointPair.classify(bpp)))
예제 #3
0
 def test_inverted_translocation(self):
     b = BreakpointPair(Breakpoint(1, 1, 2, ORIENT.LEFT),
                        Breakpoint(2, 1, 2, ORIENT.LEFT),
                        opposing_strands=True)
     BreakpointPair.classify(b)
예제 #4
0
 def test_translocation(self):
     b = BreakpointPair(Breakpoint(1, 1, 2, ORIENT.RIGHT),
                        Breakpoint(2, 1, 2, ORIENT.LEFT),
                        opposing_strands=False)
     BreakpointPair.classify(b)
예제 #5
0
 def test___init__stranded(self):
     with self.assertRaises(NotSpecifiedError):
         BreakpointPair(Breakpoint('1', 1),
                        Breakpoint('1', 2),
                        stranded=True,
                        opposing_strands=True)
예제 #6
0
 def test___init__invalid_inter_lr_opp(self):
     with self.assertRaises(InvalidRearrangement):
         BreakpointPair(Breakpoint(1, 1, 2, ORIENT.LEFT),
                        Breakpoint(2, 1, 2, ORIENT.RIGHT),
                        opposing_strands=True)
예제 #7
0
 def test___init__opstrand_not_specified(self):
     with self.assertRaises(NotSpecifiedError):
         BreakpointPair(Breakpoint('1', 1), Breakpoint('1', 2))
예제 #8
0
 def test___init__opstrand_conflict(self):
     with self.assertRaises(AssertionError):
         BreakpointPair(Breakpoint('1', 1, strand=STRAND.POS),
                        Breakpoint('1', 2, strand=STRAND.POS),
                        opposing_strands=True)
예제 #9
0
 def test_insertion_in_intron(self):
     # 55238868_55238906
     bpp = BreakpointPair(Breakpoint('7', 5523750, orient=ORIENT.LEFT),
                          Breakpoint('7', 5523751, orient=ORIENT.RIGHT),
                          untemplated_seq='TTATCG')
     self.assertEqual(Interval(6), bpp.net_size(self.egfr_distance))
예제 #10
0
    def test_draw_translocation_with_template(self):
        d = DiagramSettings()
        d1 = protein.Domain('PF0001', [(55, 61), (71, 73)])
        d2 = protein.Domain('PF0002', [(10, 20), (30, 34)])
        g1 = genomic.Gene(TEMPLATE_METADATA['1'],
                          150,
                          1000,
                          strand=STRAND.POS,
                          aliases=['HUGO2'])
        g2 = genomic.Gene(TEMPLATE_METADATA['X'],
                          5000,
                          7500,
                          strand=STRAND.NEG,
                          aliases=['HUGO3'])
        t1 = build_transcript(gene=g1,
                              name='transcript1',
                              cds_start=50,
                              cds_end=249,
                              exons=[(200, 299), (400, 499), (700, 899)],
                              domains=[d2, d1])
        t2 = build_transcript(gene=g2,
                              name='transcript2',
                              cds_start=120,
                              cds_end=700,
                              exons=[(5100, 5299), (5800, 6199), (6500, 6549),
                                     (6700, 6799)],
                              domains=[])
        b1 = Breakpoint('1', 350, orient=ORIENT.LEFT)
        b2 = Breakpoint('2', 6520, orient=ORIENT.LEFT)
        bpp = BreakpointPair(b1, b2, opposing_strands=True, untemplated_seq='')
        ann = variant.Annotation(bpp,
                                 transcript1=t1,
                                 transcript2=t2,
                                 event_type=SVTYPE.ITRANS,
                                 protocol=PROTOCOL.GENOME)
        # genes 1
        ann.add_gene(
            genomic.Gene('1', 1500, 1950, strand=STRAND.POS,
                         aliases=['HUGO5']))
        ann.add_gene(genomic.Gene('1', 3000, 3980, strand=STRAND.POS))
        ann.add_gene(genomic.Gene('1', 3700, 4400, strand=STRAND.NEG))
        # genes 2
        ann.add_gene(genomic.Gene('2', 1500, 1950, strand=STRAND.NEG))
        ann.add_gene(genomic.Gene('2', 5500, 9000, strand=STRAND.POS))
        ann.add_gene(genomic.Gene('2', 3700, 4400, strand=STRAND.NEG))

        reference_genome = {
            '1': MockObject(seq=MockString('A')),
            '2': MockObject(seq=MockString('A'))
        }

        ft = variant.FusionTranscript.build(ann, reference_genome)
        ann.fusion = ft
        canvas, legend = draw_sv_summary_diagram(d,
                                                 ann,
                                                 draw_reference_templates=True,
                                                 templates=TEMPLATE_METADATA)
        if OUTPUT_SVG:
            canvas.saveas('test_draw_translocation_with_template.svg')
        self.assertEqual(8, len(canvas.elements))  # defs counts as element
        expected_height = d.top_margin + d.bottom_margin + \
            d.track_height * 2 + d.padding + d.breakpoint_bottom_margin + d.breakpoint_top_margin + \
            d.inner_margin + \
            d.track_height + d.splice_height + d.breakpoint_bottom_margin + d.breakpoint_top_margin + \
            d.padding + d.translation_track_height + \
            d.padding * 2 + d.domain_track_height * 2 + \
            d.inner_margin * 2 + \
            d.track_height + d.breakpoint_bottom_margin + d.breakpoint_top_margin + d.splice_height + \
            d.template_track_height
        self.assertAlmostEqual(expected_height, canvas.attribs['height'])
예제 #11
0
 def test___init__opstrand_indv_not_specified(self):
     bpp = BreakpointPair(Breakpoint('test', 1), Breakpoint('test', 10), opposing_strands=True)
     self.assertTrue(bpp.opposing_strands)
     bpp = BreakpointPair(Breakpoint('test', 1), Breakpoint('test', 10), opposing_strands=False)
     self.assertFalse(bpp.opposing_strands)