420 lines
14 KiB
C++
420 lines
14 KiB
C++
#include "DerevyankoReport.h"
|
|
#include "individual/Trait.h"
|
|
#include "individual/Phenotype.h"
|
|
//#include "population/BreedingStrategies/PopulationBreedingStrategy.h"
|
|
#include "population/BreedingStrategies/NeutralEvolutionBreedStrat.h"
|
|
|
|
#include <list>
|
|
#include <fstream>
|
|
|
|
using std::string;
|
|
|
|
BisexualPopulation* DerevyankoReport::populationFactory(int size, std::string initMtGenome){
|
|
BisexualPopulation* ans;
|
|
|
|
std::list<Individual*> males;
|
|
std::list<Individual*> females;
|
|
|
|
Gene gene1(Gene::Sequence, "mtDna1", initMtGenome);
|
|
Chromosome chrom1("Mitochondrial chromosome");
|
|
chrom1.insertGeneToEnd(gene1);
|
|
|
|
std::vector<Chromosome> fGenome;
|
|
std::vector<Chromosome> mGenome;
|
|
fGenome.push_back(chrom1);
|
|
mGenome.push_back(chrom1);
|
|
|
|
// Ôåíîòèï
|
|
Trait trait1(Trait::Discrete, "Age", 20);
|
|
// Ïóë ñóáñòðàòîâ
|
|
InnerSubstratesPool* subPool = 0;
|
|
// (END) Ïóë ñóáñòðàòîâ
|
|
|
|
for(int i = 0; i < size/2; i++){
|
|
Genotype* genotype = new Genotype(fGenome, mGenome);
|
|
Phenotype* phenotype = new Phenotype(trait1);
|
|
males.push_back(new Individual(genotype, phenotype, subPool, Individual::male, 0));
|
|
|
|
genotype = new Genotype(fGenome, mGenome);
|
|
phenotype = new Phenotype(trait1);
|
|
females.push_back(new Individual(genotype, phenotype, subPool, Individual::female, 0));
|
|
}
|
|
|
|
ans = new BisexualPopulation(males,females);
|
|
return ans;
|
|
}
|
|
void DerevyankoReport::reportRFBR2013_01(){
|
|
|
|
// Ìèòîõîíäðèàëüíàÿ ÄÍÊ (ïîïóëÿöèÿ f)
|
|
string initMtDNA = "TTCTTTCATGGGGAAGCAGATTTGGGTACCACCCAAGTATTGACTCACCCATCAACAACC";
|
|
initMtDNA += "GCTATGTATTTCGTACATTACTGCCAGCCACCATGAATATTGTACGGTACCATAAATACT";
|
|
initMtDNA += "TGACCACCTGTAGTACATAAAAACCCAATCCACATCAAAACCCCCCCCTCATGCTTACAA";
|
|
initMtDNA += "GCAAGTACAGCAATCAACCTTCAACTATCACACATCAACTGCAACTCCAAAGCCACCCCT";
|
|
initMtDNA += "CACCCACTAGGATATCAACAAACCTACCCATCCTTAACAGTACATGGTACATAAAGCCAT";
|
|
initMtDNA += "TTACCGTACATAGCACATTACAGTCAAATCCCTTCTCGTCCCCATGGATGACCCCCCTCA";
|
|
|
|
// Ìóòàíòíàÿ ìòÄÍÊ (ïîïóëÿöèÿ G)
|
|
string initMtDNA_G = initMtDNA;
|
|
initMtDNA_G.replace(60,1,"T");
|
|
initMtDNA_G.replace(120,1,"A");
|
|
initMtDNA_G.replace(180,1,"C");
|
|
initMtDNA_G.replace(240,1,"G");
|
|
|
|
// Ãåíåðàöèÿ ñòàðòîâûõ ïîïóëÿöèé
|
|
//
|
|
int basePopSize = 5000;
|
|
float initBirthRate = 0.25f;
|
|
float deltaBirthRate = 0.0002f;
|
|
BisexualPopulation* pop_f = populationFactory(basePopSize, initMtDNA);
|
|
NeutralEvolutionBreedingStrategy* breedStrat_f =
|
|
dynamic_cast<NeutralEvolutionBreedingStrategy*>(PopulationBreedingStrategy::getInstance("neutral"));
|
|
breedStrat_f->setBirthRate(initBirthRate);
|
|
breedStrat_f->setDeathRate(initBirthRate-deltaBirthRate);
|
|
pop_f->setBreedingStrategy(breedStrat_f);
|
|
|
|
BisexualPopulation* pop_G = populationFactory(basePopSize, initMtDNA_G);
|
|
NeutralEvolutionBreedingStrategy* breedStrat_G =
|
|
dynamic_cast<NeutralEvolutionBreedingStrategy*>(PopulationBreedingStrategy::getInstance("neutral"));
|
|
breedStrat_G->setBirthRate(initBirthRate);
|
|
breedStrat_G->setDeathRate(initBirthRate-deltaBirthRate);
|
|
pop_G->setBreedingStrategy(breedStrat_G);
|
|
|
|
///////////////////////////////////////////
|
|
//
|
|
// Ýâîëþöèîííûé ïðîöåññ
|
|
//
|
|
///////////////////////////////////////////
|
|
|
|
unsigned int generation;
|
|
|
|
// Øàã 1.
|
|
// Âàðèàíò 1
|
|
int genPerMigr_f_G = 100;
|
|
float part_f_to_G = 0.01f;
|
|
float part_G_to_f = 0.01f;
|
|
std::cout<<"Variant 1"<<std::endl;
|
|
|
|
// Âàðèàíò 2
|
|
//int genPerMigr_f_G = 1000;
|
|
//float part_f_to_G = 0.1f;
|
|
//float part_G_to_f = 0.1f;
|
|
//std::cout<<"Variant 2"<<std::endl;
|
|
|
|
for(generation = 0; generation < 7000; generation++){
|
|
std::cout<<"gen\t"<<generation<<std::endl;
|
|
pop_f->breedAll();
|
|
pop_f->mutationAll();
|
|
|
|
pop_G->breedAll();
|
|
pop_G->mutationAll();
|
|
|
|
if(generation != 0 && ((generation % genPerMigr_f_G) == 0)){
|
|
std::string code = BisexualPopulation::mutualMigration(pop_f, pop_G, part_f_to_G, part_G_to_f);
|
|
std::cout<<"Migration f<->G\t"<<code<<std::endl;
|
|
}
|
|
}
|
|
|
|
// Øàã 2.
|
|
// Âû÷ëåíåíèå ïîïóëÿöèè e è å¸ æèçíü (10 ïîêîëåíèé) f íàñ áîëüøå íå èíòåðåñóåò
|
|
float fraction_e_founder = 0.5f;
|
|
BisexualPopulation* pop_e = pop_f->createSubpopulation(fraction_e_founder);
|
|
std::cout<<"pop_e has been created"<<std::endl;
|
|
|
|
for(; generation < 7010; generation++){
|
|
std::cout<<"gen\t"<<generation<<std::endl;
|
|
pop_e->breedAll();
|
|
pop_e->mutationAll();
|
|
|
|
pop_G->breedAll();
|
|
pop_G->mutationAll();
|
|
}
|
|
|
|
// Øàã 3.
|
|
// Ðàçäåëåíèå ïîïóëÿöèè å íà F è d
|
|
// Äàëåå ýâîëþöèÿ 50 ïîêîëåíèé
|
|
// ìàæîðíàÿ âåòêà - ýòî ïîïóëÿöèÿ d, åé îñòà¸òñÿ 90% ïîïóëÿöèè
|
|
float fraction_F_founder = 0.1f;
|
|
BisexualPopulation* pop_F = pop_e->createSubpopulation(fraction_F_founder);
|
|
std::cout<<"pop_F has been created"<<std::endl;
|
|
|
|
BisexualPopulation* pop_d = pop_e; // Îñòàòîê ñòàíîâèòñÿ d
|
|
NeutralEvolutionBreedingStrategy* breedStrat_d =
|
|
dynamic_cast<NeutralEvolutionBreedingStrategy*>(PopulationBreedingStrategy::getInstance("neutral"));
|
|
breedStrat_d->setBirthRate(initBirthRate);
|
|
breedStrat_d->setDeathRate(initBirthRate-deltaBirthRate*2);
|
|
pop_d->setBreedingStrategy(breedStrat_d);
|
|
std::cout<<"pop_e -> pop_d\tPop dynamics coeffs have been changed:\td =\t";
|
|
std::cout<<(initBirthRate-deltaBirthRate*2)<<std::endl;
|
|
|
|
for(; generation < 7060; generation++){
|
|
std::cout<<"gen\t"<<generation<<std::endl;
|
|
pop_d->breedAll();
|
|
pop_d->mutationAll();
|
|
|
|
pop_F->breedAll();
|
|
pop_F->mutationAll();
|
|
|
|
pop_G->breedAll();
|
|
pop_G->mutationAll();
|
|
}
|
|
|
|
// Øàã 4.
|
|
// Ðàçäåëåíèå ïîïóëÿöèè d íà E è c
|
|
// Äàëåå ýâîëþöèÿ 100 ïîêîëåíèé
|
|
// ìàæîðíàÿ âåòêà - ýòî ïîïóëÿöèÿ c, åé îñòà¸òñÿ 90% ïîïóëÿöèè
|
|
float fraction_E_founder = 0.1f;
|
|
BisexualPopulation* pop_E = pop_d->createSubpopulation(fraction_E_founder);
|
|
std::cout<<"pop_E has been created"<<std::endl;
|
|
|
|
BisexualPopulation* pop_c = pop_d; // Îñòàòîê ñòàíîâèòñÿ c
|
|
NeutralEvolutionBreedingStrategy* breedStrat_c =
|
|
dynamic_cast<NeutralEvolutionBreedingStrategy*>(PopulationBreedingStrategy::getInstance("neutral"));
|
|
breedStrat_c->setBirthRate(initBirthRate);
|
|
breedStrat_c->setDeathRate(initBirthRate-deltaBirthRate*2.5f);
|
|
pop_c->setBreedingStrategy(breedStrat_c);
|
|
std::cout<<"pop_d -> pop_c\tPop dynamics coeffs have been changed:\td =\t";
|
|
std::cout<<(initBirthRate-deltaBirthRate*2.5f)<<std::endl;
|
|
|
|
for(; generation < 7160; generation++){
|
|
std::cout<<"gen\t"<<generation<<std::endl;
|
|
pop_c->breedAll();
|
|
pop_c->mutationAll();
|
|
|
|
pop_E->breedAll();
|
|
pop_E->mutationAll();
|
|
|
|
pop_F->breedAll();
|
|
pop_F->mutationAll();
|
|
|
|
pop_G->breedAll();
|
|
pop_G->mutationAll();
|
|
}
|
|
|
|
// Øàã 5.
|
|
// Ðàçäåëåíèå ïîïóëÿöèè c íà D è b
|
|
// Äàëåå ýâîëþöèÿ 100 ïîêîëåíèé
|
|
// ìàæîðíàÿ âåòêà - ýòî ïîïóëÿöèÿ b, åé îñòà¸òñÿ 90% ïîïóëÿöèè
|
|
float fraction_D_founder = 0.1f;
|
|
BisexualPopulation* pop_D = pop_c->createSubpopulation(fraction_D_founder);
|
|
std::cout<<"pop_D has been created"<<std::endl;
|
|
|
|
BisexualPopulation* pop_b = pop_c; // Îñòàòîê ñòàíîâèòñÿ b
|
|
NeutralEvolutionBreedingStrategy* breedStrat_b =
|
|
dynamic_cast<NeutralEvolutionBreedingStrategy*>(PopulationBreedingStrategy::getInstance("neutral"));
|
|
breedStrat_b->setBirthRate(initBirthRate);
|
|
breedStrat_b->setDeathRate(initBirthRate-deltaBirthRate*3.f);
|
|
pop_b->setBreedingStrategy(breedStrat_b);
|
|
std::cout<<"pop_c -> pop_b\tPop dynamics coeffs have been changed:\td =\t";
|
|
std::cout<<(initBirthRate-deltaBirthRate*3.f)<<std::endl;
|
|
|
|
for(; generation < 7260; generation++){
|
|
std::cout<<"gen\t"<<generation<<std::endl;
|
|
pop_b->breedAll();
|
|
pop_b->mutationAll();
|
|
|
|
pop_D->breedAll();
|
|
pop_D->mutationAll();
|
|
|
|
pop_E->breedAll();
|
|
pop_E->mutationAll();
|
|
|
|
pop_F->breedAll();
|
|
pop_F->mutationAll();
|
|
|
|
pop_G->breedAll();
|
|
pop_G->mutationAll();
|
|
}
|
|
|
|
// Øàã 6.
|
|
// Ðàçäåëåíèå ïîïóëÿöèè b íà C è a
|
|
// Äàëåå ýâîëþöèÿ 200 ïîêîëåíèé
|
|
// ìàæîðíàÿ âåòêà - ýòî ïîïóëÿöèÿ a, åé îñòà¸òñÿ 90% ïîïóëÿöèè
|
|
float fraction_C_founder = 0.1f;
|
|
BisexualPopulation* pop_C = pop_b->createSubpopulation(fraction_C_founder);
|
|
std::cout<<"pop_C has been created"<<std::endl;
|
|
|
|
BisexualPopulation* pop_a = pop_b; // Îñòàòîê ñòàíîâèòñÿ b
|
|
NeutralEvolutionBreedingStrategy* breedStrat_a =
|
|
dynamic_cast<NeutralEvolutionBreedingStrategy*>(PopulationBreedingStrategy::getInstance("neutral"));
|
|
breedStrat_a->setBirthRate(initBirthRate);
|
|
breedStrat_a->setDeathRate(initBirthRate-deltaBirthRate*3.5f);
|
|
pop_a->setBreedingStrategy(breedStrat_a);
|
|
std::cout<<"pop_b -> pop_a\tPop dynamics coeffs have been changed:\td =\t";
|
|
std::cout<<(initBirthRate-deltaBirthRate*3.5f)<<std::endl;
|
|
|
|
for(; generation < 7460; generation++){
|
|
std::cout<<"gen\t"<<generation<<std::endl;
|
|
pop_a->breedAll();
|
|
pop_a->mutationAll();
|
|
|
|
pop_C->breedAll();
|
|
pop_C->mutationAll();
|
|
|
|
pop_D->breedAll();
|
|
pop_D->mutationAll();
|
|
|
|
pop_E->breedAll();
|
|
pop_E->mutationAll();
|
|
|
|
pop_F->breedAll();
|
|
pop_F->mutationAll();
|
|
|
|
pop_G->breedAll();
|
|
pop_G->mutationAll();
|
|
}
|
|
|
|
// Øàã 7.
|
|
// Ðàçäåëåíèå ïîïóëÿöèè a íà A è B
|
|
// Äàëåå ýâîëþöèÿ 2540 ïîêîëåíèé
|
|
// ïîëóìàæîðíàÿ âåòêà - ýòî ïîïóëÿöèÿ A, åé îñòà¸òñÿ 50% ïîïóëÿöèè,
|
|
// íî ÷óòü ìåíüøàÿ ñìåðòíîñòü.
|
|
// Íà ïðîòÿæåíèè ýâîëþöèè ìèãðàöèè ìåæäó A è B, à òàêæå èç A â C, D, E, F (G âûâîäèòñÿ èç ýâîëþöèè)
|
|
float fraction_B_founder = 0.5f;
|
|
BisexualPopulation* pop_B = pop_a->createSubpopulation(fraction_B_founder);
|
|
std::cout<<"pop_B has been created"<<std::endl;
|
|
|
|
BisexualPopulation* pop_A = pop_a; // Îñòàòîê ñòàíîâèòñÿ A
|
|
NeutralEvolutionBreedingStrategy* breedStrat_A =
|
|
dynamic_cast<NeutralEvolutionBreedingStrategy*>(PopulationBreedingStrategy::getInstance("neutral"));
|
|
breedStrat_A->setBirthRate(initBirthRate);
|
|
breedStrat_A->setDeathRate(initBirthRate-deltaBirthRate*4.f);
|
|
pop_A->setBreedingStrategy(breedStrat_A);
|
|
std::cout<<"pop_a -> pop_A\tPop dynamics coeffs have been changed:\td =\t";
|
|
std::cout<<(initBirthRate-deltaBirthRate*4.f)<<std::endl;
|
|
|
|
// Âàðèàíò 1
|
|
int genPerMigr_A_B = 100;
|
|
int genPerMigr_A_C = 150;
|
|
int genPerMigr_A_D = 200;
|
|
int genPerMigr_A_E = 250;
|
|
int genPerMigr_A_F = 300;
|
|
|
|
float part_A_to_B = 0.01f;
|
|
float part_B_to_A = 0.01f;
|
|
float part_A_to_C = 0.005f;
|
|
float part_A_to_D = 0.005f;
|
|
float part_A_to_E = 0.005f;
|
|
float part_A_to_F = 0.005f;
|
|
|
|
for(; generation < 10001; generation++){
|
|
std::cout<<"gen\t"<<generation<<std::endl;
|
|
pop_A->breedAll();
|
|
pop_A->mutationAll();
|
|
|
|
pop_B->breedAll();
|
|
pop_B->mutationAll();
|
|
|
|
pop_C->breedAll();
|
|
pop_C->mutationAll();
|
|
|
|
pop_D->breedAll();
|
|
pop_D->mutationAll();
|
|
|
|
pop_E->breedAll();
|
|
pop_E->mutationAll();
|
|
|
|
pop_F->breedAll();
|
|
pop_F->mutationAll();
|
|
|
|
if((generation % genPerMigr_A_B) == 0){
|
|
std::string code = BisexualPopulation::mutualMigration(pop_A, pop_B, part_A_to_B, part_B_to_A);
|
|
std::cout<<"Migration A<->B\t"<<code<<std::endl;
|
|
}
|
|
if((generation % genPerMigr_A_C) == 0){
|
|
std::string code = BisexualPopulation::mutualMigration(pop_A, pop_C, part_A_to_C, 0.f);
|
|
std::cout<<"Migration A->C\t"<<code<<std::endl;
|
|
}
|
|
if((generation % genPerMigr_A_D) == 0){
|
|
std::string code = BisexualPopulation::mutualMigration(pop_A, pop_D, part_A_to_D, 0.f);
|
|
std::cout<<"Migration A->D\t"<<code<<std::endl;
|
|
}
|
|
if((generation % genPerMigr_A_E) == 0){
|
|
std::string code = BisexualPopulation::mutualMigration(pop_A, pop_E, part_A_to_E, 0.f);
|
|
std::cout<<"Migration A->E\t"<<code<<std::endl;
|
|
}
|
|
if((generation % genPerMigr_A_F) == 0){
|
|
std::string code = BisexualPopulation::mutualMigration(pop_A, pop_F, part_A_to_F, 0.f);
|
|
std::cout<<"Migration A->F\t"<<code<<std::endl;
|
|
}
|
|
}
|
|
|
|
// Êîíåö ýâîëþöèè - âûâîä ñòàòèñòèêè â ôàéëû
|
|
std::ofstream file("GenStatistics.pop_A.fasta");
|
|
pop_A->putGeneticStatisticsToStream(file);
|
|
file.close();
|
|
|
|
file.open("GenStatistics.pop_A.txt");
|
|
pop_A->putGeneticSimpleStatisticsToStream(file);
|
|
file.close();
|
|
|
|
////////////////////////////////////////
|
|
file.open("GenStatistics.pop_B.fasta");
|
|
pop_B->putGeneticStatisticsToStream(file);
|
|
file.close();
|
|
|
|
file.open("GenStatistics.pop_B.txt");
|
|
pop_B->putGeneticSimpleStatisticsToStream(file);
|
|
file.close();
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
file.open("GenStatistics.pop_C.fasta");
|
|
pop_C->putGeneticStatisticsToStream(file);
|
|
file.close();
|
|
|
|
file.open("GenStatistics.pop_C.txt");
|
|
pop_C->putGeneticSimpleStatisticsToStream(file);
|
|
file.close();
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
file.open("GenStatistics.pop_D.fasta");
|
|
pop_D->putGeneticStatisticsToStream(file);
|
|
file.close();
|
|
|
|
file.open("GenStatistics.pop_D.txt");
|
|
pop_D->putGeneticSimpleStatisticsToStream(file);
|
|
file.close();
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
file.open("GenStatistics.pop_E.fasta");
|
|
pop_E->putGeneticStatisticsToStream(file);
|
|
file.close();
|
|
|
|
file.open("GenStatistics.pop_E.txt");
|
|
pop_E->putGeneticSimpleStatisticsToStream(file);
|
|
file.close();
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
file.open("GenStatistics.pop_F.fasta");
|
|
pop_F->putGeneticStatisticsToStream(file);
|
|
file.close();
|
|
|
|
file.open("GenStatistics.pop_F.txt");
|
|
pop_F->putGeneticSimpleStatisticsToStream(file);
|
|
file.close();
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
file.open("GenStatistics.pop_G.fasta");
|
|
pop_G->putGeneticStatisticsToStream(file);
|
|
file.close();
|
|
|
|
file.open("GenStatistics.pop_G.txt");
|
|
pop_G->putGeneticSimpleStatisticsToStream(file);
|
|
file.close();
|
|
////////////////////////////////////////
|
|
|
|
////////////////////////////////////////
|
|
file.open("GenStatistics.pop_flittle.fasta");
|
|
pop_f->putGeneticStatisticsToStream(file);
|
|
file.close();
|
|
|
|
file.open("GenStatistics.pop_flittle.txt");
|
|
pop_f->putGeneticSimpleStatisticsToStream(file);
|
|
file.close();
|
|
////////////////////////////////////////
|
|
}
|