Exemplo n.º 1
0
void test000047::test_delay()
{
  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING));
  CModel* pModel = pDataModel->getModel();
  CPPUNIT_ASSERT(pModel != NULL);
  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CUnit::mMol);
  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CUnit::ml);
  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CUnit::s);
  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
  const CCompartment* pCompartment = pModel->getCompartments()[0];
  CPPUNIT_ASSERT(pCompartment != NULL);
  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
  const CMetab* pB = pModel->getMetabolites()[1];
  CPPUNIT_ASSERT(pB != NULL);
  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::FIXED);
  CMetab* pA = pModel->getMetabolites()[0];
  CPPUNIT_ASSERT(pA != NULL);
  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::ASSIGNMENT);
  const CExpression* pExpr = pA->getExpressionPtr();
  CPPUNIT_ASSERT(pExpr != NULL);
  const CEvaluationNode* pNode = pExpr->getRoot();
  CPPUNIT_ASSERT(pNode != NULL);
  const CEvaluationNodeDelay* pDelayNode = dynamic_cast<const CEvaluationNodeDelay*>(pNode);
  CPPUNIT_ASSERT(pDelayNode != NULL);
  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pDelayNode->getChild());
  CPPUNIT_ASSERT(pObjectNode != NULL);
  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
  CPPUNIT_ASSERT(!objectCN.empty());
  std::vector<CCopasiContainer*> listOfContainers;
  listOfContainers.push_back(pModel);
  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
  CPPUNIT_ASSERT(pObject != NULL);
  CPPUNIT_ASSERT(pObject->isReference() == true);
  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Concentration"));
  CPPUNIT_ASSERT(pObject->getObjectParent() == pB);
  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pObjectNode->getSibling());
  CPPUNIT_ASSERT(pNumberNode != NULL);
  CPPUNIT_ASSERT(((CEvaluationNodeNumber::SubType)CEvaluationNode::subType(pNumberNode->getType())) == CEvaluationNodeNumber::DOUBLE);
  CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 0.5) / 0.5) < 1e-3);

  CPPUNIT_ASSERT(pNumberNode->getSibling() == NULL);

  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
  const CModelValue* pModelValue = pModel->getModelValues()[0];
  CPPUNIT_ASSERT(pModelValue != NULL);
  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
  CPPUNIT_ASSERT(pModel->getReactions().size() == 0);
  //CPPUNIT_ASSERT(CCopasiMessage::size() == 2);
  CCopasiMessage message = CCopasiMessage::getLastMessage();
  CPPUNIT_ASSERT(message.getType() == CCopasiMessage::WARNING);
  std::string s = message.getText();
  CPPUNIT_ASSERT(!s.empty());
  CPPUNIT_ASSERT(s.find(std::string("COPASI does not support time delays. Calculations on this model will most likely lead to unusable results.")) != std::string::npos);
  // right now, we don't care about the last message since it is a units
  // warning from libSBML
}
Exemplo n.º 2
0
void test000052::test_bug988()
{
    CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
    CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING));
    CModel* pModel = pDataModel->getModel();
    CPPUNIT_ASSERT(pModel != NULL);
    CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
    CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
    CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
    CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
    const CCompartment* pCompartment = pModel->getCompartments()[0];
    CPPUNIT_ASSERT(pCompartment != NULL);
    CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
    CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
    CMetab* pA = pModel->getMetabolites()[0];
    CPPUNIT_ASSERT(pA != NULL);
    CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::ASSIGNMENT);
    const CExpression* pExpr = pA->getExpressionPtr();
    // check the expression
    const CEvaluationNode* pNode = pExpr->getRoot();
    CPPUNIT_ASSERT(pNode != NULL);
    const CEvaluationNodeChoice* pChoiceNode = dynamic_cast<const CEvaluationNodeChoice*>(pNode);
    CPPUNIT_ASSERT(pChoiceNode != NULL);
    pNode = dynamic_cast<const CEvaluationNode*>(pChoiceNode->getChild());
    CPPUNIT_ASSERT(pNode != NULL);
    const CEvaluationNodeLogical* pLogicalNode = dynamic_cast<const CEvaluationNodeLogical*>(pNode);
    CPPUNIT_ASSERT(pLogicalNode != NULL);
    CPPUNIT_ASSERT(((CEvaluationNodeLogical::SubType)CEvaluationNode::subType(pLogicalNode->getType())) == CEvaluationNodeLogical::LT);
    const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pLogicalNode->getChild());
    CPPUNIT_ASSERT(pObjectNode != NULL);
    CCopasiObjectName objectCN = pObjectNode->getObjectCN();
    CPPUNIT_ASSERT(!objectCN.empty());
    std::vector<CCopasiContainer*> listOfContainers;
    listOfContainers.push_back(pModel);
    const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
    CPPUNIT_ASSERT(pObject != NULL);
    CPPUNIT_ASSERT(pObject->isReference() == true);
    CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
    CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
    const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pObjectNode->getSibling());
    CPPUNIT_ASSERT(pNumberNode != NULL);
    CPPUNIT_ASSERT(((CEvaluationNodeNumber::SubType)CEvaluationNode::subType(pNumberNode->getType())) == CEvaluationNodeNumber::DOUBLE);
    CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 5.0) / 5.0) < 1e-3);
    pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pLogicalNode->getSibling());
    CPPUNIT_ASSERT(pNumberNode != NULL);
    CPPUNIT_ASSERT(((CEvaluationNodeNumber::SubType)CEvaluationNode::subType(pNumberNode->getType())) == CEvaluationNodeNumber::DOUBLE);
    CPPUNIT_ASSERT(pNumberNode->getValue() < 1e-3);
    pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNumberNode->getSibling());
    CPPUNIT_ASSERT(pNumberNode != NULL);
    CPPUNIT_ASSERT(((CEvaluationNodeNumber::SubType)CEvaluationNode::subType(pNumberNode->getType())) == CEvaluationNodeNumber::DOUBLE);
    CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 10.0) / 10.0) < 1e-3);

    CPPUNIT_ASSERT(pModel->getModelValues().size() == 0);
    CPPUNIT_ASSERT(pModel->getReactions().size() == 0);
}
Exemplo n.º 3
0
// virtual
void CModelParameterReactionParameter::compile()
{
    CModelParameter::compile();

    mGlobalQuantityCN = std::string();

    std::string Infix = getInitialExpression();

    if (Infix.length() > 2)
    {
        // Infix: <CN,Reference=InitialValue> or <CN,Reference=Value>
        CCopasiObjectName Tmp = Infix.substr(1, Infix.length() - 2);
        std::string Separator = "";

        for (; Tmp != ""; Tmp = Tmp.getRemainder())
        {
            CCopasiObjectName Primary = Tmp.getPrimary();

            if (Primary.getObjectType() == "Reference")
            {
                break;
            }

            mGlobalQuantityCN += Separator + Primary;
            Separator = ",";
        }

        setSimulationType(CModelEntity::ASSIGNMENT);
    }
    else
    {
        setSimulationType(CModelEntity::FIXED);
    }

    mpGlobalQuantity = this->getSet()->getModelParameter(mGlobalQuantityCN);

    if (mpGlobalQuantity != NULL)
    {
        mValue = mpGlobalQuantity->getValue(ParticleNumbers);
    }

    std::vector< CCopasiContainer * > ListOfContainer;

    CModel * pModel = getModel();
    ListOfContainer.push_back(pModel);

    mpReaction = static_cast< CReaction * >(pModel->getObjectDataModel()->ObjectFromName(ListOfContainer, mpParent->getCN()));
}
Exemplo n.º 4
0
// static
std::string CModelParameter::nameFromCN(const CCopasiObjectName & cn)
{
    CCopasiObjectName Primary = cn.getPrimary();
    CCopasiObjectName Remainder = cn.getRemainder();

    while (Remainder != "")
    {
        Primary = Remainder.getPrimary();
        Remainder = Remainder.getRemainder();
    }

    std::string Name = Primary.getElementName(0);

    if (Name != "")
    {
        return Name;
    }

    return Primary.getObjectName();
}
Exemplo n.º 5
0
// virtual
void CModelParameterSpecies::setCN(const CCopasiObjectName & cn)
{
    CModelParameter::setCN(cn);

    // Determine the CN for the compartment.
    // "CN=Root,Model=New Model,Vector=Compartments[compartment],Vector=Metabolites[A]"
    CCopasiObjectName Tmp = mCN;
    std::string Separator = "";

    for (; Tmp != ""; Tmp = Tmp.getRemainder())
    {
        CCopasiObjectName Primary = Tmp.getPrimary();
        mCompartmentCN += Separator + Primary;
        Separator = ",";

        if (Primary.getObjectType() == "Vector" &&
                Primary.getObjectName() == "Compartments")
        {
            break;
        }
    }
}
Exemplo n.º 6
0
void test000027::test_hasOnlySubstanceUnits()
{
  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING));
  CModel* pModel = pDataModel->getModel();
  CPPUNIT_ASSERT(pModel != NULL);
  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CUnit::mMol);
  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CUnit::ml);
  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CUnit::s);
  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
  const CCompartment* pCompartment = pModel->getCompartments()[0];
  CPPUNIT_ASSERT(pCompartment != NULL);
  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
  CMetab* pA = pModel->getMetabolites()[0];
  CPPUNIT_ASSERT(pA != NULL);
  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::REACTIONS);
  const CMetab* pB = pModel->getMetabolites()[1];
  CPPUNIT_ASSERT(pB != NULL);
  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
  CPPUNIT_ASSERT(pModel->getModelValues().size() == 2);
  // check the kinetic law
  const CModelValue* pFactor = pModel->getModelValues()[1];
  CPPUNIT_ASSERT(pFactor != NULL);
  CPPUNIT_ASSERT(pFactor->getStatus() == CModelEntity::FIXED);
  CPPUNIT_ASSERT(fabs((pFactor->getInitialValue() - pModel->getQuantity2NumberFactor()) / pModel->getQuantity2NumberFactor()) < 1e-3);
  const CModelValue* pModelValue = pModel->getModelValues()[0];
  CPPUNIT_ASSERT(pModelValue != NULL);
  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::ASSIGNMENT);
  const CExpression* pExpr = pModelValue->getExpressionPtr();
  // check the expression
  const CEvaluationNode* pNode = pExpr->getRoot();
  CPPUNIT_ASSERT(pNode != NULL);
  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
  CPPUNIT_ASSERT(pObjectNode != NULL);
  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
  CPPUNIT_ASSERT(!objectCN.empty());
  CObjectInterface::ContainerList listOfContainers;
  listOfContainers.push_back(pModel);
  const CCopasiObject* pObject = CObjectInterface::DataModel(pCOPASIDATAMODEL->getObjectFromCN(listOfContainers, objectCN));
  CPPUNIT_ASSERT(pObject != NULL);
  CPPUNIT_ASSERT(pObject->isReference() == true);
  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("ParticleNumber"));
  CPPUNIT_ASSERT(pObject->getObjectParent() == pA);

  CPPUNIT_ASSERT(pModel->getReactions().size() == 2);
  const CReaction* pReaction1 = pModel->getReactions()[0];
  CPPUNIT_ASSERT(pReaction1 != NULL);
  CPPUNIT_ASSERT(pReaction1->isReversible() == false);
  const CFunction* pKineticFunction = pReaction1->getFunction();
  CPPUNIT_ASSERT(pKineticFunction != NULL);
  const CMassAction* pMassAction = dynamic_cast<const CMassAction*>(pKineticFunction);
  //FTB: this no longer is recognized as mass action reaction because of the
  //     special case of a species with hOSU
  CPPUNIT_ASSERT(pMassAction == NULL);
  const CChemEq* pChemEq = &pReaction1->getChemEq();
  CPPUNIT_ASSERT(pChemEq != NULL);
  CPPUNIT_ASSERT(pChemEq->getCompartmentNumber() == 1);
  CPPUNIT_ASSERT(pChemEq->getSubstrates().size() == 1);
  const CChemEqElement* pElement = pChemEq->getSubstrates()[0];
  CPPUNIT_ASSERT(pElement != NULL);
  CPPUNIT_ASSERT(fabs(pElement->getMultiplicity() - 1.0) < 1e-3);
  CPPUNIT_ASSERT(pElement->getMetabolite() == pA);
  CPPUNIT_ASSERT(pChemEq->getProducts().size() == 0);
  CPPUNIT_ASSERT(pChemEq->getModifiers().size() == 0);

  const CReaction* pReaction2 = pModel->getReactions()[1];
  CPPUNIT_ASSERT(pReaction2 != NULL);
  CPPUNIT_ASSERT(pReaction2->isReversible() == false);
  // check the kinetic law
  pKineticFunction = pReaction2->getFunction();
  CPPUNIT_ASSERT(pKineticFunction != NULL);
  CPPUNIT_ASSERT(pKineticFunction->getObjectName() == std::string("Henri-Michaelis-Menten (irreversible)"));
  // check the function parameters one should be the reference to the substrate
  pChemEq = &pReaction2->getChemEq();
  CPPUNIT_ASSERT(pChemEq != NULL);
  CPPUNIT_ASSERT(pChemEq->getCompartmentNumber() == 1);
  CPPUNIT_ASSERT(pChemEq->getSubstrates().size() == 1);
  pElement = pChemEq->getSubstrates()[0];
  CPPUNIT_ASSERT(pElement != NULL);
  CPPUNIT_ASSERT(fabs(pElement->getMultiplicity() - 1.0) < 1e-3);
  CPPUNIT_ASSERT(pElement->getMetabolite() == pA);
  CPPUNIT_ASSERT(pChemEq->getProducts().size() == 1);
  pElement = pChemEq->getProducts()[0];
  CPPUNIT_ASSERT(pElement != NULL);
  CPPUNIT_ASSERT(fabs(pElement->getMultiplicity() - 1.0) < 1e-3);
  CPPUNIT_ASSERT(pElement->getMetabolite() == pB);
  CPPUNIT_ASSERT(pChemEq->getModifiers().size() == 0);
  const std::vector<std::vector<std::string> > parameterMappings = pReaction2->getParameterMappings();
  CPPUNIT_ASSERT(parameterMappings.size() == 3);
  CPPUNIT_ASSERT(parameterMappings[0].size() == 1);
  const std::string parameterKey = parameterMappings[0][0];
  CPPUNIT_ASSERT(parameterKey == pA->getKey());
}
Exemplo n.º 7
0
void CModelExpansion::updateExpression(CExpression* exp, const std::string & index, const SetOfModelElements & sourceSet, ElementsMap & emap)
{
  if (!exp)
    return;

  //we loop through the complete expression
  std::vector< CEvaluationNode * >::const_iterator it = exp->getNodeList().begin();
  std::vector< CEvaluationNode * >::const_iterator end = exp->getNodeList().end();

  for (; it != end; ++it)
    {
      CEvaluationNodeObject * node = dynamic_cast<CEvaluationNodeObject*>(*it);

      if (!node)
        continue;

      //std::cout << node->getData() << std::endl;
      const CCopasiObject * pObj = dynamic_cast<const CCopasiObject*>(node->getObjectInterfacePtr());
      std::string refname = "";
      std::string reftype = "";

      //when copying between models, pObj=NULL. This is because the expression could not be compiled
      //if it points to an object in a different model.
      //We try to fix this now:
      if (!pObj && mpSourceModel)
        {
          CCopasiObjectName cn = node->getObjectCN();

          while (cn.getPrimary().getObjectType() != "Model" && !cn.empty())
            {
              cn = cn.getRemainder();
            }

          pObj = dynamic_cast<const CCopasiObject*>(mpSourceModel->getObject(cn));
        }

      if (pObj)
        {
          refname = pObj->getObjectName();
          reftype = pObj->getObjectType();
          pObj = pObj->getObjectParent();
        }

      //is the object one that is/should be copied?
      if (sourceSet.contains(pObj))
        {
          if (!emap.exists(pObj))
            {
              //we have to create the duplicate
              std::cout << "!!!" << std::endl;

              if (dynamic_cast<const CCompartment*>(pObj))
                duplicateCompartment(dynamic_cast<const CCompartment*>(pObj), index, sourceSet, emap);

              if (dynamic_cast<const CMetab*>(pObj))
                duplicateMetab(dynamic_cast<const CMetab*>(pObj), index, sourceSet, emap);

              if (dynamic_cast<const CModelValue*>(pObj))
                duplicateGlobalQuantity(dynamic_cast<const CModelValue*>(pObj), index, sourceSet, emap);

              if (dynamic_cast<const CReaction*>(pObj))
                duplicateReaction(dynamic_cast<const CReaction*>(pObj), index, sourceSet, emap);
            }

          //find the duplicate
          const CCopasiObject* duplicate = emap.getDuplicatePtr(pObj);

          if (duplicate)
            {
              //get the reference object
              const CCopasiObject* pRef = dynamic_cast<const CCopasiObject*>(duplicate->getObject(reftype + "=" + refname));

              //update the node
              if (pRef)
                node->setData("<" + pRef->getCN() + ">");

              //std::cout << node->getData() << std::endl;
            }
        }
    }
}
Exemplo n.º 8
0
void test000043::test_hasOnlySubstanceUnits()
{
  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING));
  CModel* pModel = pDataModel->getModel();
  CPPUNIT_ASSERT(pModel != NULL);
  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CUnit::number);
  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CUnit::ml);
  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CUnit::s);
  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
  const CCompartment* pCompartment = pModel->getCompartments()[0];
  CPPUNIT_ASSERT(pCompartment != NULL);
  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
  CMetab* pA = pModel->getMetabolites()[0];
  CPPUNIT_ASSERT(pA != NULL);
  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::REACTIONS);
  const CMetab* pB = pModel->getMetabolites()[1];
  CPPUNIT_ASSERT(pB != NULL);
  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
  const CModelValue* pModelValue = pModel->getModelValues()[0];
  CPPUNIT_ASSERT(pModelValue != NULL);
  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
  CPPUNIT_ASSERT(pModelValue->getInitialExpression() != "");
  const CExpression* pExpr = pModelValue->getInitialExpressionPtr();
  CPPUNIT_ASSERT(pExpr != NULL);
  // check the expression
  const CEvaluationNode* pNode = pExpr->getRoot();
  CPPUNIT_ASSERT(pNode != NULL);
  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
  CPPUNIT_ASSERT(pObjectNode != NULL);
  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
  CPPUNIT_ASSERT(!objectCN.empty());
  CObjectInterface::ContainerList listOfContainers;
  listOfContainers.push_back(pModel);
  const CCopasiObject* pObject = CObjectInterface::DataModel(pCOPASIDATAMODEL->getObjectFromCN(listOfContainers, objectCN));
  CPPUNIT_ASSERT(pObject != NULL);
  CPPUNIT_ASSERT(pObject->isReference() == true);
  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("InitialParticleNumber"));
  CPPUNIT_ASSERT(pObject->getObjectParent() == pA);
  // check the reactions
  CPPUNIT_ASSERT(pModel->getReactions().size() == 2);
  const CReaction* pReaction1 = pModel->getReactions()[0];
  CPPUNIT_ASSERT(pReaction1 != NULL);
  CPPUNIT_ASSERT(pReaction1->isReversible() == false);
  // check the kinetic law
  const CFunction* pKineticFunction = pReaction1->getFunction();
  CPPUNIT_ASSERT(pKineticFunction != NULL);
  const CMassAction* pMassAction = dynamic_cast<const CMassAction*>(pKineticFunction);
  //FTB: this no longer is recognized as mass action reaction because of the
  //     special case of a species with hOSU
  CPPUNIT_ASSERT(pMassAction == NULL);
  const CChemEq* pChemEq = &pReaction1->getChemEq();
  CPPUNIT_ASSERT(pChemEq != NULL);
  CPPUNIT_ASSERT(pChemEq->getCompartmentNumber() == 1);
  CPPUNIT_ASSERT(pChemEq->getSubstrates().size() == 1);
  const CChemEqElement* pElement = pChemEq->getSubstrates()[0];
  CPPUNIT_ASSERT(pElement != NULL);
  CPPUNIT_ASSERT(fabs(pElement->getMultiplicity() - 1.0) < 1e-3);
  CPPUNIT_ASSERT(pElement->getMetabolite() == pA);
  CPPUNIT_ASSERT(pChemEq->getProducts().size() == 0);
  CPPUNIT_ASSERT(pChemEq->getModifiers().size() == 0);

  const CReaction* pReaction2 = pModel->getReactions()[1];
  CPPUNIT_ASSERT(pReaction2 != NULL);
  CPPUNIT_ASSERT(pReaction2->isReversible() == false);
  // check the kinetic law
  pKineticFunction = pReaction2->getFunction();
  CPPUNIT_ASSERT(pKineticFunction != NULL);
  CPPUNIT_ASSERT(pKineticFunction->getObjectName() == std::string("Function for reaction_1"));
  const CFunctionParameters* pFunctionParameters = &pKineticFunction->getVariables();
  CPPUNIT_ASSERT(pFunctionParameters->size() == 4);
  const CFunctionParameter* pFunctionParameter = (*pFunctionParameters)[0];
  CPPUNIT_ASSERT(pFunctionParameter != NULL);
  CPPUNIT_ASSERT(pFunctionParameter->getType() == CFunctionParameter::FLOAT64);
  CPPUNIT_ASSERT(pFunctionParameter->getUsage() == CFunctionParameter::PARAMETER);
  pFunctionParameter = (*pFunctionParameters)[1];
  CPPUNIT_ASSERT(pFunctionParameter != NULL);
  CPPUNIT_ASSERT(pFunctionParameter->getType() == CFunctionParameter::FLOAT64);
  CPPUNIT_ASSERT(pFunctionParameter->getUsage() == CFunctionParameter::PARAMETER);
  pFunctionParameter = (*pFunctionParameters)[2];
  CPPUNIT_ASSERT(pFunctionParameter != NULL);
  CPPUNIT_ASSERT(pFunctionParameter->getType() == CFunctionParameter::FLOAT64);
  CPPUNIT_ASSERT(pFunctionParameter->getUsage() == CFunctionParameter::VOLUME);
  pFunctionParameter = (*pFunctionParameters)[3];
  CPPUNIT_ASSERT(pFunctionParameter != NULL);
  CPPUNIT_ASSERT(pFunctionParameter->getType() == CFunctionParameter::FLOAT64);
  CPPUNIT_ASSERT(pFunctionParameter->getUsage() == CFunctionParameter::SUBSTRATE);
  pNode = pKineticFunction->getRoot();
  const CEvaluationNodeCall* pCallNode = dynamic_cast<const CEvaluationNodeCall*>(pNode);
  CPPUNIT_ASSERT(pCallNode != NULL);
  CPPUNIT_ASSERT((pCallNode->subType()) == CEvaluationNode::S_FUNCTION);
  CPPUNIT_ASSERT(pCallNode->getData() == std::string("Henri-Michaelis-Menten (irreversible)_2"));
  const CEvaluationNodeOperator* pOperatorNode = dynamic_cast<const CEvaluationNodeOperator*>(pCallNode->getChild());
  CPPUNIT_ASSERT(pOperatorNode != NULL);
  CPPUNIT_ASSERT((pOperatorNode->subType()) == CEvaluationNode::S_MULTIPLY);
  const CEvaluationNodeVariable* pVariableNode = dynamic_cast<const CEvaluationNodeVariable*>(pOperatorNode->getChild());
  CPPUNIT_ASSERT(pVariableNode != NULL);
  CPPUNIT_ASSERT(pVariableNode->getIndex() == 3);
  pVariableNode = dynamic_cast<const CEvaluationNodeVariable*>(pOperatorNode->getChild()->getSibling());
  CPPUNIT_ASSERT(pVariableNode != NULL);
  CPPUNIT_ASSERT(pVariableNode->getIndex() == 2);
  pVariableNode = dynamic_cast<const CEvaluationNodeVariable*>(pCallNode->getChild()->getSibling());
  CPPUNIT_ASSERT(pVariableNode != NULL);
  CPPUNIT_ASSERT(pVariableNode->getIndex() == 0);
  pVariableNode = dynamic_cast<const CEvaluationNodeVariable*>(pCallNode->getChild()->getSibling()->getSibling());
  CPPUNIT_ASSERT(pVariableNode != NULL);
  CPPUNIT_ASSERT(pVariableNode->getIndex() == 1);

  pKineticFunction = dynamic_cast<const CFunction*>(pCallNode->getCalledTree());
  CPPUNIT_ASSERT(pKineticFunction != NULL);
  CPPUNIT_ASSERT(pKineticFunction->getObjectName() == std::string("Henri-Michaelis-Menten (irreversible)_2"));
  pNode = pKineticFunction->getRoot();
  CPPUNIT_ASSERT(pNode != NULL);
  pOperatorNode = dynamic_cast<const CEvaluationNodeOperator*>(pNode);
  CPPUNIT_ASSERT(pOperatorNode != NULL);
  CPPUNIT_ASSERT((pOperatorNode->subType()) == CEvaluationNode::S_DIVIDE);
  const CEvaluationNodeOperator* pOperatorNode2 = dynamic_cast<const CEvaluationNodeOperator*>(pOperatorNode->getChild());
  CPPUNIT_ASSERT(pOperatorNode2 != NULL);
  CPPUNIT_ASSERT((pOperatorNode2->subType()) == CEvaluationNode::S_MULTIPLY);
  pVariableNode = dynamic_cast<const CEvaluationNodeVariable*>(pOperatorNode2->getChild());
  CPPUNIT_ASSERT(pVariableNode != NULL);
  CPPUNIT_ASSERT(pVariableNode->getIndex() == 2);
  pVariableNode = dynamic_cast<const CEvaluationNodeVariable*>(pOperatorNode2->getChild()->getSibling());
  CPPUNIT_ASSERT(pVariableNode != NULL);
  CPPUNIT_ASSERT(pVariableNode->getIndex() == 0);
  pOperatorNode2 = dynamic_cast<const CEvaluationNodeOperator*>(pOperatorNode->getChild()->getSibling());
  CPPUNIT_ASSERT(pOperatorNode2 != NULL);
  CPPUNIT_ASSERT((pOperatorNode2->subType()) == CEvaluationNode::S_PLUS);
  pVariableNode = dynamic_cast<const CEvaluationNodeVariable*>(pOperatorNode2->getChild());
  CPPUNIT_ASSERT(pVariableNode != NULL);
  CPPUNIT_ASSERT(pVariableNode->getIndex() == 1);
  pVariableNode = dynamic_cast<const CEvaluationNodeVariable*>(pOperatorNode2->getChild()->getSibling());
  CPPUNIT_ASSERT(pVariableNode != NULL);
  CPPUNIT_ASSERT(pVariableNode->getIndex() == 0);

  // check the function parameters one should be the reference to the substrate
  pChemEq = &pReaction2->getChemEq();
  CPPUNIT_ASSERT(pChemEq != NULL);
  CPPUNIT_ASSERT(pChemEq->getCompartmentNumber() == 1);
  CPPUNIT_ASSERT(pChemEq->getSubstrates().size() == 1);
  pElement = pChemEq->getSubstrates()[0];
  CPPUNIT_ASSERT(pElement != NULL);
  CPPUNIT_ASSERT(fabs(pElement->getMultiplicity() - 1.0) < 1e-3);
  CPPUNIT_ASSERT(pElement->getMetabolite() == pA);
  CPPUNIT_ASSERT(pChemEq->getProducts().size() == 1);
  pElement = pChemEq->getProducts()[0];
  CPPUNIT_ASSERT(pElement != NULL);
  CPPUNIT_ASSERT(fabs(pElement->getMultiplicity() - 1.0) < 1e-3);
  CPPUNIT_ASSERT(pElement->getMetabolite() == pB);
  CPPUNIT_ASSERT(pChemEq->getModifiers().size() == 0);
  const std::vector<std::vector<std::string> > parameterMappings = pReaction2->getParameterMappings();
  CPPUNIT_ASSERT(parameterMappings.size() == 4);
  CPPUNIT_ASSERT(parameterMappings[2].size() == 1);
  std::string parameterKey = parameterMappings[2][0];
  CPPUNIT_ASSERT(parameterKey == pCompartment->getKey());
  CPPUNIT_ASSERT(parameterMappings[3].size() == 1);
  parameterKey = parameterMappings[3][0];
  CPPUNIT_ASSERT(parameterKey == pA->getKey());
}