22 #include "utilities.hpp"
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);
62 CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
63 CMetab* pA = pModel->getMetabolites()[0];
64 CPPUNIT_ASSERT(pA != NULL);
66 const CMetab* pB = pModel->getMetabolites()[1];
67 CPPUNIT_ASSERT(pB != NULL);
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);
75 CPPUNIT_ASSERT(fabs((pFactor->
getInitialValue() - pModel->getQuantity2NumberFactor()) / pModel->getQuantity2NumberFactor()) < 1e-3);
77 const CExpression* pExpr = pModelValue->getExpressionPtr();
80 CPPUNIT_ASSERT(pNode != NULL);
82 CPPUNIT_ASSERT(pOperatorNode != NULL);
85 CPPUNIT_ASSERT(pNumberNode != NULL);
88 CPPUNIT_ASSERT(pOperatorNode != NULL);
91 CPPUNIT_ASSERT(pObjectNode != NULL);
93 CPPUNIT_ASSERT(!objectCN.empty());
94 std::vector<CCopasiContainer*> listOfContainers;
95 listOfContainers.push_back(pModel);
97 CPPUNIT_ASSERT(pObject != NULL);
99 CPPUNIT_ASSERT(pObject->
getObjectName() == std::string(
"ParticleNumber"));
102 CPPUNIT_ASSERT(pObjectNode != NULL);
103 objectCN = pObjectNode->getObjectCN();
104 CPPUNIT_ASSERT(!objectCN.empty());
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);
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);
116 const CFunction* pKineticFunction = pReaction1->getFunction();
117 CPPUNIT_ASSERT(pKineticFunction != NULL);
121 CPPUNIT_ASSERT(pMassAction == NULL);
122 const CChemEq* pChemEq = &pReaction1->getChemEq();
123 CPPUNIT_ASSERT(pChemEq != NULL);
127 CPPUNIT_ASSERT(pElement != NULL);
128 CPPUNIT_ASSERT(fabs(pElement->getMultiplicity() - 1.0) < 1e-3);
129 CPPUNIT_ASSERT(pElement->getMetabolite() == pA);
133 const CReaction* pReaction2 = pModel->getReactions()[1];
134 CPPUNIT_ASSERT(pReaction2 != NULL);
135 CPPUNIT_ASSERT(pReaction2->isReversible() ==
false);
137 pKineticFunction = pReaction2->getFunction();
138 CPPUNIT_ASSERT(pKineticFunction != NULL);
139 CPPUNIT_ASSERT(pKineticFunction->getObjectName() == std::string(
"Henri-Michaelis-Menten (irreversible)"));
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());
163 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
164 "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">\n"
165 " <model id=\"Model_1\" name=\"New Model\">\n"
167 " <body xmlns=\"http://www.w3.org/1999/xhtml\">\n"
168 " <p>Model with fixed compartment volume, two species with hasOnlySubstanceUnits flag set to true. The units are set to ml and mMol. There is an assignment rule for the global parameter that contains a reference to species A multiplied by a constant that is not the quantity2number factor.</p>\n"
169 " <p>The imported model should contain an assignment for the global parameter that consists of the reference to the particle number of species A multiplied by the factor and divided by the quantity2unit factor. The species references in the reactions should be imported multiplied by the volume.</p>\n"
172 " <listOfFunctionDefinitions>\n"
173 " <functionDefinition id=\"function_1\" name=\"Henri-Michaelis-Menten (irreversible)\">\n"
174 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
177 " <ci> substrate </ci>\n"
190 " <ci> substrate </ci>\n"
195 " <ci> substrate </ci>\n"
200 " </functionDefinition>\n"
201 " </listOfFunctionDefinitions>\n"
202 " <listOfUnitDefinitions>\n"
203 " <unitDefinition id=\"volume\">\n"
205 " <unit kind=\"litre\" scale=\"-3\"/>\n"
207 " </unitDefinition>\n"
208 " <unitDefinition id=\"substance\">\n"
210 " <unit kind=\"mole\" scale=\"-3\"/>\n"
212 " </unitDefinition>\n"
213 " </listOfUnitDefinitions>\n"
214 " <listOfCompartments>\n"
215 " <compartment id=\"compartment_1\" name=\"compartment\" size=\"1\"/>\n"
216 " </listOfCompartments>\n"
218 " <species id=\"species_1\" name=\"A\" compartment=\"compartment_1\" initialAmount=\"1\" hasOnlySubstanceUnits=\"true\"/>\n"
219 " <species id=\"species_2\" name=\"B\" compartment=\"compartment_1\" initialAmount=\"1\" hasOnlySubstanceUnits=\"true\"/>\n"
220 " </listOfSpecies>\n"
221 " <listOfParameters>\n"
222 " <parameter id=\"parameter_1\" name=\"K\" value=\"0\" constant=\"false\"/>\n"
223 " </listOfParameters>\n"
225 " <assignmentRule variable=\"parameter_1\">\n"
226 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
229 " <ci> species_1 </ci>\n"
230 " <cn> 3.0221415e20 </cn>\n"
233 " </assignmentRule>\n"
235 " <listOfReactions>\n"
236 " <reaction id=\"reaction_1\" name=\"reaction_0\" reversible=\"false\">\n"
237 " <listOfReactants>\n"
238 " <speciesReference species=\"species_1\"/>\n"
239 " </listOfReactants>\n"
241 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
245 " <ci> species_1 </ci>\n"
248 " <listOfParameters>\n"
249 " <parameter id=\"k1\" value=\"0.1\"/>\n"
250 " </listOfParameters>\n"
253 " <reaction id=\"reaction_2\" name=\"reaction_1\" reversible=\"false\">\n"
254 " <listOfReactants>\n"
255 " <speciesReference species=\"species_1\"/>\n"
256 " </listOfReactants>\n"
257 " <listOfProducts>\n"
258 " <speciesReference species=\"species_2\"/>\n"
259 " </listOfProducts>\n"
261 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
264 " <ci> compartment_1 </ci>\n"
266 " <ci> function_1 </ci>\n"
269 " <ci> species_1 </ci>\n"
270 " <ci> compartment_1 </ci>\n"
277 " <listOfParameters>\n"
278 " <parameter id=\"Km\" value=\"0.1\"/>\n"
279 " <parameter id=\"V\" value=\"0.1\"/>\n"
280 " </listOfParameters>\n"
283 " </listOfReactions>\n"
Header file of class CExpression.
size_t getCompartmentNumber() const
Header file of class CModelEntity and CModelValue.
const std::string & getObjectName() const
virtual size_t size() const
const Type & getType() const
void test_hasOnlySubstanceUnits()
const C_FLOAT64 & getInitialValue() const
const CCopasiVector< CChemEqElement > & getProducts() const
static const char * MODEL_STRING
const CCopasiVector< CChemEqElement > & getSubstrates() const
static CCopasiDataModel * addDatamodel()
static Type subType(const Type &type)
static CCopasiDataModel * pCOPASIDATAMODEL
const CCopasiVector< CChemEqElement > & getModifiers() const
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
The class for handling a chemical kinetic function.
static void init(int argc, char *argv[], const bool &withGui=false)
const CModelEntity::Status & getStatus() const
CCopasiNode< Data > * getChild()
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
CCopasiContainer * getObjectParent() const