copasi API  0.1
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes
SBMLImporter Class Reference

#include <SBMLImporter.h>

List of all members.

Public Member Functions

 SBMLImporter ()
 ~SBMLImporter ()
CModelreadSBML (std::string filename, CFunctionDB *funDB, SBMLDocument *&pSBMLDocument, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, CListOfLayouts *&prLol, CCopasiDataModel *pDataModel)
CModelparseSBML (const std::string &sbmlDocumentText, CFunctionDB *funDB, SBMLDocument *&pSBMLDocument, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, CListOfLayouts *&prLol, CCopasiDataModel *pDataModel)
void restoreFunctionDB ()
void setImportHandler (CProcessReport *pHandler)
CProcessReportgetImportHandlerAddr ()
bool getImportCOPASIMIRIAM () const
void setImportCOPASIMIRIAM (bool import)
std::string findIdInASTTree (const ASTNode *pMath, const std::set< std::string > &reactionIds)

Static Public Member Functions

static bool areSBMLUnitDefinitionsIdentical (const UnitDefinition *pUdef1, const UnitDefinition *pUdef2)
static UnitDefinition * getSBMLUnitDefinitionForId (const std::string &unitId, const Model *pSBMLModel)

Protected Member Functions

CModelcreateCModelFromSBMLDocument (SBMLDocument *doc, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
CFunctioncreateCFunctionFromFunctionDefinition (const FunctionDefinition *sbmlFunction, CFunctionDB *pTmpFunctionDB, Model *pSBMLModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
CFunctioncreateCFunctionFromFunctionTree (const FunctionDefinition *pSBMLFunction, Model *pSBMLModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
CCompartmentcreateCCompartmentFromCompartment (const Compartment *sbmlComp, CModel *copasiModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, const Model *pSBMLModel)
CMetabcreateCMetabFromSpecies (const Species *sbmlSpecies, CModel *copasiModel, CCompartment *copasiCompartment, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, const Model *pSBMLModel)
void areRulesUnique (const Model *copasiMode)
void importSBMLRule (const Rule *sbmlRule, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, Model *pSBMLModel)
void importRuleForModelEntity (const Rule *rule, CModelEntity *pMV, CModelEntity::Status ruleType, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, Model *pSBMLModel)
void importEvents (Model *pSBMLModel, CModel *pCopasiModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
void importEvent (const Event *pEvent, Model *pSBMLModel, CModel *pCopasiModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
void importRule (const Rule *rule, CModelEntity::Status ruleType, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, Model *pSBMLModel)
void getIdsFromNode (const ASTNode *pNode, std::set< std::string > &idSet)
void checkRuleMathConsistency (const Rule *pRule, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
CModelValuecreateCModelValueFromParameter (const Parameter *sbmlParameter, CModel *copasiModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
CReactioncreateCReactionFromReaction (Reaction *sbmlReaction, Model *sbmlModel, CModel *cmodel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, CFunctionDB *pTmpFunctionDB)
std::map< std::string, ASTNode * > createBVarMap (const ASTNode *uDefFunction, const ASTNode *function)
const FunctionDefinition * getFunctionDefinitionForName (const std::string name, const Model *model)
ConverterASTNodereplaceBvars (const ASTNode *node, std::map< std::string, ASTNode * > bvarMap)
void replacePowerFunctionNodes (ASTNode *node)
std::pair< CModel::LengthUnit,
bool > 
handleLengthUnit (const UnitDefinition *uDef)
std::pair< CModel::AreaUnit, bool > handleAreaUnit (const UnitDefinition *uDef)
std::pair< CModel::VolumeUnit,
bool > 
handleVolumeUnit (const UnitDefinition *uDef)
std::pair
< CModel::QuantityUnit, bool > 
handleSubstanceUnit (const UnitDefinition *uDef)
std::pair< CModel::TimeUnit, bool > handleTimeUnit (const UnitDefinition *uDef)
void replaceLog (ConverterASTNode *sourceNode)
void replaceRoot (ConverterASTNode *sourceNode)
bool sbmlId2CopasiCN (ASTNode *pNode, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, CCopasiParameterGroup &pParamGroup)
void replaceCallNodeNames (ASTNode *pNode)
void replace_delay_nodes (ConverterASTNode *pNode, Model *pModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, Reaction *pSBMLReaction, std::map< std::string, std::string > &localReplacementMap)
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)
void replace_name_nodes (ASTNode *pNode, const std::map< std::string, std::string > &replacementMap)
void replaceTimeNodeNames (ASTNode *pNode)
bool isDelayFunctionUsed (ConverterASTNode *pNode)
void preprocessNode (ConverterASTNode *pNode, Model *pSBMLModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, Reaction *pSBMLReaction=NULL)
CFunctionfindCorrespondingFunction (const CFunction *tree, const CReaction *reaction)
bool areEqualFunctions (const CFunction *pFun, const CFunction *pFun2)
bool areEqualSubtrees (const CEvaluationNode *pNode1, const CEvaluationNode *pNode2)
std::vector
< CEvaluationNodeObject * > * 
isMassAction (const CEvaluationTree *pTree, const CChemEq &chemicalEquation, const CEvaluationNodeCall *pCallNode=NULL)
std::vector
< CEvaluationNodeObject * > * 
isMassActionExpression (const CEvaluationNode *pRootNode, const CChemEq &chemicalEquation)
std::vector
< CEvaluationNodeObject * > * 
isMassActionFunction (const CFunction *pFun, const CChemEq &chemicalEquation, const std::vector< std::vector< std::string > > &functionArgumentCNs)
void separateProductArguments (const CEvaluationNode *pRootNode, std::vector< const CEvaluationNode * > &arguments)
void doMapping (CReaction *pCopasiReaction, const CEvaluationNodeCall *pCallNode)
bool isSimpleFunctionCall (const CEvaluationNode *pRootNode)
void setCorrectUsage (CReaction *pCopasiReaction, const CEvaluationNodeCall *pCallNode)
ConverterASTNodeisMultipliedByVolume (const ASTNode *node, const std::string &compartmentSBMLId)
CEvaluationNodevariables2objects (const CEvaluationNode *pOrigNode, const std::map< std::string, std::string > &replacementMap)
CEvaluationTreecreateExpressionFromFunction (const CFunction *pFun, const std::vector< std::vector< std::string > > &functionArgumentCNs)
void renameMassActionParameters (CEvaluationNodeCall *pCallNode)
bool containsVolume (const ASTNode *pNode, const std::string &compartmentCN)
bool removeUnusedFunctions (CFunctionDB *pTmpFunctionDB, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
void findFunctionCalls (const CEvaluationNode *pNode, std::set< std::string > &functionNameSet)
bool isStochasticModel (const Model *pSBMLModel)
void replace_time_with_initial_time (ASTNode *pNode, const CModel *pCOPASIModel)
void replaceObjectNames (ASTNode *pNode, const std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, bool initialExpression=false)
bool replaceTimeNodesInFunctionDefinition (ASTNode *root, std::string newNodeName)
void replaceTimeDependentFunctionCalls (ASTNode *root)
bool setInitialValues (CModel *pModel, const std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
void checkElementUnits (const Model *pSBMLModel, CModel *pCopasiModel, int level, int version)
void importInitialAssignments (Model *pSBMLModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlMap, const CModel *pCOPASIModel)
void applyStoichiometricExpressions (std::map< CCopasiObject *, SBase * > &copasi2sbmlmap, Model *pSBMLModel)
void createDelayFunctionDefinition ()
void findAvogadroConstant (Model *pSBMLModel, double factor)
void replaceAmountReferences (ConverterASTNode *pNode, Model *pSBMLModel, double factor, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
void createHasOnlySubstanceUnitFactor (Model *pSBMLModel, double factor, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)
void multiplySubstanceOnlySpeciesByVolume (ConverterASTNode *pNode)
bool importMIRIAM (const SBase *pSBMLObject, CCopasiObject *pCOPASIObject)
CFunctionDBimportFunctionDefinitions (Model *pSBMLModel, std::map< CCopasiObject *, SBase * > &copasi2sbmlmap)

Static Protected Member Functions

static C_FLOAT64 round (const C_FLOAT64 &x)
static bool areApproximatelyEqual (const double &x, const double &y, const double &t=1e-9)
static CCopasiObjectisConstantFlux (const CEvaluationNode *pRoot, CModel *pModel, CFunctionDB *pFunctionDB)
static Unit * convertSBMLCubicmetresToLitres (const Unit *pU)
static void normalizeSBMLUnit (Unit *pU)
static void findDirectDependencies (const FunctionDefinition *pFunDef, std::map< const FunctionDefinition *, std::set< std::string > > &dependencies)
static void findDirectDependencies (const ASTNode *pNode, std::set< std::string > &dependencies)

Protected Attributes

std::set< unsigned int > mIgnoredSBMLMessages
std::map< std::string, CMetab * > speciesMap
CFunctionDBfunctionDB
bool mIncompleteModel
bool mUnsupportedRuleFound
bool mUnsupportedRateRuleFound
bool mUnsupportedAssignmentRuleFound
bool mUnitOnNumberFound
bool mAssignmentToSpeciesReferenceFound
unsigned int mLevel
unsigned int mOriginalLevel
unsigned int mVersion
std::map< CEvaluationTree
*, std::string > 
sbmlIdMap
std::set< std::string > mUsedFunctions
CCopasiDataModelmpDataModel
CModelmpCopasiModel
std::map< std::string,
std::string > 
mFunctionNameMapping
std::set< std::string > mDivisionByCompartmentReactions
CProcessReportmpImportHandler
unsigned C_INT32 mImportStep
unsigned C_INT32 mhImportStep
unsigned C_INT32 mTotalSteps
std::map< Species
*, Compartment * > 
mSubstanceOnlySpecies
std::set< std::string > mFastReactions
std::set< std::string > mReactionsWithReplacedLocalParameters
std::set< std::string > mExplicitelyTimeDependentFunctionDefinitions
std::vector< std::string > mIgnoredParameterUnits
std::map< const ASTNode
*, CChemEqElement * > 
mStoichiometricExpressionMap
bool mDelayFound
std::set< const Parameter * > mPotentialAvogadroNumbers
bool mAvogadroCreated
bool mImportCOPASIMIRIAM
std::map< std::string,
std::string > 
mDelayNodeMap
std::set< std::string > mUsedSBMLIds
bool mUsedSBMLIdsPopulated

Constructor & Destructor Documentation

SBMLImporter::SBMLImporter ( )

Constructor that initializes speciesMap and the FunctionDB object

SBMLImporter::~SBMLImporter ( )

Destructor that does nothing.


Member Function Documentation

void SBMLImporter::applyStoichiometricExpressions ( std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap,
Model *  pSBMLModel 
) [protected]

This method evaluates all stoichiometric expressions and sets them as constants on the CChemEqElement.

bool SBMLImporter::areApproximatelyEqual ( const double &  x,
const double &  y,
const double &  t = 1e-9 
) [static, protected]
bool SBMLImporter::areEqualFunctions ( const CFunction pFun,
const CFunction pFun2 
) [protected]
bool SBMLImporter::areEqualSubtrees ( const CEvaluationNode pNode1,
const CEvaluationNode pNode2 
) [protected]

Compares to CEvaluationNode based subtrees recursively.

void SBMLImporter::areRulesUnique ( const Model *  copasiMode) [protected]

Checks if no id is used in more than one Assignment and RateRule.

bool SBMLImporter::areSBMLUnitDefinitionsIdentical ( const UnitDefinition *  pUdef1,
const UnitDefinition *  pUdef2 
) [static]

Enhanced method to identify identical SBML unit definitions. This method uses the areIdentical method from libSBML, but if the method return false, it does some extra checks. Right now it check for example if two volumes, one given in litre and one given in cubic meters are identical.

Enhanced method to identify identical sbml unit definitions. The method first converts the unit definitions to SI units and simplifies them, only then they are compared.

void SBMLImporter::checkElementUnits ( const Model *  pSBMLModel,
CModel pCopasiModel,
int  level,
int  version 
) [protected]
void SBMLImporter::checkRuleMathConsistency ( const Rule *  pRule,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap 
) [protected]

Checks the expression for a give rate or assignment rule for consistency. This basically means it checks that no id present in the expression is the target for one of the following rate or assignment rules.

bool SBMLImporter::containsVolume ( const ASTNode *  pNode,
const std::string &  compartmentCN 
) [protected]

Checks if the volume with the given CN is one of the parameters to the given call node.

Unit * SBMLImporter::convertSBMLCubicmetresToLitres ( const Unit *  pU) [static, protected]

If the given UnitDefinition can be converted to a form of litre, the function return the UnitDefinition in litre, otherwise NULL is returned.

std::map< std::string, ASTNode * > SBMLImporter::createBVarMap ( const ASTNode *  uDefFunction,
const ASTNode *  function 
) [protected]

Creates a map of each parameter of the function definition and its corresponding parameter in the function call.

CCompartment * SBMLImporter::createCCompartmentFromCompartment ( const Compartment *  sbmlCompartment,
CModel copasiModel,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap,
const Model *  pSBMLModel 
) [protected]

Creates and returns a COPASI CCompartment from the SBML Compartment given as argument.

Creates and returns a Copasi CCompartment from the SBML Compartment given as argument.

CFunction * SBMLImporter::createCFunctionFromFunctionDefinition ( const FunctionDefinition *  sbmlFunction,
CFunctionDB pTmpFunctionDB,
Model *  pSBMLModel,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap 
) [protected]

Creates and returns a COPASI CFunction from the SBML FunctionDefinition given as argument.

CFunction * SBMLImporter::createCFunctionFromFunctionTree ( const FunctionDefinition *  pSBMLFunction,
Model *  pSBMLModel,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap 
) [protected]
CMetab * SBMLImporter::createCMetabFromSpecies ( const Species *  sbmlSpecies,
CModel copasiModel,
CCompartment copasiCompartment,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap,
const Model *  pSBMLModel 
) [protected]

Creates and returns a COPASI CMetab from the given SBML Species object.

Creates and returns a Copasi CMetab from the given SBML Species object.

CModel * SBMLImporter::createCModelFromSBMLDocument ( SBMLDocument *  sbmlDocument,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap 
) [protected]

Creates and returns a COPASI CModel from the SBMLDocument given as argument.

Creates and returns a Copasi CModel from the SBMLDocument given as argument.

CModelValue * SBMLImporter::createCModelValueFromParameter ( const Parameter *  sbmlParameter,
CModel copasiModel,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap 
) [protected]

Creates and returns a COPASI CModelValue from the given SBML Parameter object.

CReaction * SBMLImporter::createCReactionFromReaction ( Reaction *  sbmlReaction,
Model *  pSBMLModel,
CModel copasiModel,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap,
CFunctionDB pTmpFunctionDB 
) [protected]

Creates and returns a COPASI CReaction object from the given SBML Reaction object.

Creates and returns a Copasi CReaction object from the given SBML Reaction object.

void SBMLImporter::createDelayFunctionDefinition ( ) [protected]

Creates a function definition for the delay function.

CEvaluationTree * SBMLImporter::createExpressionFromFunction ( const CFunction pFun,
const std::vector< std::vector< std::string > > &  functionArgumentCNs 
) [protected]
void SBMLImporter::createHasOnlySubstanceUnitFactor ( Model *  pSBMLModel,
double  factor,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap 
) [protected]

This method creates a global parameter the represents the factor that is used to convert a particle number into the amount units set on the model. The parameter is only created if it is needed and after exporting the model, the parameter is deleted from the COPASI model again.

void SBMLImporter::doMapping ( CReaction pCopasiReaction,
const CEvaluationNodeCall pCallNode 
) [protected]
void SBMLImporter::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 
) [protected]

If we replace delay nodes within kineitc laws, we have to make sure that there is no reference to a local parameter within the replaced delay node because that would mean that we end up with a reference to a local parameter in the rule for the delay replacement which is not allowed in SBML. Therefore we have to convert all local parameters which occur within a delay call into global parameters. This method finds all local parameters that have to be converted to global parameters and it already creates the necessary global parameters. The localReplacementMap returns a mapping between the is of the original parameter and the id of the new parameter it will be replaced with. This map is used in a second step to actually replace the nodes in the expression.

If we replace delay nodes within kineitc laws, we have to make sure that there is no reference to a local parameter within the replaced delay node because that would mean that we end up with a reference to a local parameter in the rule for the delay replacement which is not allowed in SBML. Therefore we have to convert all local parameters which occur within a delay call into global parameters.

void SBMLImporter::findAvogadroConstant ( Model *  pSBMLModel,
double  factor 
) [protected]

This method goes through the list of global parameters and tries to find a parameter that could correspond to avogadros number.

CFunction * SBMLImporter::findCorrespondingFunction ( const CFunction tree,
const CReaction pCopasiReaction 
) [protected]

The methods gets a function where all the parameters have a usage of "PARAMETER". In addition it get the root node of a call to that function which is an expression and contains the acutal objects with which the function is called in a certain reaction. From this expression we can determine if there already is a function in the database that does the same. Or we can find out if this function is a Mass Action kinetic.

void SBMLImporter::findDirectDependencies ( const FunctionDefinition *  pFunDef,
std::map< const FunctionDefinition *, std::set< std::string > > &  dependencies 
) [static, protected]

static method that finds all direct function dependencies of a given function definition.

void SBMLImporter::findDirectDependencies ( const ASTNode *  pNode,
std::set< std::string > &  dependencies 
) [static, protected]

static method that recursively finds all direct function dependencies of the expression rooted at the given node.

void SBMLImporter::findFunctionCalls ( const CEvaluationNode pNode,
std::set< std::string > &  functionNameSet 
) [protected]

Finds all functions calls directly or indirectly used in a function tree.

std::string SBMLImporter::findIdInASTTree ( const ASTNode *  pMath,
const std::set< std::string > &  reactionIds 
)

This method takes an AST node and a set of ids and returns the first id from the set it finds in the AST tree. This is e.g. used to check if expression in L2V1 contain references to reaction ids.

const FunctionDefinition * SBMLImporter::getFunctionDefinitionForName ( const std::string  name,
const Model *  sbmlModel 
) [protected]

Returns the user defined SBML function definition that belongs to the given name, or NULL if none can be found.

void SBMLImporter::getIdsFromNode ( const ASTNode *  pNode,
std::set< std::string > &  idSet 
) [protected]

Recurses an ASTNode tree and gets all SBML Ids in the tree. The ids are stored in the given set.

bool SBMLImporter::getImportCOPASIMIRIAM ( ) const

Returns the flag that determines whether COPASI MIRIAM annotation is imported if it is present.

CProcessReport * SBMLImporter::getImportHandlerAddr ( )
UnitDefinition * SBMLImporter::getSBMLUnitDefinitionForId ( const std::string &  unitId,
const Model *  pSBMLModel 
) [static]

This method takes the id of a unit as it can appear in an SBML file, and returns a new UnitDefinition object for that id.

std::pair< CModel::AreaUnit, bool > SBMLImporter::handleAreaUnit ( const UnitDefinition *  uDef) [protected]

Returns the copasi AreaUnit corresponding to the given SBML area UnitDefinition.

std::pair< CModel::LengthUnit, bool > SBMLImporter::handleLengthUnit ( const UnitDefinition *  uDef) [protected]

This functions replaces all species nodes for species that are in the substanceOnlySpeciesVector. With the node multiplied by the volume of the species compartment. void replaceSubstanceOnlySpeciesNodes(ConverterASTNode* node, const std::map<Species*, Compartment*>& substanceOnlySpecies); Returns the copasi LengthUnit corresponding to the given SBML length UnitDefinition.

Returns the copasi LengthUnit corresponding to the given SBML length UnitDefinition.

std::pair< CModel::QuantityUnit, bool > SBMLImporter::handleSubstanceUnit ( const UnitDefinition *  uDef) [protected]

Returns the COPASI QuantityUnit corresponding to the given SBML Substance UnitDefinition.

Returns the copasi QuantityUnit corresponding to the given SBML Substance UnitDefinition.

std::pair< CModel::TimeUnit, bool > SBMLImporter::handleTimeUnit ( const UnitDefinition *  uDef) [protected]

Returns the COPASI TimeUnit corresponding to the given SBML Time UnitDefinition.

Returns the copasi TimeUnit corresponding to the given SBML Time UnitDefinition.

std::pair< CModel::VolumeUnit, bool > SBMLImporter::handleVolumeUnit ( const UnitDefinition *  uDef) [protected]

Returns the copasi VolumeUnit corresponding to the given SBML Volume UnitDefinition.

void SBMLImporter::importEvent ( const Event *  pEvent,
Model *  pSBMLModel,
CModel pCopasiModel,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap 
) [protected]

Imports the given event.

void SBMLImporter::importEvents ( Model *  pSBMLModel,
CModel pCopasiModel,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap 
) [protected]

Imports all events

CFunctionDB * SBMLImporter::importFunctionDefinitions ( Model *  pSBMLModel,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap 
) [protected]

Starting with SBML Level 2 Version 4, function definitions no longer need to be ordered, i.e. a function definition may refer to another function definition that is defined somewhere further down in the file. So we have to import the function definitions in the correct order.

void SBMLImporter::importInitialAssignments ( Model *  pSBMLModel,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlMap,
const CModel pCOPASIModel 
) [protected]

Imports all initial assignments if there are any.

bool SBMLImporter::importMIRIAM ( const SBase *  pSBMLObject,
CCopasiObject pCOPASIObject 
) [protected]

Imports the MIRIAM annotation from the given SBML object and sets it on the given COPASI object.

void SBMLImporter::importRule ( const Rule *  rule,
CModelEntity::Status  ruleType,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap,
Model *  pSBMLModel 
) [protected]

Imports the given RateRule if COPASI supports this kind of RateRule, otherwise a warning is created.

void SBMLImporter::importRuleForModelEntity ( const Rule *  rule,
CModelEntity pMV,
CModelEntity::Status  ruleType,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap,
Model *  pSBMLModel 
) [protected]

Imports the given AssignmentRule which is for a global parameter.

void SBMLImporter::importSBMLRule ( const Rule *  sbmlRule,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap,
Model *  pSBMLModel 
) [protected]

Imports the given Rule if COPASI supports this kind of Rule, otherwise a warning is created.

CCopasiObject * SBMLImporter::isConstantFlux ( const CEvaluationNode pRoot,
CModel pModel,
CFunctionDB pFunctionDB 
) [static, protected]

Checks if the given node is an object node that represents a parameter or a model value or a function which has a single parameter and a single node which also represents a parameter.

bool SBMLImporter::isDelayFunctionUsed ( ConverterASTNode pNode) [protected]

COPASI can not handle the delay function yet, so if it is used in some expression, we have to abort reading the file.

std::vector< CEvaluationNodeObject * > * SBMLImporter::isMassAction ( const CEvaluationTree pTree,
const CChemEq chemicalEquation,
const CEvaluationNodeCall pCallNode = NULL 
) [protected]
std::vector< CEvaluationNodeObject * > * SBMLImporter::isMassActionExpression ( const CEvaluationNode pRootNode,
const CChemEq chemicalEquation 
) [protected]
std::vector< CEvaluationNodeObject * > * SBMLImporter::isMassActionFunction ( const CFunction pFun,
const CChemEq chemicalEquation,
const std::vector< std::vector< std::string > > &  functionArgumentCNs 
) [protected]
ConverterASTNode * SBMLImporter::isMultipliedByVolume ( const ASTNode *  node,
const std::string &  compartmentSBMLId 
) [protected]

Checks if a given tree is multiplied by a compartment identifier. If so, a copy of the tree is returned in which the multiplication has been removed.

bool SBMLImporter::isSimpleFunctionCall ( const CEvaluationNode pRootNode) [protected]
bool SBMLImporter::isStochasticModel ( const Model *  pSBMLModel) [protected]

Heuristically checks whether a model was meant to be simulated stochastically. If the substance units are set to items and all reaction are irreversible this function will return true;

void SBMLImporter::multiplySubstanceOnlySpeciesByVolume ( ConverterASTNode pNode) [protected]

Multiplies all species nodes that belong to species with the hasSubstanceOnlyUnits flag set with the volume of the compartment that the species belongs to. This is only done for kineticLaw, all other mathematical expressions import those references as particle number nodes divided by the quantity2unit factor.

void SBMLImporter::normalizeSBMLUnit ( Unit *  pU) [static, protected]

This function normalizes the multiplier to be within the range 1.0 <= multiplier < 10.0.

CModel * SBMLImporter::parseSBML ( const std::string &  sbmlDocumentText,
CFunctionDB funDB,
SBMLDocument *&  pSBMLDocument,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap,
CListOfLayouts *&  prLol,
CCopasiDataModel pDataModel 
)

Function parses an SBML document with libsbml and converts it to a COPASI CModel object which is returned. Deletion of the returned pointer is up to the caller.

void SBMLImporter::preprocessNode ( ConverterASTNode pNode,
Model *  pSBMLModel,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap,
Reaction *  pSBMLReaction = NULL 
) [protected]

In a preprocessing step each expression tree that is imported, e.g. for function definitions, rules, event or kinetic laws is preprocessed to replace some of the nodes data. See also replaceCallNodeNames and replaceTimeNodeNames.

CModel * SBMLImporter::readSBML ( std::string  filename,
CFunctionDB funDB,
SBMLDocument *&  pSBMLDocument,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap,
CListOfLayouts *&  prLol,
CCopasiDataModel pDataModel 
)

This functions replaces all species nodes for species that are in the substanceOnlySpeciesVector. With the node multiplied by the volume of the species compartment. void SBMLImporter::replaceSubstanceOnlySpeciesNodes(ConverterASTNode* node, const std::map<Species*, Compartment*>& substanceOnlySpecies) { if (node != NULL) { if (node->getType() == AST_NAME) { std::map<Species*, Compartment*>::const_iterator it = substanceOnlySpecies.begin(); std::map<Species*, Compartment*>::const_iterator endIt = substanceOnlySpecies.end(); while (it != endIt) { if (it->first->getId() == node->getName()) { replace node List* l = new List(); ConverterASTNode* child1 = new ConverterASTNode(AST_NAME); child1->setName(node->getName()); ConverterASTNode* child2 = new ConverterASTNode(AST_NAME); child2->setName(it->second->getId().c_str()); l->add(child1); l->add(child2); node->setChildren(l); node->setType(AST_TIMES); break; } ++it; } } else { unsigned int counter; for (counter = 0;counter < node->getNumChildren();counter++) { this->replaceSubstanceOnlySpeciesNodes((ConverterASTNode*)node->getChild(counter), substanceOnlySpecies); } } } } Function reads an SBML file with libsbml and converts it to a Copasi CModel

bool SBMLImporter::removeUnusedFunctions ( CFunctionDB pTmpFunctionDB,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap 
) [protected]

Finds all functions that are used and removes those that are not.

void SBMLImporter::renameMassActionParameters ( CEvaluationNodeCall pCallNode) [protected]
void SBMLImporter::replace_delay_nodes ( ConverterASTNode pNode,
Model *  pModel,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap,
Reaction *  pSBMLReaction,
std::map< std::string, std::string > &  localReplacementMap 
) [protected]

This function replaces calls to the delay function in an ASTNode tree by a node that references a new global parameter which the function creates. The global parameter gets an expression which corresponds to the delay call. This is necessary because all knetic laws in COPASI are function calls and function definitions should not contain a call to delay.

void SBMLImporter::replace_name_nodes ( ASTNode *  pNode,
const std::map< std::string, std::string > &  replacementMap 
) [protected]

This method gets an ASTNode and a map between old node names and new node names. All AST_NAME nodes with an "old" name are replaced by a node with the "new" name.

void SBMLImporter::replace_time_with_initial_time ( ASTNode *  pNode,
const CModel pCopasiModel 
) [protected]

If an initial expression uses time, we have to import it as initial time instead. This method takes an AST node and converts all time nodes to object nodes that have the common name of the time as the name.

void SBMLImporter::replaceAmountReferences ( ConverterASTNode pNode,
Model *  pSBMLModel,
double  factor,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap 
) [protected]

This method replaces references to the id of species which have the hasOnlySubstanceUnits flag set with the reference divided by avogadros number. The method tries to determine if there already is a multiplication with avogadros number and removes this multiplication rather than adding a new division.

ConverterASTNode * SBMLImporter::replaceBvars ( const ASTNode *  node,
std::map< std::string, ASTNode * >  bvarMap 
) [protected]

Replaces the variables in a function definition with the actual function parameters that were used when the function was called. The function returns a pointer to the ConverterAST node with the replaced variables.

void SBMLImporter::replaceCallNodeNames ( ASTNode *  pNode) [protected]

Upon import a function object might change its name due to naming conflicts in the function database. So each ASTNode tree has its call node names replaced before it will be processed further.

void SBMLImporter::replaceLog ( ConverterASTNode sourceNode) [protected]

Replaces all occurrences of the log function with two arguments by a division of two separate calls to log.

void SBMLImporter::replaceObjectNames ( ASTNode *  pNode,
const std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap,
bool  initialExpression = false 
) [protected]
void SBMLImporter::replacePowerFunctionNodes ( ASTNode *  node) [protected]

This function replaces the AST_FUNCTION_POWER ASTNodes in a ASTNode tree with the AST_POWER node.

void SBMLImporter::replaceRoot ( ConverterASTNode sourceNode) [protected]

Replaces all occurrences of the root function with two arguments by a call to the power function with the inverse of the first argument.

void SBMLImporter::replaceTimeDependentFunctionCalls ( ASTNode *  root) [protected]

This function replaces function calls to all functions listed in mExplicitelyTimeDependentFunctionDefinitions with the same call but an additional parameter which is the time. This replacement includes all model entities that have a mathematical expression, so depending on the version of SBML, this would include: initial assignments, rules, constraints, kinetic laws and events. The corresponding replacement for the function definitions is done in replaceTimeNodesInFunctionDefinition.

void SBMLImporter::replaceTimeNodeNames ( ASTNode *  pNode) [protected]

The data for a CEvaluationNodeObject needs to have the common name of the model it refers to as its data. Since this model is only known via a pointer in the SBMLImporter at the time of import, all AST_NAME_TIME nodes that are imported need to have their name replaced by the common name of this model.

bool SBMLImporter::replaceTimeNodesInFunctionDefinition ( ASTNode *  root,
std::string  newNodeName 
) [protected]

For function definitions that use the time symbol we have to make this a variable that is passed to the function instead. The function recursively goes through the AST tree rooted in root and changes all time nodes to variable nodes with name newNodeName. If a time node has been found, the function return true, otherwise false is returned.

For function definitions that use the time symbol we have to make this a variable that is passed to the function instead. The function recursively goes through the AST tree rooted in root and changs all time nodes to variable nodes with name newNodeName. Additionally all function calls to functions in mExplicitelyTimeDependentFunctionDefinitions have to be changed to contain the added parameter. If a time node has been found, the function return true, otherwise false is returned.

void SBMLImporter::restoreFunctionDB ( )
C_FLOAT64 SBMLImporter::round ( const C_FLOAT64 &  x) [static, protected]
bool SBMLImporter::sbmlId2CopasiCN ( ASTNode *  pNode,
std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap,
CCopasiParameterGroup pParamGroup 
) [protected]

Replaces the ids of named nodes in an ASTNode tree with the correspondingCopasi Common Names.

void SBMLImporter::separateProductArguments ( const CEvaluationNode pRootNode,
std::vector< const CEvaluationNode * > &  arguments 
) [protected]

This function takes a node and tries to find out whether the tree under this node consists only of multiply operators and object nodes. The arguments to the multiply operators are returned.

void SBMLImporter::setCorrectUsage ( CReaction pCopasiReaction,
const CEvaluationNodeCall pCallNode 
) [protected]
void SBMLImporter::setImportCOPASIMIRIAM ( bool  import)

Sets the flag that determines whether COPASI MIRIAM annotation is imported if it is present.

void SBMLImporter::setImportHandler ( CProcessReport pHandler)
bool SBMLImporter::setInitialValues ( CModel pModel,
const std::map< CCopasiObject *, SBase * > &  copasi2sbmlmap 
) [protected]

Sets the initial values on compartments, metabolites and model values if those initial values have been set in the SBML model. Otherwise the routine checks if a rule or an initial assignment has been set for the entity. If the entity has not been set in any way, an error message is created.

CEvaluationNode * SBMLImporter::variables2objects ( const CEvaluationNode pOrigNode,
const std::map< std::string, std::string > &  replacementMap 
) [protected]

Member Data Documentation

bool SBMLImporter::mDelayFound [protected]
std::map<std::string, std::string> SBMLImporter::mDelayNodeMap [protected]
std::set<std::string> SBMLImporter::mDivisionByCompartmentReactions [protected]
std::set<std::string> SBMLImporter::mFastReactions [protected]
std::map<std::string, std::string> SBMLImporter::mFunctionNameMapping [protected]
unsigned C_INT32 SBMLImporter::mhImportStep [protected]
std::vector<std::string> SBMLImporter::mIgnoredParameterUnits [protected]
std::set<unsigned int> SBMLImporter::mIgnoredSBMLMessages [protected]
unsigned C_INT32 SBMLImporter::mImportStep [protected]
unsigned int SBMLImporter::mLevel [protected]
unsigned int SBMLImporter::mOriginalLevel [protected]
std::set<const Parameter*> SBMLImporter::mPotentialAvogadroNumbers [protected]
std::set<std::string> SBMLImporter::mReactionsWithReplacedLocalParameters [protected]
std::map<const ASTNode*, CChemEqElement* > SBMLImporter::mStoichiometricExpressionMap [protected]
std::map<Species*, Compartment*> SBMLImporter::mSubstanceOnlySpecies [protected]
unsigned C_INT32 SBMLImporter::mTotalSteps [protected]
std::set<std::string> SBMLImporter::mUsedFunctions [protected]
std::set<std::string> SBMLImporter::mUsedSBMLIds [protected]
unsigned int SBMLImporter::mVersion [protected]
std::map<CEvaluationTree*, std::string> SBMLImporter::sbmlIdMap [protected]
std::map<std::string, CMetab*> SBMLImporter::speciesMap [protected]

The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines