COPASI API  4.16.103
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CReactionInterface Class Reference

#include <CReactionInterface.h>

Collaboration diagram for CReactionInterface:
Collaboration graph
[legend]

Public Member Functions

 CReactionInterface (CModel *pModel)
 
bool createMetabolites ()
 
bool createOtherObjects () const
 
const CChemEqInterfacegetChemEqInterface () const
 
std::string getChemEqString () const
 
std::set< const CCopasiObject * > getDeletedParameters () const
 
const CFunctiongetFunction () const
 
const std::string & getFunctionDescription () const
 
const std::string & getFunctionName () const
 
const std::vector< std::string > & getListOfMetabs (CFunctionParameter::Role role) const
 
std::vector< std::string > getListOfPossibleFunctions () const
 
const C_FLOAT64getLocalValue (size_t index) const
 
const std::string & getMapping (size_t index) const
 
const std::vector< std::string > & getMappings (size_t index) const
 
std::string getParameterName (size_t index) const
 
CFunctionParameter::Role getUsage (size_t index) const
 
void initFromReaction (const std::string &key)
 
void initFromReaction (const C_INT32 index)
 
void initFromReaction (const CReaction *rea)
 
bool isLocalValue (size_t index) const
 
bool isLocked (size_t index) const
 
bool isLocked (CFunctionParameter::Role usage) const
 
bool isMulticompartment () const
 
bool isReversible () const
 
bool isValid () const
 
bool isVector (size_t index) const
 
void removeMapping (size_t index, std::string mn)
 
void reverse (bool rev, const std::string &newFunction)
 
void setChemEqString (const std::string &eq, const std::string &newFunction)
 
void setFunctionAndDoMapping (const std::string &fn)
 
void setFunctionWithEmptyMapping (const std::string &fn)
 
void setLocal (size_t index)
 
void setLocalValue (size_t index, C_FLOAT64 value)
 
void setMapping (size_t index, std::string mn)
 
void setReversibility (bool rev, const std::string &newFunction)
 
size_t size () const
 
bool writeBackToReaction (CReaction *rea)
 
 ~CReactionInterface ()
 

Private Member Functions

void clearFunction ()
 
void connectFromScratch (CFunctionParameter::Role role)
 
void connectNonMetabolites ()
 
void copyMapping ()
 
 CReactionInterface ()
 
void findAndSetFunction (const std::string &newFunction)
 
std::vector< std::string > getExpandedMetabList (CFunctionParameter::Role role) const
 
void initMapping ()
 
bool loadMappingAndValues (const CReaction &rea)
 
void updateModifiersInChemEq ()
 

Private Attributes

std::string emptyString
 
CChemEqInterface mChemEqI
 
std::vector< bool > mIsLocal
 
std::vector< std::vector
< std::string > > 
mNameMap
 
const CFunctionmpFunction
 
CModelmpModel
 
CFunctionParametersmpParameters
 
std::string mReactionReferenceKey
 
std::vector< C_FLOAT64mValues
 

Detailed Description

This class provides an interface for dealing with reactions. For representing the parameter mappings it uses object names. A CReactionInterface allows editing a reaction while trying to keep everything consistent.

Note: Many of the methods need to be provided with a model. While handling of the metabolites is completely independent of the model (they are handled by name, and they don't need to exist), the mapping of Compartments and global parameters is done with the entities that exist in the model. This may seem inconsistent, but the idea is that metabolites can be created from the gui by entering them into the reaction equation. Compartments and global parameters can only be chosen from the list of existing objects.

Definition at line 52 of file CReactionInterface.h.

Constructor & Destructor Documentation

CReactionInterface::CReactionInterface ( )
private
CReactionInterface::CReactionInterface ( CModel pModel)

Definition at line 27 of file CReactionInterface.cpp.

References emptyString, and mpModel.

27  :
28  mpModel(pModel),
29  mChemEqI(pModel),
30  mpFunction(NULL),
31  mpParameters(NULL)
32 {
33  assert(mpModel != NULL);
34  emptyString = "";
35 }
CChemEqInterface mChemEqI
CFunctionParameters * mpParameters
const CFunction * mpFunction
CReactionInterface::~CReactionInterface ( )

Definition at line 37 of file CReactionInterface.cpp.

References mpParameters, and pdelete.

38 {
40  //pdelete(mpChemEq);
41 }
#define pdelete(p)
Definition: copasi.h:215
CFunctionParameters * mpParameters

Member Function Documentation

void CReactionInterface::clearFunction ( )
private

Definition at line 315 of file CReactionInterface.cpp.

References mNameMap, mpFunction, mpParameters, mValues, and pdelete.

Referenced by setFunctionAndDoMapping(), and setFunctionWithEmptyMapping().

316 {
317  mpFunction = NULL;
319  //mValid = false;
320 
321  mValues.clear();
322  mNameMap.clear();
323 }
#define pdelete(p)
Definition: copasi.h:215
std::vector< C_FLOAT64 > mValues
std::vector< std::vector< std::string > > mNameMap
CFunctionParameters * mpParameters
const CFunction * mpFunction
void CReactionInterface::connectFromScratch ( CFunctionParameter::Role  role)
private

guesses how to connect metabs with parameters for a specific usage

Definition at line 444 of file CReactionInterface.cpp.

References fatalError, CFunctionParameter::FLOAT64, getExpandedMetabList(), CFunctionParameters::getNumberOfParametersByUsage(), CFunctionParameters::getParameterByUsage(), CFunctionParameter::getType(), mNameMap, mpParameters, and CFunctionParameter::VFLOAT64.

Referenced by setFunctionAndDoMapping().

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 }
const CFunctionParameter::DataType & getType() const
#define fatalError()
size_t getNumberOfParametersByUsage(CFunctionParameter::Role usage) const
std::vector< std::vector< std::string > > mNameMap
const CFunctionParameter * getParameterByUsage(CFunctionParameter::Role usage, size_t &pos) const
std::vector< std::string > getExpandedMetabList(CFunctionParameter::Role role) const
CFunctionParameters * mpParameters
void CReactionInterface::connectNonMetabolites ( )
private

