COPASI API  4.16.103
CReactionInterface.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2005 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #include <string>
16 
17 #include "CReactionInterface.h"
18 #include "CReaction.h"
19 #include "CModel.h"
20 #include "CChemEqElement.h"
22 #include "function/CFunctionDB.h"
23 #include "report/CKeyFactory.h"
26 
28  mpModel(pModel),
29  mChemEqI(pModel),
30  mpFunction(NULL),
31  mpParameters(NULL)
32 {
33  assert(mpModel != NULL);
34  emptyString = "";
35 }
36 
38 {
40  //pdelete(mpChemEq);
41 }
42 
43 const std::vector<std::string> & CReactionInterface::getListOfMetabs(CFunctionParameter::Role role) const
44 {
45  return mChemEqI.getListOfDisplayNames(role);
46 }
47 
48 std::vector< std::string > CReactionInterface::getListOfPossibleFunctions() const
49 {
50  TriLogic reversible;
51 
52  if (isReversible() == false)
53  reversible = TriFalse;
54  else
55  reversible = TriTrue;
56 
57  std::vector<CFunction*> functionVector =
61  reversible);
62 
63  std::vector<std::string> ret;
64  size_t i, imax = functionVector.size();
65 
66  for (i = 0; i < imax; ++i)
67  ret.push_back(functionVector[i]->getObjectName());
68 
69  return ret;
70 }
71 
72 void CReactionInterface::initFromReaction(const std::string & key)
73 {
75 
76  const CReaction *rea;
77  rea = dynamic_cast< CReaction *>(CCopasiRootContainer::getKeyFactory()->get(key));
78  assert(rea);
79  initFromReaction(rea);
80 }
81 
83 {
84  const CReaction *rea = mpModel->getReactions()[index];
85 
87  assert(rea);
88  initFromReaction(rea);
89 }
90 
92 {
93  //chemical equation
95 
97  {
98  //function
99  mpFunction = rea->getFunction();
102 
103  //mapping
104  loadMappingAndValues(*rea);
105  }
106  else
107  {
109  }
110 }
111 
113 {
114  bool success = true;
115  std::vector< std::vector<std::string> >::const_iterator it;
116  std::vector< std::vector<std::string> >::const_iterator iEnd;
117  std::vector<std::string>::const_iterator jt;
118  std::vector<std::string>::const_iterator jEnd;
119  size_t i;
120 
121  std::string metabName;
122  const CModelEntity* pObj;
123 
124  std::vector<std::string> SubList;
125  SubList.resize(1);
126  SubList[0] = "unknown";
127 
128  mNameMap.resize(size());
129 
130  for (i = 0; i != size(); ++i)
131  {
132  mNameMap[i] = SubList;
133  }
134 
135  mValues.resize(size(), 0.1);
136  mIsLocal.resize(size(), false);
137 
138  it = rea.getParameterMappings().begin();
139  iEnd = rea.getParameterMappings().end();
140 
141  for (i = 0; it != iEnd; ++it, ++i)
142  {
143 
144  if (isVector(i))
145  {
149 
150  SubList.clear();
151 
152  for (jt = it->begin(), jEnd = it->end(); jt != jEnd; ++jt)
153  {
154  metabName = CMetabNameInterface::getDisplayName(mpModel, *jt, true);
155  assert(metabName != "");
156  SubList.push_back(metabName);
157  }
158  }
159  else
160  {
161  assert(it->size() == 1);
162  SubList.resize(1); SubList[0] = "unknown";
163 
164  switch (getUsage(i))
165  {
169  metabName = CMetabNameInterface::getDisplayName(mpModel, *(it->begin()), true);
170  // assert(metabName != "");
171  SubList[0] = metabName;
172  //TODO: check if the metabolite is in the chemical equation with the correct rule
173  break;
174 
176  pObj = dynamic_cast<const CCompartment*>(CCopasiRootContainer::getKeyFactory()->get(*(it->begin())));
177  assert(pObj);
178  SubList[0] = pObj->getObjectName();
179  break;
180 
182  pObj = dynamic_cast<const CModel*>(CCopasiRootContainer::getKeyFactory()->get(*(it->begin())));
183  assert(pObj);
184  SubList[0] = pObj->getObjectName();
185  break;
186 
188  {
189  const CCopasiParameter * pParameter = rea.getParameters().getParameter(getParameterName(i));
190 
191  if (pParameter != NULL)
192  {
193  mValues[i] = * pParameter->getValue().pDOUBLE;
194  }
195  else
196  {
197  mValues[i] = std::numeric_limits< C_FLOAT64 >::quiet_NaN();
198  }
199 
200  mIsLocal[i] = rea.isLocalParameter(i);
201 
202  if (!mIsLocal[i])
203  {
204  pObj = dynamic_cast<const CModelValue*>(CCopasiRootContainer::getKeyFactory()->get(*(it->begin())));
205 
206  if (pObj)
207  {
208  SubList[0] = pObj->getObjectName();
209  mValues[i] = pObj->getInitialValue();
210  }
211  }
212  }
213  break;
214 
215  default:
216  break;
217  }
218  }
219 
220  mNameMap[i] = SubList;
221  }
222 
223  return success;
224 }
225 
227 {
228  bool success = true;
229 
230  //CReaction *rea;
231  if (rea == NULL)
233 
234  if (rea == NULL) return false;
235 
236  // Now we can safely write to the equation as we are sure that only unique metabolites
237  // may have the empty string as compartments
239 
240  if (!isValid()) return false; // do nothing
241 
242  if (mpFunction == NULL) return false;
243 
244  if (mpFunction->getObjectName() == "undefined") return false;
245 
246  if (mpParameters == NULL) return false;
247 
248  if (!(*mpParameters == mpFunction->getVariables())) return false; // do nothing
249 
250  // TODO. check if function has changed since it was set in the R.I.
252 
253  size_t j, jmax;
254  size_t i, imax = size();
255  std::pair< std::string, std::string > Names;
256 
257  for (i = 0; i < imax; ++i)
258  {
259  switch (getUsage(i))
260  {
262 
263  if (mIsLocal[i])
265  else
266  {
267  rea->setParameterValue(getParameterName(i), mValues[i], false);
269  }
270 
271  break;
272 
275  break;
276 
278  rea->setParameterMapping(i, mpModel->getKey()); //time is the value of the model
279  break;
280 
284 
285  if (isVector(i))
286  {
287  rea->clearParameterMapping(i);
288  jmax = mNameMap[i].size();
289 
290  for (j = 0; j < jmax; ++j)
291  {
293  rea->addParameterMapping(i, CMetabNameInterface::getMetaboliteKey(mpModel, Names.first, Names.second));
294  }
295  }
296  else
297  {
299  rea->setParameterMapping(i, CMetabNameInterface::getMetaboliteKey(mpModel, Names.first, Names.second));
300  }
301 
302  break;
303 
304  default:
305  break;
306  }
307  }
308 
309  rea->compile();
310  mpModel->setCompileFlag(); //TODO: check if really necessary
311 
312  return success;
313 }
314 
316 {
317  mpFunction = NULL;
319  //mValid = false;
320 
321  mValues.clear();
322  mNameMap.clear();
323 }
324 
325 void CReactionInterface::setChemEqString(const std::string & eq, const std::string & newFunction)
326 {
328  findAndSetFunction(newFunction);
329 }
330 
331 void CReactionInterface::setReversibility(bool rev, const std::string & newFunction)
332 {
334  findAndSetFunction(newFunction);
335 }
336 
337 void CReactionInterface::reverse(bool rev, const std::string & newFunction)
338 {
340  mChemEqI.reverse();
341  findAndSetFunction(newFunction);
342 }
343 
344 void CReactionInterface::findAndSetFunction(const std::string & newFunction)
345 {
346  std::vector<std::string> fl = getListOfPossibleFunctions();
347  size_t i, imax = fl.size();
348 
349  //no valid function?
350  if (imax == 0)
351  {
353  return;
354  }
355 
356  //first try the function provided as argument
357  if (newFunction != "")
358  {
359  for (i = 0; i < imax; ++i)
360  if (fl[i] == newFunction)
361  {
363  return;
364  }
365  }
366 
367  //next try if the current function works
368  std::string currentFunctionName = getFunctionName();
369 
370  if ("" != currentFunctionName)
371  {
372  for (i = 0; i < imax; ++i)
373  if (fl[i] == currentFunctionName)
374  {
376  return;
377  }
378  }
379 
380  // if not found then see if there is a best match in the list (i.e. a corresponding rev/irrev function).
381  //if there is a current function try to find a related new function
382  std::string s;
383 
384  if (currentFunctionName != "")
385  {
386  s = currentFunctionName.substr(0, currentFunctionName.find('(') - 1);
387 
388  //'-1' so as to strip off the white space before '('
389  //This is purely heuristics
390  for (i = 0; i < imax; i++)
391  {
392  if (fl[i].find(s) != std::string::npos) // if find succeeds, the return value is likely to be 0
393  //if (fl[i].find(s) >= 0) - for some reason this doesn't work
394  {
396  return;
397  }
398  }
399  }
400 
401  //try mass action next
402  s = "Mass action";
403 
404  for (i = 0; i < imax; i++)
405  {
406  if (fl[i].find(s) != std::string::npos) // if find succeeds, the return value is likely to be 0
407  //if (fl[i].find(s) >= 0) - for some reason this doesn't work
408  {
410  return;
411  }
412  }
413 
414  //try constant flux next
415  s = "Constant flux";
416 
417  for (i = 0; i < imax; i++)
418  {
419  if (fl[i].find(s) != std::string::npos) // if find succeeds, the return value is likely to be 0
420  //if (fl[i].find(s) >= 0) - for some reason this doesn't work
421  {
423 
424  // If we have a reaction of the type X + Y = and the function
425  // is Constant flux (reversible) we need to set the parameter v to
426  // be negative to avoid negative concentrations during time course simulations.
427  // Note, this fix is only done when we are assigning a default rate law.
428  if (mChemEqI.getReversibility() == true &&
430  {
431  C_FLOAT64 v = - fabs(getLocalValue(0));
432  setLocalValue(0, v);
433  }
434 
435  return;
436  }
437  }
438 
439  //if everything else fails just take the first function from the list
440  //this should not be reached since constant flux is a valid kinetic function for every reaction
442 }
443 
445 {
446  size_t i, imax = mpParameters->getNumberOfParametersByUsage(role);
447 
448  if (!imax) return;
449 
450  // get the list of chem eq elements
451  std::vector<std::string> el = getExpandedMetabList(role);
452 
453  // get the first parameter with the respective role
455  size_t pos = 0;
456  Type = mpParameters->getParameterByUsage(role, pos)->getType();
457 
458  if (Type == CFunctionParameter::VFLOAT64)
459  {
460  mNameMap[pos - 1] = el;
461  }
462  else if (Type == CFunctionParameter::FLOAT64)
463  {
464  if (el.size() > 0)
465  mNameMap[pos - 1][0] = el[0];
466  else
467  {mNameMap[pos - 1][0] = "unknown"; /*mValid = false;*/}
468 
469  for (i = 1; i < imax; ++i)
470  {
471  Type = mpParameters->getParameterByUsage(role, pos)->getType();
472 
474 
475  if (el.size() > i)
476  mNameMap[pos - 1][0] = el[i];
477  else
478  {mNameMap[pos - 1][0] = "unknown"; /*mValid = false;*/}
479  }
480  }
481  else fatalError();
482 }
483 
484 bool CReactionInterface::isLocked(size_t index) const
485 {return isLocked(getUsage(index));}
486 
488 {
489  switch (usage)
490  {
492  return false;
493  break;
494 
496  return true;
497  break;
498 
501  {
502  // get number of parameters
503  size_t paramSize = mpParameters->getNumberOfParametersByUsage(usage);
504 
505  if (paramSize == 0)
506  return true;
507 
508  // get index of first parameter
509  size_t pos = 0;
510  mpParameters->getParameterByUsage(usage, pos); --pos;
511 
512  if (isVector(pos))
513  {
514  assert(paramSize == 1);
515  return true;
516  }
517  else
518  {
519  return (mChemEqI.getListOfDisplayNames(usage).size() == 1);
520  }
521  }
522  break;
523 
525  return mpModel->getModelValues().size() <= 1;
526  break;
527 
529  return mpModel->getCompartments().size() <= 1;
530  break;
531 
532  default:
533  break;
534  }
535 
536  return false;
537 }
538 
539 std::set< const CCopasiObject * > CReactionInterface::getDeletedParameters() const
540 {
541  std::set< const CCopasiObject * > ToBeDeleted;
542 
543  // We need to compare the current visible local parameter with the one stored
544  // in the reaction.
545  const CReaction * pReaction
547 
548  if (pReaction == NULL)
549  return ToBeDeleted;
550 
551  if (pReaction->getFunction() == NULL)
552  return ToBeDeleted;
553 
554  const CFunctionParameters & OriginalParameters
555  = pReaction->getFunction()->getVariables();
556 
557  size_t j, jmax = size();
558  size_t i, imax = OriginalParameters.size();
559  const CFunctionParameter * pParameter;
560 
561  for (i = 0; i < imax; ++i)
562  {
563  pParameter = OriginalParameters[i];
564 
565  if (pParameter->getUsage() == CFunctionParameter::PARAMETER &&
566  pReaction->isLocalParameter(i))
567  {
568  const std::string & Name = pParameter->getObjectName();
569 
570  //find parameter with same name in current parameters
571  for (j = 0; j < jmax; ++j)
572  if (Name == getParameterName(j)) break;
573 
574  if (j < jmax && mIsLocal[j])
575  continue;
576 
577  // The old parameter is either not found or is no longer local, i.e., it needs to
578  // be added to values to be deleted.
579  ToBeDeleted.insert(pReaction->getParameters().getParameter(Name));
580  }
581  }
582 
583  return ToBeDeleted;
584 }
585 
587 {
589  //make sure mpParameters is deleted! (e.g. in copyMapping())
590  mNameMap.resize(size());
591  mValues.resize(size());
592  mIsLocal.resize(size());
593  size_t i, imax = size();
594 
595  for (i = 0; i < imax; ++i)
596  {
597  if (isVector(i))
598  mNameMap[i].resize(0);
599  else
600  {
601  mNameMap[i].resize(1);
602  mNameMap[i][0] = "unknown";
603  }
604 
606  mIsLocal[i] = true;
607  else
608  mIsLocal[i] = false;
609 
610  mValues[i] = 0.1;
611  }
612 }
613 
615 {
616  if (!mpParameters) //nothing to copy
617  {
618  initMapping();
619  return;
620  }
621 
622  // save the old information
623  CFunctionParameters *oldParameters = mpParameters;
624  std::vector<std::vector<std::string> > oldMap = mNameMap;
625  std::vector<C_FLOAT64> oldValues = mValues;
626  std::vector<bool> oldIsLocal = mIsLocal;
627 
628  //create new mapping
629  initMapping();
630 
631  //try to preserve as much information from the old mapping as possible
632  size_t j, jmax = oldParameters->size();
633  size_t i, imax = size();
634 
635  for (i = 0; i < imax; ++i)
636  {
637  //find parameter with same name in old parameters
638  for (j = 0; j < jmax; ++j)
639  if ((*oldParameters)[j]->getObjectName() == getParameterName(i)) break;
640 
641  if (j == jmax) continue;
642 
643  //see if usage matches
644  if (getUsage(i) != (*oldParameters)[j]->getUsage()) continue;
645 
646  //see if vector property matches
647  if (isVector(i) != ((*oldParameters)[j]->getType() == CFunctionParameter::VFLOAT64))
648  continue;
649 
650  mIsLocal[i] = oldIsLocal[j];
651  mValues[i] = oldValues[j];
652 
653  switch (getUsage(i))
654  {
657  //TODO: check with chemeq
658  mNameMap[i] = oldMap[j];
659  break;
660 
662  //TODO: check existence?
663  mNameMap[i] = oldMap[j];
664  //TODO: add to chemeq
665  break;
666 
670  //TODO: check existence?
671  mNameMap[i] = oldMap[j];
672  break;
673 
674  default:
675  break;
676  }
677  }
678 
679  pdelete(oldParameters);
680 }
681 
683 {
684  size_t i, imax = size();
685 
686  for (i = 0; i < imax; ++i)
687  {
688  //only do something if the current mapping is "unknown"
689  if (mNameMap[i].size())
690  if (mNameMap[i][0] != "unknown")
691  continue;
692 
693  if (isLocalValue(i))
694  continue;
695 
696  switch (getUsage(i))
697  {
701  break;
702 
704 
705  if (mpModel->getModelValues().size() == 1)
706  mNameMap[i][0] = mpModel->getModelValues()[0]->getObjectName();
707 
708  break;
709 
711  //if (mpModel->getCompartments().size()==1)
712  // mNameMap[i][0] = mpModel->getCompartments()[0]->getObjectName();
713  {
714  const CCompartment* comp = mChemEqI.getCompartment();
715 
716  if (comp)
717  mNameMap[i][0] = comp->getObjectName();
718  }
719  break;
720 
722  mNameMap[i][0] = mpModel->getObjectName();
723  break;
724 
725  default:
726  break;
727  }
728  }
729 }
730 
732 {
733  if ((fn == "") || (fn == "undefined"))
734  {clearFunction(); return;}
735 
736  //get the function
737  mpFunction = dynamic_cast<CFunction *>
739 
740  if (!mpFunction) fatalError();
741 
743  initMapping(); //empty mapping
744 }
745 
747 {
748  if ((fn == "") || (fn == "undefined"))
749  {clearFunction(); return;}
750 
751  //get the function
752  mpFunction = dynamic_cast<CFunction *>
754 
755  if (!mpFunction) fatalError();
756 
757  copyMapping();
759 
760  //guess initial connections between metabs and function parameters
763  connectFromScratch(CFunctionParameter::MODIFIER); // we can not be pedantic about modifiers
764  // because modifiers are not taken into acount
765  // when looking for suitable functions
766 }
767 
769 {
771  size_t j, jmax = size();
772 
773  for (j = 0; j < jmax; ++j)
774  if (getUsage(j) == CFunctionParameter::MODIFIER) //all the modifiers in the table
775  if (getMapping(j) != "unknown")
777 }
778 
779 void CReactionInterface::setMapping(size_t index, std::string mn)
780 {
781  mIsLocal[index] = false;
782 
783  switch (getUsage(index))
784  {
788  assert(!isVector(index));
789  mNameMap[index][0] = mn;
790  break;
791 
794 
795  if (isVector(index))
796  mNameMap[index].push_back(mn);
797  else
798  {
799  mNameMap[index][0] = mn;
800 
801  //TODO: check the following
802  // if we have two parameters of this usage change the other one.
803  size_t listSize = mChemEqI.getListOfDisplayNames(getUsage(index)).size();
804 
805  if ((listSize == 2) && (mpParameters->getNumberOfParametersByUsage(getUsage(index)) == 2))
806  {
807  // get index of other parameter
808  size_t pos = 0;
810 
811  if ((pos - 1) == index) mpParameters->getParameterByUsage(getUsage(index), pos);
812 
813  --pos;
814 
815  // get name if other metab
816  std::vector<std::string> ml = getListOfMetabs(getUsage(index));
817  std::string otherMetab;
818  if (ml[0] == mn) otherMetab = ml[1]; else otherMetab = ml[0];
819 
820  // set other parameter
821  mNameMap[pos][0] = otherMetab;
822  }
823  }
824 
825  break;
826 
828  assert(!isVector(index));
829  mNameMap[index][0] = mn;
831  break;
832 
833  default:
834  break;
835  }
836 }
837 
839 {
840  const std::vector<std::string> & names = mChemEqI.getListOfDisplayNames(role);
841  const std::vector<C_FLOAT64> & mults = mChemEqI.getListOfMultiplicities(role);
842 
843  size_t j, jmax;
844  size_t i, imax = names.size();
845 
846  std::vector<std::string> ret;
847 
848  for (i = 0; i < imax; ++i)
849  {
850  if (role == CFunctionParameter::MODIFIER)
851  {
852  jmax = 1;
853  }
854  else
855  {
856  C_FLOAT64 Multiplicity = mults[i];
857 
858  if (Multiplicity == floor(Multiplicity + 0.5))
859  {
860  jmax = (size_t) Multiplicity;
861  }
862  else
863  {
864  jmax = 1;
865  }
866  }
867 
868  for (j = 0; j < jmax; ++j)
869  {
870  ret.push_back(names[i]);
871  }
872  }
873 
874  return ret;
875 }
876 
878 {
879  bool created = mChemEqI.createNonExistingMetabs();
880 
881  // Update the parameter mapping to assure that the new names match.
882  if (created)
884 
885  return created;
886 }
887 
889 {
890  bool ret = false;
891 
892  size_t i, imax = size();
893 
894  for (i = 0; i < imax; ++i)
895  {
896  switch (getUsage(i))
897  {
899 
900  if (mNameMap[i][0] == "unknown" || mNameMap[i][0] == "") break;
901 
902  if (mpModel->createCompartment(mNameMap[i][0], 1.0))
903  ret = true;
904 
905  break;
906 
908 
909  if (mNameMap[i][0] == "unknown" || mNameMap[i][0] == "") break;
910 
911  if (!isLocalValue(i))
912  if (mpModel->createModelValue(mNameMap[i][0], 1.0))
913  ret = true;
914 
915  break;
916 
917  default:
918  break;
919  }
920  }
921 
922  return ret;
923 }
924 
926 {
927  return mChemEqI.isMulticompartment();
928 }
929 
931 {
932  //A reaction is invalid if it has a metab, a global parameter, or a compartment "unknown"
933  size_t j, jmax = size();
934 
935  for (j = 0; j < jmax; ++j)
936  if ((mNameMap[j][0] == "unknown") && (!mIsLocal[j]))
937  return false;
938 
939  return true;
940 }
941 
942 #ifdef COPASI_DEBUG
943 void CReactionInterface::printDebug() const
944 {
945  std::cout << "Reaction interface " << std::endl;
946  std::cout << " Function: " << getFunctionName() << std::endl;
947  std::cout << " ChemEq: " << getChemEqString() << std::endl;
948 
949  size_t i, imax = size();
950 
951  for (i = 0; i < imax; ++i)
952  {
953  std::cout << " --- " << i << ": " << getParameterName(i)
954  << ", vector: " << isVector(i) << " local: " << isLocalValue(i)
955  << ", value: " << mValues[i] << std::endl;
956 
957  size_t j, jmax = mNameMap[i].size();
958 
959  for (j = 0; j < jmax; ++j)
960  std::cout << " " << mNameMap[i][j] << std::endl;
961  }
962 
963  std::cout << std::endl;
964 }
965 #endif // COPASI_DEBUG
size_t getMolecularity(CFunctionParameter::Role role) const
std::string getParameterName(size_t index) const
bool loadFromChemEq(const CChemEq &ce)
void setChemEqString(const std::string &eq, const std::string &newFunction)
void findAndSetFunction(const std::string &newFunction)
static std::string getMetaboliteKey(const CModel *model, const std::string &metabolite, const std::string &compartment)
bool createOtherObjects() const
#define pdelete(p)
Definition: copasi.h:215
void setReversibility(bool rev)
static CFunction * getUndefinedFunction()
const CFunctionParameter::DataType & getType() const
const std::string & getObjectName() const
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
virtual size_t size() const
std::vector< CFunction * > suitableFunctions(const size_t noSubstrates, const size_t noProducts, const TriLogic reversibility)
CCopasiObject * get(const std::string &key)
virtual const std::string & getKey() const
Definition: CReaction.cpp:190
TriLogic
Definition: copasi.h:125
void setParameterValue(const std::string &parameterName, const C_FLOAT64 &value, const bool &updateStatus=true)
Definition: CReaction.cpp:303
#define fatalError()
void connectFromScratch(CFunctionParameter::Role role)
void initFromReaction(const std::string &key)
size_t getNumberOfParametersByUsage(CFunctionParameter::Role usage) const
bool isLocalParameter(const size_t &index) const
Definition: CReaction.cpp:449
const CCompartment * getCompartment() const
void clearParameterMapping(const std::string &parameterName)
Definition: CReaction.cpp:407
CModelValue * createModelValue(const std::string &name, const C_FLOAT64 &value=0.0)
Definition: CModel.cpp:2838
bool isVector(size_t index) const
std::vector< C_FLOAT64 > mValues
#define C_INT32
Definition: copasi.h:90
static std::string getDisplayName(const CModel *model, const std::string &key, const bool &quoted)
CFunction * findLoadFunction(const std::string &functionName)
bool isLocked(size_t index) const
const C_FLOAT64 & getLocalValue(size_t index) const
const std::string & getMapping(size_t index) const
virtual const std::string & getKey() const
const C_FLOAT64 & getInitialValue() const
void compile()
Definition: CReaction.cpp:583
const CFunction * getFunction() const
Definition: CReaction.cpp:252
CFunctionParameter::Role getUsage(size_t index) const
std::string mReactionReferenceKey
bool loadMappingAndValues(const CReaction &rea)
bool setFunction(const std::string &functionName)
Definition: CReaction.cpp:255
const std::vector< std::string > & getListOfDisplayNames(CFunctionParameter::Role role) const
bool setChemEqString(const std::string &ces)
std::vector< std::vector< std::string > > mNameMap
bool isReversible() const
const Value & getValue() const
void setMapping(size_t index, std::string mn)
void reverse(bool rev, const std::string &newFunction)
const CFunctionParameter * getParameterByUsage(CFunctionParameter::Role usage, size_t &pos) const
CCopasiParameter * getParameter(const std::string &name)
const std::string & getKey() const
Definition: CModel.cpp:1142
static CFunctionDB * getFunctionList()
const std::vector< C_FLOAT64 > & getListOfMultiplicities(CFunctionParameter::Role role) const
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607
bool writeToChemEq(CChemEq &ce) const
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
void setLocalValue(size_t index, C_FLOAT64 value)
static std::pair< std::string, std::string > splitDisplayName(const std::string &name)
std::set< const CCopasiObject * > getDeletedParameters() const
static CKeyFactory * getKeyFactory()
const std::vector< std::string > & getListOfMetabs(CFunctionParameter::Role role) const
std::vector< std::string > getExpandedMetabList(CFunctionParameter::Role role) const
#define C_FLOAT64
Definition: copasi.h:92
std::vector< bool > mIsLocal
const CCopasiParameterGroup & getParameters() const
Definition: CReaction.cpp:333
void setParameterMapping(const size_t &index, const std::string &key)
Definition: CReaction.cpp:339
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
CChemEqInterface mChemEqI
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
std::string getChemEqString() const
void addModifier(const std::string &name)
Definition: CModel.h:50
const std::string & getFunctionName() const
bool isMulticompartment() const
CFunctionParameters * mpParameters
size_t size() const
bool writeBackToReaction(CReaction *rea)
bool getReversibility() const
const CFunction * mpFunction
bool isLocalValue(size_t index) const
const std::vector< std::vector< std::string > > & getParameterMappings() const
Definition: CReaction.h:285
std::vector< std::string > getListOfPossibleFunctions() const
bool isMulticompartment() const
void setFunctionAndDoMapping(const std::string &fn)
const CChemEq & getChemEq() const
Definition: CReaction.cpp:223
void setReversibility(bool rev, const std::string &newFunction)
CFunctionParameters & getVariables()
Definition: CFunction.cpp:148
void addParameterMapping(const size_t &index, const std::string &key)
Definition: CReaction.cpp:348
CCompartment * createCompartment(const std::string &name, const C_FLOAT64 &volume=1.0)
Definition: CModel.cpp:2698
void setFunctionWithEmptyMapping(const std::string &fn)