예제 #1
0
    def from_pileup_units(cls, raw_tumor_ref_units, raw_tumor_obs_units, raw_normal_ref_units, raw_normal_obs_units):
        v = HeterozygousGermlineVariant()
        params = settings.hetero_germline_variant
        variant_key = raw_tumor_obs_units[0].key()

        tumor_ref_units = pileup_unit.filter_by_base_quality(raw_tumor_ref_units, settings.base_quality_threshold)
        tumor_obs_units = pileup_unit.filter_by_base_quality(raw_tumor_obs_units, settings.base_quality_threshold)
        normal_ref_units = pileup_unit.filter_by_base_quality(raw_normal_ref_units, settings.base_quality_threshold)
        normal_obs_units = pileup_unit.filter_by_base_quality(raw_normal_obs_units, settings.base_quality_threshold)

        v.tumor_ref_count = pileup_unit.get_depth_without_indel(tumor_ref_units)
        v.normal_ref_count = pileup_unit.get_depth_without_indel(normal_ref_units)
        v.tumor_obs_count = len(tumor_obs_units)
        v.normal_obs_count = len(normal_obs_units)

        if not (v.tumor_obs_count >= settings.min_variant_supporting_reads):
            raise common.TooFewVariantReadsError

        if not (v.normal_obs_count >= settings.min_variant_supporting_reads):
            raise common.TooFewVariantReadsError

        tumor_depth = pileup_unit.get_depth_without_indel(tumor_ref_units + tumor_obs_units)
        if tumor_depth < settings.min_depth:
            raise common.LowDepthError

        v.tumor_freq = float(v.tumor_obs_count) / tumor_depth
        if not (params.min_freq <= v.tumor_freq <= params.max_freq):
            raise common.AlleleFreqOutOfRangeError

        v.tumor_strand = pileup_unit.calc_strand_freq(tumor_obs_units)
        if not (params.min_strand_freq <= v.tumor_strand <= params.max_strand_freq):
            raise common.StrandFreqOutOfRangeError

        normal_depth = pileup_unit.get_depth_without_indel(normal_ref_units + normal_obs_units)
        if normal_depth < settings.min_depth:
            raise common.LowDepthError

        v.normal_freq = float(v.normal_obs_count) / normal_depth
        if not (params.min_freq <= v.normal_freq <= params.max_freq):
            raise common.AlleleFreqOutOfRangeError

        v.normal_strand = pileup_unit.calc_strand_freq(normal_obs_units)
        if not (params.min_strand_freq <= v.normal_strand <= params.max_strand_freq):
            raise common.StrandFreqOutOfRangeError

        v.tumor_ref_avg_base_quality = pileup_unit.calc_avg_base_quality(raw_tumor_ref_units)
        v.tumor_obs_avg_base_quality = pileup_unit.calc_avg_base_quality(raw_tumor_obs_units)
        v.normal_ref_avg_base_quality = pileup_unit.calc_avg_base_quality(raw_normal_ref_units)
        v.normal_obs_avg_base_quality = pileup_unit.calc_avg_base_quality(raw_normal_obs_units)

        for avg_bq in [v.tumor_ref_avg_base_quality,
                       v.tumor_obs_avg_base_quality,
                       v.normal_ref_avg_base_quality,
                       v.normal_obs_avg_base_quality]:
            if avg_bq is not None and not (params.min_avg_base_quality <= avg_bq):
                raise common.LowBaseQualityError(u"low_avg_base_quality({0} < {1})".format(avg_bq, params.min_avg_base_quality))

        return v
