COPASI API  4.16.103
Public Member Functions | Static Protected Attributes | Private Member Functions | List of all members
test000042 Class Reference

#include <test000042.h>

Inheritance diagram for test000042:
Inheritance graph
[legend]
Collaboration diagram for test000042:
Collaboration graph
[legend]

Public Member Functions

void setUp ()
 
void tearDown ()
 
void test_hasOnlySubstanceUnits ()
 

Static Protected Attributes

static const char * MODEL_STRING
 
static CCopasiDataModelpCOPASIDATAMODEL = NULL
 

Private Member Functions

 CPPUNIT_TEST (test_hasOnlySubstanceUnits)
 
 CPPUNIT_TEST_SUITE (test000042)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 24 of file test000042.h.

Member Function Documentation

test000042::CPPUNIT_TEST ( test_hasOnlySubstanceUnits  )
private
test000042::CPPUNIT_TEST_SUITE ( test000042  )
private
test000042::CPPUNIT_TEST_SUITE_END ( )
private
void test000042::setUp ( )

Definition at line 28 of file test000042.cpp.

References CCopasiRootContainer::addDatamodel(), CCopasiRootContainer::init(), and pCOPASIDATAMODEL.

29 {
30  // Create the root container.
31  CCopasiRootContainer::init(0, NULL, false);
32  // Create the global data model.
34 }
static CCopasiDataModel * addDatamodel()
static void init(int argc, char *argv[], const bool &withGui=false)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000042.h:32
void test000042::tearDown ( )

Definition at line 36 of file test000042.cpp.

References CCopasiRootContainer::destroy().

void test000042::test_hasOnlySubstanceUnits ( )

Definition at line 41 of file test000042.cpp.

