def test_inversion(self): bpp = BreakpointPair( Breakpoint('1', 10, orient=ORIENT.LEFT), Breakpoint('1', 15, orient=ORIENT.LEFT), untemplated_seq='', ) assert bpp.net_size() == Interval(0)
def test_indel(self): bpp = BreakpointPair( Breakpoint('1', 13, orient=ORIENT.RIGHT), Breakpoint('1', 10, orient=ORIENT.LEFT), untemplated_seq='TTT', ) assert bpp.net_size() == Interval(1)
def test_large_indel(self): bpp = BreakpointPair( Breakpoint('1', 10, orient=ORIENT.LEFT), Breakpoint('1', 101, orient=ORIENT.RIGHT), untemplated_seq='TTT', ) self.assertEqual(Interval(-87), bpp.net_size())
def test_order_is_retained(self): # BPP(Breakpoint(1:1925143-1925155R), Breakpoint(1:1925144L), opposing=False) # >> BPP(Breakpoint(1:1925144L), Breakpoint(1:1925144-1925158R), opposing=False) # >> BPP(Breakpoint(1:1925143L), Breakpoint(1:1925143-1925158R), opposing=False) pairs = [ BreakpointPair( Breakpoint('2', 1925144, 1925144, 'L'), Breakpoint('2', 1925144, 1925158, 'R'), event_type='deletion', opposing_strands=False, ), BreakpointPair( Breakpoint('2', 1925143, 1925143, 'L'), Breakpoint('2', 1925143, 1925158, 'R'), event_type='deletion', opposing_strands=False, ), ] mapping = merge_breakpoint_pairs(pairs, 100, 25) for merge, inputs in mapping.items(): print(merge) print(inputs) self.assertEqual(1, len(mapping)) merge = list(mapping)[0] self.assertEqual('L', merge.break1.orient) self.assertEqual('R', merge.break2.orient)
def test_translocation(self): b = BreakpointPair( Breakpoint(1, 1, 2, ORIENT.RIGHT), Breakpoint(2, 1, 2, ORIENT.LEFT), opposing_strands=False, ) BreakpointPair.classify(b)
def test_insertion(self): b = BreakpointPair( Breakpoint(1, 1, 1, strand=STRAND.NS, orient=ORIENT.LEFT), Breakpoint(1, 2, 2, strand=STRAND.NS, orient=ORIENT.RIGHT), opposing_strands=False, ) self.assertEqual(sorted([SVTYPE.INS]), sorted(BreakpointPair.classify(b)))
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)
def test_deletion(self): bpp = BreakpointPair( Breakpoint('1', 10, orient=ORIENT.LEFT), Breakpoint('1', 15, orient=ORIENT.RIGHT), untemplated_seq='', ) self.assertEqual(Interval(-4), bpp.net_size())
def test_mixed_protocol_fusions_same_sequence_diff_translation( self, genomic_event1, genomic_event2, transcripts ): genome_ev = BreakpointPair( Breakpoint('1', 1), Breakpoint('1', 10), opposing_strands=True, **{ COLUMNS.event_type: SVTYPE.DEL, COLUMNS.call_method: CALL_METHOD.CONTIG, COLUMNS.fusion_sequence_fasta_id: 'a', COLUMNS.protocol: PROTOCOL.GENOME, COLUMNS.transcript1: None, COLUMNS.transcript2: None, COLUMNS.fusion_cdna_coding_start: 1, COLUMNS.fusion_cdna_coding_end: 10, }, ) trans_ev = BreakpointPair( Breakpoint('1', 50), Breakpoint('1', 60), opposing_strands=True, **{ COLUMNS.event_type: SVTYPE.DEL, COLUMNS.call_method: CALL_METHOD.CONTIG, COLUMNS.fusion_sequence_fasta_id: 'a', COLUMNS.protocol: PROTOCOL.TRANS, COLUMNS.transcript1: None, COLUMNS.transcript2: None, COLUMNS.fusion_cdna_coding_start: 1, COLUMNS.fusion_cdna_coding_end: 50, }, ) assert not pairing.inferred_equivalent(genome_ev, trans_ev, transcripts)
def test_net_zero(self): transcript = PreTranscript([(1001, 1100), (1301, 1400), (1701, 1800)], strand=STRAND.POS) for patt in transcript.generate_splicing_patterns(): transcript.transcripts.append(Transcript(transcript, patt)) trans_evidence = MockObject( annotations={}, read_length=100, max_expected_fragment_size=550, call_error=11, overlapping_transcripts={transcript}, ) setattr( trans_evidence, '_select_transcripts', lambda *pos: trans_evidence.overlapping_transcripts, ) setattr( trans_evidence, 'distance', partial(TranscriptomeEvidence.distance, trans_evidence), ) bpp = BreakpointPair( Breakpoint('1', 1099, orient=ORIENT.LEFT), Breakpoint('1', 1302, orient=ORIENT.RIGHT), untemplated_seq='TT', ) dist = partial(TranscriptomeEvidence.distance, trans_evidence) assert bpp.net_size() == Interval(-200) assert bpp.net_size(dist) == Interval(0)
def test_duplication(self): b = BreakpointPair( Breakpoint(1, 1, 2, strand=STRAND.POS, orient=ORIENT.RIGHT), Breakpoint(1, 10, 11, strand=STRAND.POS, orient=ORIENT.LEFT)) self.assertEqual({SVTYPE.DUP}, BreakpointPair.classify(b)) b = BreakpointPair( Breakpoint(1, 1, 2, strand=STRAND.POS, orient=ORIENT.RIGHT), Breakpoint(1, 10, 11, strand=STRAND.POS, orient=ORIENT.LEFT)) self.assertEqual({SVTYPE.DUP}, BreakpointPair.classify(b)) b = BreakpointPair( Breakpoint(1, 1, 2, strand=STRAND.NEG, orient=ORIENT.RIGHT), Breakpoint(1, 10, 11, strand=STRAND.NEG, orient=ORIENT.LEFT)) self.assertEqual({SVTYPE.DUP}, BreakpointPair.classify(b)) b = BreakpointPair( Breakpoint(1, 1, 2, strand=STRAND.POS, orient=ORIENT.RIGHT), Breakpoint(1, 10, 11, strand=STRAND.POS, orient=ORIENT.NS)) self.assertEqual({SVTYPE.DUP}, BreakpointPair.classify(b)) b = BreakpointPair( Breakpoint(1, 1, 2, strand=STRAND.NEG, orient=ORIENT.RIGHT), Breakpoint(1, 10, 11, strand=STRAND.NEG, orient=ORIENT.NS)) self.assertEqual({SVTYPE.DUP}, BreakpointPair.classify(b))
def setUp(self): self.gev1 = BreakpointPair( Breakpoint('1', 1), Breakpoint('1', 10), opposing_strands=True, data={ COLUMNS.event_type: SVTYPE.DEL, COLUMNS.call_method: CALL_METHOD.CONTIG, COLUMNS.fusion_sequence_fasta_id: None, COLUMNS.protocol: PROTOCOL.GENOME, COLUMNS.fusion_cdna_coding_end: None, COLUMNS.fusion_cdna_coding_start: None, }, ) self.gev2 = BreakpointPair( Breakpoint('1', 1), Breakpoint('1', 100), opposing_strands=True, data={ COLUMNS.event_type: SVTYPE.DEL, COLUMNS.call_method: CALL_METHOD.CONTIG, COLUMNS.fusion_sequence_fasta_id: None, COLUMNS.protocol: PROTOCOL.GENOME, COLUMNS.fusion_cdna_coding_start: None, COLUMNS.fusion_cdna_coding_end: None, }, ) self.best_transcripts = {'ABCA': True, 'ABCD': True}
def test_mixed_protocol_fusions_different_sequence(self): genome_ev = BreakpointPair(Breakpoint('1', 1), Breakpoint('1', 10), opposing_strands=True, data={ COLUMNS.event_type: SVTYPE.DEL, COLUMNS.call_method: CALL_METHOD.CONTIG, COLUMNS.fusion_sequence_fasta_id: 'a', COLUMNS.protocol: PROTOCOL.GENOME, COLUMNS.transcript1: None, COLUMNS.transcript2: None, COLUMNS.fusion_cdna_coding_start: 1, COLUMNS.fusion_cdna_coding_end: 10 }) trans_ev = BreakpointPair(Breakpoint('1', 50), Breakpoint('1', 60), opposing_strands=True, data={ COLUMNS.event_type: SVTYPE.DEL, COLUMNS.call_method: CALL_METHOD.CONTIG, COLUMNS.fusion_sequence_fasta_id: 'b', COLUMNS.protocol: PROTOCOL.TRANS, COLUMNS.transcript1: None, COLUMNS.transcript2: None, COLUMNS.fusion_cdna_coding_start: 1, COLUMNS.fusion_cdna_coding_end: 10 }) self.assertFalse( pairing.inferred_equivalent(genome_ev, trans_ev, self.TRANSCRIPTS))
def test_close_del(self): # ....TT|TT.... b1 = Breakpoint(REF_CHR, 1001, strand=STRAND.POS, orient=ORIENT.LEFT) b2 = Breakpoint(REF_CHR, 1002, strand=STRAND.POS, orient=ORIENT.RIGHT) bpp = BreakpointPair(b1, b2) self.assertEqual(('', ''), bpp.breakpoint_sequence_homology(REFERENCE_GENOME))
def test_inversion_insertion(self): bpp = BreakpointPair( Breakpoint('1', 10, orient=ORIENT.LEFT), Breakpoint('1', 15, orient=ORIENT.LEFT), untemplated_seq='TT', ) self.assertEqual(Interval(2), bpp.net_size())
def test_net_zero(self): bpp = BreakpointPair(Breakpoint('1', 1099, orient=ORIENT.LEFT), Breakpoint('1', 1302, orient=ORIENT.RIGHT), untemplated_seq='TT') dist = partial(TranscriptomeEvidence.distance, self.trans_evidence) self.assertEqual(Interval(-200), bpp.net_size()) self.assertEqual(Interval(0), bpp.net_size(dist))
def test_duplication_with_insertion(self): bpp = BreakpointPair( Breakpoint('1', 10, orient=ORIENT.RIGHT), Breakpoint('1', 15, orient=ORIENT.LEFT), untemplated_seq='TTT', ) self.assertEqual(Interval(9), bpp.net_size())
def test_events_separate(self): bpps = [ BreakpointPair( Breakpoint('4', 157002032, 157002046, orient='L'), Breakpoint('4', 157002343, 157002343, orient='R'), event_type=SVTYPE.DEL, untemplated_seq='', protocol='genome', tracking_id='manta-MantaDEL:55718:0:0:1:0:0', ), BreakpointPair( Breakpoint('4', 156935061, orient='L'), Breakpoint('4', 156935245, orient='R'), event_type=SVTYPE.DEL, untemplated_seq='', protocol='genome', tracking_id='delly-DEL00011007', ), BreakpointPair( Breakpoint('4', 157002046, orient='L'), Breakpoint('4', 157002358, orient='R'), event_type=SVTYPE.DEL, untemplated_seq='', protocol='genome', tracking_id='delly-DEL00011008', ), ] mapping = merge_breakpoint_pairs(bpps, 100, 25, verbose=True) self.assertEqual(2, len(mapping))
def test_indel_in_intron(self): # 55238868_55238906 bpp = BreakpointPair( Breakpoint('7', 5523700, orient=ORIENT.LEFT), Breakpoint('7', 5523751, orient=ORIENT.RIGHT), untemplated_seq='TTATCG', ) self.assertEqual(Interval(-44), bpp.net_size(self.egfr_distance))
def test_insertion_at_exon_start_mixed(self): # EXON 15: 55232973-55233130 # EXON 16: 55238868-55238906 # EXON 17: 55240676-55240817 bpp = BreakpointPair(Breakpoint('7', 55238867, orient=ORIENT.LEFT), Breakpoint('7', 55238868, orient=ORIENT.RIGHT), untemplated_seq='TTATCG') self.assertEqual(Interval(6), bpp.net_size(self.egfr_distance))
def test_insertion_at_exon_end_mixed(self): # 55238868_55238906 bpp = BreakpointPair( Breakpoint('7', 55238905, orient=ORIENT.LEFT), Breakpoint('7', 55238906, orient=ORIENT.RIGHT), untemplated_seq='TTATCG', ) self.assertEqual(Interval(6), bpp.net_size(self.egfr_distance))
def test_deletion(self): b = BreakpointPair( Breakpoint(1, 1, 1, strand=STRAND.NS, orient=ORIENT.LEFT), Breakpoint(1, 3, 3, strand=STRAND.NS, orient=ORIENT.RIGHT), opposing_strands=False, untemplated_seq='', ) self.assertEqual(sorted([SVTYPE.DEL]), sorted(BreakpointPair.classify(b)))
def test_no_type(self): b = BreakpointPair( Breakpoint(1, 1, 1, strand=STRAND.NS, orient=ORIENT.LEFT), Breakpoint(1, 2, 2, strand=STRAND.NS, orient=ORIENT.RIGHT), opposing_strands=False, untemplated_seq='', ) self.assertEqual(set(), BreakpointPair.classify(b))
def test_break2(self): bpp1 = BreakpointPair(Breakpoint('1', 1, 10, orient=ORIENT.LEFT), Breakpoint('2', 1, orient=ORIENT.RIGHT), untemplated_seq='') bpp2 = BreakpointPair(Breakpoint('1', 1, 10, orient=ORIENT.LEFT), Breakpoint('2', 1, orient=ORIENT.LEFT), untemplated_seq=None) self.assertTrue(bpp2 < bpp1)
def test_insertion_at_exon_start(self, egfr_evidence): # 55238868_55238906 bpp = BreakpointPair( Breakpoint('7', 55233130, orient=ORIENT.LEFT), Breakpoint('7', 55238868, orient=ORIENT.RIGHT), untemplated_seq='TTATCG', ) assert bpp.net_size(lambda p1, p2: TranscriptomeEvidence.distance( egfr_evidence, p1, p2)) == Interval(6)
def test_right_neg_right_pos(self): # CCC|AAA ------------ TTT|GGG # GGG GGG # AAA AAA b1 = Breakpoint(REF_CHR, 1460, strand=STRAND.NEG, orient=ORIENT.RIGHT) b2 = Breakpoint(REF_CHR, 2915, strand=STRAND.POS, orient=ORIENT.RIGHT) bpp = BreakpointPair(b1, b2) assert bpp.breakpoint_sequence_homology(REFERENCE_GENOME) == ('AAA', 'GGG')
def test_left_neg_left_pos(self): # CCC|AAA ------------ TTT|GGG # CCC CCC # TTT TTT b1 = Breakpoint(REF_CHR, 1459, strand=STRAND.NEG, orient=ORIENT.LEFT) b2 = Breakpoint(REF_CHR, 2914, strand=STRAND.POS, orient=ORIENT.LEFT) bpp = BreakpointPair(b1, b2) assert bpp.breakpoint_sequence_homology(REFERENCE_GENOME) == ('CCC', 'TTT')
def test_indel_in_intron(self, egfr_evidence): # 55238868_55238906 bpp = BreakpointPair( Breakpoint('7', 5523700, orient=ORIENT.LEFT), Breakpoint('7', 5523751, orient=ORIENT.RIGHT), untemplated_seq='TTATCG', ) assert bpp.net_size(lambda p1, p2: TranscriptomeEvidence.distance( egfr_evidence, p1, p2)) == Interval(-44)
def test_interchromosomal(self): bp1 = Breakpoint(1, 1, 2, ORIENT.LEFT) bp2 = Breakpoint(2, 1, 2, ORIENT.LEFT) bpp = BreakpointPair(bp1, bp2, opposing_strands=True) self.assertTrue(bpp.interchromosomal) bp1 = Breakpoint(1, 1, 2, ORIENT.LEFT) bp2 = Breakpoint(1, 7, 8, ORIENT.LEFT) bpp = BreakpointPair(bp1, bp2, opposing_strands=True) self.assertFalse(bpp.interchromosomal)
def test___init__swap_break_order(self): b1 = Breakpoint('1', 1) b2 = Breakpoint('1', 50) bpp = BreakpointPair(b1, b2, opposing_strands=True) self.assertEqual(bpp.break1, b1) self.assertEqual(bpp.break2, b2) bpp = BreakpointPair(b2, b1, opposing_strands=True) self.assertEqual(bpp.break1, b1) self.assertEqual(bpp.break2, b2)