tries to determine the mapping for PARAMETER, VOLUME, TIME only if the current mapping is "unknown". Is typically called after initMapping() and copyMapping()

Definition at line 682 of file CReactionInterface.cpp.

References CChemEqInterface::getCompartment(), CModel::getModelValues(), CCopasiObject::getObjectName(), getUsage(), isLocalValue(), mChemEqI, mNameMap, CFunctionParameter::MODIFIER, mpModel, CFunctionParameter::PARAMETER, CFunctionParameter::PRODUCT, size(), CCopasiVector< T >::size(), CFunctionParameter::SUBSTRATE, CFunctionParameter::TIME, and CFunctionParameter::VOLUME.

Referenced by setFunctionAndDoMapping().

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 }
const std::string & getObjectName() const
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
virtual size_t size() const
const CCompartment * getCompartment() const
CFunctionParameter::Role getUsage(size_t index) const
std::vector< std::vector< std::string > > mNameMap
CChemEqInterface mChemEqI
size_t size() const
bool isLocalValue(size_t index) const
void CReactionInterface::copyMapping ( )
private

create new mapping, try to keep as much information from the current mapping. Calls initMapping().

Definition at line 614 of file CReactionInterface.cpp.

References getParameterName(), getUsage(), initMapping(), isVector(), mIsLocal, mNameMap, CFunctionParameter::MODIFIER, mpParameters, mValues, CFunctionParameter::PARAMETER, pdelete, CFunctionParameter::PRODUCT, CFunctionParameters::size(), size(), CFunctionParameter::SUBSTRATE, CFunctionParameter::TIME, CFunctionParameter::VFLOAT64, and CFunctionParameter::VOLUME.

Referenced by setFunctionAndDoMapping().

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 }
std::string getParameterName(size_t index) const
#define pdelete(p)
Definition: copasi.h:215
bool isVector(size_t index) const
std::vector< C_FLOAT64 > mValues
CFunctionParameter::Role getUsage(size_t index) const
std::vector< std::vector< std::string > > mNameMap
std::vector< bool > mIsLocal
CFunctionParameters * mpParameters
size_t size() const
bool CReactionInterface::createMetabolites ( )

create all metabolites that are needed by the reaction but do not exist in the model yet.

Definition at line 877 of file CReactionInterface.cpp.

References CChemEqInterface::createNonExistingMetabs(), getFunctionName(), mChemEqI, and setFunctionAndDoMapping().

Referenced by ReactionsWidget1::saveToReaction(), and CQReactionDM::setEquation().

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 }
CChemEqInterface mChemEqI
const std::string & getFunctionName() const
void setFunctionAndDoMapping(const std::string &fn)
bool CReactionInterface::createOtherObjects ( ) const

create all other objects that are needed by the reaction but do not exist in the model yet.

Definition at line 888 of file CReactionInterface.cpp.

References CModel::createCompartment(), CModel::createModelValue(), getUsage(), isLocalValue(), mNameMap, mpModel, CFunctionParameter::PARAMETER, size(), and CFunctionParameter::VOLUME.

Referenced by ReactionsWidget1::saveToReaction(), and CQReactionDM::setEquation().

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 }
CModelValue * createModelValue(const std::string &name, const C_FLOAT64 &value=0.0)
Definition: CModel.cpp:2838
CFunctionParameter::Role getUsage(size_t index) const
std::vector< std::vector< std::string > > mNameMap
size_t size() const
bool isLocalValue(size_t index) const
CCompartment * createCompartment(const std::string &name, const C_FLOAT64 &volume=1.0)
Definition: CModel.cpp:2698
void CReactionInterface::findAndSetFunction ( const std::string &  newFunction)
private

