Exemple #1
0
void Caller::compute_top_frequencies(const BasePileup& bp,
                                     const vector<pair<int, int> >& base_offsets,
                                     char& top_base, int& top_count,
                                     char& second_base, int& second_count) {

    const string& bases = bp.bases();
    // frequency of each base (nidx / idxn converts to from / int)
    int hist[5] = {0};
    for (auto i : base_offsets) {
        char base = Pileups::extract_match(bp, i.first);
        ++hist[nidx(base)];
    }
    
    int first = max_element(hist, hist + 4) - hist;
    int second = first == 0 ? 1 : 0;
    for (int i = 0; i < 4; ++i) {
        if (i != first && hist[i] > hist[second]) {
            second = i;
        }
    }

    // break ties with reference
    int refidx = nidx(bp.ref_base());
    if (hist[first] == hist[refidx]) {
        first = refidx;
    } else if (hist[second] == hist[refidx]) {
        second = refidx;
    }

    top_base = idxn(first);
    top_count = hist[first];
    second_base = idxn(second);
    second_count = hist[second];
}
template<typename PointT> float
SmoothNormal<PointT>::calculateResidual(int idx){
	std::vector<int> knbrs;
	std::vector<float> kdist;

	this->search_->nearestKSearch(idx, cluster_N_nbrs, knbrs, kdist);
	Eigen::Map<Eigen::Vector3f> idxp((float*) this->input_->points[idx].data);
	Eigen::Map<Eigen::Vector3f> idxn(this->normals_->points[idx].normal);
	float res=0;
	for(int i=0; i<knbrs.size(); i++){
		Eigen::Map<Eigen::Vector3f> pt((float*) this->input_->points[knbrs[i]].data);
		res = res + fabs(idxn.dot((pt-idxp)));
	}
	return res/(float) knbrs.size();
}