19 #include <sbml/math/FormulaParser.h>
21 #include <sedml/SedTypes.h>
22 #include <sbml/SBMLTypes.h>
47 std::string &sbmlModelSource,
48 unsigned int sedmlLevel,
49 unsigned int sedmlVersion)
56 SedWriter* writer =
new SedWriter();
58 writer->setProgramName(
"COPASI");
62 std::string returnValue = d;
74 std::string current = baseName + extension;
78 std::stringstream temp;
79 temp << baseName << count << extension;
93 const std::string& filename,
94 const std::string& sbmlDocument,
95 unsigned int sedmlLevel,
96 unsigned int sedmlVersion,
106 std::string sbmlFileName;
111 if (sbmlFile && !overwrite)
120 sbmlOutFile << sbmlDocument;
134 if (testInfile && !overwrite)
157 const SedDocument* pOldSEDMLDocument = NULL;
160 assert(plotDef != NULL);
161 assert(pModel != NULL);
163 if (pOldSEDMLDocument == NULL)
169 this->
mpSEDMLDocument =
dynamic_cast<SedDocument*
>(pOldSEDMLDocument->clone());
188 if (pTask == NULL)
return "";
203 std::string subTaskId;
220 for (
size_t i = 0; i < numItems; ++i)
237 SedUniformRange *range = task->createUniformRange();
240 range->setEnd(numSteps);
241 range->setNumberOfPoints(numSteps);
242 range->setType(
"linear");
244 if (task->isSetRangeId())
245 task->setRangeId(range->getId());
257 SedUniformRange *range = task->createUniformRange();
259 range->setStart(min);
261 range->setNumberOfPoints(numSteps);
262 range->setType(log ?
"log" :
"linear");
273 SedSetValue *change = task->createTaskChange();
274 change->setModelReference(modelId);
278 change->setSymbol(xpath);
282 change->setTarget(xpath);
285 change->setRange(range->getId());
286 change->setMath(SBML_parseFormula(range->getId().c_str()));
292 if (!task->isSetRangeId() && task->getNumRanges() > 0)
293 task->setRangeId(task->getRange(0)->getId());
296 SedSubTask* subTask = task->createSubTask();
297 subTask->setOrder(1);
298 subTask->setTask(subTaskId);
322 alg->setKisaoID(
"KISAO:0000241");
324 alg->setKisaoID(
"KISAO:0000019");
347 SedAlgorithm* alg = steady->createAlgorithm();
348 alg->setKisaoID(
"KISAO:0000282");
353 task->setSimulationReference(steady->getId());
354 task->setModelReference(modelId);
365 model->setId(modelRef.substr(0, modelRef.length() - 4));
366 model->setSource(modelRef);
367 model->setLanguage(
"urn:sedml:language:sbml");
376 std::string modelId = modelRef.substr(0, modelRef.length() - 4);
388 SedDocument* mpSEDMLDocument,
389 const std::string &sbmlId,
390 const std::string &targetXPathString,
391 const std::string& taskId,
395 SedDataGenerator *pPDGen = mpSEDMLDocument->createDataGenerator();
396 std::ostringstream idStrStream;
397 idStrStream << sbmlId;
399 idStrStream << j + 1;
400 pPDGen->setId(idStrStream.str());
402 pPDGen->setName(sbmlId);
404 SedVariable * pPVar = pPDGen->createVariable();
405 std::ostringstream idVarStrStream;
406 idVarStrStream <<
"p";
407 idVarStrStream << i + 1;
408 idVarStrStream <<
"_";
409 idVarStrStream << pPDGen->getName();
410 pPVar->setId(idVarStrStream.str());
411 pPVar->setTaskReference(taskId);
412 pPVar->setName(pPDGen->getName());
414 pPDGen->setMath(SBML_parseFormula(pPVar->getId().c_str()));
418 pPVar->setSymbol(targetXPathString);
422 pPVar->setTarget(targetXPathString);
432 std::string & taskId,
436 std::vector<std::string> stringsContainer;
441 SedPlot2D* pPSedPlot;
446 SedDataGenerator *pTimeDGenp = this->
mpSEDMLDocument->createDataGenerator();
447 pTimeDGenp->setId(
"time");
449 SedVariable *pTimeVar = pTimeDGenp->createVariable();
450 pTimeVar->setId(
"var_time");
451 pTimeVar->setTaskReference(taskId);
453 pTimeDGenp->setMath(SBML_parseFormula(pTimeVar->getId().c_str()));
456 SedDataGenerator *pPDGen;
473 pReport->setName(name);
475 std::vector<CRegisteredObjectName> header = *def->
getHeaderAddr();
476 std::vector<CRegisteredObjectName> body =
482 for (
size_t i = 0; i < body.size(); ++i)
490 if (
object == NULL)
continue;
493 std::string xAxis =
object->getObjectDisplayName();
510 SedDataSet* pDS = pReport->createDataSet();
517 if (header.size() > i)
522 if (headerObj != NULL)
525 pDS->setLabel(xAxis);
528 pDS->setLabel(xAxis);
530 pDS->setDataReference(pPDGen->getId());
536 for (i = 0; i < imax; i++)
545 pPSedPlot->setName(plotName);
549 for (j = 0; j < jmax; j++)
571 bool xIsTime = objectX->
getCN() == pTime->
getCN();
591 std::string sbmlId = yAxis;
595 if (targetXPathString.empty())
610 pPDGen->setName(yAxis);
612 pCurve = pPSedPlot->createCurve();
613 std::ostringstream idCurveStrStream;
614 idCurveStrStream <<
"p";
615 idCurveStrStream << i + 1;
616 idCurveStrStream <<
"_curve_";
617 idCurveStrStream << j + 1;
618 pCurve->setId(idCurveStrStream.str());
619 pCurve->setLogX(pPlot->
isLogX());
620 pCurve->setLogY(pPlot->
isLogY());
621 pCurve->setName(yAxis);
622 pCurve->setYDataReference(pPDGen->getId());
626 pCurve->setXDataReference(pTimeDGenp->getId());
643 pCurve->setXDataReference(pPDGen->getId());
650 : mpSEDMLDocument(NULL)
652 , mpTimecourseTask(NULL)
unsigned int mSEDMLVersion
CCopasiObject * getDataObject(const CCopasiObjectName &CN) const
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
Header file of class CModelEntity and CModelValue.
CCopasiProblem * getProblem()
virtual CCopasiObjectName getCN() const
const std::string & getObjectName() const
virtual size_t size() const
SedDataGenerator * createDataGenerator(SedDocument *mpSEDMLDocument, const std::string &sbmlId, const std::string &targetXPathString, const std::string &taskId, size_t i, size_t j)
const unsigned C_INT32 & getStepNumber() const
std::string createScanTask(CCopasiDataModel &dataModel, const std::string &modelId)
SedDocument * mpSEDMLDocument
const CCopasiReportSeparator & getSeparator() const
std::vector< CPlotDataChannelSpec > & getChannels()
const std::string & getTarget() const
size_t getNumberOfScanItems() const
const std::string exportModelAndTasksToString(CCopasiDataModel &dataModel, std::string &sbmldocument, unsigned int sedmlLevel, unsigned int sedmlVersion)
static std::string getXPathAndName(std::string &sbmlId, const std::string &type, const CModel *pModel, const CCopasiDataModel &dataModel)
CRegisteredObjectName * pCN
static std::string dirName(const std::string &path)
void createTasks(CCopasiDataModel &dataModel, std::string &modelRef)
void createDataGenerators(CCopasiDataModel &dataModel, std::string &taskId, CCopasiTask *task=NULL)
const C_FLOAT64 & getStepSize() const
std::string createUniqueModelFileName(const std::string &dir, const std::string &baseName, const std::string &extension=".xml")
SedTask * mpTimecourseTask
std::vector< CRegisteredObjectName > * getTableAddr()
static bool exist(const std::string &path)
static const std::string Separator
std::string createTimeCourseTask(CCopasiDataModel &dataModel, const std::string &modelId)
const Value & getValue() const
CCopasiVectorN< CCopasiTask > * getTaskList()
void createModels(CCopasiDataModel &dataModel, std::string &modelRef)
CCopasiParameter * getParameter(const std::string &name)
void createSEDMLDocument(CCopasiDataModel &dataModel, std::string modelRef)
SedUniformTimeCourse * mpTimecourse
bool getContinueFromCurrentState() const
static std::string getXPathForObject(const CCopasiObject &object)
CCopasiMethod * getMethod()
const C_FLOAT64 & getOutputStartTime() const
const COutputDefinitionVector * getPlotDefinitionList() const
const CCopasiVector< CPlotItem > & getItems() const
std::vector< CRegisteredObjectName > * getBodyAddr()
static std::string getNextId(const std::string &base, int count)
CCopasiTask::Type getSubtask() const
const CCopasiParameterGroup * getScanItem(size_t index) const
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
static CLocaleString fromUtf8(const std::string &utf8)
std::string createSteadyStateTask(CCopasiDataModel &dataModel, const std::string &modelId)
CReportDefinition * getReportDefinition()
static std::string & removeCharactersFromString(std::string &str, const std::string &characters)
std::vector< CRegisteredObjectName > * getHeaderAddr()
bool exportModelAndTasks(CCopasiDataModel &dataModel, const std::string &SEDMLFilename, const std::string &SBMLFilename, unsigned int sedmlLevel=1, unsigned int sedmlVersion=1, bool overwrite=false)
static const CVersion VERSION