checks if newFunction is an valid function for the reaction. If it is not or if newFunction="" another function is chosen.

Definition at line 344 of file CReactionInterface.cpp.

References C_FLOAT64, fl(), getFunctionName(), CChemEqInterface::getListOfDisplayNames(), getListOfPossibleFunctions(), getLocalValue(), CChemEqInterface::getReversibility(), mChemEqI, CFunctionParameter::PRODUCT, setFunctionAndDoMapping(), and setLocalValue().

Referenced by reverse(), setChemEqString(), and setReversibility().

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 }
const C_FLOAT64 & getLocalValue(size_t index) const
const std::vector< std::string > & getListOfDisplayNames(CFunctionParameter::Role role) const
void setLocalValue(size_t index, C_FLOAT64 value)
#define C_FLOAT64
Definition: copasi.h:92
bool fl(const C_FLOAT64 &d1, const C_FLOAT64 &d2)
CChemEqInterface mChemEqI
const std::string & getFunctionName() const
bool getReversibility() const
std::vector< std::string > getListOfPossibleFunctions() const
void setFunctionAndDoMapping(const std::string &fn)
const CChemEqInterface& CReactionInterface::getChemEqInterface ( ) const
inline

Definition at line 110 of file CReactionInterface.h.

References mChemEqI.

Referenced by CQCompartment::copy(), and ParameterTable::updateTable().

110 {return mChemEqI;};
CChemEqInterface mChemEqI
std::string CReactionInterface::getChemEqString ( ) const
inline

Definition at line 108 of file CReactionInterface.h.

References CChemEqInterface::getChemEqString(), and mChemEqI.

Referenced by ReactionsWidget1::FillWidgetFromRI(), and CQReactionDM::setEquation().

108 {return mChemEqI.getChemEqString(false);};
std::string getChemEqString(bool expanded) const
CChemEqInterface mChemEqI
std::set< const CCopasiObject * > CReactionInterface::getDeletedParameters ( ) const

Retrieve the list of parameters which will be deleted

Returns
std::set< const CCopasiObject * > DeletedParameters

Definition at line 539 of file CReactionInterface.cpp.

References CKeyFactory::get(), CReaction::getFunction(), CCopasiRootContainer::getKeyFactory(), CCopasiObject::getObjectName(), CCopasiParameterGroup::getParameter(), getParameterName(), CReaction::getParameters(), CFunctionParameter::getUsage(), CFunction::getVariables(), CReaction::isLocalParameter(), mIsLocal, mReactionReferenceKey, CFunctionParameter::PARAMETER, CFunctionParameters::size(), and size().

Referenced by ReactionsWidget1::saveToReaction(), and CQReactionDM::setEquation().

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 }
std::string getParameterName(size_t index) const
const std::string & getObjectName() const
CCopasiObject * get(const std::string &key)
bool isLocalParameter(const size_t &index) const
Definition: CReaction.cpp:449
const CFunction * getFunction() const
Definition: CReaction.cpp:252
std::string mReactionReferenceKey
CCopasiParameter * getParameter(const std::string &name)
static CKeyFactory * getKeyFactory()
std::vector< bool > mIsLocal
const CCopasiParameterGroup & getParameters() const
Definition: CReaction.cpp:333
size_t size() const
CFunctionParameters & getVariables()
Definition: CFunction.cpp:148
std::vector< std::string > CReactionInterface::getExpandedMetabList ( CFunctionParameter::Role  role) const
private

returns a list of metabolites (from the chemical equation). Species can occur several times according to theit multiplicity

Definition at line 838 of file CReactionInterface.cpp.

References C_FLOAT64, CChemEqInterface::getListOfDisplayNames(), CChemEqInterface::getListOfMultiplicities(), mChemEqI, and CFunctionParameter::MODIFIER.

Referenced by connectFromScratch().

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 }
const std::vector< std::string > & getListOfDisplayNames(CFunctionParameter::Role role) const
const std::vector< C_FLOAT64 > & getListOfMultiplicities(CFunctionParameter::Role role) const
#define C_FLOAT64
Definition: copasi.h:92
CChemEqInterface mChemEqI
const CFunction* CReactionInterface::getFunction ( ) const
inline

Definition at line 159 of file CReactionInterface.h.

References mpFunction.

Referenced by ParameterTable::updateTable().

160  {return mpFunction;}
const CFunction * mpFunction
const std::string& CReactionInterface::getFunctionDescription ( ) const
inline

Definition at line 156 of file CReactionInterface.h.

