Exemplo n.º 1
0
    def test_simple_case(self):
        reference_coverage = ProbeCoverage(min_depth=100,
                                           percent_coverage=100,
                                           median_depth=100)
        alt1 = ProbeCoverage(min_depth=80,
                             percent_coverage=100,
                             median_depth=100)
        alternate_coverages = [alt1]
        v1 = VariantProbeCoverage(var_name="A123T",
                                  reference_coverage=reference_coverage,
                                  alternate_coverages=alternate_coverages)

        call = self.vt_no_contaim.type(v1)
        assert call['genotype'] == [0, 1]

        alt1 = ProbeCoverage(min_depth=1,
                             percent_coverage=100,
                             median_depth=100)
        alternate_coverages = [alt1]
        v1 = VariantProbeCoverage(var_name="A123T",
                                  reference_coverage=reference_coverage,
                                  alternate_coverages=alternate_coverages)

        call = self.vt_no_contaim.type(v1)
        assert call['genotype'] == [0, 0]
Exemplo n.º 2
0
    def test_simple_case(self):
        reference_coverage = ProbeCoverage(min_depth=100,
                                           percent_coverage=100,
                                           median_depth=80)
        alt1 = ProbeCoverage(min_depth=100,
                             percent_coverage=50,
                             median_depth=20)
        alt2 = ProbeCoverage(min_depth=100,
                             percent_coverage=40,
                             median_depth=80)
        alternate_coverages = [alt1, alt2]
        v1 = VariantProbeCoverage(var_name="A123T",
                                  reference_coverage=reference_coverage,
                                  alternate_coverages=alternate_coverages)

        reference_coverage = ProbeCoverage(min_depth=100,
                                           percent_coverage=80,
                                           median_depth=80)
        alt1 = ProbeCoverage(min_depth=100,
                             percent_coverage=50,
                             median_depth=20)
        alt2 = ProbeCoverage(min_depth=100,
                             percent_coverage=100,
                             median_depth=80)

        alternate_coverages = [alt1, alt2]

        v2 = VariantProbeCoverage(var_name="A123T",
                                  reference_coverage=reference_coverage,
                                  alternate_coverages=alternate_coverages)

        call = self.vt_no_contaim.type([v1, v2])
        assert call['genotype'] == [1, 1]
Exemplo n.º 3
0
    def _parse_variant_panel(self, row):
        allele, median_depth, min_depth, percent_coverage, k_count = self._parse_summary_covgs_row(
            row)
        params = get_params(allele)
        if 'var_name' in params:
            var_name = params.get('var_name')
        else:
            var_name = allele.split('?')[0].split('-')[1]

        num_alts = int(params.get("num_alts", 0))
        reference_coverages = [
            ProbeCoverage(percent_coverage=percent_coverage,
                          median_depth=median_depth,
                          min_depth=min_depth,
                          k_count=k_count)
        ]
        alt_or_ref = 'ref'
        alternate_coverages = []
        for i in range(num_alts - 1):
            row = next(self.reader)
            ref_allele, median_depth, min_depth, percent_coverage, k_count = self._parse_summary_covgs_row(
                row)
            if ref_allele.split('-')[0] != 'ref':
                logger.warning("Fewer ref alleles than alt alleles for %s" %
                               ref_allele)
                alternate_coverages.append(
                    ProbeCoverage(min_depth=min_depth,
                                  k_count=k_count,
                                  percent_coverage=percent_coverage,
                                  median_depth=median_depth))
                num_alts -= 1
                break

            assert ref_allele.split('-')[0] == 'ref'
            reference_coverages.append(
                ProbeCoverage(percent_coverage=percent_coverage,
                              median_depth=median_depth,
                              min_depth=min_depth,
                              k_count=k_count))
        for i in range(num_alts):
            row = next(self.reader)
            alt_allele, median_depth, min_depth, percent_coverage, k_count = self._parse_summary_covgs_row(
                row)
            assert alt_allele.split('-')[0] == 'alt'
            alternate_coverages.append(
                ProbeCoverage(min_depth=min_depth,
                              k_count=k_count,
                              percent_coverage=percent_coverage,
                              median_depth=median_depth))
        variant_probe_coverage = VariantProbeCoverage(
            reference_coverages=reference_coverages,
            alternate_coverages=alternate_coverages,
            var_name=var_name,
            params=params)
        try:
            self.variant_covgs[allele].append(variant_probe_coverage)
        except KeyError:
            self.variant_covgs[allele] = [variant_probe_coverage]
