15 #ifndef SBMLIMPORTER_H__
16 #define SBMLIMPORTER_H__
22 #include "sbml/math/ASTNode.h"
38 class FunctionDefinition;
95 #if LIBSBML_VERSION >= 40100
100 std::map<CChemEqElement*, std::pair<std::string, CChemEq::MetaboliteRole> > mChemEqElementSpeciesIdMap;
103 std::map<std::string, const CModelValue*> mSpeciesConversionParameterMap;
105 std::map<std::string, const CModelValue*> mSBMLIdModelValueMap;
110 std::map<std::string, double> mSBMLSpeciesReferenceIds;
112 bool mRateRuleForSpeciesReferenceIgnored;
113 bool mEventAssignmentForSpeciesReferenceIgnored;
114 bool mConversionFactorFound;
115 #if LIBSBML_VERSION >= 40200
116 bool mEventPrioritiesIgnored;
117 bool mInitialTriggerValues;
118 bool mNonPersistentTriggerFound;
119 #endif // LIBSBML_VERSION >= 40200
121 #endif // LIBSBML_VERSION >= 40100
127 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap);
136 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap);
140 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap);
148 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap,
149 const Model* pSBMLModel);
157 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap,
158 const Model* pSBMLModel);
169 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap,
178 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap,
186 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap);
194 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap);
201 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap,
209 std::set<std::string>& idSet);
218 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap);
225 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap);
233 CModel* cmodel, std::map<CCopasiObject*, SBase*>& copasi2sbmlmap,
240 std::map<std::string , ASTNode*>
createBVarMap(
const ASTNode* uDefFunction,
241 const ASTNode*
function);
274 std::pair<CModel::LengthUnit, bool>
handleLengthUnit(
const UnitDefinition* uDef);
280 std::pair<CModel::AreaUnit, bool>
handleAreaUnit(
const UnitDefinition* uDef);
286 std::pair<CModel::VolumeUnit, bool>
handleVolumeUnit(
const UnitDefinition* uDef);
298 std::pair<CModel::TimeUnit, bool>
handleTimeUnit(
const UnitDefinition* uDef);
317 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap,
337 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap,
338 Reaction* pSBMLReaction,
339 std::map<std::string, std::string>& localReplacementMap
358 Reaction* pSBMLReaction,
360 std::map<std::string, std::string>& localReplacementMap,
361 const std::set<std::string>& localIds,
362 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap
370 void replace_name_nodes(ASTNode* pNode,
const std::map<std::string, std::string>& replacementMap);
396 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap,
397 Reaction* pSBMLReaction = NULL);
411 const CChemEq& chemicalEquation,
423 const CChemEq& chemicalEquation);
426 const CChemEq& chemicalEquation,
427 const std::vector<std::vector< std::string > >& functionArgumentCNs);
435 std::vector<const CEvaluationNode*>& arguments);
450 const std::map<std::string, std::string>& replacementMap);
453 const std::vector<std::vector<std::string > >& functionArgumentCNs);
460 bool containsVolume(
const ASTNode* pNode,
const std::string& compartmentCN);
466 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap);
490 const std::map<CCopasiObject*, SBase*>& copasi2sbmlmap,
491 bool initialExpression =
false);
521 const std::map<CCopasiObject*, SBase*>& copasi2sbmlmap);
574 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap);
585 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap);
610 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap);
617 std::map<
const FunctionDefinition*, std::set<std::string> >& dependencies);
624 std::set<std::string>& dependencies);
632 SBMLDocument*& pSBMLDocument,
633 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap,
641 SBMLDocument *& pSBMLDocument,
642 std::map<CCopasiObject*, SBase*>& copasi2sbmlmap,
648 static void printMap(
const std::map<CCopasiObject*, SBase*>& map);
649 #endif // COPASI_DEBUG
675 const Model* pSBMLModel);
696 std::string
findIdInASTTree(
const ASTNode* pMath,
const std::set<std::string>& reactionIds);
697 std::string
findIdInASTTree(
const ASTNode* pMath,
const std::map<std::string, double>& reactionIds);
711 #if LIBSBML_VERSION >= 40100
716 static bool checkForUnitsOnNumbers(
const ASTNode* pNode);
722 void applyConversionFactors();
727 static void updateSBMLSpeciesReferenceIds(
const Model* pModel, std::map<std::string, double>& ids);
729 #endif // LIBSBML_VERSION
732 #endif // SBMLIMPORTER_H__
void multiplySubstanceOnlySpeciesByVolume(ConverterASTNode *pNode)
void setImportCOPASIMIRIAM(bool import)
void createDelayFunctionDefinition()
std::pair< CModel::TimeUnit, bool > handleTimeUnit(const UnitDefinition *uDef)
std::set< unsigned int > mIgnoredSBMLMessages
void replace_delay_nodes(ConverterASTNode *pNode, Model *pModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, Reaction *pSBMLReaction, std::map< std::string, std::string > &localReplacementMap)
static void normalizeSBMLUnit(Unit *pU)
void importSBMLRule(const Rule *sbmlRule, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, Model *pSBMLModel)
static C_FLOAT64 round(const C_FLOAT64 &x)
void checkRuleMathConsistency(const Rule *pRule, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
void importRule(const Rule *rule, CModelEntity::Status ruleType, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, Model *pSBMLModel)
bool mUnsupportedRateRuleFound
bool containsVolume(const ASTNode *pNode, const std::string &compartmentCN)
std::map< std::string, std::string > mKnownInitalValues
void replaceTimeDependentFunctionCalls(ASTNode *root)
void find_local_parameters_in_delay(ASTNode *pNode, Reaction *pSBMLReaction, Model *pModel, std::map< std::string, std::string > &localReplacementMap, const std::set< std::string > &localIds, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
std::map< std::string, std::string > mFunctionNameMapping
std::set< std::string > mReactionsWithReplacedLocalParameters
std::vector< CEvaluationNodeObject * > * isMassActionFunction(const CFunction *pFun, const CChemEq &chemicalEquation, const std::vector< std::vector< std::string > > &functionArgumentCNs)
void importInitialAssignments(Model *pSBMLModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlMap, const CModel *pCOPASIModel)
void findAvogadroConstant(Model *pSBMLModel, double factor)
void replace_name_nodes(ASTNode *pNode, const std::map< std::string, std::string > &replacementMap)
static Unit * convertSBMLCubicmetresToLitres(const Unit *pU)
std::map< Species *, Compartment * > mSubstanceOnlySpecies
void setImportHandler(CProcessReport *pHandler)
std::map< std::string, ASTNode * > createBVarMap(const ASTNode *uDefFunction, const ASTNode *function)
CProcessReport * mpImportHandler
CFunction * createCFunctionFromFunctionDefinition(const FunctionDefinition *sbmlFunction, CFunctionDB *pTmpFunctionDB, Model *pSBMLModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
void renameMassActionParameters(CEvaluationNodeCall *pCallNode)
bool isDelayFunctionUsed(ConverterASTNode *pNode)
void getIdsFromNode(const ASTNode *pNode, std::set< std::string > &idSet)
CModel * createCModelFromSBMLDocument(SBMLDocument *doc, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
void replaceObjectNames(ASTNode *pNode, const std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, bool initialExpression=false)
bool mUnsupportedRuleFound
void replace_time_with_initial_time(ASTNode *pNode, const CModel *pCOPASIModel)
CFunctionDB * importFunctionDefinitions(Model *pSBMLModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
void importEvent(const Event *pEvent, Model *pSBMLModel, CModel *pCopasiModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
std::set< const Parameter * > mPotentialAvogadroNumbers
void replaceLog(ConverterASTNode *sourceNode)
void replaceRoot(ConverterASTNode *sourceNode)
CMetab * createCMetabFromSpecies(const Species *sbmlSpecies, CModel *copasiModel, CCompartment *copasiCompartment, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, const Model *pSBMLModel)
CCopasiObject * isConstantFlux(const CEvaluationNode *pRoot, CModel *pModel, CFunctionDB *pFunctionDB)
void checkElementUnits(const Model *pSBMLModel, CModel *pCopasiModel, int level, int version)
void createHasOnlySubstanceUnitFactor(Model *pSBMLModel, double factor, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
std::set< std::string > mUsedFunctions
std::set< std::string > mUsedSBMLIds
CProcessReport * getImportHandlerAddr()
CFunction * createCFunctionFromFunctionTree(const FunctionDefinition *pSBMLFunction, Model *pSBMLModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
void separateProductArguments(const CEvaluationNode *pRootNode, std::vector< const CEvaluationNode * > &arguments)
ConverterASTNode * isMultipliedByVolume(const ASTNode *node, const std::string &compartmentSBMLId)
unsigned C_INT32 mImportStep
std::pair< CModel::QuantityUnit, bool > handleSubstanceUnit(const UnitDefinition *uDef)
static CEvaluationNode * divideByObject(const CEvaluationNode *pOrigNode, const CCopasiObject *pObject)
void setCorrectUsage(CReaction *pCopasiReaction, const CEvaluationNodeCall *pCallNode)
std::vector< CEvaluationNodeObject * > * isMassAction(const CEvaluationTree *pTree, const CChemEq &chemicalEquation, const CEvaluationNodeCall *pCallNode=NULL)
std::map< std::string, std::string > mKnownCustomUserDefinedFunctions
CCopasiDataModel * mpDataModel
std::vector< CEvaluationNodeObject * > * isMassActionExpression(const CEvaluationNode *pRootNode, const CChemEq &chemicalEquation)
static bool areEqualSubtrees(const CEvaluationNode *pNode1, const CEvaluationNode *pNode2)
static bool areEqualFunctions(const CFunction *pFun, const CFunction *pFun2)
bool setInitialValues(CModel *pModel, const std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
CModel * parseSBML(const std::string &sbmlDocumentText, CFunctionDB *funDB, SBMLDocument *&pSBMLDocument, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, CListOfLayouts *&prLol, CCopasiDataModel *pDataModel)
CFunction * findCorrespondingFunction(const CExpression *pExpression, const CReaction *reaction)
bool mAssignmentToSpeciesReferenceFound
void areRulesUnique(const Model *copasiMode)
CEvaluationNode * variables2objects(const CEvaluationNode *pOrigNode, const std::map< std::string, std::string > &replacementMap)
void preprocessNode(ConverterASTNode *pNode, Model *pSBMLModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, Reaction *pSBMLReaction=NULL)
bool sbmlId2CopasiCN(ASTNode *pNode, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, CCopasiParameterGroup &pParamGroup)
bool isSimpleFunctionCall(const CEvaluationNode *pRootNode)
std::map< const ASTNode *, CChemEqElement * > mStoichiometricExpressionMap
std::set< std::string > mDivisionByCompartmentReactions
bool removeUnusedFunctions(CFunctionDB *pTmpFunctionDB, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
CEvaluationTree * createExpressionFromFunction(const CFunction *pFun, const std::vector< std::vector< std::string > > &functionArgumentCNs)
bool isStochasticModel(const Model *pSBMLModel)
void findFunctionCalls(const CEvaluationNode *pNode, std::set< std::string > &functionNameSet)
std::pair< CModel::AreaUnit, bool > handleAreaUnit(const UnitDefinition *uDef)
static UnitDefinition * getSBMLUnitDefinitionForId(const std::string &unitId, const Model *pSBMLModel)
std::set< std::string > mFastReactions
void doMapping(CReaction *pCopasiReaction, const CEvaluationNodeCall *pCallNode)
std::map< std::string, std::string > mDelayNodeMap
void replaceCallNodeNames(ASTNode *pNode)
CCompartment * createCCompartmentFromCompartment(const Compartment *sbmlComp, CModel *copasiModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, const Model *pSBMLModel)
std::set< std::string > mExplicitelyTimeDependentFunctionDefinitions
std::string findIdInASTTree(const ASTNode *pMath, const std::set< std::string > &reactionIds)
const FunctionDefinition * getFunctionDefinitionForName(const std::string name, const Model *model)
static bool areApproximatelyEqual(const double &x, const double &y, const double &t=1e-9)
bool replaceTimeNodesInFunctionDefinition(ASTNode *root, std::string newNodeName)
void importEvents(Model *pSBMLModel, CModel *pCopasiModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
The class for handling a chemical kinetic function.
std::map< CFunction *, std::string > sbmlIdMap
static void findDirectDependencies(const FunctionDefinition *pFunDef, std::map< const FunctionDefinition *, std::set< std::string > > &dependencies)
std::pair< CModel::LengthUnit, bool > handleLengthUnit(const UnitDefinition *uDef)
bool importMIRIAM(const SBase *pSBMLObject, CCopasiObject *pCOPASIObject)
CReaction * createCReactionFromReaction(Reaction *sbmlReaction, Model *sbmlModel, CModel *cmodel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, CFunctionDB *pTmpFunctionDB)
CModelValue * createCModelValueFromParameter(const Parameter *sbmlParameter, CModel *copasiModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
unsigned C_INT32 mTotalSteps
bool getImportCOPASIMIRIAM() const
void replacePowerFunctionNodes(ASTNode *node)
std::map< std::string, CMetab * > speciesMap
std::vector< std::string > mIgnoredParameterUnits
void replaceTimeAndAvogadroNodeNames(ASTNode *pNode)
CModel * readSBML(std::string filename, CFunctionDB *funDB, SBMLDocument *&pSBMLDocument, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, CListOfLayouts *&prLol, CCopasiDataModel *pDataModel)
static bool importNotes(CAnnotation *pAnno, const SBase *pSBase)
void replaceAmountReferences(ConverterASTNode *pNode, Model *pSBMLModel, double factor, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
std::pair< CModel::VolumeUnit, bool > handleVolumeUnit(const UnitDefinition *uDef)
void importRuleForModelEntity(const Rule *rule, CModelEntity *pMV, CModelEntity::Status ruleType, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, Model *pSBMLModel)
unsigned int mOriginalLevel
void applyStoichiometricExpressions(std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, Model *pSBMLModel)
static bool areSBMLUnitDefinitionsIdentical(const UnitDefinition *pUdef1, const UnitDefinition *pUdef2)
bool mUnsupportedAssignmentRuleFound
bool mUsedSBMLIdsPopulated