Simulation::Simulation(InfoFile &info, ProgramOptions &theProgOpt, ThreadPool &_tp) : progOpt(theProgOpt) , numGen(progOpt.getNumberOfGenerations()) , tp(_tp) { // create chromosomes Randomness &rng = tp[0].getRNG(); vector<seqLen_t> lengths = progOpt.get<vector<seqLen_t> >("length"); nat idC = 0; nat numPop = 1; // TODO pops for(auto& length : lengths) { FitnessFunction fFun(progOpt.get<vector<string>>("selCoef")); Chromosome* chromo = new Chromosome(length, theProgOpt.hasOption("neutral"), fFun, idC++, numPop); chromo->init(rng); chromosomes.push_back(chromo); } // create parameters of populations vector<nat> popSizes = progOpt.get<vector<nat> >("popSize"); assert(popSizes.size() == 1 ); popParams.push_back( PopulationParams(0, numGen, popSizes[0], progOpt)); fractionalSimulation = new FractionalSimulation(tp,info, progOpt, numGen, chromosomes, popParams); }
PopulationParams::PopulationParams(nat id, nat numberOfGenerations, popSize_t initSize, const ProgramOptions &progOpt) : initSize(initSize) , correction(1) // , correction(progOpt.get<nat>("ploidy") - 1 ) , isNeutral(false) { vector<string> stringEvents; if(progOpt.hasOption("popEvent")) stringEvents = progOpt.get<vector<string> >("popEvent"); // parse rates recombinationRate = parseRate(progOpt.get<vector<string> >("recRate"),id); // geneConversionRate = parseRate(progOpt.get<vector<string> >("mutRate"), id); mutationRate = parseRate(progOpt.get<vector<string> >("mutRate"), id); if(NOT stringEvents.empty()) { parseEvents(stringEvents,id); nat lastPopSize = initSize; // for(auto event : events) for(auto eventI = events.begin(); eventI != events.end(); ++eventI) { (*eventI)->init(lastPopSize); if(eventI+1 != events.end()) { nat whenIsNext = (*(eventI+1))->getWhen(); lastPopSize = (*eventI)->getByTime(whenIsNext-1); } } } }
Graph::Graph(nat initSize, const ProgramOptions &progOpt) : mutNodes(1000) , recNodes(1000) , nodMan(1000, progOpt.hasOption("refForCoal") ? progOpt.get<nat>("refForCoal") - 1 : 0 , NOT progOpt.hasOption("refForCoal")) , buffer(100) #ifndef NDEBUG , survivorsContainStartingNode(true) #endif { previousState.resize(initSize); fill(previousState.begin(), previousState.end(), nullptr); }