References CEvaluationNodeOperator::DIVIDE, CModelEntity::FIXED, CFunctionParameter::FLOAT64, CEvaluationNodeCall::FUNCTION, CEvaluationNodeCall::getCalledTree(), CCopasiNode< _Data >::getChild(), CChemEq::getCompartmentNumber(), CEvaluationNodeCall::getData(), CCopasiDataModel::getModel(), CChemEq::getModifiers(), CEvaluationNodeObject::getObjectCN(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CChemEq::getProducts(), CChemEq::getSubstrates(), CEvaluationNode::getType(), CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CModel::ml, CModel::mMol, MODEL_STRING, CEvaluationNodeOperator::MULTIPLY, CCopasiDataModel::ObjectFromName(), CFunctionParameter::PARAMETER, pCOPASIDATAMODEL, CEvaluationNodeOperator::PLUS, CModelEntity::REACTIONS, CModel::s, CCopasiVector< T >::size(), CFunctionParameter::SUBSTRATE, CEvaluationNode::subType(), and CFunctionParameter::VOLUME.

42 {
43  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
44  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING));
45  CModel* pModel = pDataModel->getModel();
46  CPPUNIT_ASSERT(pModel != NULL);
47  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
48  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
49  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
50  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
51  const CCompartment* pCompartment = pModel->getCompartments()[0];
52  CPPUNIT_ASSERT(pCompartment != NULL);
53  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
54  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
55  CMetab* pA = pModel->getMetabolites()[0];
56  CPPUNIT_ASSERT(pA != NULL);
57  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::REACTIONS);
58  const CMetab* pB = pModel->getMetabolites()[1];
59  CPPUNIT_ASSERT(pB != NULL);
60  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
61  CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
62  const CModelValue* pModelValue = pModel->getModelValues()[0];
63  CPPUNIT_ASSERT(pModelValue != NULL);
64  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
65  CPPUNIT_ASSERT(pModelValue->getInitialExpression() != "");
66  const CExpression* pExpr = pModelValue->getInitialExpressionPtr();
67  // check the expression
68  const CEvaluationNode* pNode = pExpr->getRoot();
69  CPPUNIT_ASSERT(pNode != NULL);
70  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
71  CPPUNIT_ASSERT(pObjectNode != NULL);
72  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
73  CPPUNIT_ASSERT(!objectCN.empty());
74  std::vector<CCopasiContainer*> listOfContainers;
75  listOfContainers.push_back(pModel);
76  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
77  CPPUNIT_ASSERT(pObject != NULL);
78  CPPUNIT_ASSERT(pObject->isReference() == true);
79  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("InitialParticleNumber"));
80  CPPUNIT_ASSERT(pObject->getObjectParent() == pA);
81 
82  // check the reactions
83  CPPUNIT_ASSERT(pModel->getReactions().size() == 2);
84  const CReaction* pReaction1 = pModel->getReactions()[0];
85  CPPUNIT_ASSERT(pReaction1 != NULL);
86  CPPUNIT_ASSERT(pReaction1->isReversible() == false);
87  // check the kinetic law
88  const CFunction* pKineticFunction = pReaction1->getFunction();
89  CPPUNIT_ASSERT(pKineticFunction != NULL);
90  const CMassAction* pMassAction = dynamic_cast<const CMassAction*>(pKineticFunction);
91  //FTB: this no longer is recognized as mass action reaction because of the
92  // special case of a species with hOSU
93  CPPUNIT_ASSERT(pMassAction == NULL);
94  const CChemEq* pChemEq = &pReaction1->getChemEq();
95  CPPUNIT_ASSERT(pChemEq != NULL);
96  CPPUNIT_ASSERT(pChemEq->getCompartmentNumber() == 1);
97  CPPUNIT_ASSERT(pChemEq->getSubstrates().size() == 1);
98  const CChemEqElement* pElement = pChemEq->getSubstrates()[0];
99  CPPUNIT_ASSERT(pElement != NULL);
100  CPPUNIT_ASSERT(fabs(pElement->getMultiplicity() - 1.0) < 1e-3);
101  CPPUNIT_ASSERT(pElement->getMetabolite() == pA);
102  CPPUNIT_ASSERT(pChemEq->getProducts().size() == 0);
103  CPPUNIT_ASSERT(pChemEq->getModifiers().size() == 0);
104 
105  const CReaction* pReaction2 = pModel->getReactions()[1];
106  CPPUNIT_ASSERT(pReaction2 != NULL);
107  CPPUNIT_ASSERT(pReaction2->isReversible() == false);
108  // check the kinetic law
109  pKineticFunction = pReaction2->getFunction();
110  CPPUNIT_ASSERT(pKineticFunction != NULL);
111  CPPUNIT_ASSERT(pKineticFunction->getObjectName() == std::string("Function for reaction_1"));
112  const CFunctionParameters* pFunctionParameters = &pKineticFunction->getVariables();
113  CPPUNIT_ASSERT(pFunctionParameters->size() == 4);
114  const CFunctionParameter* pFunctionParameter = (*pFunctionParameters)[0];
115  CPPUNIT_ASSERT(pFunctionParameter != NULL);
116  CPPUNIT_ASSERT(pFunctionParameter->getType() == CFunctionParameter::FLOAT64);
117  CPPUNIT_ASSERT(pFunctionParameter->getUsage() == CFunctionParameter::PARAMETER);
118  pFunctionParameter = (*pFunctionParameters)[1];
119  CPPUNIT_ASSERT(pFunctionParameter != NULL);
120  CPPUNIT_ASSERT(pFunctionParameter->getType() == CFunctionParameter::FLOAT64);
121  CPPUNIT_ASSERT(pFunctionParameter->getUsage() == CFunctionParameter::PARAMETER);
122  pFunctionParameter = (*pFunctionParameters)[2];
123  CPPUNIT_ASSERT(pFunctionParameter != NULL);
124  CPPUNIT_ASSERT(pFunctionParameter->getType() == CFunctionParameter::FLOAT64);
125  CPPUNIT_ASSERT(pFunctionParameter->getUsage() == CFunctionParameter::VOLUME);
126  pFunctionParameter = (*pFunctionParameters)[3];
127  CPPUNIT_ASSERT(pFunctionParameter != NULL);
128  CPPUNIT_ASSERT(pFunctionParameter->getType() == CFunctionParameter::FLOAT64);
129  CPPUNIT_ASSERT(pFunctionParameter->getUsage() == CFunctionParameter::SUBSTRATE);
130  pNode = pKineticFunction->getRoot();
131  const CEvaluationNodeCall* pCallNode = dynamic_cast<const CEvaluationNodeCall*>(pNode);
132  CPPUNIT_ASSERT(pCallNode != NULL);
134  CPPUNIT_ASSERT(pCallNode->getData() == std::string("Henri-Michaelis-Menten (irreversible)_2"));
135  const CEvaluationNodeOperator* pOperatorNode = dynamic_cast<const CEvaluationNodeOperator*>(pCallNode->getChild());
136  CPPUNIT_ASSERT(pOperatorNode != NULL);
138  const CEvaluationNodeVariable* pVariableNode = dynamic_cast<const CEvaluationNodeVariable*>(pOperatorNode->getChild());
139  CPPUNIT_ASSERT(pVariableNode != NULL);
140  CPPUNIT_ASSERT(pVariableNode->getIndex() == 3);
141  pVariableNode = dynamic_cast<const CEvaluationNodeVariable*>(pOperatorNode->getChild()->getSibling());
142  CPPUNIT_ASSERT(pVariableNode != NULL);
143  CPPUNIT_ASSERT(pVariableNode->getIndex() == 2);
144  pVariableNode = dynamic_cast<const CEvaluationNodeVariable*>(pCallNode->getChild()->getSibling());
145  CPPUNIT_ASSERT(pVariableNode != NULL);
146  CPPUNIT_ASSERT(pVariableNode->getIndex() == 0);
147  pVariableNode = dynamic_cast<const CEvaluationNodeVariable*>(pCallNode->getChild()->getSibling()->getSibling());
148  CPPUNIT_ASSERT(pVariableNode != NULL);
149  CPPUNIT_ASSERT(pVariableNode->getIndex() == 1);
150 
151  pKineticFunction = dynamic_cast<const CFunction*>(pCallNode->getCalledTree());
152  CPPUNIT_ASSERT(pKineticFunction != NULL);
153  CPPUNIT_ASSERT(pKineticFunction->getObjectName() == std::string("Henri-Michaelis-Menten (irreversible)_2"));
154  pNode = pKineticFunction->getRoot();
155  CPPUNIT_ASSERT(pNode != NULL);
156  pOperatorNode = dynamic_cast<const CEvaluationNodeOperator*>(pNode);
157  CPPUNIT_ASSERT(pOperatorNode != NULL);
158  CPPUNIT_ASSERT(((CEvaluationNodeOperator::SubType)CEvaluationNode::subType(pOperatorNode->getType())) == CEvaluationNodeOperator::DIVIDE);
159  const CEvaluationNodeOperator* pOperatorNode2 = dynamic_cast<const CEvaluationNodeOperator*>(pOperatorNode->getChild());
160  CPPUNIT_ASSERT(pOperatorNode2 != NULL);
162  pVariableNode = dynamic_cast<const CEvaluationNodeVariable*>(pOperatorNode2->getChild());
163  CPPUNIT_ASSERT(pVariableNode != NULL);
164  CPPUNIT_ASSERT(pVariableNode->getIndex() == 2);
165  pVariableNode = dynamic_cast<const CEvaluationNodeVariable*>(pOperatorNode2->getChild()->getSibling());
166  CPPUNIT_ASSERT(pVariableNode != NULL);
167  CPPUNIT_ASSERT(pVariableNode->getIndex() == 0);
168  pOperatorNode2 = dynamic_cast<const CEvaluationNodeOperator*>(pOperatorNode->getChild()->getSibling());
169  CPPUNIT_ASSERT(pOperatorNode2 != NULL);
171  pVariableNode = dynamic_cast<const CEvaluationNodeVariable*>(pOperatorNode2->getChild());
172  CPPUNIT_ASSERT(pVariableNode != NULL);
173  CPPUNIT_ASSERT(pVariableNode->getIndex() == 1);
174  pVariableNode = dynamic_cast<const CEvaluationNodeVariable*>(pOperatorNode2->getChild()->getSibling());
175  CPPUNIT_ASSERT(pVariableNode != NULL);
176  CPPUNIT_ASSERT(pVariableNode->getIndex() == 0);
177 
178  // check the function parameters one should be the reference to the substrate
179  pChemEq = &pReaction2->getChemEq();
180  CPPUNIT_ASSERT(pChemEq != NULL);
181  CPPUNIT_ASSERT(pChemEq->getCompartmentNumber() == 1);
182  CPPUNIT_ASSERT(pChemEq->getSubstrates().size() == 1);
183  pElement = pChemEq->getSubstrates()[0];
184  CPPUNIT_ASSERT(pElement != NULL);
185  CPPUNIT_ASSERT(fabs(pElement->getMultiplicity() - 1.0) < 1e-3);
186  CPPUNIT_ASSERT(pElement->getMetabolite() == pA);
187  CPPUNIT_ASSERT(pChemEq->getProducts().size() == 1);
188  pElement = pChemEq->getProducts()[0];
189  CPPUNIT_ASSERT(pElement != NULL);
190  CPPUNIT_ASSERT(fabs(pElement->getMultiplicity() - 1.0) < 1e-3);
191  CPPUNIT_ASSERT(pElement->getMetabolite() == pB);
192  CPPUNIT_ASSERT(pChemEq->getModifiers().size() == 0);
193  const std::vector<std::vector<std::string> > parameterMappings = pReaction2->getParameterMappings();
194  CPPUNIT_ASSERT(parameterMappings.size() == 4);
195  CPPUNIT_ASSERT(parameterMappings[2].size() == 1);
196  std::string parameterKey = parameterMappings[2][0];
197  CPPUNIT_ASSERT(parameterKey == pCompartment->getKey());
198  CPPUNIT_ASSERT(parameterMappings[3].size() == 1);
199  parameterKey = parameterMappings[3][0];
200  CPPUNIT_ASSERT(parameterKey == pA->getKey());
201 }
size_t getCompartmentNumber() const
Definition: CChemEq.cpp:110
const CEvaluationTree * getCalledTree() const
static const char * MODEL_STRING
Definition: test000042.h:31
const std::string & getObjectName() const
virtual size_t size() const
const CRegisteredObjectName & getObjectCN() const
const Type & getType() const
Definition: CMetab.h:178
const CCopasiVector< CChemEqElement > & getProducts() const
Definition: CChemEq.cpp:63
virtual const Data & getData() const
bool isReference() const
const CCopasiVector< CChemEqElement > & getSubstrates() const
Definition: CChemEq.cpp:60
static Type subType(const Type &type)
const CCopasiVector< CChemEqElement > & getModifiers() const
Definition: CChemEq.cpp:66
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
The class for handling a chemical kinetic function.
Definition: CFunction.h:29
Definition: CModel.h:50
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000042.h:32
CCopasiContainer * getObjectParent() const

Member Data Documentation

const char * test000042::MODEL_STRING
staticprotected

Definition at line 31 of file test000042.h.

Referenced by test_hasOnlySubstanceUnits().

CCopasiDataModel * test000042::pCOPASIDATAMODEL = NULL
staticprotected

Definition at line 32 of file test000042.h.

Referenced by setUp(), and test_hasOnlySubstanceUnits().


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