References emptyString, CEvaluationTree::getInfix(), and mpFunction.

Referenced by ReactionsWidget1::FillWidgetFromRI().

157  {if (mpFunction) return mpFunction->getInfix(); else return emptyString;};
const CFunction * mpFunction
const std::string & getInfix() const
const std::string& CReactionInterface::getFunctionName ( ) const
inline

Definition at line 153 of file CReactionInterface.h.

References emptyString, CCopasiObject::getObjectName(), and mpFunction.

Referenced by createMetabolites(), ReactionsWidget1::FillWidgetFromRI(), and findAndSetFunction().

154  {if (mpFunction) return mpFunction->getObjectName(); else return emptyString;};
const std::string & getObjectName() const
const CFunction * mpFunction
const std::vector< std::string > & CReactionInterface::getListOfMetabs ( CFunctionParameter::Role  role) const

This produces a list of metab names (from the chem eq) for use in the combo boxes. The role must be given like a usage, e.g. "SUBSTRATE".

Definition at line 43 of file CReactionInterface.cpp.

References CChemEqInterface::getListOfDisplayNames(), and mChemEqI.

Referenced by ParameterTable::getListOfAllMetabNames(), setMapping(), and ParameterTable::updateTable().

44 {
45  return mChemEqI.getListOfDisplayNames(role);
46 }
const std::vector< std::string > & getListOfDisplayNames(CFunctionParameter::Role role) const
CChemEqInterface mChemEqI
std::vector< std::string > CReactionInterface::getListOfPossibleFunctions ( ) const

Definition at line 48 of file CReactionInterface.cpp.

References CCopasiRootContainer::getFunctionList(), CChemEqInterface::getMolecularity(), isReversible(), mChemEqI, CFunctionParameter::PRODUCT, CFunctionParameter::SUBSTRATE, CFunctionDB::suitableFunctions(), TriFalse, and TriTrue.

Referenced by ReactionsWidget1::FillWidgetFromRI(), and findAndSetFunction().

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 }
size_t getMolecularity(CFunctionParameter::Role role) const
std::vector< CFunction * > suitableFunctions(const size_t noSubstrates, const size_t noProducts, const TriLogic reversibility)
TriLogic
Definition: copasi.h:125
bool isReversible() const
static CFunctionDB * getFunctionList()
CChemEqInterface mChemEqI
const C_FLOAT64& CReactionInterface::getLocalValue ( size_t  index) const
inline

Definition at line 213 of file CReactionInterface.h.

References mValues.

Referenced by findAndSetFunction(), and ParameterTable::updateTable().

213 {return mValues[index];}
std::vector< C_FLOAT64 > mValues
const std::string& CReactionInterface::getMapping ( size_t  index) const
inline

Definition at line 196 of file CReactionInterface.h.

References isVector(), and mNameMap.

Referenced by updateModifiersInChemEq(), and ParameterTable::updateTable().

197  {
198  assert(!isVector(index));
199  return mNameMap[index][0];
200  }
bool isVector(size_t index) const
std::vector< std::vector< std::string > > mNameMap
const std::vector< std::string >& CReactionInterface::getMappings ( size_t  index) const
inline

Definition at line 193 of file CReactionInterface.h.

References mNameMap.

Referenced by ParameterTable::updateTable().

194  {return mNameMap[index];}
std::vector< std::vector< std::string > > mNameMap
std::string CReactionInterface::getParameterName ( size_t  index) const
inline

Definition at line 181 of file CReactionInterface.h.

References emptyString, mpFunction, and mpParameters.

Referenced by copyMapping(), getDeletedParameters(), loadMappingAndValues(), ParameterTable::updateTable(), and writeBackToReaction().

182  {
183  if (mpFunction) return (*mpParameters)[index]->getObjectName();
184  else return emptyString;
185  }
CFunctionParameters * mpParameters
const CFunction * mpFunction
CFunctionParameter::Role CReactionInterface::getUsage ( size_t  index) const
inline
void CReactionInterface::initFromReaction ( const std::string &  key)

associate the function parameter referenced by "index" with the global parameter named pn. Only valid if the role for this function parameter is "PARAMETER". returns success

Definition at line 72 of file CReactionInterface.cpp.

References CKeyFactory::get(), CCopasiRootContainer::getKeyFactory(), and mReactionReferenceKey.

Referenced by CQCompartment::copy(), initFromReaction(), ReactionsWidget1::loadFromReaction(), and CQReactionDM::setEquation().

73 {
75 
76  const CReaction *rea;
77  rea = dynamic_cast< CReaction *>(CCopasiRootContainer::getKeyFactory()->get(key));
78  assert(rea);
79  initFromReaction(rea);
80 }
CCopasiObject * get(const std::string &key)
void initFromReaction(const std::string &key)
std::string mReactionReferenceKey
static CKeyFactory * getKeyFactory()
void CReactionInterface::initFromReaction ( const C_INT32  index)

