本文整理汇总了C++中CCopasiDataModel::exportSBML方法的典型用法代码示例。如果您正苦于以下问题:C++ CCopasiDataModel::exportSBML方法的具体用法?C++ CCopasiDataModel::exportSBML怎么用?C++ CCopasiDataModel::exportSBML使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCopasiDataModel
的用法示例。
在下文中一共展示了CCopasiDataModel::exportSBML方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
assert(pModel->getReactions().size() == 1);
// reaction converts S to P
// we can set these on the chemical equation of the reaction
CChemEq* pChemEq = &pReaction->getChemEq();
// S is a substrate with stoichiometry 1
pChemEq->addMetabolite(pS->getKey(), 1.0, CChemEq::SUBSTRATE);
// P is a product with stoichiometry 1
pChemEq->addMetabolite(pP->getKey(), 1.0, CChemEq::PRODUCT);
assert(pChemEq->getSubstrates().size() == 1);
assert(pChemEq->getProducts().size() == 1);
// this reaction is to be irreversible
pReaction->setReversible(false);
assert(pReaction->isReversible() == false);
CModelValue* pMV = pModel->createModelValue("K", 42.0);
// set the status to FIXED
pMV->setStatus(CModelValue::FIXED);
assert(pMV != NULL);
pObject = pMV->getInitialValueReference();
assert(pObject != NULL);
changedObjects.insert(pObject);
assert(pModel->getModelValues().size() == 1);
// now we ned to set a kinetic law on the reaction
// for this we create a user defined function
CFunctionDB* pFunDB = CCopasiRootContainer::getFunctionList();
assert(pFunDB != NULL);
CKinFunction* pFunction = new CKinFunction("My Rate Law");
pFunDB->add(pFunction, true);
CFunction* pRateLaw = dynamic_cast<CFunction*>(pFunDB->findFunction("My Rate Law"));
assert(pRateLaw != NULL);
// now we create the formula for the function and set it on the function
std::string formula = "(1-0.4/(EXPONENTIALE^(temp-37)))*0.00001448471257*1.4^(temp-37)*substrate";
bool result = pFunction->setInfix(formula);
assert(result == true);
// make the function irreversible
pFunction->setReversible(TriFalse);
// the formula string should have been parsed now
// and COPASI should have determined that the formula string contained 2 parameters (temp and substrate)
CFunctionParameters& variables = pFunction->getVariables();
// per default the usage of those parameters will be set to VARIABLE
size_t index = pFunction->getVariableIndex("temp");
assert(index != C_INVALID_INDEX);
CFunctionParameter* pParam = variables[index];
assert(pParam->getUsage() == CFunctionParameter::VARIABLE);
// This is correct for temp, but substrate should get the usage SUBSTRATE in order
// for us to use the function with the reaction created above
// So we need to set the usage for "substrate" manually
index = pFunction->getVariableIndex("substrate");
assert(index != C_INVALID_INDEX);
pParam = variables[index];
pParam->setUsage(CFunctionParameter::SUBSTRATE);
// set the rate law for the reaction
pReaction->setFunction(pFunction);
assert(pReaction->getFunction() != NULL);
// COPASI also needs to know what object it has to assocuiate with the individual function parameters
// In our case we need to tell COPASI that substrate is to be replaced by the substrate of the reaction
// and temp is to be replaced by the global parameter K
pReaction->setParameterMapping("substrate", pS->getKey());
pReaction->setParameterMapping("temp", pMV->getKey());
// finally compile the model
// compile needs to be done before updating all initial values for
// the model with the refresh sequence
pModel->compileIfNecessary(NULL);
// now that we are done building the model, we have to make sure all
// initial values are updated according to their dependencies
std::vector<Refresh*> refreshes = pModel->buildInitialRefreshSequence(changedObjects);
std::vector<Refresh*>::iterator it2 = refreshes.begin(), endit2 = refreshes.end();
while (it2 != endit2)
{
// call each refresh
(**it2)();
++it2;
}
// save the model to a COPASI file
// we save to a file named example1.cps, we don't want a progress report
// and we want to overwrite any existing file with the same name
// Default tasks are automatically generated and will always appear in cps
// file unless they are explicitley deleted before saving.
pDataModel->saveModel("example7.cps", NULL, true);
// export the model to an SBML file
// we save to a file named example1.xml, we want to overwrite any
// existing file with the same name and we want SBML L2V3
pDataModel->exportSBML("example7.xml", true, 2, 3);
// destroy the root container once we are done
CCopasiRootContainer::destroy();
}