copasi/sedml/SEDMLImporter.cpp
/**
 * Creates and returns a COPASI CTrajectoryTask from the SEDML simulation
 * given as argument.
 */
Creates and returns a COPASI CTrajectoryTask from the SEDML simulation
given as argument.
Creates and returns a COPASI CTrajectoryTask from the SEDML simulation given as argument .
void SEDMLImporter::updateCopasiTaskForSimulation(SedSimulation* sedmlsim,
    std::map<CDataObject*, SedBase*>& copasi2sedmlmap)
{
  switch (sedmlsim->getTypeCode())
    {
      case SEDML_SIMULATION_UNIFORMTIMECOURSE:
      {
        CTrajectoryTask *tTask = static_cast<CTrajectoryTask*>(&mpDataModel->getTaskList()->operator[]("Time-Course"));
        tTask->setScheduled(true);
        CTrajectoryProblem* tProblem = static_cast<CTrajectoryProblem*>(tTask->getProblem());
        SedUniformTimeCourse* tc = static_cast<SedUniformTimeCourse*>(sedmlsim);
        double outputStartTime = tc->getOutputStartTime();
        double outputEndTime = tc->getOutputEndTime();
        int numberOfPoints = tc->getNumberOfPoints();
        tProblem->setOutputStartTime(outputStartTime);
        if (tc->getInitialTime() != outputStartTime)
          {
            double stepSize = (outputEndTime - outputStartTime) / numberOfPoints;
            int additionalSteps = (int)ceil((outputStartTime - tc->getInitialTime()) / stepSize);
            tProblem->setStepNumber(numberOfPoints + additionalSteps);
            tProblem->setDuration(outputEndTime);
          }
        else
          {
            tProblem->setDuration(outputEndTime - outputStartTime);
            tProblem->setStepNumber(numberOfPoints);
          }
         TODO read kisao terms
        if (tc->isSetAlgorithm())
          {
            const SedAlgorithm* alg = tc->getAlgorithm();
            if (alg->isSetKisaoID())
              {
                if (alg->getKisaoID() == SEDML_KISAO_STOCHASTIC)
                  {
                    tTask->setMethodType(CTaskEnum::Method::stochastic);
                  }
              }
          }
        break;
      }
      case SEDML_SIMULATION_ONESTEP:
      {
        CTrajectoryTask *tTask = static_cast<CTrajectoryTask*>(&mpDataModel->getTaskList()->operator[]("Time-Course"));
        tTask->setScheduled(true);
        CTrajectoryProblem* tProblem = static_cast<CTrajectoryProblem*>(tTask->getProblem());
        SedOneStep* step = static_cast<SedOneStep*>(sedmlsim);
        tProblem->setOutputStartTime(0);
        tProblem->setDuration(step->getStep());
        tProblem->setStepNumber(1);
         TODO read kisao terms
        break;
      }
      case SEDML_SIMULATION_STEADYSTATE:
      {
         nothing to be done for this one
        CSteadyStateTask *tTask = static_cast<CSteadyStateTask*>(&mpDataModel->getTaskList()->operator[]("Steady-State"));
        tTask->setScheduled(true);
         TODO read kisao terms
        CCopasiProblem* tProblem = static_cast<CCopasiProblem*>(tTask->getProblem());
        SedSteadyState* tc = static_cast<SedSteadyState*>(sedmlsim);
        break;
      }
      default:
        CCopasiMessage(CCopasiMessage::EXCEPTION, "SEDMLImporter Error: encountered unknown simulation.");
        break;
    }
}
void SEDMLImporter :: updateCopasiTaskForSimulation ( SedSimulation * sedmlsim , std :: map < CDataObject * , SedBase * > & copasi2sedmlmap ) { switch ( sedmlsim -> getTypeCode ( ) ) { case SEDML_SIMULATION_UNIFORMTIMECOURSE : { CTrajectoryTask * tTask = static_cast < CTrajectoryTask * > ( & mpDataModel -> getTaskList ( ) -> operator [ ] ( " " ) ) ; tTask -> setScheduled ( true ) ; CTrajectoryProblem * tProblem = static_cast < CTrajectoryProblem * > ( tTask -> getProblem ( ) ) ; SedUniformTimeCourse * tc = static_cast < SedUniformTimeCourse * > ( sedmlsim ) ; double outputStartTime = tc -> getOutputStartTime ( ) ; double outputEndTime = tc -> getOutputEndTime ( ) ; int numberOfPoints = tc -> getNumberOfPoints ( ) ; tProblem -> setOutputStartTime ( outputStartTime ) ; if ( tc -> getInitialTime ( ) != outputStartTime ) { double stepSize = ( outputEndTime - outputStartTime ) / numberOfPoints ; int additionalSteps = ( int ) ceil ( ( outputStartTime - tc -> getInitialTime ( ) ) / stepSize ) ; tProblem -> setStepNumber ( numberOfPoints + additionalSteps ) ; tProblem -> setDuration ( outputEndTime ) ; } else { tProblem -> setDuration ( outputEndTime - outputStartTime ) ; tProblem -> setStepNumber ( numberOfPoints ) ; } if ( tc -> isSetAlgorithm ( ) ) { const SedAlgorithm * alg = tc -> getAlgorithm ( ) ; if ( alg -> isSetKisaoID ( ) ) { if ( alg -> getKisaoID ( ) == SEDML_KISAO_STOCHASTIC ) { tTask -> setMethodType ( CTaskEnum :: Method :: stochastic ) ; } } } break ; } case SEDML_SIMULATION_ONESTEP : { CTrajectoryTask * tTask = static_cast < CTrajectoryTask * > ( & mpDataModel -> getTaskList ( ) -> operator [ ] ( " " ) ) ; tTask -> setScheduled ( true ) ; CTrajectoryProblem * tProblem = static_cast < CTrajectoryProblem * > ( tTask -> getProblem ( ) ) ; SedOneStep * step = static_cast < SedOneStep * > ( sedmlsim ) ; tProblem -> setOutputStartTime ( 0 ) ; tProblem -> setDuration ( step -> getStep ( ) ) ; tProblem -> setStepNumber ( 1 ) ; break ; } case SEDML_SIMULATION_STEADYSTATE : { CSteadyStateTask * tTask = static_cast < CSteadyStateTask * > ( & mpDataModel -> getTaskList ( ) -> operator [ ] ( " " ) ) ; tTask -> setScheduled ( true ) ; break ; } default : CCopasiMessage ( CCopasiMessage :: EXCEPTION , " " ) ; break ; } }
Creates and returns a COPASI CTrajectoryTask from the SEDML simulation
 given as argument.
Creates and returns a COPASI CTrajectoryTask from the SEDML simulation given as argument .
// calculate number of steps between (timeStart, timeEnd) // // TODO read kisao terms // TODO read kisao terms // nothing to be done for this one // TODO read kisao terms //CCopasiProblem* tProblem = static_cast<CCopasiProblem*>(tTask->getProblem()); //SedSteadyState* tc = static_cast<SedSteadyState*>(sedmlsim);