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

#include <test000026.h>

Inheritance diagram for test000026:
Inheritance graph
[legend]
Collaboration diagram for test000026:
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 (test000026)
 
 CPPUNIT_TEST_SUITE_END ()
 

Detailed Description

Definition at line 24 of file test000026.h.

Member Function Documentation

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

Definition at line 36 of file test000026.cpp.

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

37 {
38  // Create the root container.
39  CCopasiRootContainer::init(0, NULL, false);
40  // Create the global data model.
42 }
static CCopasiDataModel * addDatamodel()
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000026.h:32
static void init(int argc, char *argv[], const bool &withGui=false)
void test000026::tearDown ( )

Definition at line 44 of file test000026.cpp.

References CCopasiRootContainer::destroy().

void test000026::test_hasOnlySubstanceUnits ( )

Definition at line 49 of file test000026.cpp.

References CModelEntity::ASSIGNMENT, CEvaluationNodeOperator::DIVIDE, CEvaluationNodeNumber::DOUBLE, CModelEntity::FIXED, CCopasiNode< _Data >::getChild(), CChemEq::getCompartmentNumber(), CModelEntity::getInitialValue(), CCopasiDataModel::getModel(), CChemEq::getModifiers(), CCopasiObject::getObjectName(), CCopasiObject::getObjectParent(), CChemEq::getProducts(), CModelEntity::getStatus(), CChemEq::getSubstrates(), CEvaluationNode::getType(), CCopasiDataModel::importSBMLFromString(), CCopasiObject::isReference(), CModel::ml, CModel::mMol, MODEL_STRING, CEvaluationNodeOperator::MULTIPLY, CCopasiDataModel::ObjectFromName(), pCOPASIDATAMODEL, CModelEntity::REACTIONS, CModel::s, CCopasiVector< T >::size(), and CEvaluationNode::subType().

