Example #1
0
    def test_calls_correct_reference_between_clusters_with_uncalled_indel_between(
            self):
        chrom = "1"

        driver = SVCDriver(self)
        driver.with_ref_sequence(
            "AAAAAAAATAACGCACGCCCCATAAAAAAATTTTTTTTTTT",
            chrom=chrom).with_read(
                "       ..*.......................        ",
                n_fwd=10,
                n_rev=10).with_read(
                    ".......................*............     ",
                    n_fwd=1,
                    n_rev=1).with_read(
                        ".......................T..               ",
                        n_fwd=10,
                        n_rev=10).with_output_ref_calls(
                            True).with_max_cluster_distance(5)

        expect = driver.call()
        vcf_expect = expect.with_output_vcf()
        vcf_expect.has_reference_calls(ChromInterval(chrom, 0, 8))

        vcf_expect.has_record_for_variant(Variant(chrom, 8, "TA", "T"))

        vcf_expect.has_reference_calls(ChromInterval(chrom, 10, 23))

        vcf_expect.has_record_for_variant(Variant(chrom, 23, "A", "T"))

        vcf_expect.has_reference_calls(ChromInterval(chrom, 24, 41))
Example #2
0
    def test_calls_reference_on_location_with_low_quality_variant_support(
            self):
        chrom = "1"

        driver = SVCDriver(self)
        driver.with_ref_sequence(
            "AAAAAAAATAACGCACGCCCCATAAAAAAATTTTTTTTTTT",
            chrom=chrom).with_read(
                "       ..*.......................        ", n_fwd=2,
                n_rev=1).with_read(
                    ".................T.....T.........        ",
                    "                 1                       ",
                    n_fwd=1,
                    n_rev=1).with_read(
                        ".......................T..               ",
                        n_fwd=1,
                        n_rev=0).with_output_ref_calls(True)

        expect = driver.call()
        vcf_expect = expect.with_output_vcf()
        vcf_expect.has_reference_calls(ChromInterval(chrom, 0, 8))

        vcf_expect.has_record_for_variant(Variant(chrom, 8, "TA", "T"))

        vcf_expect.has_reference_calls(ChromInterval(chrom, 10, 23))

        vcf_expect.has_record_for_variant(Variant(chrom, 23, "A", "T"))

        vcf_expect.has_reference_calls(ChromInterval(chrom, 24, 41))
    def calls_variants_in_bed_region(self,
                                     ref,
                                     sequence_list,
                                     expected_ascii_haplotypes=None,
                                     expected_variant_stubs=None,
                                     bed_regions=[],
                                     compress=False):

        bed_filename = os.path.join(self.work_dir, "test.bed")
        with BEDWriterContextManager(bed_filename) as bed_writer:
            # TODO - link chromosomes
            for region in bed_regions:
                bed_writer.write_chrom_interval(
                    ChromInterval(DEFAULT_CHROM, region.start, region.end))

        if compress:
            indexer = BEDIndexer(bed_filename)
            indexer.index()
            bed_filename = indexer.compressed_filename

        self.calls_variants(ref,
                            sequence_list,
                            expected_ascii_haplotypes,
                            expected_variant_stubs,
                            n_fwd=10,
                            n_rev=10,
                            config_dict={
                                "regions": bed_filename,
                                "allowMNPCalls": "True"
                            })
Example #4
0
    def test_should_write_line_to_stream(self):
        output_stream = MockStream()

        writer = BEDWriter(output_stream)
        writer.write_chrom_interval(ChromInterval("20", 1, 2))

        # Then
        self.assertEqual(output_stream.lines, ["20\t1\t2\n"])
Example #5
0
 def __init__(self,
              chrom,
              start,
              end,
              label=None,
              score=None,
              strand=None,
              build=None):
     self.chrom_interval = ChromInterval(chrom, start, end)
     self.build = build
     self.label = label
     self.score = score
     self.strand = strand
Example #6
0
    def test_bed_extension_is_not_required(self):
        region_filename = os.path.join(self.work_dir, "bed.txt")

        with BEDWriterContextManager(region_filename) as bed:
            bed.write_chrom_interval(ChromInterval("1", 0, 29))

        svc = SVCDriver(self).with_ref_sequence(
            "ACGTACGTACGTACGTACGTACGT", chrom="1"
        ).with_read(
            "....G...................", n_rev=10, n_fwd=10
        ).with_region_string(region_filename)

        expect = svc.call()

        expect.with_output_vcf() \
            .record_count(1)
Example #7
0
    def setUp(self):
        BaseTest.setUp(self)
        self.bed_filename = os.path.join(self.work_dir, "_.bed")
        self.log_filename = os.path.join(self.work_dir, "_.log")

        chrom = "1"

        with BEDWriterContextManager(self.bed_filename) as bed_file:
            bed_file.write_chrom_interval(ChromInterval(chrom, 0, 42))

        self.output_vcf = os.path.join(self.work_dir, "output.vcf")
        self.svc_driver = SVCDriver(self)
        self.svc_driver.with_ref_sequence(
            "AAAAAAAAAAACGCACCCCCCATAAAAAAAATTTTTTTTTTT", chrom=chrom)
        self.svc_driver.with_read("       ..............C.............       ",
                                  chrom=chrom)
        self.svc_driver.with_log_timings(True)
        self.svc_driver.with_region_string(self.bed_filename)
        self.svc_driver.with_log_filename(self.log_filename)
        self.svc_driver.with_output_vcf_filename(self.output_vcf)
Example #8
0
 def test_should_overlap_mnp_at_region_end(self):
     mnp = variant.Variant('1', 15, 'ACGT', 'GCGC')
     self.assertTrue(mnp.overlap(ChromInterval('1', 15, 16)))
Example #9
0
 def has_reference_calls_for_region(self, chrom, start, end):
     return self.has_reference_calls(ChromInterval(chrom, start, end))
Example #10
0
    def test_should_write_tab_delimited_region(self):
        region = ChromInterval("20", 1, 2)

        output_line = bed_line_from_chrom_interval(region)
        self.assertEqual(output_line, "20\t1\t2")
Example #11
0
 def chrom_interval(self):
     return ChromInterval(self.chrom, self.pos_from, self.pos_to)
Example #12
0
 def test_should_not_overlap_mnp_after_region(self):
     mnp = variant.Variant('1', 15, 'ACGT', 'GCGC')
     self.assertFalse(mnp.overlap(ChromInterval('1', 19, 20)))
Example #13
0
 def overlap(self, chrom_interval):
     return chrom_interval.overlap(
         ChromInterval(self.chrom, self.pos_from, self.pos_to))
Example #14
0
 def test_should_overlap_insertion_at_region_end(self):
     ins = variant.Variant('1', 15, 'A', 'AAAAA')
     self.assertTrue(ins.overlap(ChromInterval('1', 15, 16)))
Example #15
0
 def test_should_not_overlap_deletion_after_region(self):
     deletion = variant.Variant('1', 15, 'AAAAA', 'A')
     self.assertFalse(deletion.overlap(ChromInterval('1', 20, 21)))
Example #16
0
 def test_should_not_overlap_insertion_before_region(self):
     ins = variant.Variant('1', 15, 'A', 'AAAAA')
     self.assertFalse(ins.overlap(ChromInterval('1', 16, 20)))
Example #17
0
 def test_should_overlap_deletion_at_region_end(self):
     deletion = variant.Variant('1', 15, 'AAAAA', 'A')
     self.assertTrue(deletion.overlap(ChromInterval('1', 15, 16)))