void Host::MutateGenesForMutualInvasion(int mutationType, KIRGene& kir_hap2, Map& kirMap, GenePool& mhcPool, double simulationTime, double time_invasion, int gene_type) { if(mutationType == 1)//pick another molecule as mutation { KIRGene newGene(RandomNumber(2,16)); /*if(!kirMap.IsGeneInMap(newGene)) { kirMap.FillMap(mhcPool, newGene); //cout <<simulationTime << "|" <<time_invasion <<endl; if(simulationTime < time_invasion)//only after the invasion time, the receptor type should be allowed to mutate newGene.SetGeneType(gene_type); kir_hap2.Copy(newGene); }//*/ int M_id = 0; int mhcPoolSize = mhcPool.GetPoolSize(); //calculate the value of M_id to determine whether the gene is pseudogene or not for(unsigned int i = 0; i < mhcPoolSize; i++) { Gene mhcGene; mhcGene.SetGeneID(mhcPool.GetGenes().at(i)); int L = newGene.BindMolecule(mhcGene); if(L >= newGene.GetGeneSpecificity()) M_id += (1<<i); } //set the Gene pseudo newGene.SetPseudogene(M_id); if(gene_type !=2)////force to have only one type of receptors, if the user wants it! newGene.SetGeneType(gene_type); kir_hap2.Copy(newGene); return; } if(mutationType == 2)//point mutation + L { if(RandomNumberDouble()<0.8) { kir_hap2.PointMutation(); //kirMap.FillMap(mhcPool, kir_hap2); int M_id = 0; int mhcPoolSize = mhcPool.GetPoolSize(); //calculate the value of M_id to determine whether the gene is pseudogene or not for(unsigned int i = 0; i < mhcPoolSize; i++) { Gene mhcGene; mhcGene.SetGeneID(mhcPool.GetGenes().at(i)); int L = kir_hap2.BindMolecule(mhcGene); if(L >= kir_hap2.GetGeneSpecificity()) M_id+= (1<<i); } //set the Gene pseudo kir_hap2.SetPseudogene(M_id); } if(RandomNumberDouble()<0.2) { kir_hap2.MutateSpecificity(); //kirMap.FillMap(mhcPool, kir_hap2); int M_id = 0; int mhcPoolSize = mhcPool.GetPoolSize(); //calculate the value of M_id to determine whether the gene is pseudogene or not for(unsigned int i = 0; i < mhcPoolSize; i++) { Gene mhcGene; mhcGene.SetGeneID(mhcPool.GetGenes().at(i)); int L = kir_hap2.BindMolecule(mhcGene); if(L >= kir_hap2.GetGeneSpecificity()) M_id+= (1<<i); } //set the Gene pseudo kir_hap2.SetPseudogene(M_id); } if(RandomNumberDouble()<0.2) { if(simulationTime >= time_invasion) //only after the invasion time, the receptor type should be allowed to mutate kir_hap2.MutateReceptorType(); } return; } }
void GeneManager::initBasicRules() { // <GS><GT><MD><DT><MET><DS><MS><I_E><I_U><E_E><E_U><MUT> // growth seg newGene(1 , 0 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 50 , 50 , 20 , 1 , 0 , 0 , 0 , 0 , 0 , 0); //0 newGene(2 , 0 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 25 , 25 , 40 , 1 , 0 , 0 , 0 , 0 , 0 , 0); newGene(3 , 0 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 10 , 10 , 60 , 1 , 0 , 0 , 0 , 0 , 0 , 0); newGene(4 , 0 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 5 , 5 , 80 , 1 , 0 , 0 , 0 , 0 , 0 , 0); newGene(-1 , 0 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 50 , 40 , 20 , -1 , 0 , 0 , 0 , 0 , 0 , 0); newGene(-2 , 0 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 20 , 20 , 40 , -1 , 0 , 0 , 0 , 0 , 0 , 0); newGene(-3 , 0 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 10 , 10 , 60 , -1 , 0 , 0 , 0 , 0 , 0 , 0); newGene(-4 , 0 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 5 , 5 , 80 , -1 , 0 , 0 , 0 , 0 , 0 , 0); //7 // growth turns newGene(0 , 1 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 50 , 50 , 20 , 0 , 1 , 0 , 0 , 0 , 0 , 0); //8 newGene(0 , 2 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 25 , 25 , 40 , 0 , 1 , 0 , 0 , 0 , 0 , 0); newGene(0 , 3 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 10 , 10 , 60 , 0 , 1 , 0 , 0 , 0 , 0 , 0); newGene(0 , 4 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 5 , 5 , 80 , 0 , 1 , 0 , 0 , 0 , 0 , 0); newGene(0 , -1 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 50 , 40 , 20 , 0 , -1 , 0 , 0 , 0 , 0 , 0); newGene(0 , -2 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 20 , 20 , 40 , 0 , -1 , 0 , 0 , 0 , 0 , 0); newGene(0 , -3 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 10 , 10 , 60 , 0 , -1 , 0 , 0 , 0 , 0 , 0); newGene(0 , -4 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 5 , 5 , 80 , 0 , -1 , 0 , 0 , 0 , 0 , 0); //15 // maturedDuration newGene(0 , 0 , 1 , 0 , 0 , 0 , 0 , 100 , 10 , 50 , 50 , 20 , 0 , 0 , 1 , 0 , 0 , 0 , 0); //16 newGene(0 , 0 , 2 , 0 , 0 , 0 , 0 , 100 , 10 , 25 , 25 , 40 , 0 , 0 , 1 , 0 , 0 , 0 , 0); newGene(0 , 0 , 3 , 0 , 0 , 0 , 0 , 100 , 10 , 10 , 10 , 60 , 0 , 0 , 1 , 0 , 0 , 0 , 0); newGene(0 , 0 , 4 , 0 , 0 , 0 , 0 , 100 , 10 , 5 , 5 , 80 , 0 , 0 , 1 , 0 , 0 , 0 , 0); newGene(0 , 0 , -1 , 0 , 0 , 0 , 0 , 100 , 10 , 50 , 40 , 20 , 0 , 0 , -1 , 0 , 0 , 0 , 0); newGene(0 , 0 , -2 , 0 , 0 , 0 , 0 , 100 , 10 , 20 , 20 , 40 , 0 , 0 , -1 , 0 , 0 , 0 , 0); newGene(0 , 0 , -3 , 0 , 0 , 0 , 0 , 100 , 10 , 10 , 10 , 60 , 0 , 0 , -1 , 0 , 0 , 0 , 0); newGene(0 , 0 , -4 , 0 , 0 , 0 , 0 , 100 , 10 , 5 , 5 , 80 , 0 , 0 , -1 , 0 , 0 , 0 , 0); //23 //decayTurns newGene(0 , 0 , 0 , 1 , 0 , 0 , 0 , 100 , 10 , 50 , 50 , 20 , 0 , 0 , 0 , 1 , 0 , 0 , 0); //24 newGene(0 , 0 , 0 , 2 , 0 , 0 , 0 , 100 , 10 , 25 , 25 , 40 , 0 , 0 , 0 , 1 , 0 , 0 , 0); newGene(0 , 0 , 0 , 3 , 0 , 0 , 0 , 100 , 10 , 10 , 10 , 60 , 0 , 0 , 0 , 1 , 0 , 0 , 0); newGene(0 , 0 , 0 , 4 , 0 , 0 , 0 , 100 , 10 , 5 , 5 , 80 , 0 , 0 , 0 , 1 , 0 , 0 , 0); newGene(0 , 0 , 0 , -1 , 0 , 0 , 0 , 100 , 10 , 50 , 40 , 20 , 0 , 0 , 0 , -1 , 0 , 0 , 0); newGene(0 , 0 , 0 , -2 , 0 , 0 , 0 , 100 , 10 , 20 , 20 , 40 , 0 , 0 , 0 , -1 , 0 , 0 , 0); newGene(0 , 0 , 0 , -3 , 0 , 0 , 0 , 100 , 10 , 10 , 10 , 60 , 0 , 0 , 0 , -1 , 0 , 0 , 0); newGene(0 , 0 , 0 , -4 , 0 , 0 , 0 , 100 , 10 , 5 , 5 , 80 , 0 , 0 , 0 , -1 , 0 , 0 , 0); //31 //chance to get seed when decaying newGene(0 , 0 , 0 , 0 , 0 , 5 , 0 , 100 , 10 , 50 , 50 , 20 , 0 , 0 , 0 , 0 , 0 , 5 , 0); //32 newGene(0 , 0 , 0 , 0 , 0 , 10 , 0 , 100 , 10 , 25 , 25 , 40 , 0 , 0 , 0 , 0 , 0 , 5 , 0); newGene(0 , 0 , 0 , 0 , 0 , 15 , 0 , 100 , 10 , 10 , 10 , 60 , 0 , 0 , 0 , 0 , 0 , 5 , 0); newGene(0 , 0 , 0 , 0 , 0 , 20 , 0 , 100 , 10 , 5 , 5 , 80 , 0 , 0 , 0 , 0 , 0 , 5 , 0); newGene(0 , 0 , 0 , 0 , 0 , -5 , 0 , 100 , 10 , 50 , 40 , 20 , 0 , 0 , 0 , 0 , 0 , -5 , 0); newGene(0 , 0 , 0 , 0 , 0 , -10 , 0 , 100 , 10 , 20 , 20 , 40 , 0 , 0 , 0 , 0 , 0 , -5 , 0); newGene(0 , 0 , 0 , 0 , 0 , -15 , 0 , 100 , 10 , 10 , 10 , 60 , 0 , 0 , 0 , 0 , 0 , -5 , 0); newGene(0 , 0 , 0 , 0 , 0 , -20 , 0 , 100 , 10 , 5 , 5 , 80 , 0 , 0 , 0 , 0 , 0 , -5 , 0); //39 //chance to get seed when matured newGene(0 , 0 , 0 , 0 , 0 , 0 , 5 , 100 , 10 , 50 , 50 , 20 , 0 , 0 , 0 , 0 , 0 , 0 , 5); //40 newGene(0 , 0 , 0 , 0 , 0 , 0 , 10 , 100 , 10 , 25 , 25 , 40 , 0 , 0 , 0 , 0 , 0 , 0 , 5); newGene(0 , 0 , 0 , 0 , 0 , 0 , 15 , 100 , 10 , 10 , 10 , 60 , 0 , 0 , 0 , 0 , 0 , 0 , 5); newGene(0 , 0 , 0 , 0 , 0 , 0 , 20 , 100 , 10 , 5 , 5 , 80 , 0 , 0 , 0 , 0 , 0 , 0 , 5); newGene(0 , 0 , 0 , 0 , 0 , 0 , -5 , 100 , 10 , 50 , 40 , 20 , 0 , 0 , 0 , 0 , 0 , 0 , -5); newGene(0 , 0 , 0 , 0 , 0 , 0 , -10 , 100 , 10 , 20 , 20 , 40 , 0 , 0 , 0 , 0 , 0 , 0 , -5); newGene(0 , 0 , 0 , 0 , 0 , 0 , -15 , 100 , 10 , 10 , 10 , 60 , 0 , 0 , 0 , 0 , 0 , 0 , -5); newGene(0 , 0 , 0 , 0 , 0 , 0 , -20 , 100 , 10 , 5 , 5 , 80 , 0 , 0 , 0 , 0 , 0 , 0 , -5); //47 //special seed denying gene for stem seed. //48 newGene(0 , 0 , 0 , 0 , 0 , -20 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0); // seed chance when decay - 20% //49 newGene(0 , 0 , 0 , 0 , 0 , 0 , -20 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0); // seed chance when matured - 20% // only provide mutation benefits //maxExpressedTraits - Does not add benefits , but provide mutation benefits newGene(0 , 0 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 50 , 50 , 10 , 0 , 0 , 0 , 0 , 1 , 0 , 0); //50 newGene(0 , 0 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 25 , 25 , 20 , 0 , 0 , 0 , 0 , 1 , 0 , 0); newGene(0 , 0 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 10 , 10 , 30 , 0 , 0 , 0 , 0 , 1 , 0 , 0); newGene(0 , 0 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 5 , 5 , 40 , 0 , 0 , 0 , 0 , 1 , 0 , 0); newGene(0 , 0 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 50 , 40 , 10 , 0 , 0 , 0 , 0 , -1 , 0 , 0); newGene(0 , 0 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 20 , 20 , 20 , 0 , 0 , 0 , 0 , -1 , 0 , 0); newGene(0 , 0 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 10 , 10 , 30 , 0 , 0 , 0 , 0 , -1 , 0 , 0); newGene(0 , 0 , 0 , 0 , 0 , 0 , 0 , 100 , 10 , 5 , 5 , 40 , 0 , 0 , 0 , 0 , -1 , 0 , 0); //57 }
void Host :: MutateGenes(int mutationType, KIRGene& kir_hap2, Map& kirMap, GenePool& mhcPool, int gene_type) { if(mutationType == 1)//pick another molecules as mutation { KIRGene newGene(RandomNumber(2,16)); /*if(!kirMap.IsGeneInMap(newGene)) { kirMap.FillMap(mhcPool, newGene); if(gene_type !=2)////force to have only one type of receptors, if the user wants it! newGene.SetGeneType(gene_type); kir_hap2.Copy(newGene); }//*/ int M_id = 0; int mhcPoolSize = mhcPool.GetPoolSize(); //calculate the value of M_id to determine whether the gene is pseudogene or not for(unsigned int i = 0; i < mhcPoolSize; i++) { Gene mhcGene; mhcGene.SetGeneID(mhcPool.GetGenes().at(i)); int L = newGene.BindMolecule(mhcGene); if(L >= newGene.GetGeneSpecificity()) M_id += (1<<i); } newGene.SetPseudogene(M_id); if(gene_type !=2)////force to have only one type of receptors, if the user wants it! newGene.SetGeneType(gene_type); kir_hap2.Copy(newGene); return; } if(mutationType == 2)//point mutation + L { if(RandomNumberDouble()<0.8) //pointmutation { kir_hap2.PointMutation(); //kirMap.FillMap(mhcPool, kir_hap2); int M_id = 0; int mhcPoolSize = mhcPool.GetPoolSize(); //calculate the value of M_id to determine whether the gene is pseudogene or not for(unsigned int i = 0; i < mhcPoolSize; i++) { Gene mhcGene; mhcGene.SetGeneID(mhcPool.GetGenes().at(i)); int L = kir_hap2.BindMolecule(mhcGene); if(L >= kir_hap2.GetGeneSpecificity()) M_id += (1<<i); } kir_hap2.SetPseudogene(M_id); } if(RandomNumberDouble()<0.8) //mutate L { kir_hap2.MutateSpecificity(); //kirMap.FillMap(mhcPool, kir_hap2); int M_id = 0; int mhcPoolSize = mhcPool.GetPoolSize(); //calculate the value of M_id to determine whether the gene is pseudogene or not for(unsigned int i = 0; i < mhcPoolSize; i++) { Gene mhcGene; mhcGene.SetGeneID(mhcPool.GetGenes().at(i)); int L = kir_hap2.BindMolecule(mhcGene); if(L >= kir_hap2.GetGeneSpecificity()) M_id += (1<<i); } kir_hap2.SetPseudogene(M_id); } if(RandomNumberDouble()<0.8)//mutate type { kir_hap2.MutateReceptorType(); } return; } }