Exemple #1
0
__tb_no_sanitize_address__ tb_size_t tb_pool_data_size(tb_cpointer_t data)
{
    // check
    tb_check_return_val(data, 0);

    // done
    tb_size_t               size = 0;
    tb_pool_data_head_t*    data_head = tb_null;
    do
    {
        // tbox must be running normally
        tb_check_break(tb_state() == TB_STATE_OK);

        // get global allocator
        tb_allocator_ref_t allocator = tb_allocator();
        tb_check_break(allocator);

        // have this data address?
        tb_check_break(tb_allocator_have(allocator, data));

        // the data head
        data_head = &(((tb_pool_data_head_t*)data)[-1]);
        tb_check_break(data_head->debug.magic == TB_POOL_DATA_MAGIC);

        // ok
        size = data_head->size;

    } while (0);

    // ok?
    return size;
}
Exemple #2
0
    //! When a transitionFunc is to be called it must performs a traceback
	//! and get the required sequence to pass to the function
	//! \param 
    double trellis::transitionFuncTraceback(state* st, size_t position,transitionFuncParam* func){
        
        std::vector<int> tracebackPath;
        std::vector<std::string> tracebackString;
                
       //How far to traceback
        tracebackIdentifier traceback_identifier = func->getTracebackType();
        const std::string& tracebackIdentifierName = func->getTracebackName();
        
        
        //What to combine
        combineIdentifier combineIdent = func->getCombineType();
        const std::string& combineIdentName = func->getCombineName();
        
        
        //Deterimine which track to use
        track* alphaTrack = func->getTrack();
        size_t trackIndex = alphaTrack->getIndex();
        if (!alphaTrack->isAlpha()){
            
			std::cerr << "External transition function called on track that isn't discrete (ALPHANUMERIC)\n";
			exit(2);
            
        }
        
        const sequence* seq = seqs->getSeq(trackIndex);
        int16_t tb_state(st->getIterator());
		int16_t starting_state = tb_state;

		
        for(size_t trellisPos = position-1; trellisPos != SIZE_MAX ; --trellisPos){
            
            tracebackPath.push_back(tb_state);
            
            if ((combineIdent == FULL) ||
                (combineIdent == STATENAME && combineIdentName.compare(st->getName())==0)||
                (combineIdent == STATELABEL && combineIdentName.compare(st->getLabel())==0)||
                (combineIdent == STATEGFF && combineIdentName.compare(st->getGFF())==0))

            {
                tracebackString.push_back(seq->getSymbol(trellisPos));
            }
			
            tb_state= (*traceback_table)[trellisPos][tb_state];
            state* temp_st = hmm->getState(tb_state);

            //Check to see if stop conditions of traceback are met, if so break;
            if(traceback_identifier == START_INIT && tb_state == -1) {break;}
            else if (traceback_identifier == DIFF_STATE  && starting_state != tb_state) {  break;}
            else if (traceback_identifier == STATE_NAME  && tracebackIdentifierName.compare(temp_st->getName())==0){ break;}
            else if (traceback_identifier == STATE_LABEL && tracebackIdentifierName.compare(temp_st->getLabel())==0) {  break;}
            else if (traceback_identifier == STATE_GFF   && tracebackIdentifierName.compare(temp_st->getGFF())==0) {  break;}
        }
        
        size_t length=tracebackPath.size();
        std::string CombinedString;
		
        size_t maxSymbolSize = alphaTrack->getAlphaMax();
		//For single letter characters
        if (maxSymbolSize ==1){
            for(std::vector<std::string>::reverse_iterator rit = tracebackString.rbegin(); rit!=tracebackString.rend();++rit){
                CombinedString+=(*rit);
            }
        }
		else{  // For kmer words > 1 in length
			std::vector<std::string>::reverse_iterator rit = tracebackString.rbegin();
			CombinedString+=(*rit);
			++rit;
			for(; rit!=tracebackString.rend();++rit){
				CombinedString+="," + (*rit);
            }
		}
        
		//Call the transitionFunc and get the score back
        double transitionValue = func->evaluate(seqs->getUndigitized(trackIndex), position, &CombinedString, length);
        
        return transitionValue;
    }