コード例 #1
0
// Calculate the expected ratio of reads observed to support each
// allele. Note that for sites and single breakpoints this is expected
// to match the sample allele ratio, however for indels this can
// change as a funciton of indel and read length.
//
// Note this routine does not accoung for overlapping indels
//
static
void
get_het_observed_allele_ratio(const unsigned read_length,
                              const unsigned min_overlap,
                              const indel_key& ik,
                              const double het_allele_ratio,
                              double& log_ref_prob,
                              double& log_indel_prob) {

    assert((ik.type==INDEL::INSERT) ||
           (ik.type==INDEL::DELETE) ||
           (ik.type == INDEL::SWAP));

    // the expected relative read depth for two breakpoints separated by a distance of 0:
    const unsigned base_expect( (read_length+1)<(2*min_overlap) ? 0 : (read_length+1)-(2*min_overlap) );

    // Get expected relative read depth for the shorter and longer
    // paths of a general sequence replacement. Note this includes
    // basic insertions and deletions, in these cases
    // spath_break_distance is 0 and spath_expect equals base_expect:
    //
    const double ref_path_expect(base_expect+std::min(ik.delete_length(),base_expect));
    const double indel_path_expect(base_expect+std::min(ik.insert_length(),base_expect));
    const double ref_path_term((1-het_allele_ratio)*ref_path_expect);
    const double indel_path_term(het_allele_ratio*indel_path_expect);
    const double total_path_term(ref_path_term+indel_path_term);

    if (total_path_term>0) {
        const double indel_prob(indel_path_term/total_path_term);
        log_ref_prob=std::log(1.-indel_prob);
        log_indel_prob=std::log(indel_prob);
    }
}
コード例 #2
0
/// get the indel cigar and ref and indel strings used in the indel
/// summary line output
///
static
void
get_vcf_summary_strings(const indel_key& ik,
                        const indel_data& id,
                        const reference_contig_segment& ref,
                        std::string& vcf_indel_seq,
                        std::string& vcf_ref_seq) {

    if       (ik.is_breakpoint()) {
        if       (ik.type == INDEL::BP_LEFT) {
            copy_ref_subseq(ref,ik.pos-1,ik.pos,vcf_ref_seq);
            vcf_indel_seq = vcf_ref_seq + id.get_insert_seq() + '.';
        } else if(ik.type == INDEL::BP_RIGHT) {
            copy_ref_subseq(ref,ik.pos,ik.pos+1,vcf_ref_seq);
            vcf_indel_seq = '.' + id.get_insert_seq() + vcf_ref_seq;
        } else {
            assert(0);
        }
    } else {
        copy_ref_subseq(ref,ik.pos-1,ik.pos+ik.delete_length(),vcf_ref_seq);
        copy_ref_subseq(ref,ik.pos-1,ik.pos,vcf_indel_seq);
        vcf_indel_seq += id.get_insert_seq();
    }
}