Esempio n. 1
0
    std::vector<alignment_result> align_sc(Iterator begin, Iterator end,
                                           int gap, score_matrix const & matrix,
                                           double score_part)
    {
        struct results_vector
        {
            std::vector<alignment_result> m_vec;
            double                        m_score;

            results_vector(double s) : m_score(s)
            {
            }

            bool operator()(alignment_result && res)
            {
                if (res.score >= m_score)
                {
                    m_vec.push_back(res);
                }
                return true;
            }
        };

        std::string query(begin, end);
        results_vector rv(score_part *
                          needleman_wunsch(query, query, gap,
                                           matrix).back().back());

        align_template(begin, end, gap, matrix, rv);

        return rv.m_vec;
    }
Esempio n. 2
0
int map_consistence (  int NX, int NY, Map * combined_map, Map *map1, Map *map2,
		       double *total_ptr,  double *gap_score) {
    int i,j;
    double val1, val2;
    double total = 0;
    double aln_score;

    if (!NX) NX = map1->x2y_size; /* TODO: rename */
    if (!NY) NY = map1->y2x_size; /* TODO: rename */
    
    for (i=0; i<NX; i++) {
	for (j=0; j<NY; j++) {
	    val1 =  map1->sse_pair_score[i][j];
	    val2 =  map2->sse_pair_score[i][j];

	    if ( val1 > val2) {
		combined_map->sse_pair_score[i][j]  = val1;
		combined_map->cosine[i][j] = map1->cosine[i][j];
	    } else {
		combined_map->sse_pair_score[i][j]  = val2;
		combined_map->cosine[i][j] = map2->cosine[i][j];
	    }
	}
    }
      

    /* Needleman on combined sse_pair_score */
    needleman_wunsch (NX, NY, combined_map->sse_pair_score,
		      combined_map->x2y,  combined_map->y2x, &aln_score );
    /* how do lengths compare? */
    combined_map->matches = match_length (NX, combined_map->x2y);

    if ( ! combined_map->matches ) {
	combined_map->assigned_score = 0.0;
    } else {
	for (i=0; i<NX; i++) {
	    j = combined_map->x2y[i];
	    if (j<0) continue;
	    total += combined_map->sse_pair_score[i][j];
	}
	combined_map->assigned_score = total;
    }
    /* pass NULL for total_ptr  if I don't need it */
    if (total_ptr) *total_ptr = combined_map->assigned_score;
    
    return  0;
}