24 #include "utilities.hpp"
40 #include <sbml/SBMLDocument.h>
41 #include <sbml/Model.h>
42 #include <sbml/Species.h>
43 #include <sbml/Reaction.h>
44 #include <sbml/Rule.h>
45 #include <sbml/math/ASTNode.h>
75 for (i = 0; i < iMax; ++i)
86 CPPUNIT_ASSERT(found81 ==
true);
91 CPPUNIT_ASSERT(
false);
103 CPPUNIT_ASSERT(
false);
112 CPPUNIT_ASSERT(pReaction != NULL);
114 CPPUNIT_ASSERT(pMV != NULL);
117 CPPUNIT_ASSERT(pExpr != NULL);
119 CPPUNIT_ASSERT(pRoot != NULL);
122 CPPUNIT_ASSERT(pObjectNode != NULL);
124 std::vector<CCopasiContainer*> listOfContainers;
127 CPPUNIT_ASSERT(pObject != NULL);
144 bool found80 =
false;
146 for (i = 0; i < iMax; ++i)
157 CPPUNIT_ASSERT(found80 ==
true);
162 CPPUNIT_ASSERT(
false);
171 CPPUNIT_ASSERT(result ==
true);
177 CPPUNIT_ASSERT(
false);
187 CPPUNIT_ASSERT(
false);
192 CPPUNIT_ASSERT(pDocument != NULL);
193 CPPUNIT_ASSERT(pDocument->getLevel() == 2);
194 CPPUNIT_ASSERT(pDocument->getVersion() == 3);
195 const Model* pModel = pDocument->getModel();
196 CPPUNIT_ASSERT(pModel != NULL);
197 CPPUNIT_ASSERT(pModel->getListOfFunctionDefinitions()->size() == 0);
198 CPPUNIT_ASSERT(pModel->getListOfCompartments()->size() == 1);
199 CPPUNIT_ASSERT(pModel->getListOfSpecies()->size() == 3);
200 CPPUNIT_ASSERT(pModel->getListOfReactions()->size() == 1);
201 CPPUNIT_ASSERT(pModel->getListOfRules()->size() == 1);
202 const Reaction* pReaction = pModel->getReaction(0);
203 CPPUNIT_ASSERT(pReaction != NULL);
204 std::string reactionId = pReaction->getId();
205 CPPUNIT_ASSERT(reactionId.empty() ==
false);
206 const Rule* pRule = pModel->getRule(0);
207 CPPUNIT_ASSERT(pRule != NULL);
208 CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
209 const AssignmentRule* pAssignmentRule =
dynamic_cast<const AssignmentRule*
>(pRule);
210 CPPUNIT_ASSERT(pAssignmentRule != NULL);
211 const Species* pSpecies = pModel->getSpecies(pAssignmentRule->getVariable());
212 CPPUNIT_ASSERT(pSpecies != NULL);
213 CPPUNIT_ASSERT(pSpecies->getName() ==
"C");
214 const ASTNode* pMath = pAssignmentRule->getMath();
215 CPPUNIT_ASSERT(pMath != NULL);
216 CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
217 CPPUNIT_ASSERT(pMath->getName() == reactionId);
226 CPPUNIT_ASSERT(result ==
true);
232 CPPUNIT_ASSERT(
false);
238 CPPUNIT_ASSERT(result.empty());
257 std::string s = message.getText();
259 if (s.find(std::string(
"SBML Incompatibility (10)")) != std::string::npos)
267 CPPUNIT_ASSERT_MESSAGE(
"Error message not found.", found ==
true);
271 CPPUNIT_ASSERT(
false);
279 CPPUNIT_ASSERT(result =
true);
284 CPPUNIT_ASSERT(
false);
288 CPPUNIT_ASSERT(pModel != NULL);
294 CPPUNIT_ASSERT(pReaction != NULL);
299 for (i = 0; i < iMax; ++i)
312 CPPUNIT_ASSERT(pConstParameter != NULL);
313 CPPUNIT_ASSERT(pNonConstParameter != NULL);
315 CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
316 CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
317 CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
318 CPPUNIT_ASSERT(pReaction->isReversible() ==
false);
319 const CFunction* pKineticLaw = pReaction->getFunction();
320 CPPUNIT_ASSERT(pKineticLaw != NULL);
322 const std::vector< std::vector<std::string> > & parameterMappings = pReaction->getParameterMappings();
323 CPPUNIT_ASSERT(parameterMappings.size() == 2);
324 CPPUNIT_ASSERT(parameterMappings[0].size() == 1);
325 CPPUNIT_ASSERT(parameterMappings[0][0] == pConstParameter->
getKey());
326 CPPUNIT_ASSERT(parameterMappings[1].size() == 1);
327 std::string substrateKey = parameterMappings[1][0];
329 CPPUNIT_ASSERT(pTempObject != NULL);
330 const CMetab* pSubstrate =
dynamic_cast<const CMetab*
>(pTempObject);
331 CPPUNIT_ASSERT(pSubstrate != NULL);
334 CPPUNIT_ASSERT(pExpression != NULL);
336 CPPUNIT_ASSERT(pRoot != NULL);
339 CPPUNIT_ASSERT(pObjectNode != NULL);
341 std::vector<CCopasiContainer*> listOfContainers;
344 CPPUNIT_ASSERT(pObject != NULL);
350 std::ostringstream result;
359 std::vector<CRegisteredObjectName>* pHeader = pReport->
getHeaderAddr();
360 std::vector<CRegisteredObjectName>* pBody = pReport->
getBodyAddr();
401 TaskList.
remove(
"Time-Course");
402 TaskList.
add(pTrajectoryTask,
true);
407 pTrajectoryTask->
process(
true);
413 CPPUNIT_ASSERT(
false);
417 CPPUNIT_ASSERT(!result.str().empty());
418 std::string result_string = result.str();
419 std::string delimiter =
"\n";
420 std::string delimiter2 =
",";
421 std::size_t lastPos = result_string.find_first_not_of(delimiter);
423 std::string line, number_string;
424 unsigned int index = 0;
426 std::size_t lastPos2;
430 while (lastPos != std::string::npos)
432 pos = result_string.find_first_of(delimiter, lastPos);
433 line = result_string.substr(lastPos, pos - lastPos);
434 lastPos = result_string.find_first_not_of(delimiter, pos);
435 lastPos2 = line.find_first_not_of(delimiter2);
442 while (lastPos2 != std::string::npos)
444 pos2 = line.find_first_of(delimiter2, lastPos2);
445 number_string = line.substr(lastPos2, pos2 - lastPos2);
446 lastPos2 = line.find_first_not_of(delimiter2, pos2);
469 current =
strToDouble(number_string.c_str(), NULL);
470 CPPUNIT_ASSERT(fabs((current - last) / last) < 1e-20);
483 CPPUNIT_ASSERT(index > 1);
486 CPPUNIT_ASSERT(last < *pMethod->getParameter(
"Absolute Tolerance")->getValue().pDOUBLE);
490 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
491 "<sbml xmlns=\"http://www.sbml.org/sbml/level2\" level=\"2\" version=\"1\">\n"
492 " <model id=\"model_1\" name=\"model\">\n"
493 " <listOfCompartments>\n"
494 " <compartment id=\"compartment_1\" size=\"1\"/>\n"
495 " </listOfCompartments>\n"
497 " <species compartment=\"compartment_1\" id=\"species_1\" initialConcentration=\"1\" />\n"
498 " <species compartment=\"compartment_1\" id=\"species_2\" initialConcentration=\"1\" />\n"
499 " </listOfSpecies>\n"
500 " <listOfParameters>\n"
501 " <parameter constant=\"false\" id=\"parameter_1\"/>\n"
502 " </listOfParameters>\n"
504 " <assignmentRule variable=\"parameter_1\">\n"
505 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
506 " <ci> reaction_1 </ci>\n"
508 " </assignmentRule>\n"
510 " <listOfReactions>\n"
511 " <reaction id=\"reaction_1\" reversible=\"false\">\n"
512 " <listOfReactants>\n"
513 " <speciesReference species=\"species_1\"/>\n"
514 " </listOfReactants>\n"
515 " <listOfProducts>\n"
516 " <speciesReference species=\"species_2\"/>\n"
517 " </listOfProducts>\n"
519 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
523 " <ci> species_1 </ci>\n"
528 " </listOfReactions>\n"
533 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
534 "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">\n"
535 " <model id=\"model_1\" name=\"model\">\n"
536 " <listOfCompartments>\n"
537 " <compartment id=\"compartment_1\" size=\"1\"/>\n"
538 " </listOfCompartments>\n"
540 " <species compartment=\"compartment_1\" id=\"species_1\" initialConcentration=\"1\" />\n"
541 " <species compartment=\"compartment_1\" id=\"species_2\" initialConcentration=\"1\" />\n"
542 " </listOfSpecies>\n"
543 " <listOfParameters>\n"
544 " <parameter constant=\"false\" id=\"parameter_1\"/>\n"
545 " </listOfParameters>\n"
547 " <assignmentRule variable=\"parameter_1\">\n"
548 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
549 " <ci> reaction_1 </ci>\n"
551 " </assignmentRule>\n"
553 " <listOfReactions>\n"
554 " <reaction id=\"reaction_1\" reversible=\"false\">\n"
555 " <listOfReactants>\n"
556 " <speciesReference species=\"species_1\"/>\n"
557 " </listOfReactants>\n"
558 " <listOfProducts>\n"
559 " <speciesReference species=\"species_2\"/>\n"
560 " </listOfProducts>\n"
562 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
566 " <ci> species_1 </ci>\n"
571 " </listOfReactions>\n"
576 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
577 "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">\n"
578 " <model id=\"model_1\" name=\"model\">\n"
579 " <listOfCompartments>\n"
580 " <compartment id=\"compartment_1\" size=\"1\"/>\n"
581 " </listOfCompartments>\n"
583 " <species compartment=\"compartment_1\" id=\"species_1\" initialConcentration=\"1\" />\n"
584 " <species compartment=\"compartment_1\" id=\"species_2\" initialConcentration=\"1\" />\n"
585 " </listOfSpecies>\n"
586 " <listOfParameters>\n"
587 " <parameter constant=\"false\" id=\"parameter_1\"/>\n"
588 " </listOfParameters>\n"
590 " <assignmentRule variable=\"parameter_1\">\n"
591 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
592 " <ci> reaction_1 </ci>\n"
594 " </assignmentRule>\n"
596 " <listOfReactions>\n"
597 " <reaction id=\"reaction_1\" reversible=\"false\">\n"
598 " <listOfReactants>\n"
599 " <speciesReference species=\"species_1\"/>\n"
600 " </listOfReactants>\n"
601 " <listOfProducts>\n"
602 " <speciesReference species=\"species_2\"/>\n"
603 " </listOfProducts>\n"
605 " </listOfReactions>\n"
610 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
611 "<COPASI xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation=\"http://www.copasi.org/static/schema.xsd\" versionMajor=\"1\" versionMinor=\"0\" versionDevel=\"30\">\n"
612 " <ListOfFunctions>\n"
613 " <Function key=\"Function_13\" name=\"Mass action (irreversible)\" type=\"MassAction\" reversible=\"false\">\n"
615 " k1*PRODUCT<substrate_i>\n"
617 " <ListOfParameterDescriptions>\n"
618 " <ParameterDescription key=\"FunctionParameter_81\" name=\"k1\" order=\"0\" role=\"constant\"/>\n"
619 " <ParameterDescription key=\"FunctionParameter_79\" name=\"substrate\" order=\"1\" role=\"substrate\"/>\n"
620 " </ListOfParameterDescriptions>\n"
622 " </ListOfFunctions>\n"
623 " <Model key=\"Model_1\" name=\"New Model\" timeUnit=\"s\" volumeUnit=\"ml\" areaUnit=\"m²\" lengthUnit=\"m\" quantityUnit=\"mmol\" type=\"deterministic\">\n"
624 " <ListOfCompartments>\n"
625 " <Compartment key=\"Compartment_0\" name=\"compartment\" simulationType=\"fixed\" dimensionality=\"3\">\n"
627 " </ListOfCompartments>\n"
628 " <ListOfMetabolites>\n"
629 " <Metabolite key=\"Metabolite_0\" name=\"A\" simulationType=\"reactions\" compartment=\"Compartment_0\">\n"
631 " <Metabolite key=\"Metabolite_1\" name=\"B\" simulationType=\"reactions\" compartment=\"Compartment_0\">\n"
633 " <Metabolite key=\"Metabolite_2\" name=\"C\" simulationType=\"assignment\" compartment=\"Compartment_0\">\n"
635 " <CN=Root,Model=New Model,Vector=Reactions[Reaction 1],Reference=Flux>\n"
638 " </ListOfMetabolites>\n"
639 " <ListOfReactions>\n"
640 " <Reaction key=\"Reaction_0\" name=\"Reaction 1\" reversible=\"false\">\n"
641 " <ListOfSubstrates>\n"
642 " <Substrate metabolite=\"Metabolite_0\" stoichiometry=\"1\"/>\n"
643 " </ListOfSubstrates>\n"
644 " <ListOfProducts>\n"
645 " <Product metabolite=\"Metabolite_1\" stoichiometry=\"1\"/>\n"
646 " </ListOfProducts>\n"
647 " <ListOfConstants>\n"
648 " <Constant key=\"Parameter_511\" name=\"k1\" value=\"0.1\"/>\n"
649 " </ListOfConstants>\n"
650 " <KineticLaw function=\"Function_13\">\n"
651 " <ListOfCallParameters>\n"
652 " <CallParameter functionParameter=\"FunctionParameter_81\">\n"
653 " <SourceParameter reference=\"Parameter_511\"/>\n"
654 " </CallParameter>\n"
655 " <CallParameter functionParameter=\"FunctionParameter_79\">\n"
656 " <SourceParameter reference=\"Metabolite_0\"/>\n"
657 " </CallParameter>\n"
658 " </ListOfCallParameters>\n"
661 " </ListOfReactions>\n"
663 " <StateTemplateVariable objectReference=\"Model_1\"/>\n"
664 " <StateTemplateVariable objectReference=\"Metabolite_0\"/>\n"
665 " <StateTemplateVariable objectReference=\"Metabolite_1\"/>\n"
666 " <StateTemplateVariable objectReference=\"Metabolite_2\"/>\n"
667 " <StateTemplateVariable objectReference=\"Compartment_0\"/>\n"
668 " </StateTemplate>\n"
669 " <InitialState type=\"initialState\">\n"
670 " 0 10000.0 0.0 NaN 1\n"
676 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
677 "<sbml xmlns=\"http://www.sbml.org/sbml/level2/version3\" level=\"2\" version=\"3\">\n"
678 " <model id=\"model_1\" name=\"model\">\n"
679 " <listOfCompartments>\n"
680 " <compartment id=\"compartment_1\" size=\"1\"/>\n"
681 " </listOfCompartments>\n"
683 " <species compartment=\"compartment_1\" id=\"species_1\" initialConcentration=\"5\" />\n"
684 " <species compartment=\"compartment_1\" id=\"species_2\" initialConcentration=\"0\" />\n"
685 " </listOfSpecies>\n"
686 " <listOfParameters>\n"
687 " <parameter constant=\"false\" id=\"parameter_1\"/>\n"
688 " <parameter constant=\"true\" id=\"parameter_2\" value=\"1.0\" />\n"
689 " </listOfParameters>\n"
691 " <assignmentRule variable=\"parameter_1\">\n"
692 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
693 " <ci> reaction_1 </ci>\n"
695 " </assignmentRule>\n"
697 " <listOfReactions>\n"
698 " <reaction id=\"reaction_1\" reversible=\"false\">\n"
699 " <listOfReactants>\n"
700 " <speciesReference species=\"species_1\"/>\n"
701 " </listOfReactants>\n"
702 " <listOfProducts>\n"
703 " <speciesReference species=\"species_2\"/>\n"
704 " </listOfProducts>\n"
706 " <math xmlns=\"http://www.w3.org/1998/Math/MathML\">\n"
709 " <ci> compartment_1 </ci>\n"
710 " <ci> parameter_2 </ci>\n"
711 " <ci> species_1 </ci>\n"
716 " </listOfReactions>\n"
const CExpression * getExpressionPtr() const
Header file of class CExpression.
SBMLDocument * getCurrentSBMLDocument()
Header file of class CModelEntity and CModelValue.
bool setValue(const CType &value)
void setScheduled(const bool &scheduled)
virtual bool initialize(const OutputFlag &of, COutputHandler *pOutputHandler, std::ostream *pOstream)
void test_simulate_reaction_flux_reference_1()
CCopasiProblem * getProblem()
virtual CCopasiObjectName getCN() const
bool setTaskType(const CCopasiTask::Type &taskType)
const CCopasiVector< CMetab > & getMetabolites() const
const std::string & getObjectName() const
const CCopasiVectorN< CModelValue > & getModelValues() const
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
virtual size_t size() const
const CRegisteredObjectName & getObjectCN() const
CCopasiObject * get(const std::string &key)
const Type & getType() const
const CCopasiReportSeparator & getSeparator() const
const size_t & getNumber() const
static const char * MODEL_STRING2
virtual bool process(const bool &useInitialValues)
void setDuration(const C_FLOAT64 &duration)
void setSeparator(const CCopasiReportSeparator &Separator)
void test_export_reaction_flux_reference_1()
void test_import_reaction_flux_reference_2()
static const char * MODEL_STRING3
void test_import_reaction_flux_reference_3()
bool load_cps_model_from_stream(std::istream &is, CCopasiDataModel &dataModel)
void setIsTable(bool table)
virtual bool setModel(CModel *pModel)
void test_export_reaction_flux_reference_2()
const CReportDefinitionVector * getReportDefinitionList() const
void setInitialTime(const C_FLOAT64 &time)
const C_FLOAT64 & getInitialValue() const
static const char * MODEL_STRING5
static Type type(const Type &type)
virtual bool add(const CType &src)
virtual const std::string & getKey() const
void setTimeSeriesRequested(bool flag)
CCopasiVectorN< CCopasiTask > * getTaskList()
void test_import_reaction_flux_reference_1()
void setStepNumber(const unsigned C_INT32 &stepNumber)
static const char * MODEL_STRING4
CCopasiParameter * getParameter(const std::string &name)
CReportDefinition * createReportDefinition(const std::string &name, const std::string &comment)
virtual void remove(const std::string &name)
void setTarget(const std::string &target)
static CCopasiDataModel * addDatamodel()
CCopasiVectorNS< CCompartment > & getCompartments()
CCopasiMethod * getMethod()
static CKeyFactory * getKeyFactory()
double strToDouble(const char *str, char const **pTail)
static CCopasiMessage getLastMessage()
std::vector< CRegisteredObjectName > * getBodyAddr()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
The class for handling a chemical kinetic function.
CCopasiVectorNS< CReaction > & getReactions()
static void init(int argc, char *argv[], const bool &withGui=false)
const CModelEntity::Status & getStatus() const
static CCopasiDataModel * pCOPASIDATAMODEL
void setReportDefinition(CReportDefinition *reportDef)
CCopasiObject * ObjectFromName(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &CN) const
virtual bool setMethodType(const int &type)
std::vector< CRegisteredObjectName > * getHeaderAddr()
CEvaluationNode * getRoot()
CCopasiContainer * getObjectParent() const
static const char * MODEL_STRING1