Definition at line 82 of file CReactionInterface.cpp.

References CReaction::getKey(), CModel::getReactions(), initFromReaction(), mpModel, and mReactionReferenceKey.

83 {
84  const CReaction *rea = mpModel->getReactions()[index];
85 
87  assert(rea);
88  initFromReaction(rea);
89 }
virtual const std::string & getKey() const
Definition: CReaction.cpp:190
void initFromReaction(const std::string &key)
std::string mReactionReferenceKey
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
void CReactionInterface::initFromReaction ( const CReaction rea)

Definition at line 91 of file CReactionInterface.cpp.

References CReaction::getChemEq(), CReaction::getFunction(), CCopasiRootContainer::getUndefinedFunction(), CFunction::getVariables(), CChemEqInterface::loadFromChemEq(), loadMappingAndValues(), mChemEqI, mpFunction, mpParameters, pdelete, and setFunctionWithEmptyMapping().

92 {
93  //chemical equation
95 
97  {
98  //function
99  mpFunction = rea->getFunction();
101  mpParameters = new CFunctionParameters(mpFunction->getVariables());
102 
103  //mapping
104  loadMappingAndValues(*rea);
105  }
106  else
107  {
109  }
110 }
bool loadFromChemEq(const CChemEq &ce)
#define pdelete(p)
Definition: copasi.h:215
static CFunction * getUndefinedFunction()
const CFunction * getFunction() const
Definition: CReaction.cpp:252
bool loadMappingAndValues(const CReaction &rea)
CChemEqInterface mChemEqI
CFunctionParameters * mpParameters
const CFunction * mpFunction
const CChemEq & getChemEq() const
Definition: CReaction.cpp:223
void setFunctionWithEmptyMapping(const std::string &fn)
void CReactionInterface::initMapping ( )
private

initialize mapping (resize vectors and set names to "unknown"). Also initializes mpParameters but doesn't delete the old mpParameters.

Definition at line 586 of file CReactionInterface.cpp.

References getUsage(), CFunction::getVariables(), isVector(), mIsLocal, mNameMap, mpFunction, mpParameters, mValues, CFunctionParameter::PARAMETER, and size().

Referenced by copyMapping(), and setFunctionWithEmptyMapping().

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 }
bool isVector(size_t index) const
std::vector< C_FLOAT64 > mValues
CFunctionParameter::Role getUsage(size_t index) const
std::vector< std::vector< std::string > > mNameMap
std::vector< bool > mIsLocal
CFunctionParameters * mpParameters
size_t size() const
const CFunction * mpFunction
CFunctionParameters & getVariables()
Definition: CFunction.cpp:148
bool CReactionInterface::isLocalValue ( size_t  index) const
inline

Definition at line 215 of file CReactionInterface.h.

References mIsLocal.

Referenced by connectNonMetabolites(), createOtherObjects(), ReactionsWidget1::slotTableChanged(), and ParameterTable::updateTable().

215 {return mIsLocal[index];};
std::vector< bool > mIsLocal
bool CReactionInterface::isLocked ( size_t  index) const

Is the mapping of this parameter locked? The bahaviour of this method is different for different roles: SUBSTRATE, PRODUCT: according to the chemical equation MODIFIER: always unlocked TIME: always locked VOLUME, PARAMETER: according to the model

The idea is that in the reaction GUI new species can be entered in the chemical equation that are then created automatically. Compartments and global parameters can only be chosen from those existing in the model.

Definition at line 484 of file CReactionInterface.cpp.

References getUsage().

Referenced by ParameterTable::updateTable().

485 {return isLocked(getUsage(index));}
bool isLocked(size_t index) const
CFunctionParameter::Role getUsage(size_t index) const
bool CReactionInterface::isLocked ( CFunctionParameter::Role  usage) const

Definition at line 487 of file CReactionInterface.cpp.

References CModel::getCompartments(), CChemEqInterface::getListOfDisplayNames(), CModel::getModelValues(), CFunctionParameters::getNumberOfParametersByUsage(), CFunctionParameters::getParameterByUsage(), isVector(), mChemEqI, CFunctionParameter::MODIFIER, mpModel, mpParameters, CFunctionParameter::PARAMETER, CFunctionParameter::PRODUCT, CCopasiVector< T >::size(), CFunctionParameter::SUBSTRATE, CFunctionParameter::TIME, and CFunctionParameter::VOLUME.

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 }
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
virtual size_t size() const
size_t getNumberOfParametersByUsage(CFunctionParameter::Role usage) const
bool isVector(size_t index) const
const std::vector< std::string > & getListOfDisplayNames(CFunctionParameter::Role role) const
const CFunctionParameter * getParameterByUsage(CFunctionParameter::Role usage, size_t &pos) const
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
CChemEqInterface mChemEqI
CFunctionParameters * mpParameters
bool CReactionInterface::isMulticompartment ( ) const

