// -*- mode: c++; indent-tabs-mode: nil; -*- // // Copyright 2009 Illumina, Inc. // // This software is covered by the "Illumina Genome Analyzer Software // License Agreement" and the "Illumina Source Code License Agreement", // and certain third party copyright/licenses, and any user of this // source file is bound by the terms therein (see accompanying files // Illumina_Genome_Analyzer_Software_License_Agreement.pdf and // Illumina_Source_Code_License_Agreement.pdf and third party // copyright/license notices). // // /// \file /// \author Chris Saunders /// #include "starling_indel_call_pprob_digt.hh" #include "blt_util/math_util.hh" #include #include #include #include #include #ifdef DEBUG_INDEL_CALL #include "blt_util/log.hh" #endif /// find more accurate complement of posterior_probability: static double prob_comp(const double* const dindel_prob, const unsigned cgt){ double val(0.); for(unsigned gt(0);gtsecond); // get alt path lnp: double alt_path_lnp(path_lnp.ref); if(is_use_alt_indel and (not path_lnp.alt_indel.empty()) ) { aiter j(path_lnp.alt_indel.begin()), j_end(path_lnp.alt_indel.end()); for(;j!=j_end;++j){ if(j->second>alt_path_lnp) alt_path_lnp=j->second; } } const double noindel_lnp(log_sum(alt_path_lnp+ref_real_lnp,path_lnp.indel+indel_error_lnp)); const double hom_lnp(log_sum(alt_path_lnp+ref_error_lnp,path_lnp.indel+indel_real_lnp)); double log_ref_prob(loghalf); double log_indel_prob(loghalf); if(is_corrected_het_ratio and (not is_breakpoint)) { // get expected het ratio const unsigned L(path_lnp.read_length); const unsigned B(client_opt.min_read_bp_flank); const unsigned spath_expect((2*B)>(L+1) ? 0 : (L+1)-(2*B) ); const unsigned total_expect((2*spath_expect)+std::min(ik.length,spath_expect)); if(total_expect>0){ const double spath_prob(static_cast(spath_expect)/static_cast(total_expect)); const double lpath_prob(1.-spath_prob); if(ik.type==INDEL::INSERT) { log_ref_prob=std::log(spath_prob); log_indel_prob=std::log(lpath_prob); } else if(ik.type==INDEL::DELETE){ log_ref_prob=std::log(lpath_prob); log_indel_prob=std::log(spath_prob); } else { assert(0); //unexpected indel type } } } const double het_lnp(log_sum(noindel_lnp+log_ref_prob,hom_lnp+log_indel_prob)); lhood[STAR_DIINDEL::NOINDEL] += integrate_out_sites(client_dopt,path_lnp.nonsite,noindel_lnp); lhood[STAR_DIINDEL::HOM] += integrate_out_sites(client_dopt,path_lnp.nonsite,hom_lnp); lhood[STAR_DIINDEL::HET] += integrate_out_sites(client_dopt,path_lnp.nonsite,het_lnp); #ifdef DEBUG_INDEL_CALL log_os << std::setprecision(8); log_os << "INDEL_CALL i,ref_lnp,indel_lnp,lhood(noindel),lhood(hom),lhood(het): " << i << " " << path_lnp.ref << " " << path_lnp.indel << " " << lhood[STAR_DIINDEL::NOINDEL] << " " << lhood[STAR_DIINDEL::HOM] << " " << lhood[STAR_DIINDEL::HET] << "\n"; #endif } // mult by prior distro to get unnormalized pprob: const double* lnprior(client_dopt.diploid_indel_state_lnprior); for(unsigned gt(0);gt max){ max2 = max; max = dindel.pprob[gt]; dindel.max2_gt = dindel.max_gt; dindel.max_gt = gt; } else if(dindel.pprob[gt] > max2) { max2 = dindel.pprob[gt]; dindel.max2_gt = gt; } } double sum(0.); for(unsigned gt(0);gt