00001 // MichaelisMentenReaction.cpp: implementation of the MichaelisMentenReaction class. 00002 // 00004 00005 #include "MichaelisMentenReaction.h" 00006 00008 // Construction/Destruction 00010 00011 MichaelisMentenReaction::MichaelisMentenReaction(Chemical *Enzyme, Chemical *Substrate, Chemical *Product, RateConstant *k_2, RateConstant *K_m, std::string reactionName) 00012 :Reaction(reactionName) 00013 { 00014 // stoichiometry 00015 this->Enzyme = chemicals.size(); 00016 chemicals.push_back(Enzyme); 00017 numberOfEachChemicalChangedByReaction.push_back(0); 00018 00019 this->Substrate = chemicals.size(); 00020 chemicals.push_back(Substrate); 00021 numberOfEachChemicalChangedByReaction.push_back(-1); 00022 00023 this->Product = chemicals.size(); 00024 chemicals.push_back(Product); 00025 numberOfEachChemicalChangedByReaction.push_back(+1); 00026 00027 // rates 00028 this->k_2 = rateConstants.size(); 00029 rateConstants.push_back(k_2); 00030 00031 this->K_m = rateConstants.size(); 00032 rateConstants.push_back(K_m); 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 chemicalJacobian.push_back(new JElement(-1,-1)); 00038 00039 this->SetTeXForm(); 00040 } 00041 00042 MichaelisMentenReaction::~MichaelisMentenReaction() 00043 { 00044 00045 } 00046 00047 double MichaelisMentenReaction::GetRate() const 00048 { 00049 return rateConstants[k_2]->GetValue()*chemicals[Enzyme]->GetAmount()* 00050 (chemicals[Substrate]->GetAmount()/(chemicals[Substrate]->GetAmount() + rateConstants[K_m]->GetValue())); 00051 } 00052 00053 void MichaelisMentenReaction::SetTeXForm() 00054 { 00055 std::stringstream stream; 00056 // TeX form of the reaction 00057 stream << rateConstants[k_2]->GetTeXName().c_str(); 00058 stream << " \\left[" << chemicals[Enzyme]->GetTeXName().c_str() << "\\right]"; 00059 stream << " {\\left[" << chemicals[Substrate]->GetTeXName().c_str() << "\\right]"; 00060 stream << "\\over {"; 00061 stream << "\\left[" << chemicals[Substrate]->GetTeXName().c_str() << "\\right]"; 00062 stream << " + " << rateConstants[K_m]->GetTeXName().c_str() << "}}"; 00063 // add a NULL 00064 stream << ends; 00065 // set the TeX string equal to what's in the stream 00066 m_sTeXForm = stream.str(); 00067 // allow memory to be freed 00068 // stream.rdbuf()->freeze(0); 00069 } 00070 00071 std::vector<Reaction::JElement *> *MichaelisMentenReaction::GetChemicalJacobian() 00072 { 00073 chemicalJacobian[0]->SetWithRespectTo(chemicals[Enzyme]->GetChemicalNumber()); 00074 chemicalJacobian[0]->SetJValue((rateConstants[k_2]->GetValue()*chemicals[Substrate]->GetAmount())/(chemicals[Substrate]->GetAmount() + rateConstants[K_m]->GetValue())); 00075 00076 chemicalJacobian[1]->SetWithRespectTo(chemicals[Substrate]->GetChemicalNumber()); 00077 chemicalJacobian[1]->SetJValue((rateConstants[k_2]->GetValue()*rateConstants[K_m]->GetValue()*chemicals[Enzyme]->GetAmount()) 00078 / ((chemicals[Substrate]->GetAmount() + rateConstants[K_m]->GetValue())*(chemicals[Substrate]->GetAmount() + rateConstants[K_m]->GetValue())) ); 00079 00080 return &chemicalJacobian; 00081 }