double
get_hapscore(hap_set_t& hap_set) {

    std::sort(hap_set.begin(),hap_set.end());

    std::vector<hinfo> haps;

    typedef hap_set_t::const_iterator hiter;
    {
        hiter i(hap_set.begin()), i_end(hap_set.end());
        for (; i!=i_end; ++i) {
            // 1: check if we match any types; add new type if not
            bool is_match(false);
            const unsigned hs(haps.size());
            for (unsigned j(0); j<hs; ++j) {
                if (is_hap_match(*i,haps[j])) {
                    is_match=true;
                    break;
                }
            }
            if (! is_match) haps.push_back(hinfo(*i));
        }
    }

    const bool is_2hap(haps.size()>1);

    // 2: get two most likely haplotypes:
    if (is_2hap) {
        std::partial_sort(haps.begin(),haps.begin()+2,haps.end());
    }

    // 3: calculate average read alignment score restricted to two best haplotypes:
    //static const double neginf(std::log(0));
    double ln2hapratio(0);
    {
        hiter i(hap_set.begin()), i_end(hap_set.end());
        for (; i!=i_end; ++i) {
            double als(get_align_score(*i,haps[0]));
            if (is_2hap) {
                als=std::max(als,get_align_score(*i,haps[1]));
            }
            //ln2hapratio = log_sum(ln2hapratio,als);
            ln2hapratio += als;
        }

        // target is log(avg(read_prob_ratio)), not avg(log(read_prob_ratio)):
        //
        //ln2hapratio -= std::log(static_cast<double>(hap_set.size()));
        ln2hapratio /= static_cast<double>(hap_set.size());
    }

    return ln2hapratio;
}
//-------------------------------------------------------------------------------
// General dumping methods -- dumping relevant parts of ontology
//-------------------------------------------------------------------------------
void TBox :: dump ( dumpInterface* dump ) const
{
	dump->prologue();

	// dump all (relevant) roles
	dumpAllRoles(dump);

	// dump all (relevant) concepts
	for ( c_const_iterator pc = c_begin(); pc != c_end(); ++pc )
		if ( isRelevant(*pc) )
			dumpConcept( dump, *pc );

	for ( i_const_iterator pi = i_begin(); pi != i_end(); ++pi )
		if ( isRelevant(*pi) )
			dumpConcept( dump, *pi );

	// dump GCIs
	if ( getTG() != bpTOP )
	{
		dump->startAx (diImpliesC);
		dump->dumpTop();
		dump->contAx (diImpliesC);
		dumpExpression ( dump, getTG() );
		dump->finishAx (diImpliesC);
	}

	dump->epilogue();
}
std::ostream&
operator<<(std::ostream& os,
           const indel_data& id) {
    os << "seq: " << id.get_insert_seq() << "\n";

    report_indel_evidence_set(id.all_read_ids,"all_read",os);
    report_indel_evidence_set(id.contig_ids,"contig",os);
    //    report_indel_evidence_set(id.tier1_map_read_ids,"tier1_map_read",os);
    report_indel_evidence_set(id.tier2_map_read_ids,"tier2_map_read",os);
    report_indel_evidence_set(id.submap_read_ids,"submap_read",os);
    report_indel_evidence_set(id.noise_read_ids,"noise_read",os);

    {
        typedef indel_data::score_t::const_iterator siter;
        siter i(id.read_path_lnp.begin()), i_end(id.read_path_lnp.end());
        for(unsigned n(0); i!=i_end; ++i) {
            os << "read_path_lnp no: " << ++n
               << " id: " << i->first
               << " " << i->second
               << "\n";
        }
    }

    report_indel_evidence_set(id.suboverlap_tier1_read_ids,"suboverlap_tier1_read",os);
    report_indel_evidence_set(id.suboverlap_tier2_read_ids,"suboverlap_tier2_read",os);

    os << "is_external_candidate: " << id.is_external_candidate << "\n";

    return os;
}
std::ostream&
operator<<(std::ostream& os,
           const read_path_scores& rps) {

    os << "ref: " << rps.ref
       << " indel: " << rps.indel
       << " nsite: " << rps.nsite;

#if 0
    if(rps.is_alt) {
        os << " alt: " << rps.alt;
    }
#else
    typedef read_path_scores::alt_indel_t::const_iterator aiter;
    aiter i(rps.alt_indel.begin()), i_end(rps.alt_indel.end());
    for(; i!=i_end; ++i) {
        const indel_key& ik(i->first);
        os << " alt-" << ik.pos << "-" << INDEL::get_index_label(ik.type) << ik.length << ": " << i->second;
    }
#endif

    os << " ist1?: " << rps.is_tier1_read;

    return os;
}
int
main(int, char*[])
{
  // This is a simple example of using the transform_iterators class to
  // generate iterators that multiply the value returned by dereferencing
  // the iterator. In this case we are multiplying by 2.
  // Would be cooler to use lambda library in this example.

  int x[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
  const int N = sizeof(x)/sizeof(int);

  typedef boost::binder1st< std::multiplies<int> > Function;
  typedef boost::transform_iterator_generator<Function, int*>::type doubling_iterator;

  doubling_iterator i(x, boost::bind1st(std::multiplies<int>(), 2)),
    i_end(x + N, boost::bind1st(std::multiplies<int>(), 2));

  std::cout << "multiplying the array by 2:" << std::endl;
  while (i != i_end)
    std::cout << *i++ << " ";
  std::cout << std::endl;

  std::cout << "adding 4 to each element in the array:" << std::endl;

  std::copy(boost::make_transform_iterator(x, boost::bind1st(std::plus<int>(), 4)),
            boost::make_transform_iterator(x + N, boost::bind1st(std::plus<int>(), 4)),
            std::ostream_iterator<int>(std::cout, " "));
  std::cout << std::endl;
  
  return 0;
}
void
dump_indel_set(const indel_set_t& is,
               std::ostream& os) {

    indel_set_t::const_iterator i(is.begin()), i_end(is.end());
    for (; i!=i_end; ++i) os << *i;
}
// debug dumpers:
void
pos_basecall_buffer::
dump(std::ostream& os) const {

    pciter i(_pdata.begin()), i_end(_pdata.end());
    for(; i!=i_end; ++i) {
        os << "pc_buff pos: " << i->first << "\n";
    }
}
void
stage_data::
dump(std::ostream& os) const {
    typedef stage_pos_t::const_iterator siter;

    os << "stage_pos:\n";
    siter i(_stage_pos.begin()), i_end(_stage_pos.end());
    for (; i!=i_end; ++i) {
        os << "pos: " << i->first << " id: " << i->second << "\n";
    }
}
static
void
report_indel_evidence_set(const indel_data::evidence_t& e,
                          const char* label,
                          std::ostream& os) {
    typedef indel_data::evidence_t::const_iterator viter;
    viter i(e.begin()),i_end(e.end());
    for(unsigned n(0); i!=i_end; ++i) {
        os << label << " no: " << ++n << " id: " << *i << "\n";
    }
}
void
htype_buffer::
dump(std::ostream& os) const {

    os << "Haplotype buffer dump ON\n";
    const_iterator i(_hdata.begin()),i_end(_hdata.end());
    for (; i!=i_end; ++i) {
        os << i->first << " count: " << i->second << "\n";
    }
    os << "Haplotype buffer dump OFF\n";
}
uint8_t BayGPRSInterface::changeIPR(long baud) {
	_baud = baud;
	long t_baud[] = { baud, 9600, 38400, 57600 };
	for (uint8_t i = 0; i < 4; i++) {
		i_begin(t_baud[i]);
		skipChars();
		printP("AT"); //Will autoconfigure BAUD-Rate - Auto BAUD-Rate did not work with Sleep-Mode!
		delay(100);
		println();
		printP("AT+IPR=");
		println(_baud);
		if (!wait_forOK(200)) {
			i_end();
			i_begin(_baud);
			return 0;
		}
		i_end();
	}
	return 1;

}
void
TBox :: answerQuery ( const std::vector<DLTree*>& Cs )
{
	DLHeap.removeQuery();
	std::cout << "Transforming concepts...";
	// create BPs for all the concepts
	concepts.clear();
	for ( std::vector<DLTree*>::const_iterator q = Cs.begin(), q_end = Cs.end(); q != q_end; ++q )
		concepts.push_back(tree2dag(*q));
	std::cout << " done" << std::endl << "Filling all individuals...";

	// all individuals to go thru
	std::vector<TIndividual*> AllInd;
	for ( i_iterator i = i_begin(), i_e = i_end(); i != i_e; i++ )
		AllInd.push_back(*i);

	std::cout << " done with " << AllInd.size() << " individuals" << std::endl;
	size_t size = Cs.size();

	std::cout << "Creating iterables...";
	IV.clear();
	for ( size_t j = 0; j < size; j++ )
		IV.add(new Iterable<TIndividual*>(AllInd));
	std::cout << " done\n";

	std::cout << "Run consistency checks...";

	size_t n = 0, nAns = 0;
	TsProcTimer timer;
	timer.Start();
	do
	{
		if ( n++ % 100 == 0 )
		{
			float time = timer;
			std::cout << n << " tries, " << nAns << " answers, " << time << " total time, " << time/n << " avg time" << std::endl;
		}
		if ( static_cast<NominalReasoner*>(nomReasoner)->checkExtraCond() )
		{
			for ( size_t k = 0; k < size; k++ )
				std::cout << IV.get(k)->getName() << " ";
			std::cout << "\n";
		}
	} while ( !IV.next() );
	timer.Stop();
	std::cout << "Total " << n << " tries, " << nAns << " answers, " << timer << " total time, " << timer/n << " avg time" << std::endl;
}
ordinal_type
Stokhos::Sparse3Tensor<ordinal_type, value_type>::
num_entries() const
{
#ifdef STOKHOS_DEBUG
  TEUCHOS_TEST_FOR_EXCEPTION(fill_completed == false, std::logic_error,
		     "You must call fillComplete() before calling num_entries()!");
#endif

  ordinal_type num = 0;
  for (k_iterator k = k_begin(); k != k_end(); ++k)
    for (kj_iterator j = j_begin(k); j != j_end(k); ++j)
      for (kji_iterator i = i_begin(j); i != i_end(j); ++i)
	++num;

  return num;
}
void
Stokhos::Sparse3Tensor<ordinal_type, value_type>::
print(std::ostream& os) const
{
#ifdef STOKHOS_DEBUG
  TEUCHOS_TEST_FOR_EXCEPTION(fill_completed == false, std::logic_error,
		     "You must call fillComplete() before calling print()!");
#endif

  for (k_iterator k=k_begin(); k!=k_end(); ++k)
    for (kj_iterator j=j_begin(k); j!=j_end(k); ++j)
      for (kji_iterator i=i_begin(j); i!=i_end(j); ++i)
	os << "k = " << index(k) 
	   << ", j = " << index(j) 
	   << ", i = " << index(i) 
	   << ", Cijk = " << value(i) << std::endl;
}
Exemple #15
0
void e () {
     i_local_t a,b,c,d,e,f,g,h,i,j,k,l;
     int (*ip)(int (*)(int,int),int,int,int,int,int,int,int,int,int);
     
     i_init(100);

     a = i_paramk(I_I,1);
     b = i_paramk(I_I,2);
     c = i_param(I_I);
     d = i_param(I_I);
     e = i_param(I_I);
     g = i_param(I_I);
     h = i_param(I_I);
     i = i_param(I_I);
     j = i_param(I_I);
     k = i_local(0,I_I);
     l = i_local(0,I_I);
     f = i_paramk(I_P,0);

     i_argi(a);
     i_argi(b);
     i_calli(k, f);
     i_argi(c);
     i_argi(d);
     i_calli(d, f);
     i_addi(k,k,d);
     i_argi(e);
     i_argi(g);
     i_calli(g, f);
     i_addi(k,k,g);
     i_argi(h);
     i_argi(i);
     i_calli(i, f);
     i_addi(k,k,i);
     i_addi(k,k,j);
     i_addii(l,k,3);
     i_reti(l);
     i_end();

     i_unparse();
     ip = (int (*)(int (*)(int,int),int,int,int,int,int,int,int,int,int))
	  i_emit().i;
     v_dump((void*)ip);
     printf("**48=%d\n", (*ip)(gg,1,2,3,4,5,6,7,8,9));
}
void
insert_seq_manager::
finalize() {
    obs_t::const_iterator i(_obs.begin()), i_end(_obs.end());

    unsigned count(0);
    std::string& candidate(_consensus_seq);

    for(; i!=i_end; ++i) {
        if((i->first.size() > candidate.size()) ||
           ( i->second > count)) {
            candidate = i->first;
            count = i->second;
        }
    }
    _consensus_seq = candidate;
    _obs.clear();
    _is_consensus=true;
}
void
BlockerVcfHeaderHandler::
process_final_header_line() {

    _os << "##INFO=<ID=END,Number=1,Type=Integer,Description=\"End position of the region described in this record\">\n";
    _os << "##INFO=<ID=" << _opt.nvopt.BlockavgLabel 
        << ",Number=0,Type=Flag,Description=\"Non-variant site block."
        << " All sites in a block are constrained to be non-variant, have the same filter value,"
        << " and have all sample values in range [x,y] , y <= max(x+3,(x*(1+" << _opt.nvopt.BlockFracTol << ")))."
        << " All printed site block sample values are the minimum observed in the region spanned by the block\">\n";
            
    // new format tags:
    _os << "##FORMAT=<ID=MQ,Number=1,Type=Integer,Description=\"RMS Mapping Quality\">\n";
    _os << "##FORMAT=<ID=GQX,Number=1,Type=Integer,Description=\"Minimum of {Genotype quality assuming variant position,Genotype quality assuming non-variant position}\">\n";

    // overlap tags:
    _os << "##FILTER=<ID=" << _opt.indel_conflict_label
           << ",Description=\"Locus is in region with conflicting indel calls.\">\n";
    _os << "##FILTER=<ID=" << _opt.site_conflict_label
        << ",Description=\"Site genotype conflicts with proximal indel call. This is typically a heterozygous SNV call made inside of a heterozygous deletion.\">\n";
            
    // special chrom-depth filter tag:
    if(_opt.is_chrom_depth()){
        _os << "##FILTER=<ID=" << _opt.max_chrom_depth_filter_tag
            << ",Description=\"Site depth is greater than " << _opt.max_chrom_depth_filter_factor.strval()
            << "x the mean chromosome depth\">\n";
        BlockerOptions::cdmap_t::const_iterator i(_opt.ChromDepth.begin()), i_end(_opt.ChromDepth.end());
        for(;i!=i_end;++i) {
            const std::string& chrom(i->first);
            const double chrom_thresh(i->second*_opt.max_chrom_depth_filter_factor.numval());
            _os << "##" <<  _opt.max_chrom_depth_filter_tag << "_" << chrom << "=" <<  chrom_thresh << "\n";
        }
    }
            
    // print the rest of the standard filter tags:
    if(NULL != _opt.GQX_filter.get()) {
        print_filter_header(*_opt.GQX_filter,"Locus",_os);
    }
    print_filter_header_set(_opt.filters,_os);
}
static
void
get_htypes_for_indel(const starling_deriv_options& dopt,
                     const starling_read_buffer& rbuff,
                     const reference_contig_segment& ref,
                     const indel_key& ik,
                     const indel_data& id,
                     htype_buffer& hdata) {

    static const bool is_tier2_pass(false);
    static const bool is_use_alt_indel(true);
    static const double include_thresh(0.999);

    typedef indel_data::score_t::const_iterator siter;

    htype_element he;
    siter i(id.read_path_lnp.begin()), i_end(id.read_path_lnp.end());
    for (; i!=i_end; ++i) {
        const align_id_t read_id(i->first);
        const read_path_scores& path_lnp(i->second);
        const read_path_scores pprob(indel_lnp_to_pprob(dopt,path_lnp,is_tier2_pass,is_use_alt_indel));

        if (pprob.indel >= include_thresh) {
            // convert indel to htype_element and insert:
            const starling_read* srptr(rbuff.get_read(read_id));

            /// TODO - add segmented read support
            if (srptr->is_segmented()) {
                log_os << "ERROR: haplotype model does not work for spliced reads\n";
                exit(EXIT_FAILURE);
            }
            const read_segment& rseg(srptr->get_full_segment());

            if (! convert_indel_to_htype(ik,id,rseg,ref,he)) continue;

            hdata.insert_element(he);
        }
    }
}
Exemple #19
0
void b () {
     i_local_t f;
     i_label_t L1;
     v_pptr pp;
     
     i_init(100);

     L1 = i_mklabel();
     f = i_local(0, I_P);
     i_setp(f, gg);
     i_nop();
     i_nop();
     i_nop();
     i_nop();
     i_retp(f);
     i_end();

     i_unparse();
     pp = i_emit().p;
     v_dump((void*)pp);
     printf("**3=%d\n", (*(int (*)(int, int))((*pp)()))(1,2));
}
Exemple #20
0
void d () {
     i_local_t a,b;
     v_iptr ip;
     
     i_init(100);

     a = i_local(0, I_I);
     b = i_local(0, I_I);

     i_seti(a, 1);
     i_seti(b, 2);  
     i_argi(a);
     i_argi(b);
     i_callii(a, gg);
     i_reti(a);
     i_end();

     i_unparse();
     ip = i_emit().i;
     v_dump((void*)ip);
     printf("**3=%d\n", (*ip)());
}
Exemple #21
0
void a () {
     i_local_t a, b, c,d;
     
     i_init(20);

     a = i_local(0, I_I);
     b = i_local(0, I_I);
     c = i_local(0, I_I);
     d = i_local(0, I_I);

     i_seti(a, 5);
     i_seti(b, 7);
     i_seti(c, 8);
     i_movi(d, c);
     i_addi(c, a, b); 
     i_addi(d, d, c); 
     i_reti(d);
     i_end();

     i_unparse();
     i_emitc();
}
value_type
Stokhos::Sparse3Tensor<ordinal_type, value_type>::
getValue(ordinal_type i, ordinal_type j, ordinal_type k) const
{
#ifdef STOKHOS_DEBUG
  TEUCHOS_TEST_FOR_EXCEPTION(fill_completed == false, std::logic_error,
		     "You must call fillComplete() before calling getValue()!");
#endif

  k_iterator k_it = find_k(k);
  if (k_it == k_end())
    return value_type(0);

  kj_iterator j_it = find_j(k_it, j);
  if (j_it == j_end(k_it))
    return value_type(0);

  kji_iterator i_it = find_i(j_it, i);
  if (i_it == i_end(j_it))
    return value_type(0);

  return i_it.value();
}
Exemple #23
0
void TBox :: buildDAG ( void )
{
	nNominalReferences = 0;

	// init concept indexing
	nC = 1;	// start with 1 to make index 0 an indicator of "not processed"
	ConceptMap.push_back(NULL);

	// make fresh concept and datatype
	concept2dag(pTemp);
	DLTree* freshDT = DTCenter.getFreshDataType();
	addDataExprToHeap ( static_cast<TDataEntry*>(freshDT->Element().getNE()) );
	deleteTree(freshDT);

	for ( c_const_iterator pc = c_begin(); pc != c_end(); ++pc )
		concept2dag(*pc);
	for ( i_const_iterator pi = i_begin(); pi != i_end(); ++pi )
		concept2dag(*pi);

	// init heads of simple rules
	for ( TSimpleRules::iterator q = SimpleRules.begin(), q_end = SimpleRules.end(); q < q_end; ++q )
		(*q)->bpHead = tree2dag((*q)->tHead);

	// builds Roles range and domain
	initRangeDomain(ORM);
	initRangeDomain(DRM);

	// build all splits
	for ( TSplitVars::iterator s = getSplits()->begin(), s_end = getSplits()->end(); s != s_end; ++s )
		split2dag(*s);

	RoleMaster::iterator p, p_end;

	// build all GCIs
	DLTree* GCI = Axioms.getGCI();

	// add special domains to the GCIs
	if ( likely(useSpecialDomains) )
		for ( p = ORM.begin(), p_end = ORM.end(); p < p_end; ++p )
			if ( !(*p)->isSynonym() && (*p)->hasSpecialDomain() )
				GCI = createSNFAnd ( GCI, clone((*p)->getTSpecialDomain()) );

	// take chains that lead to Bot role into account
	if ( !ORM.getBotRole()->isSimple() )
		GCI = createSNFAnd ( GCI,
				new DLTree ( TLexeme(FORALL), createRole(ORM.getBotRole()), createBottom() ) );

	T_G = tree2dag(GCI);
	deleteTree(GCI);

	// mark GCI flags
	GCIs.setGCI(T_G != bpTOP);
	GCIs.setReflexive(ORM.hasReflexiveRoles());

	// builds functional labels for roles
	for ( p = ORM.begin(), p_end = ORM.end(); p < p_end; ++p )
		if ( !(*p)->isSynonym() && (*p)->isTopFunc() )
			(*p)->setFunctional ( atmost2dag ( 1, *p, bpTOP ) );
	for ( p = DRM.begin(), p_end = DRM.end(); p < p_end; ++p )
		if ( !(*p)->isSynonym() && (*p)->isTopFunc() )
			(*p)->setFunctional ( atmost2dag ( 1, *p, bpTOP ) );

	// check the type of the ontology
	if ( nNominalReferences > 0 )
	{
		unsigned int nInd = i_end() - i_begin();
		if ( nInd > 100 && nNominalReferences > nInd )
			isLikeWINE = true;
	}

	// here DAG is complete; set its final size
	DLHeap.setFinalSize();
}
void
get_starling_indel_sample_report_info(const starling_deriv_options& dopt,
                                      const indel_key& ik,
                                      const indel_data& id,
                                      const pos_basecall_buffer& bc_buff,
                                      const bool is_tier2_pass,
                                      const bool is_use_alt_indel,
                                      starling_indel_sample_report_info& isri) {

    // get read info:
    {
        static const double path_pprob_thresh(0.999);

        unsigned n_subscore_reads(0);

        typedef indel_data::score_t::const_iterator siter;
        siter i(id.read_path_lnp.begin()), i_end(id.read_path_lnp.end());
        for(; i!=i_end; ++i) {
            const read_path_scores& path_lnp(i->second);

            // optionally skip tier2 data:
            if((! is_tier2_pass) && (! path_lnp.is_tier1_read)) continue;

            const read_path_scores pprob(indel_lnp_to_pprob(dopt,path_lnp,is_tier2_pass,is_use_alt_indel));
            if       (pprob.ref >= path_pprob_thresh) {
                isri.n_q30_ref_reads++;
            } else if(pprob.indel >= path_pprob_thresh) {
                isri.n_q30_indel_reads++;
            } else {
                typedef read_path_scores::alt_indel_t::const_iterator aciter;

                bool is_alt_found(false);
#if 0
                if(pprob.is_alt && (pprob.alt >= path_pprob_thresh)) {
                    isri.n_q30_alt_reads++;
                    is_alt_found=true;
                }
#else
                aciter j(pprob.alt_indel.begin()), j_end(pprob.alt_indel.end());
                for(; j!=j_end; ++j) {
                    if(j->second >= path_pprob_thresh) {
                        isri.n_q30_alt_reads++;
                        is_alt_found=true;
                        break;
                    }
                }
#endif
                if(! is_alt_found) { n_subscore_reads++; }
            }
        }

        // total number of reads with non-zero, yet insufficient indel
        // breakpoint overlap
        const unsigned n_suboverlap_tier1_reads(id.suboverlap_tier1_read_ids.size());
        isri.n_other_reads = (n_subscore_reads+n_suboverlap_tier1_reads);

        if(is_tier2_pass) {
            const unsigned n_suboverlap_tier2_reads(id.suboverlap_tier2_read_ids.size());
            isri.n_other_reads += n_suboverlap_tier2_reads;
        }
    }

    {
        // get depth of indel:
        pos_t depth_pos(ik.pos-1);
        if(ik.type==INDEL::BP_RIGHT) depth_pos=ik.pos;
        const snp_pos_info* spi_ptr(bc_buff.get_pos(depth_pos));
        if(NULL==spi_ptr) {
            isri.depth=0;
        } else {
            isri.depth=spi_ptr->calls.size();
        }
    }
}
void
indel_digt_caller::
get_high_low_het_ratio_lhood(const starling_options& /*opt*/,
                             const starling_deriv_options& dopt,
                             const starling_sample_options& sample_opt,
                             const double indel_error_lnp,
                             const double indel_real_lnp,
                             const double ref_error_lnp,
                             const double ref_real_lnp,
                             const indel_key& ik,
                             const indel_data& id,
                             const double het_ratio,
                             const bool is_tier2_pass,
                             const bool is_use_alt_indel,
                             double& het_lhood_high,
                             double& het_lhood_low) {

    // handle het ratio and its complement in one step:
    const double chet_ratio(1.-het_ratio);

    const double log_het_ratio(std::log(het_ratio));
    const double log_chet_ratio(std::log(chet_ratio));

    const bool is_breakpoint(ik.is_breakpoint());

    het_lhood_high=0;
    het_lhood_low=0;

    //    typedef read_path_scores::alt_indel_t::const_iterator aiter;

    typedef indel_data::score_t::const_iterator siter;
    siter i(id.read_path_lnp.begin()), i_end(id.read_path_lnp.end());
    for (; i!=i_end; ++i) {
        const read_path_scores& path_lnp(i->second);

        // optionally skip tier2 data:
        if ((! is_tier2_pass) && (! path_lnp.is_tier1_read)) continue;

        // get alt path lnp:
        double alt_path_lnp(path_lnp.ref);
#if 0
        if (is_use_alt_indel && path_lnp.is_alt &&
            (path_lnp.alt > alt_path_lnp)) {
            alt_path_lnp=path_lnp.alt;
        }
#else
        if (is_use_alt_indel && (! path_lnp.alt_indel.empty()) ) {
            typedef read_path_scores::alt_indel_t::const_iterator aiter;
            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;
            }
        }
#endif

        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));

        // allele ratio convention is that the indel occurs at the
        // het_allele ratio and the alternate allele occurs at
        // (1-het_allele_ratio):
        {
            double log_ref_prob(log_chet_ratio);
            double log_indel_prob(log_het_ratio);
            if (! is_breakpoint) {
                get_het_observed_allele_ratio(path_lnp.read_length,sample_opt.min_read_bp_flank,
                                              ik,het_ratio,log_ref_prob,log_indel_prob);
            }
            const double het_lnp(log_sum(noindel_lnp+log_ref_prob,hom_lnp+log_indel_prob));

            het_lhood_low += integrate_out_sites(dopt,path_lnp.nsite,het_lnp,is_tier2_pass);
        }

        {
            double log_ref_prob(log_het_ratio);
            double log_indel_prob(log_chet_ratio);
            if (! is_breakpoint) {
                get_het_observed_allele_ratio(path_lnp.read_length,sample_opt.min_read_bp_flank,
                                              ik,chet_ratio,log_ref_prob,log_indel_prob);
            }
            const double het_lnp(log_sum(noindel_lnp+log_ref_prob,hom_lnp+log_indel_prob));

            het_lhood_high += integrate_out_sites(dopt,path_lnp.nsite,het_lnp,is_tier2_pass);
        }
    }
}
Exemple #26
0
void a () {
     i_local_t a,b,c,d,e,f,g,h,i,j,w,z,func,cnt;
     i_label_t L1;
     v_iptr ip;
     
     i_init(100);

     L1 = i_mklabel();
/*     func = i_local(0, I_P);*/
     cnt = i_local(0, I_P);
     a = i_local(0, I_I);
     b = i_local(0, I_I);
     c = i_local(0, I_I);
     d = i_local(0, I_I);
     e = i_local(0, I_I);
     f = i_local(0, I_I);
     g = i_local(0, I_I);
     h = i_local(0, I_I);
     i = i_local(0, I_I);
     j = i_local(0, I_I);
     z = i_local(0, I_I);
     w = i_local(0, I_I);

/*     i_setp(func, ff);*/
     i_seti(a, 1);
     i_seti(b, 2);
     i_seti(c, 3);
     i_seti(d, 4);
     i_seti(e, 5);
     i_seti(f, 6);
     i_seti(g, 7);
     i_seti(h, 8);
     i_seti(i, 9);
     i_seti(j, 0);
     i_seti(z, 0);
     i_seti(cnt, 0);
     i_label(L1);
     i_argi(a);
     i_argi(b);
     i_argi(c);
     i_argi(d);
     i_argi(e);
     i_argi(f);
     i_argi(g);
     i_argi(h);
     i_argi(i);
     i_argi(j);
     i_callii(w, ff);
     i_addi(z,z,w);
     i_addii(cnt,cnt,1);
     i_bltii(cnt,2,L1);
     i_addi(z, z, a);
     i_addi(z, z, b);
     i_addi(z, z, c);
     i_addi(z, z, d);
     i_addi(z, z, e);
     i_addi(z, z, f);
     i_addi(z, z, g);
     i_addi(z, z, h);
     i_addi(z, z, i);
     i_addi(z, z, j);
     i_reti(z);			/* (9*10/2)*3 = 135 */
     i_end();

     i_unparse();
     ip = i_emit().i;
     v_dump((void*)ip);
     printf("**135=%d\n", (*ip)());
}
void TBox :: gatherRelevanceInfo ( void )
{
	nRelevantCCalls = 0;
	nRelevantBCalls = 0;

	// gather GCIs features
	curFeature = &GCIFeatures;
	markGCIsRelevant();
	clearRelevanceInfo();
	KBFeatures |= GCIFeatures;

	// fills in nominal cloud relevance info
	NCFeatures = GCIFeatures;

	// set up relevance info
	for ( i_iterator pi = i_begin(); pi != i_end(); ++pi )
	{
		setConceptRelevant(*pi);
		NCFeatures |= (*pi)->posFeatures;
	}

	// correct NC inverse role information
	if ( NCFeatures.hasSomeAll() && !RelatedI.empty() )
		NCFeatures.setInverseRoles();

	for ( c_iterator pc = c_begin(); pc != c_end(); ++pc )
		setConceptRelevant(*pc);
	long cSize = ( c_end() - c_begin() ) + ( i_end() - i_begin() );
	size_t bSize = DLHeap.size()-2;

	curFeature = nullptr;

	float cRatio, bRatio = 0, logCSize = 1, logBSize = 1, sqCSize = 1, sqBSize = 1;
	if ( cSize > 10 )
	{
		cRatio = ((float)nRelevantCCalls)/cSize;
		sqCSize = sqrtf((float)cSize);
		if ( cSize > 1 )
			logCSize = logf((float)cSize);
	}
	if ( bSize > 20 )
	{
		bRatio = ((float)nRelevantBCalls)/bSize;
		sqBSize = sqrtf((float)bSize);
		if ( bSize > 1 )
			logBSize = logf((float)bSize);
	}

	if (0)	// relevance stat
	{
	if ( LLM.isWritable(llAlways) && cSize > 10 )
		LL << "There were made " << nRelevantCCalls << " relevance C calls for "
		   << cSize << " concepts\nRC ratio=" << cRatio << ", ratio/logSize="
		   << cRatio/logCSize << ", ratio/sqSize=" << cRatio/sqCSize << ", ratio/size="
		   << cRatio/cSize<< "\n";
	if ( LLM.isWritable(llAlways) && bSize > 20 )
		LL << "There were made " << nRelevantBCalls << " relevance B calls for "
		   << bSize << " nodes\nRB ratio=" << bRatio << ", ratio/logSize="
		   << bRatio/logBSize << ", ratio/sqSize=" << bRatio/sqBSize << ", ratio/size="
		   << bRatio/bSize << "\n";
	}

	// set up GALEN-like flag; based on r/n^{3/2}, add r/n^2<1
	isLikeGALEN = (bRatio > sqBSize*20) && (bRatio < bSize);

	// switch off sorted reasoning iff top role appears
	if ( KBFeatures.hasTopRole() )
		useSortedReasoning = false;
}