50 {
51  CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
52  CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING));
53  CModel* pModel = pDataModel->getModel();
54  CPPUNIT_ASSERT(pModel != NULL);
55  CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
56  CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
57  CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
58  CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
59  const CCompartment* pCompartment = pModel->getCompartments()[0];
60  CPPUNIT_ASSERT(pCompartment != NULL);
61  CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
62  CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
63  CMetab* pA = pModel->getMetabolites()[0];
64  CPPUNIT_ASSERT(pA != NULL);
65  CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::REACTIONS);
66  const CMetab* pB = pModel->getMetabolites()[1];
67  CPPUNIT_ASSERT(pB != NULL);
68  CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
69  CPPUNIT_ASSERT(pModel->getModelValues().size() == 2);
70  const CModelValue* pModelValue = pModel->getModelValues()[0];
71  CPPUNIT_ASSERT(pModelValue != NULL);
72  const CModelValue* pFactor = pModel->getModelValues()[1];
73  CPPUNIT_ASSERT(pFactor != NULL);
74  CPPUNIT_ASSERT(pFactor->getStatus() == CModelEntity::FIXED);
75  CPPUNIT_ASSERT(fabs((pFactor->getInitialValue() - pModel->getQuantity2NumberFactor()) / pModel->getQuantity2NumberFactor()) < 1e-3);
76  CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::ASSIGNMENT);
77  const CExpression* pExpr = pModelValue->getExpressionPtr();
78  // check the expression
79  const CEvaluationNode* pNode = pExpr->getRoot();
80  CPPUNIT_ASSERT(pNode != NULL);
81  const CEvaluationNodeOperator* pOperatorNode = dynamic_cast<const CEvaluationNodeOperator*>(pNode);
82  CPPUNIT_ASSERT(pOperatorNode != NULL);
84  const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNode->getChild()->getSibling());
85  CPPUNIT_ASSERT(pNumberNode != NULL);
87  pOperatorNode = dynamic_cast<const CEvaluationNodeOperator*>(pOperatorNode->getChild());
88  CPPUNIT_ASSERT(pOperatorNode != NULL);
90  const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pOperatorNode->getChild());
91  CPPUNIT_ASSERT(pObjectNode != NULL);
92  CCopasiObjectName objectCN = pObjectNode->getObjectCN();
93  CPPUNIT_ASSERT(!objectCN.empty());
94  std::vector<CCopasiContainer*> listOfContainers;
95  listOfContainers.push_back(pModel);
96  const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
97  CPPUNIT_ASSERT(pObject != NULL);
98  CPPUNIT_ASSERT(pObject->isReference() == true);
99  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("ParticleNumber"));
100  CPPUNIT_ASSERT(pObject->getObjectParent() == pA);
101  pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pOperatorNode->getChild()->getSibling());
102  CPPUNIT_ASSERT(pObjectNode != NULL);
103  objectCN = pObjectNode->getObjectCN();
104  CPPUNIT_ASSERT(!objectCN.empty());
105  pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
106  CPPUNIT_ASSERT(pObject != NULL);
107  CPPUNIT_ASSERT(pObject->isReference() == true);
108  CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Value"));
109  CPPUNIT_ASSERT(pObject->getObjectParent() == pFactor);
110 
111  CPPUNIT_ASSERT(pModel->getReactions().size() == 2);
112  const CReaction* pReaction1 = pModel->getReactions()[0];
113  CPPUNIT_ASSERT(pReaction1 != NULL);
114  CPPUNIT_ASSERT(pReaction1->isReversible() == false);
115  // check the kinetic law
116  const CFunction* pKineticFunction = pReaction1->getFunction();
117  CPPUNIT_ASSERT(pKineticFunction != NULL);
118  const CMassAction* pMassAction = dynamic_cast<const CMassAction*>(pKineticFunction);
119  //FTB: this no longer is recognized as mass action reaction because of the
120  // special case of a species with hOSU
121  CPPUNIT_ASSERT(pMassAction == NULL);
122  const CChemEq* pChemEq = &pReaction1->getChemEq();
123  CPPUNIT_ASSERT(pChemEq != NULL);
124  CPPUNIT_ASSERT(pChemEq->getCompartmentNumber() == 1);
125  CPPUNIT_ASSERT(pChemEq->getSubstrates().size() == 1);
126  const CChemEqElement* pElement = pChemEq->getSubstrates()[0];
127  CPPUNIT_ASSERT(pElement != NULL);
128  CPPUNIT_ASSERT(fabs(pElement->getMultiplicity() - 1.0) < 1e-3);
129  CPPUNIT_ASSERT(pElement->getMetabolite() == pA);
130  CPPUNIT_ASSERT(pChemEq->getProducts().size() == 0);
131  CPPUNIT_ASSERT(pChemEq->getModifiers().size() == 0);
132 
133  const CReaction* pReaction2 = pModel->getReactions()[1];
134  CPPUNIT_ASSERT(pReaction2 != NULL);
135  CPPUNIT_ASSERT(pReaction2->isReversible() == false);
136  // check the kinetic law
137  pKineticFunction = pReaction2->getFunction();
138  CPPUNIT_ASSERT(pKineticFunction != NULL);
139  CPPUNIT_ASSERT(pKineticFunction->getObjectName() == std::string("Henri-Michaelis-Menten (irreversible)"));
140  // check the function parameters one should be the reference to the substrate
141  pChemEq = &pReaction2->getChemEq();
142  CPPUNIT_ASSERT(pChemEq != NULL);
143  CPPUNIT_ASSERT(pChemEq->getCompartmentNumber() == 1);
144  CPPUNIT_ASSERT(pChemEq->getSubstrates().size() == 1);
145  pElement = pChemEq->getSubstrates()[0];
146  CPPUNIT_ASSERT(pElement != NULL);
147  CPPUNIT_ASSERT(fabs(pElement->getMultiplicity() - 1.0) < 1e-3);
148  CPPUNIT_ASSERT(pElement->getMetabolite() == pA);
149  CPPUNIT_ASSERT(pChemEq->getProducts().size() == 1);
150  pElement = pChemEq->getProducts()[0];
151  CPPUNIT_ASSERT(pElement != NULL);
152  CPPUNIT_ASSERT(fabs(pElement->getMultiplicity() - 1.0) < 1e-3);
153  CPPUNIT_ASSERT(pElement->getMetabolite() == pB);
154  CPPUNIT_ASSERT(pChemEq->getModifiers().size() == 0);
155  const std::vector<std::vector<std::string> > parameterMappings = pReaction2->getParameterMappings();
156  CPPUNIT_ASSERT(parameterMappings.size() == 3);
157  CPPUNIT_ASSERT(parameterMappings[0].size() == 1);
158  const std::string parameterKey = parameterMappings[0][0];
159  CPPUNIT_ASSERT(parameterKey == pA->getKey());
160 }
size_t getCompartmentNumber() const
Definition: CChemEq.cpp:110
const std::string & getObjectName() const
virtual size_t size() const
const Type & getType() const
Definition: CMetab.h:178
const C_FLOAT64 & getInitialValue() const
const CCopasiVector< CChemEqElement > & getProducts() const
Definition: CChemEq.cpp:63
bool isReference() const
static const char * MODEL_STRING
Definition: test000026.h:31
const CCopasiVector< CChemEqElement > & getSubstrates() const
Definition: CChemEq.cpp:60
static Type subType(const Type &type)
static CCopasiDataModel * pCOPASIDATAMODEL
Definition: test000026.h:32
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
const CModelEntity::Status & getStatus() const
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CCopasiContainer * getObjectParent() const

Member Data Documentation

const char * test000026::MODEL_STRING
staticprotected

Definition at line 31 of file test000026.h.

Referenced by test_hasOnlySubstanceUnits().

CCopasiDataModel * test000026::pCOPASIDATAMODEL = NULL
staticprotected

Definition at line 32 of file test000026.h.

Referenced by setUp(), and test_hasOnlySubstanceUnits().


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