MoleculeType * NFtest_tlbr::createL(System * s, int count) { vector <string> compName; vector <string> defaultCompState; vector < vector <string> > possibleCompStates; compName.push_back("r0"); defaultCompState.push_back("No State"); vector <string> possibleR0states; possibleCompStates.push_back(possibleR0states); compName.push_back("r1"); defaultCompState.push_back("No State"); vector <string> possibleR1states; possibleCompStates.push_back(possibleR1states); compName.push_back("r2"); defaultCompState.push_back("No State"); vector <string> possibleR2states; possibleCompStates.push_back(possibleR2states); MoleculeType *L = new MoleculeType("L", compName, defaultCompState, possibleCompStates, s); L->populateWithDefaultMolecules(count); return L; }
MoleculeType * NFtest_tlbr::createR(System * s, int count) { vector <string> compName; vector <string> defaultCompState; vector < vector <string> > possibleCompStates; compName.push_back("l0"); defaultCompState.push_back("No State"); vector <string> possibleL0states; possibleCompStates.push_back(possibleL0states); compName.push_back("l1"); defaultCompState.push_back("No State"); vector <string> possibleL1states; possibleCompStates.push_back(possibleL1states); MoleculeType *R = new MoleculeType("R", compName, defaultCompState, possibleCompStates, s); R->populateWithDefaultMolecules(count); return R; }
void NFtest_transcription::run() { cout<<"Running the transcription system"<<endl; // 1) System *s = new System("Transcription System"); // 2) MoleculeType *molRNA = createRNA(s); // 3) Instantiate the actual molecules (this populate function is the easiest way, but you can do it // manually as well by creating each molecule separately - see the MoleculeType::populate function for // an example on how this can be done). molRNA->populateWithDefaultMolecules(500); // 4) Create the reactions and add them to the system. These are calls to specific functions // below where I set up the details of the reactions. The numbers are the rates and are in // arbitrary units here. In general, the rates should be in units of per second. ReactionClass * rna_degrade = createReactionRNAdegrades(molRNA, 0.5); ReactionClass *rna_transcribe = createReactionRNAtranscribed(molRNA, 100.0); s->addReaction(rna_degrade); s->addReaction(rna_transcribe); // 5) Add the observables that we want to track throughout the simulation. Again, to // see how this is done, see the function below. addObs(s, molRNA); // 6) Prepare the system for simulation (this adds molecules to reactionLists // and counts up the observables) s->prepareForSimulation(); s->printAllReactions(); // 7) Register the output file name (This will put the file in your working directory) // Here, you also want to output the header to the file, which is not done automatically // because you can run a simulation with multiple calls to the sim functions. s->registerOutputFileLocation("transcription_system_output.txt"); s->outputAllObservableNames(); //8) Run the simulation! //You can optionally equilibrate the system for a set amount of time where output is not //recorded (all times are in seconds) using this function where the first parameter is the //length of the equilibration, and the second is the number of times we want to print a //message that says how we are doing. After it equilibrates, the simulation time is reset to zero. //The first parameter is the number of seconds we want to equilibrate. The second (optional) parameter //is the number of times you want to print an 'ok' output message. If the second parameter is not //given, nothing is outputted to the console. s->equilibrate(0,10); //There are two ways to run a simulation. First, you can just call the function sim as in: s->sim(50,50); //Calling this sim function is the easist way to run a simulation. The first parameter is the //number of seconds you want to run for, the second is the number of times you want to output //the results to the outputfile. So in this example, we run for 500 seconds and output 500 times, //so we output once per second. //The second way to run a simulation is to call this stepTo function: cout<<endl<<endl<<"Calling the stepTo function and stepping to the system time t=600 seconds"<<endl; double stoppingTime = s->stepTo(600); cout<<"The last reaction was fired at simulation time: "<<stoppingTime<<endl<<endl; //This function runs the simulation until the given time is reached, and it also returns the //time of the simulation when the last reaction fired (which is now the current time in the //system. This function does not output to a file automatically, so to output using this function, //so to get results, you will have to use a call to this function: s->outputAllObservableCounts(); //The stepTo function will have to be written as part of a loop where you decide when it should //output. This gives you more control, but of course requires more work. //Here we can print out the list of reactions. This is nice because it tells us how many times //a reaction fired, and how many molecules are in each list at the end of the simulation s->printAllReactions(); //Be nice and clean up when we are done. Deleting the system (should) delete everything else //associated with the system, so we don't ever have to remember to delete individual reactions, molecules //moleculeTypes, etc... delete s; }