예제 #2
0
    def from_pileup_units(cls, raw_tumor_ref_units, raw_tumor_obs_units, raw_normal_ref_units, raw_normal_obs_units):
        v = SomaticVariant()
        params = settings.somatic_variant

        tumor_ref_units = pileup_unit.filter_by_base_quality(raw_tumor_ref_units, settings.base_quality_threshold)
        tumor_obs_units = pileup_unit.filter_by_base_quality(raw_tumor_obs_units, settings.base_quality_threshold)
        normal_ref_units = pileup_unit.filter_by_base_quality(raw_normal_ref_units, settings.base_quality_threshold)
        normal_obs_units = pileup_unit.filter_by_base_quality(raw_normal_obs_units, settings.base_quality_threshold)

        v.tumor_ref_count = pileup_unit.get_depth_without_indel(tumor_ref_units)
        v.normal_ref_count = pileup_unit.get_depth_without_indel(normal_ref_units)
        v.tumor_obs_count = len(tumor_obs_units)
        v.normal_obs_count = len(normal_obs_units)

        if not (v.tumor_obs_count >= settings.min_variant_supporting_reads):
            raise common.TooFewVariantReadsError

        if not (v.normal_obs_count <= params.max_variant_supporting_reads_normal):
            raise common.TooManyNormalVariantReadsError

        tumor_depth = pileup_unit.get_depth_without_indel(tumor_ref_units + tumor_obs_units)
        if tumor_depth < settings.min_depth:
            raise common.LowDepthError


        v.tumor_freq = float(v.tumor_obs_count) / tumor_depth
        if not (params.min_tumor_freq <= v.tumor_freq):
            if params.sufficient_num_variant_reads is not None\
                and v.tumor_obs_count < params.sufficient_num_variant_reads:
                raise common.AlleleFreqOutOfRangeError

        v.tumor_strand = pileup_unit.calc_strand_freq(tumor_obs_units)
        if not (params.min_strand_freq <= v.tumor_strand <= params.max_strand_freq):
            raise common.StrandFreqOutOfRangeError

        normal_depth = pileup_unit.get_depth_without_indel(normal_ref_units + normal_obs_units)
        if normal_depth < settings.min_depth:
            raise common.LowDepthError

        v.normal_freq = float(v.normal_obs_count) / normal_depth
        if not (v.normal_freq <= params.max_normal_freq):
            raise common.AlleleFreqOutOfRangeError

        v.normal_strand = pileup_unit.calc_strand_freq(normal_obs_units)

        v.tumor_ref_avg_base_quality = pileup_unit.calc_avg_base_quality(raw_tumor_ref_units)
        v.tumor_obs_avg_base_quality = pileup_unit.calc_avg_base_quality(raw_tumor_obs_units)
        v.normal_ref_avg_base_quality = pileup_unit.calc_avg_base_quality(raw_normal_ref_units)
        v.normal_obs_avg_base_quality = pileup_unit.calc_avg_base_quality(raw_normal_obs_units)

        for avg_bq in [v.tumor_ref_avg_base_quality,
                       v.tumor_obs_avg_base_quality,
                       v.normal_ref_avg_base_quality]:
            if avg_bq is not None and not (params.min_avg_base_quality <= avg_bq):
                raise common.LowBaseQualityError(u"low_avg_base_quality({0} < {1}".format(avg_bq, params.min_avg_base_quality))

        return v
예제 #3
0
    def from_pileup_units(cls, raw_tumor_ref_units, raw_tumor_obs_units,
                          raw_normal_ref_units, raw_normal_obs_units):
        v = HeterozygousGermlineVariant()
        params = settings.hetero_germline_variant
        variant_key = raw_tumor_obs_units[0].key()

        tumor_ref_units = pileup_unit.filter_by_base_quality(
            raw_tumor_ref_units, settings.base_quality_threshold)
        tumor_obs_units = pileup_unit.filter_by_base_quality(
            raw_tumor_obs_units, settings.base_quality_threshold)
        normal_ref_units = pileup_unit.filter_by_base_quality(
            raw_normal_ref_units, settings.base_quality_threshold)
        normal_obs_units = pileup_unit.filter_by_base_quality(
            raw_normal_obs_units, settings.base_quality_threshold)

        v.tumor_ref_count = pileup_unit.get_depth_without_indel(
            tumor_ref_units)
        v.normal_ref_count = pileup_unit.get_depth_without_indel(
            normal_ref_units)
        v.tumor_obs_count = len(tumor_obs_units)
        v.normal_obs_count = len(normal_obs_units)

        if not (v.tumor_obs_count >= settings.min_variant_supporting_reads):
            raise common.TooFewVariantReadsError

        if not (v.normal_obs_count >= settings.min_variant_supporting_reads):
            raise common.TooFewVariantReadsError

        tumor_depth = pileup_unit.get_depth_without_indel(tumor_ref_units +
                                                          tumor_obs_units)
        if tumor_depth < settings.min_depth:
            raise common.LowDepthError

        v.tumor_freq = float(v.tumor_obs_count) / tumor_depth
        if not (params.min_freq <= v.tumor_freq <= params.max_freq):
            raise common.AlleleFreqOutOfRangeError

        v.tumor_strand = pileup_unit.calc_strand_freq(tumor_obs_units)
        if not (params.min_strand_freq <= v.tumor_strand <=
                params.max_strand_freq):
            raise common.StrandFreqOutOfRangeError

        normal_depth = pileup_unit.get_depth_without_indel(normal_ref_units +
                                                           normal_obs_units)
        if normal_depth < settings.min_depth:
            raise common.LowDepthError

        v.normal_freq = float(v.normal_obs_count) / normal_depth
        if not (params.min_freq <= v.normal_freq <= params.max_freq):
            raise common.AlleleFreqOutOfRangeError

        v.normal_strand = pileup_unit.calc_strand_freq(normal_obs_units)
        if not (params.min_strand_freq <= v.normal_strand <=
                params.max_strand_freq):
            raise common.StrandFreqOutOfRangeError

        v.tumor_ref_avg_base_quality = pileup_unit.calc_avg_base_quality(
            raw_tumor_ref_units)
        v.tumor_obs_avg_base_quality = pileup_unit.calc_avg_base_quality(
            raw_tumor_obs_units)
        v.normal_ref_avg_base_quality = pileup_unit.calc_avg_base_quality(
            raw_normal_ref_units)
        v.normal_obs_avg_base_quality = pileup_unit.calc_avg_base_quality(
            raw_normal_obs_units)

        for avg_bq in [
                v.tumor_ref_avg_base_quality, v.tumor_obs_avg_base_quality,
                v.normal_ref_avg_base_quality, v.normal_obs_avg_base_quality
        ]:
            if avg_bq is not None and not (params.min_avg_base_quality <=
                                           avg_bq):
                raise common.LowBaseQualityError(
                    u"low_avg_base_quality({0} < {1})".format(
                        avg_bq, params.min_avg_base_quality))

        return v
