Пример #1
0
//!Perform traceback through trellis
//!\return [out] path trackback_path
void simpleTrellis::traceback(traceback_path& path,size_t n) {
    if (n<=ending.nth_viterbi_scores->size()) {
        if (ending.viti!=-INFINITY) {
            path.setScore((*ending.nth_viterbi_scores)[n].viterbi_score);

            int state_pointer=(*ending.nth_viterbi_scores)[n].traceback_state;
            size_t score_pointer = (*ending.nth_viterbi_scores)[n].traceback_state_score;

            path.push_back(state_pointer);

            size_t seq_length = seq->getLength();
            if (seq_length==0) {
                return;
            }

            for(size_t position=seq_length -1 ; position>0; position--) {
                state_pointer = (*trell[position][state_pointer].nth_viterbi_scores)[score_pointer].traceback_state;
                score_pointer = (*trell[position][state_pointer].nth_viterbi_scores)[score_pointer].traceback_state_score;

                path.push_back(state_pointer);

                if (state_pointer==-2) {
                    path.clear();
                    return;
                }
            }
        }
    }
    return;
}
Пример #2
0
//!Perform traceback through trellis
//!\return [out] path trackback_path
void simpleTrellis::traceback(traceback_path& path) {

    if (ending.viti!=-INFINITY) {
        path.setScore(ending.viti);
        int pointer=ending.ptr;
        path.push_back(ending.ptr);

        size_t seq_length = seq->getLength();
        if (seq_length==0) {
            return;
        }

        for(size_t position=seq_length -1 ; position>0; position--) {
            pointer=trell[position][pointer].ptr;
            path.push_back(pointer);

            if (pointer==-2) {
                path.clear();
                return;
            }
        }
    }

    return;
}
Пример #3
0
	//!Perform traceback through trellis
    //!\return path trackback_path
    void trellis::traceback(traceback_path& path){
				
		if (seq_size==0 || traceback_table == NULL){
			return;
		}
		
		if (ending_viterbi_score == -INFINITY){
			return;
		}
        else{
            path.setScore(ending_viterbi_score);
            path.push_back(ending_viterbi_tb);
            
			int16_t pointer = ending_viterbi_tb;
			
            for( size_t position = seq_size -1 ; position>0 ; position--){
				pointer = (*traceback_table)[position][pointer];
				
				if (pointer == -1){
					std::cerr << "No valid path at Position: " << position << std::endl;
					return;
				}
				
				path.push_back(pointer);
            }
        }
        return;
    }
Пример #4
0
	//TODO: Finish nth traceback function
	void trellis::traceback_nth(traceback_path& path, size_t n){
		if (seq_size == 0 || n > nth_size || (nth_traceback_table == NULL && naive_nth_scores == NULL)){
			return;
		}
		
		if (nth_traceback_table != NULL){
			int16_t st_pointer = (*ending_nth_viterbi)[n].st_tb;
			int16_t sc_pointer = (*ending_nth_viterbi)[n].score_tb;
			
			path.setScore((*ending_nth_viterbi)[n].score);
			path.push_back(st_pointer);
			
			
			for( size_t position = seq_size -1 ; position>0 ; position--){
				(*nth_traceback_table)[position].get(st_pointer,sc_pointer);
				
				if (st_pointer == -1){
					std::cerr << "No valid path at Position: " << position << std::endl;
					return;
				}
				
				path.push_back(st_pointer);
            }
			
		}
		else{
			int16_t st_pointer = (*ending_nth_viterbi)[n].st_tb;
			int16_t sc_pointer = (*ending_nth_viterbi)[n].score_tb;
			
			path.setScore((*ending_nth_viterbi)[n].score);
			path.push_back(st_pointer);
			
			for( size_t position = seq_size -1 ; position>0 ; position--){
				nthScore& temp = (*(*naive_nth_scores)[position][st_pointer])[sc_pointer];
				st_pointer = temp.st_tb;
				sc_pointer = temp.score_tb;
				if (st_pointer == -1){
					std::cerr << "No valid path at Position: " << position << std::endl;
					return;
				}
				path.push_back(st_pointer);
            }
		}
		return;
	}