Ejemplo n.º 1
0
int Rarefact::driver(RarefactionCurveData* rcd, int increment, int nIters = 1000){
	try {
			
		for(int iter=0;iter<nIters;iter++){
		
			for(int i=0;i<displays.size();i++){
				displays[i]->init(label);
			}
		
			RAbundVector* lookup	= new RAbundVector(order->getNumBins());
			SAbundVector* rank	= new SAbundVector(order->getMaxRank()+1);
			random_shuffle(order->begin(), order->end());
		
			for(int i=0;i<numSeqs;i++){
			
				if (m->control_pressed) { delete lookup; delete rank; delete rcd; return 0;  }
			
				int binNumber = order->get(i);
				int abundance = lookup->get(binNumber);
			
				rank->set(abundance, rank->get(abundance)-1);
				abundance++;
		
				lookup->set(binNumber, abundance);
				rank->set(abundance, rank->get(abundance)+1);

				if((i == 0) || ((i+1) % increment == 0) || (ends.count(i+1) != 0)){
					rcd->updateRankData(rank);
				}
			}
	
			if((numSeqs % increment != 0) || (ends.count(numSeqs) != 0)){
				rcd->updateRankData(rank);
			}

			for(int i=0;i<displays.size();i++){
				displays[i]->reset();
			}
			
			delete lookup;
			delete rank;
		}

		return 0;
	}
	catch(exception& e) {
		m->errorOut(e, "Rarefact", "driver");
		exit(1);
	}
}
Ejemplo n.º 2
0
int Collect::getCurve(float percentFreq = 0.01){
        try {
            RAbundVector* lookup = new RAbundVector(order->getNumBins());
            SAbundVector* rank        = new SAbundVector(order->getMaxRank()+1);
            
            CollectorsCurveData* ccd = new CollectorsCurveData();
            
            //sets displays label
            for(int i=0;i<displays.size();i++){ displays[i]->init(label); }
            ccd->registerDisplays(displays);
            
            //convert freq percentage to number
            int increment = 1;
            if (percentFreq < 1.0) {  increment = numSeqs * percentFreq;  }
            else { increment = percentFreq;  }
            
            for(int i=0;i<numSeqs;i++){
                
                if (m->getControl_pressed()) { delete lookup; delete rank; delete ccd;  return 1;  }
                
                int binNumber = order->get(i);
                int abundance = lookup->get(binNumber);
                
                rank->set(abundance, rank->get(abundance)-1);
                
                abundance++;
                
                lookup->set(binNumber, abundance);
                rank->set(abundance, rank->get(abundance)+1); //increment rank(abundance)
                
                if((i == 0) || (i+1) % increment == 0){ ccd->updateRankData(rank); }
            }
            
            if(numSeqs % increment != 0){ ccd->updateRankData(rank); }
            
            for(int i=0;i<displays.size();i++){ displays[i]->reset(); }
            
            delete lookup; delete rank; delete ccd;
            
            return 0;
        }
        catch(exception& e) {
			m->errorOut(e, "Collect", "getCurve");
			exit(1);
        }
}