示例#1
0
bool CChemEq::addMetabolite(const std::string & key, const C_FLOAT64 multiplicity, const MetaboliteRole & role)
{
  CChemEqElement element;
  element.setMetabolite(key);
  element.setMultiplicity(multiplicity);

  switch (role)
    {
    case CChemEq::SUBSTRATE:
      addElement(mSubstrates, element);
      addElement(mBalances, element, CChemEq::SUBSTRATE);
      break;
    case CChemEq::PRODUCT:
      addElement(mProducts, element);
      addElement(mBalances, element);
      break;
    case CChemEq::MODIFIER:
      addElement(mModifiers, element);
      break;
    default:
      fatalError();
      break;
    }

  return true;
}
示例#2
0
void CChemEq::addElement(CCopasiVector < CChemEqElement > & structure,
                         const CChemEqElement & element,
                         CChemEq::MetaboliteRole role)
{
  unsigned C_INT32 i;

  std::string key = element.getMetaboliteKey();

  if (key == "")
    return; // don�t add empty element

  for (i = 0; i < structure.size(); i++)
    if (key == structure[i]->getMetaboliteKey())
      break;

  if (i >= structure.size())
    {
      CChemEqElement * Element = new CChemEqElement(element);

      if (role == CChemEq::SUBSTRATE)
        Element->setMultiplicity(- Element->getMultiplicity());

      structure.add(Element, true);
    }
  else if (role == CChemEq::SUBSTRATE)
    structure[i]->addToMultiplicity(- element.getMultiplicity());
  else
    structure[i]->addToMultiplicity(element.getMultiplicity());
}