00001 // PlasmidReplicationReaction.cpp: implementation of the PlasmidReplicationReaction class. 00002 // 00004 00005 #include "PlasmidReplicationReaction.h" 00006 00008 // Construction/Destruction 00010 00011 PlasmidReplicationReaction::PlasmidReplicationReaction(Chemical *Generator, std::vector<Chemical *> Products, RateConstant *k_g, std::string reactionName) 00012 :Reaction(reactionName) 00013 { 00014 // stoichiometry 00015 this->Generator = chemicals.size(); 00016 chemicals.push_back(Generator); 00017 numberOfEachChemicalChangedByReaction.push_back(0); 00018 00019 this->ProductNum = Products.size(); 00020 for (int productcounter = 0; productcounter < Products.size(); ++productcounter) 00021 { 00022 this->Product = chemicals.size(); 00023 chemicals.push_back(Products[productcounter]); 00024 numberOfEachChemicalChangedByReaction.push_back(+1); 00025 // this->Product.push_back(Products[productcounter]); 00026 // chemicals.push_back(Products[productcounter]); 00027 // numberOfEachChemicalChangedByReaction.push_back(+1); 00028 } 00029 00030 // rates 00031 this->k_g = rateConstants.size(); 00032 rateConstants.push_back(k_g); 00033 00034 // put enough dummy chemicalJacobian elements on the vector 00035 // - they are recomputed every time you ask for the chemicalJacobian 00036 chemicalJacobian.push_back(new JElement(-1,-1)); 00037 00038 this->SetTeXForm(); 00039 } 00040 00041 PlasmidReplicationReaction::~PlasmidReplicationReaction() 00042 { 00043 00044 } 00045 00046 double PlasmidReplicationReaction::GetRate() const 00047 { 00048 double temp = 0.0; 00049 int productcounter; 00050 // initialize productcounter to 1 to avoid including TraRDimer 00051 /* for (productcounter = 1; productcounter <= ProductNum; ++productcounter) 00052 { 00053 temp += chemicals[productcounter]->GetAmount(); 00054 } 00055 temp = temp/ProductNum; 00056 temp += rateConstants[k_g]->GetValue() * chemicals[Generator]->GetAmount(); 00057 return temp; 00058 */ return rateConstants[k_g]->GetValue() * chemicals[Generator]->GetAmount(); 00059 } 00060 00061 void PlasmidReplicationReaction::SetTeXForm() 00062 { 00063 int productcounter; 00064 // strstream stream; 00065 std::ostringstream stream; 00066 // TeX form of the reaction 00067 stream << rateConstants[k_g]->GetTeXName().c_str(); 00068 stream << "\\left [" << chemicals[Generator]->GetTeXName().c_str(); 00069 stream << "\\right ]"; 00070 stream << "\\left (\\right )"; 00071 //initialize productcounter to 1 to avoid TraRDimer 00072 stream << " \\left [" << chemicals[1]->GetTeXName().c_str(); 00073 stream << "\\right ] \\\\ \n"; 00074 for (productcounter = 2; productcounter <= ProductNum; ++productcounter) 00075 { 00076 stream << " + \\left [" << chemicals[productcounter]->GetTeXName().c_str(); 00077 stream << "\\right ] \\\\ \n"; 00078 } 00079 stream << " \\left (\\right )"<< " / " << ProductNum; 00080 // add a NULL 00081 //int namesize = (chemicals[Generator]->GetName()).length(); 00082 //stream << (chemicals[Generator]->GetName())[namesize]; 00083 stream << std::ends; 00084 // set the TeX string equal to what's in the stream 00085 m_sTeXForm = stream.str(); 00086 // free up the string 00087 // stream.rdbuf()->freeze(0); 00088 } 00089 00090 std::vector<Reaction::JElement *> *PlasmidReplicationReaction::GetChemicalJacobian() 00091 { 00092 /* double temp = 0.0; 00093 int productcounter; 00094 for (productcounter=1; productcounter <= ProductNum; productcounter++) 00095 { 00096 temp += chemicals[productcounter]->GetAmount(); 00097 } 00098 */ 00099 chemicalJacobian[0]->SetWithRespectTo(chemicals[Generator]->GetChemicalNumber()); 00100 chemicalJacobian[0]->SetJValue(rateConstants[k_g]->GetValue()); 00101 // chemicalJacobian[0]->SetJValue(rateConstants[k_g]->GetValue()*temp); 00102 00103 /* for (productcounter=1; productcounter<=ProductNum; productcounter++) 00104 { 00105 chemicalJacobian[productcounter]->SetWithRespectTo(chemicals[productcounter]->GetChemicalNumber()); 00106 chemicalJacobian[productcounter]->SetJValue(rateConstants[k_g]->GetValue()*chemicals[Generator]->GetAmount()); 00107 } 00108 */ 00109 return &chemicalJacobian; 00110 }