this method tries to find out if the REACTION involves several compartments It only takes into account the metabs that actually exist in the model. A non existing metabolite is assumed not to be in a different compartment

Definition at line 925 of file CReactionInterface.cpp.

References CChemEqInterface::isMulticompartment(), and mChemEqI.

Referenced by CQCompartment::copy(), ReactionsWidget1::FillWidgetFromRI(), and ParameterTable::updateTable().

926 {
927  return mChemEqI.isMulticompartment();
928 }
CChemEqInterface mChemEqI
bool isMulticompartment() const
bool CReactionInterface::isReversible ( ) const
inline
bool CReactionInterface::isValid ( ) const

Definition at line 930 of file CReactionInterface.cpp.

References mIsLocal, mNameMap, and size().

Referenced by ReactionsWidget1::saveToReaction(), ReactionsWidget1::slotTableChanged(), and writeBackToReaction().

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 }
std::vector< std::vector< std::string > > mNameMap
std::vector< bool > mIsLocal
size_t size() const
bool CReactionInterface::isVector ( size_t  index) const
inline

Definition at line 169 of file CReactionInterface.h.

References mpFunction, mpParameters, and CFunctionParameter::VFLOAT64.

Referenced by copyMapping(), getMapping(), initMapping(), isLocked(), loadMappingAndValues(), setMapping(), ParameterTable::updateTable(), and writeBackToReaction().

170  {
171  if (mpFunction) return ((*mpParameters)[index]->getType() == CFunctionParameter::VFLOAT64);
172  else return (false);
173  }
CFunctionParameters * mpParameters
const CFunction * mpFunction
bool CReactionInterface::loadMappingAndValues ( const CReaction rea)
private

Definition at line 112 of file CReactionInterface.cpp.

References CKeyFactory::get(), CMetabNameInterface::getDisplayName(), CModelEntity::getInitialValue(), CCopasiRootContainer::getKeyFactory(), CCopasiObject::getObjectName(), CCopasiParameterGroup::getParameter(), CReaction::getParameterMappings(), getParameterName(), CReaction::getParameters(), getUsage(), CCopasiParameter::getValue(), CReaction::isLocalParameter(), isVector(), mIsLocal, mNameMap, CFunctionParameter::MODIFIER, mpModel, mValues, CFunctionParameter::PARAMETER, CCopasiParameter::Value::pDOUBLE, CFunctionParameter::PRODUCT, size(), CFunctionParameter::SUBSTRATE, CFunctionParameter::TIME, and CFunctionParameter::VOLUME.

Referenced by initFromReaction().

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 }
std::string getParameterName(size_t index) const
const std::string & getObjectName() const
CCopasiObject * get(const std::string &key)
bool isLocalParameter(const size_t &index) const
Definition: CReaction.cpp:449
bool isVector(size_t index) const
std::vector< C_FLOAT64 > mValues
static std::string getDisplayName(const CModel *model, const std::string &key, const bool &quoted)
const C_FLOAT64 & getInitialValue() const
CFunctionParameter::Role getUsage(size_t index) const
std::vector< std::vector< std::string > > mNameMap
const Value & getValue() const
CCopasiParameter * getParameter(const std::string &name)
static CKeyFactory * getKeyFactory()
std::vector< bool > mIsLocal
const CCopasiParameterGroup & getParameters() const
Definition: CReaction.cpp:333
Definition: CModel.h:50
size_t size() const
const std::vector< std::vector< std::string > > & getParameterMappings() const
Definition: CReaction.h:285
void CReactionInterface::removeMapping ( size_t  index,
std::string  mn 
)
void CReactionInterface::reverse ( bool  rev,
const std::string &  newFunction 
)

reverse the reaction and set the reversibility. newFunction suggests a new kinetic function which is only used if adequate.

Definition at line 337 of file CReactionInterface.cpp.

References findAndSetFunction(), mChemEqI, CChemEqInterface::reverse(), and CChemEqInterface::setReversibility().

338 {
340  mChemEqI.reverse();
341  findAndSetFunction(newFunction);
342 }
void findAndSetFunction(const std::string &newFunction)
void setReversibility(bool rev)
CChemEqInterface mChemEqI
void CReactionInterface::setChemEqString ( const std::string &  eq,
const std::string &  newFunction 
)

set a new chemical equation. newFunction suggests a new kinetic function which is only used if adequate.

Definition at line 325 of file CReactionInterface.cpp.

References findAndSetFunction(), mChemEqI, and CChemEqInterface::setChemEqString().