예제 #4
0
    def from_pileup_units(cls, raw_tumor_ref_units, raw_tumor_obs_units,
                          raw_normal_ref_units, raw_normal_obs_units):
        v = SomaticVariant()
        params = settings.somatic_variant

        tumor_ref_units = pileup_unit.filter_by_base_quality(
            raw_tumor_ref_units, settings.base_quality_threshold)
        tumor_obs_units = pileup_unit.filter_by_base_quality(
            raw_tumor_obs_units, settings.base_quality_threshold)
        normal_ref_units = pileup_unit.filter_by_base_quality(
            raw_normal_ref_units, settings.base_quality_threshold)
        normal_obs_units = pileup_unit.filter_by_base_quality(
            raw_normal_obs_units, settings.base_quality_threshold)

        v.tumor_ref_count = pileup_unit.get_depth_without_indel(
            tumor_ref_units)
        v.normal_ref_count = pileup_unit.get_depth_without_indel(
            normal_ref_units)
        v.tumor_obs_count = len(tumor_obs_units)
        v.normal_obs_count = len(normal_obs_units)

        if not (v.tumor_obs_count >= settings.min_variant_supporting_reads):
            raise common.TooFewVariantReadsError

        if not (v.normal_obs_count <=
                params.max_variant_supporting_reads_normal):
            raise common.TooManyNormalVariantReadsError

        tumor_depth = pileup_unit.get_depth_without_indel(tumor_ref_units +
                                                          tumor_obs_units)
        if tumor_depth < settings.min_depth:
            raise common.LowDepthError

        v.tumor_freq = float(v.tumor_obs_count) / tumor_depth
        if not (params.min_tumor_freq <= v.tumor_freq):
            if params.sufficient_num_variant_reads is not None\
                and v.tumor_obs_count < params.sufficient_num_variant_reads:
                raise common.AlleleFreqOutOfRangeError

        v.tumor_strand = pileup_unit.calc_strand_freq(tumor_obs_units)
        if not (params.min_strand_freq <= v.tumor_strand <=
                params.max_strand_freq):
            raise common.StrandFreqOutOfRangeError

        normal_depth = pileup_unit.get_depth_without_indel(normal_ref_units +
                                                           normal_obs_units)
        if normal_depth < settings.min_depth:
            raise common.LowDepthError

        v.normal_freq = float(v.normal_obs_count) / normal_depth
        if not (v.normal_freq <= params.max_normal_freq):
            raise common.AlleleFreqOutOfRangeError

        v.normal_strand = pileup_unit.calc_strand_freq(normal_obs_units)

        v.tumor_ref_avg_base_quality = pileup_unit.calc_avg_base_quality(
            raw_tumor_ref_units)
        v.tumor_obs_avg_base_quality = pileup_unit.calc_avg_base_quality(
            raw_tumor_obs_units)
        v.normal_ref_avg_base_quality = pileup_unit.calc_avg_base_quality(
            raw_normal_ref_units)
        v.normal_obs_avg_base_quality = pileup_unit.calc_avg_base_quality(
            raw_normal_obs_units)

        for avg_bq in [
                v.tumor_ref_avg_base_quality, v.tumor_obs_avg_base_quality,
                v.normal_ref_avg_base_quality
        ]:
            if avg_bq is not None and not (params.min_avg_base_quality <=
                                           avg_bq):
                raise common.LowBaseQualityError(
                    u"low_avg_base_quality({0} < {1}".format(
                        avg_bq, params.min_avg_base_quality))

        return v