Exemplo n.º 4
0
    def test_simple_case(self):
        reference_coverage = ProbeCoverage(min_depth=100,
                                           percent_coverage=70,
                                           median_depth=80)
        alt1 = ProbeCoverage(min_depth=100,
                             percent_coverage=70,
                             median_depth=20)
        alt2 = ProbeCoverage(min_depth=100,
                             percent_coverage=100,
                             median_depth=80)
        alternate_coverages = [alt1, alt2]
        v1 = VariantProbeCoverage(var_name="A123T",
                                  reference_coverage=reference_coverage,
                                  alternate_coverages=alternate_coverages)
        assert v1._choose_best_alternate_coverage() == alt2

        call = self.vt_no_contaim.type(v1)
        assert call['genotype'] == [1, 1]
Exemplo n.º 5
0
 def test_mixed_vars2(self):
     reference_coverage = ProbeCoverage(min_depth=11,
                                        percent_coverage=100,
                                        median_depth=42)
     alternate_coverages = [
         ProbeCoverage(min_depth=94, percent_coverage=100, median_depth=102)
     ]
     v1 = VariantProbeCoverage(var_name="A123T",
                               reference_coverage=reference_coverage,
                               alternate_coverages=alternate_coverages)
     call = self.vt.type(v1)
     assert call['genotype'] == [0, 1]
Exemplo n.º 6
0
    def test_2(self):
        reference_coverage = ProbeCoverage(min_depth=131,
                                           percent_coverage=95.2381,
                                           median_depth=155)
        alt1 = ProbeCoverage(min_depth=1, percent_coverage=100, median_depth=1)
        alternate_coverages = [alt1]
        v1 = VariantProbeCoverage(var_name="A123T",
                                  reference_coverage=reference_coverage,
                                  alternate_coverages=alternate_coverages)

        call = self.vt_no_contaim.type(v1)
        assert call['genotype'] == [0, 0]
        assert call["info"]["filter"] != "PASS"
Exemplo n.º 7
0
 def test_wt_vars(self):
     reference_coverage = ProbeCoverage(min_depth=100,
                                        percent_coverage=100,
                                        median_depth=100)
     alternate_coverages = [
         ProbeCoverage(min_depth=100, percent_coverage=3, median_depth=100)
     ]
     v1 = VariantProbeCoverage(var_name="A123T",
                               reference_coverage=reference_coverage,
                               alternate_coverages=alternate_coverages)
     call = self.vt.type([v1])
     assert call['genotype'] == [0, 0]
     assert call["info"].get('expected_depths') == [100]
Exemplo n.º 8
0
 def test_alt_vars(self):
     reference_coverage = ProbeCoverage(min_depth=100,
                                        percent_coverage=3,
                                        median_depth=100)
     alternate_coverages = [
         ProbeCoverage(min_depth=100,
                       percent_coverage=100,
                       median_depth=100)
     ]
     v1 = VariantProbeCoverage(var_name="A123T",
                               reference_coverage=reference_coverage,
                               alternate_coverages=alternate_coverages)
     call = self.vt.type([v1])
     assert call['genotype'] == [1, 1]
Exemplo n.º 9
0
    def test_3(self):
        reference_coverage = ProbeCoverage(min_depth=2,
                                           percent_coverage=59.52,
                                           median_depth=2)
        alt1 = ProbeCoverage(min_depth=1,
                             percent_coverage=83.33,
                             median_depth=1)
        alternate_coverages = [alt1]
        v1 = VariantProbeCoverage(var_name="A123T",
                                  reference_coverage=reference_coverage,
                                  alternate_coverages=alternate_coverages)

        call = self.vt2_no_contaim.type(v1)
        assert call['genotype'] == [1, 1]
        assert call["info"]["filter"] != "PASS"
Exemplo n.º 10
0
    def test_4(self):
        vt = VariantTyper(expected_depths=[6],
                          contamination_depths=[],
                          confidence_threshold=3)
        reference_coverage = ProbeCoverage(min_depth=1,
                                           percent_coverage=100,
                                           median_depth=2)
        alt1 = ProbeCoverage(min_depth=1, percent_coverage=100, median_depth=1)
        alternate_coverages = [alt1]
        v1 = VariantProbeCoverage(var_name="A123T",
                                  reference_coverage=reference_coverage,
                                  alternate_coverages=alternate_coverages)

        call = vt.type(v1)
        assert call['genotype'] == [0, 1]
        assert call["info"]["filter"] == "LOW_GT_CONF"