Referenced by CQReactionDM::setEquation(), and ReactionsWidget1::slotLineEditChanged().

326 {
328  findAndSetFunction(newFunction);
329 }
void findAndSetFunction(const std::string &newFunction)
bool setChemEqString(const std::string &ces)
CChemEqInterface mChemEqI
void CReactionInterface::setFunctionAndDoMapping ( const std::string &  fn)

set the function. a new mapping is created that tries to preserve as much information as possible from the old mapping. Then a default mapping is set from the chemical equation and the model (if possible).

Definition at line 746 of file CReactionInterface.cpp.

References clearFunction(), connectFromScratch(), connectNonMetabolites(), copyMapping(), fatalError, CFunctionDB::findLoadFunction(), CCopasiRootContainer::getFunctionList(), CFunctionParameter::MODIFIER, mpFunction, CFunctionParameter::PRODUCT, and CFunctionParameter::SUBSTRATE.

Referenced by createMetabolites(), findAndSetFunction(), and ReactionsWidget1::slotComboBoxSelectionChanged().

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 }
#define fatalError()
void connectFromScratch(CFunctionParameter::Role role)
CFunction * findLoadFunction(const std::string &functionName)
static CFunctionDB * getFunctionList()
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
const CFunction * mpFunction
void CReactionInterface::setFunctionWithEmptyMapping ( const std::string &  fn)

set the function. an empty mapping is created

Definition at line 731 of file CReactionInterface.cpp.

References clearFunction(), fatalError, CFunctionDB::findLoadFunction(), CCopasiRootContainer::getFunctionList(), initMapping(), mpFunction, mpParameters, and pdelete.

Referenced by initFromReaction(), ReactionsWidget1::saveToReaction(), CQReactionDM::setEquation(), and ReactionsWidget1::slotBtnDelete().

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 }
#define pdelete(p)
Definition: copasi.h:215
#define fatalError()
CFunction * findLoadFunction(const std::string &functionName)
static CFunctionDB * getFunctionList()
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
CFunctionParameters * mpParameters
const CFunction * mpFunction
void CReactionInterface::setLocal ( size_t  index)
inline

Definition at line 208 of file CReactionInterface.h.

References mIsLocal.

Referenced by ReactionsWidget1::slotParameterStatusChanged().

209  {
210  mIsLocal[index] = true;
211  }
std::vector< bool > mIsLocal
void CReactionInterface::setLocalValue ( size_t  index,
C_FLOAT64  value 
)
inline

Definition at line 202 of file CReactionInterface.h.

References mIsLocal, and mValues.

Referenced by findAndSetFunction(), and ReactionsWidget1::slotTableChanged().

203  {
204  mValues[index] = value;
205  mIsLocal[index] = true;
206  }
std::vector< C_FLOAT64 > mValues
std::vector< bool > mIsLocal
void CReactionInterface::setMapping ( size_t  index,
std::string  mn 
)

Definition at line 779 of file CReactionInterface.cpp.

References CChemEqInterface::getListOfDisplayNames(), getListOfMetabs(), CFunctionParameters::getNumberOfParametersByUsage(), CFunctionParameters::getParameterByUsage(), getUsage(), isVector(), mChemEqI, mIsLocal, mNameMap, CFunctionParameter::MODIFIER, mpParameters, CFunctionParameter::PARAMETER, CFunctionParameter::PRODUCT, CFunctionParameter::SUBSTRATE, CFunctionParameter::TIME, updateModifiersInChemEq(), and CFunctionParameter::VOLUME.

Referenced by ReactionsWidget1::slotParameterStatusChanged(), and ReactionsWidget1::slotTableChanged().

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 }
size_t getNumberOfParametersByUsage(CFunctionParameter::Role usage) const
bool isVector(size_t index) const
CFunctionParameter::Role getUsage(size_t index) const
const std::vector< std::string > & getListOfDisplayNames(CFunctionParameter::Role role) const
std::vector< std::vector< std::string > > mNameMap
const CFunctionParameter * getParameterByUsage(CFunctionParameter::Role usage, size_t &pos) const
const std::vector< std::string > & getListOfMetabs(CFunctionParameter::Role role) const
std::vector< bool > mIsLocal
CChemEqInterface mChemEqI
CFunctionParameters * mpParameters
void CReactionInterface::setReversibility ( bool  rev,
const std::string &  newFunction 
)

set the reversibility. newFunction suggests a new kinetic function which is only used if adequate.

Definition at line 331 of file CReactionInterface.cpp.

References findAndSetFunction(), mChemEqI, and CChemEqInterface::setReversibility().

Referenced by ReactionsWidget1::slotCheckBoxClicked().

