public static void drift() { double Nf=1e4; double MutationRatio=3e-10; //int seed =1; double tauKill=10; double tauGrowNormal=20; double tauGrowResistent=tauGrowNormal; double N0mutation = 5e3; double N0normal=5e3; string FileName = "drift.txt";//Simulation"+ MutationRate.ToString("0.##E+0") +".txt"; System.IO.FileInfo myFile = new FileInfo(FileName); myFile.Delete(); StreamWriter SR = new StreamWriter(FileName,false); int sims=10; Well[] myTest=new Well[sims] ; Simulation[] mySimulation = new Simulation[sims]; SimulationParameters SP= new SimulationParameters( Nf,Nf, MutationRatio, tauKill, tauKill , tauGrowNormal, tauGrowResistent , 0,200); for (int sim=0;sim<sims;sim++) { myTest[sim] = new Well(N0normal,0,N0mutation); mySimulation[sim]= new Simulation(myTest[sim], sim+90, SP); } int rounds=200; for(int round=0;round<rounds;round++) { double gen=round*Math.Log(100,2); SR.Write("{0}\t",gen); for (int sim=0;sim<sims;sim++) { myTest[sim]=mySimulation[sim].DoGrowing(myTest[sim]); SR.Write("{0}\t",myTest[sim].NumberOfResistant); myTest[sim]=mySimulation[sim].DoDilution(myTest[sim],100); } SR.Write("\n"); PrintPresentege(round,rounds); } SR.Close(); }
private static void DeferentDilutionCyclesSimulation(double MutationRatio,double Dilution,double N0Persisters) { double Nf=1e9; int seed; double tauNormalKill=10; double tauPersisterKill=100; double tauGrowNormal=20; double tauGrowResistant=tauGrowNormal; //double N0Persisters = 1e6; double N0normal=Nf - N0Persisters; double N0Resisters = 0; double NormalPersistersFraction = N0Persisters/N0normal; //string FileName = "CyclesSimulation"+ MutationRatio.ToString("0.##E+0") +".txt"; string FileName = "DeferentDilutionCycleOfFixation_" + MutationRatio.ToString("0.00E+000") +"_"+Dilution.ToString()+ "_" +N0Persisters.ToString("0.##E+000")+".txt"; System.IO.FileInfo myFile = new FileInfo(FileName); myFile.Delete(); StreamWriter SR = new StreamWriter(FileName,false); int Simulations = 10000; for (int sim=0;sim < Simulations;sim++) { seed = sim; SimulationParameters SP = new SimulationParameters(Nf,10*Nf,MutationRatio,tauNormalKill,tauPersisterKill ,tauGrowNormal,tauGrowResistant ,NormalPersistersFraction,Dilution); Well NormalWell = new Well(N0normal,N0Persisters,N0Resisters); Simulation NormalSimulation= new Simulation(NormalWell,seed,SP); int cycle=0; do { cycle++; NormalWell = NormalSimulation.DoSycle(); } while (NormalWell.NumberOfResistant<Nf); SR.WriteLine(cycle); } SR.Close(); }
private static void DeferentDilutionCycleSimulation(double MutationRatio,double Dilution,double N0Persisters) { double Nf=1e9; int seed=1; double tauNormalKill=10; double tauPersisterKill=100; double tauGrowNormal=20; double tauGrowResistant=tauGrowNormal; //double N0Persisters = 1e8; double N0normal=Nf - N0Persisters; double N0Resisters = 0; double NormalPersistersFraction = N0Persisters/N0normal; string FileName = "OneExp_" + MutationRatio.ToString("0.##E+000") +"_"+Dilution.ToString() + "_" +N0Persisters.ToString("0.##E+000") +".txt"; System.IO.FileInfo myFile = new FileInfo(FileName); myFile.Delete(); StreamWriter SR = new StreamWriter(FileName,false); SimulationParameters SP = new SimulationParameters(Nf,10*Nf,MutationRatio,tauNormalKill,tauPersisterKill ,tauGrowNormal,tauGrowResistant ,NormalPersistersFraction,Dilution); Well NormalWell = new Well(N0normal,N0Persisters,N0Resisters); Simulation NormalSimulation= new Simulation(NormalWell,seed,SP); int cycle=0; do { cycle++; NormalWell = NormalSimulation.DoSycle(); SR.WriteLine("{0}\t{1}\t{2}\t{3}",cycle,NormalWell.NumberOfNormal,NormalWell.NumberOfPersistent,NormalWell.NumberOfResistant); } while (NormalWell.NumberOfResistant<Nf); SR.Close(); }
private static void CyclesSimulation() { double Nf=1e9; double MutationRatio=1e-8 ; int seed ; double tauNormalKill=10; double tauPersisterKill=100; double tauGrowNormal=20; double tauGrowResistant=tauGrowNormal; double N0Persisters ; double N0normal; double N0Resisters; double NormalPersistersFraction; double HighPersistersFraction; string FileName = "CyclesSimulation"+ MutationRatio.ToString("0.##E+0") +".txt"; System.IO.FileInfo myFile = new FileInfo(FileName); myFile.Delete(); StreamWriter SR = new StreamWriter(FileName,false); int Simulations = 10000; for (int sim=0;sim < Simulations;sim++) { seed = sim; N0Persisters = 1e6; N0normal=Nf - N0Persisters; N0Resisters = 0; NormalPersistersFraction = N0Persisters/N0normal; SimulationParameters SP ; SP= new SimulationParameters(Nf,Nf,MutationRatio,tauNormalKill,tauPersisterKill ,tauGrowNormal,tauGrowResistant ,NormalPersistersFraction,200); Well NormalWell = new Well(N0normal,N0Persisters,N0Resisters); Simulation NormalSimulation= new Simulation(NormalWell,seed,SP); do { NormalWell = NormalSimulation.DoSycle(); } while (NormalWell.NumberOfResistant<Nf); N0Persisters = 1e8; N0normal=Nf - N0Persisters; N0Resisters = 0; HighPersistersFraction = N0Persisters/N0normal; SP = new SimulationParameters(Nf,Nf,MutationRatio,tauNormalKill,tauPersisterKill ,tauGrowNormal,tauGrowResistant,HighPersistersFraction ,200); Well HighPersistenceWell = new Well(N0normal,N0Persisters,N0Resisters); Simulation HighPersistenceSimulation = new Simulation(HighPersistenceWell,seed,SP); do { HighPersistenceWell = HighPersistenceSimulation.DoSycle(); } while (HighPersistenceWell.NumberOfResistant<Nf); SR.WriteLine("{0}\t{1}",NormalSimulation.Cycle,HighPersistenceSimulation.Cycle); NormalSimulation = null; HighPersistenceSimulation = null; PrintPresentege(sim,Simulations); } SR.Close(); }