332 {
334  findAndSetFunction(newFunction);
335 }
void findAndSetFunction(const std::string &newFunction)
void setReversibility(bool rev)
CChemEqInterface mChemEqI
size_t CReactionInterface::size ( ) const
inline
void CReactionInterface::updateModifiersInChemEq ( )
private

updates the modifiers in the chemical equation according to the parameter mapping

Definition at line 768 of file CReactionInterface.cpp.

References CChemEqInterface::addModifier(), CChemEqInterface::clearModifiers(), getMapping(), getUsage(), mChemEqI, CFunctionParameter::MODIFIER, and size().

Referenced by setMapping().

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 }
const std::string & getMapping(size_t index) const
CFunctionParameter::Role getUsage(size_t index) const
CChemEqInterface mChemEqI
void addModifier(const std::string &name)
size_t size() const
bool CReactionInterface::writeBackToReaction ( CReaction rea)

writes the information back to a CReaction. createMetabolites() and createOtherObjects() should be called before.

Definition at line 226 of file CReactionInterface.cpp.

References CReaction::addParameterMapping(), CReaction::clearParameterMapping(), CReaction::compile(), CKeyFactory::get(), CReaction::getChemEq(), CModel::getCompartments(), CModel::getKey(), CCopasiObject::getKey(), CCopasiRootContainer::getKeyFactory(), CMetabNameInterface::getMetaboliteKey(), CModel::getModelValues(), CCopasiObject::getObjectName(), getParameterName(), getUsage(), CFunction::getVariables(), isValid(), isVector(), mChemEqI, mIsLocal, mNameMap, CFunctionParameter::MODIFIER, mpFunction, mpModel, mpParameters, mReactionReferenceKey, mValues, CFunctionParameter::PARAMETER, CFunctionParameter::PRODUCT, CModel::setCompileFlag(), CReaction::setFunction(), CReaction::setParameterMapping(), CReaction::setParameterValue(), size(), CMetabNameInterface::splitDisplayName(), CFunctionParameter::SUBSTRATE, CFunctionParameter::TIME, CFunctionParameter::VOLUME, and CChemEqInterface::writeToChemEq().

Referenced by ReactionsWidget1::saveToReaction(), and CQReactionDM::setEquation().

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 }
std::string getParameterName(size_t index) const
static std::string getMetaboliteKey(const CModel *model, const std::string &metabolite, const std::string &compartment)
const std::string & getObjectName() const
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
CCopasiObject * get(const std::string &key)
void setParameterValue(const std::string &parameterName, const C_FLOAT64 &value, const bool &updateStatus=true)
Definition: CReaction.cpp:303
void clearParameterMapping(const std::string &parameterName)
Definition: CReaction.cpp:407
bool isVector(size_t index) const
std::vector< C_FLOAT64 > mValues
virtual const std::string & getKey() const
void compile()
Definition: CReaction.cpp:583
CFunctionParameter::Role getUsage(size_t index) const
std::string mReactionReferenceKey
bool setFunction(const std::string &functionName)
Definition: CReaction.cpp:255
std::vector< std::vector< std::string > > mNameMap
const std::string & getKey() const
Definition: CModel.cpp:1142
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607
bool writeToChemEq(CChemEq &ce) const
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
static std::pair< std::string, std::string > splitDisplayName(const std::string &name)
static CKeyFactory * getKeyFactory()
std::vector< bool > mIsLocal
void setParameterMapping(const size_t &index, const std::string &key)
Definition: CReaction.cpp:339
CChemEqInterface mChemEqI
CFunctionParameters * mpParameters
size_t size() const
const CFunction * mpFunction
const CChemEq & getChemEq() const
Definition: CReaction.cpp:223
CFunctionParameters & getVariables()
Definition: CFunction.cpp:148
void addParameterMapping(const size_t &index, const std::string &key)
Definition: CReaction.cpp:348

Member Data Documentation

std::string CReactionInterface::emptyString
private
CChemEqInterface CReactionInterface::mChemEqI
private
std::vector<bool> CReactionInterface::mIsLocal
private
std::vector< std::vector< std::string > > CReactionInterface::mNameMap
private
const CFunction* CReactionInterface::mpFunction
private
CModel* CReactionInterface::mpModel
private
CFunctionParameters* CReactionInterface::mpParameters
private
std::string CReactionInterface::mReactionReferenceKey
private

This is the key that identifies the Reaction that is beeing edited

Definition at line 62 of file CReactionInterface.h.

Referenced by getDeletedParameters(), initFromReaction(), and writeBackToReaction().

std::vector< C_FLOAT64 > CReactionInterface::mValues
private

values of the kinetic parameters

Definition at line 87 of file CReactionInterface.h.

Referenced by clearFunction(), copyMapping(), getLocalValue(), initMapping(), loadMappingAndValues(), setLocalValue(), and writeBackToReaction().


The documentation for this class was generated from the following files: