本文整理汇总了C++中CCopasiDataModel::exportSBMLToString方法的典型用法代码示例。如果您正苦于以下问题:C++ CCopasiDataModel::exportSBMLToString方法的具体用法?C++ CCopasiDataModel::exportSBMLToString怎么用?C++ CCopasiDataModel::exportSBMLToString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CCopasiDataModel
的用法示例。
在下文中一共展示了CCopasiDataModel::exportSBMLToString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
//.........这里部分代码省略.........
CPPUNIT_ASSERT(pRoot != NULL);
pReaction = pModel->getReactions()[4];
CPPUNIT_ASSERT(pReaction != NULL);
CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
CPPUNIT_ASSERT(pReaction->isReversible() == true);
// check the kinetic law
CPPUNIT_ASSERT(pReaction->getParameters().size() == 2);
pFunction = pReaction->getFunction();
CPPUNIT_ASSERT(pFunction != NULL);
CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::UserDefined);
CPPUNIT_ASSERT(pFunction->getObjectName() == "Function for reaction5");
pRoot = pFunction->getRoot();
CPPUNIT_ASSERT(pRoot != NULL);
pReaction = pModel->getReactions()[5];
CPPUNIT_ASSERT(pReaction != NULL);
CPPUNIT_ASSERT(pReaction->getChemEq().getSubstrates().size() == 1);
CPPUNIT_ASSERT(pReaction->getChemEq().getProducts().size() == 1);
CPPUNIT_ASSERT(pReaction->getChemEq().getModifiers().size() == 0);
CPPUNIT_ASSERT(pReaction->isReversible() == true);
// check the kinetic law
CPPUNIT_ASSERT(pReaction->getParameters().size() == 3);
pFunction = pReaction->getFunction();
CPPUNIT_ASSERT(pFunction != NULL);
CPPUNIT_ASSERT(pFunction->getType() == CEvaluationTree::UserDefined);
CPPUNIT_ASSERT(pFunction->getObjectName() == "Function for reaction6");
pRoot = pFunction->getRoot();
CPPUNIT_ASSERT(pRoot != NULL);
// export to SBML
std::string s = pDataModel->exportSBMLToString(NULL, 1, 2);
CPPUNIT_ASSERT(s.empty() == false);
// due to the bugfix for Bug 1086 and some issues with libsbml and the current exporter,
// we now no longer have a L1 document in the datamodel if there was an SBMLDocument prior
// to exporting to L1 already.
// To test now, we have to call newModel on the datamodel to delete the old sbml document,
// and reimport the exported model
// This will also lead to a Level 2 Version 1 model since we convert all Level 1 model to
// Level 2 Version 1 on import, but we can at least test if the export worked.
pCOPASIDATAMODEL->newModel(NULL, true);
CPPUNIT_ASSERT(pCOPASIDATAMODEL->importSBMLFromString(s));
// check the sbml model
const SBMLDocument* pDocument = pCOPASIDATAMODEL->getCurrentSBMLDocument();
CPPUNIT_ASSERT(pDocument != NULL);
CPPUNIT_ASSERT(pDocument->getLevel() == 2);
CPPUNIT_ASSERT(pDocument->getVersion() == 1);
const Model* pSBMLModel = pDocument->getModel();
CPPUNIT_ASSERT(pSBMLModel != NULL);
CPPUNIT_ASSERT(pSBMLModel->getListOfFunctionDefinitions()->size() == 0);
CPPUNIT_ASSERT(pSBMLModel->getListOfCompartments()->size() == 1);
CPPUNIT_ASSERT(pSBMLModel->getListOfSpecies()->size() == 6);
CPPUNIT_ASSERT(pSBMLModel->getListOfParameters()->size() == 3);
CPPUNIT_ASSERT(pSBMLModel->getListOfRules()->size() == 6);
CPPUNIT_ASSERT(pSBMLModel->getListOfReactions()->size() == 6);
std::map<std::string, const Rule*> ruleMap;
unsigned int i, iMax = pSBMLModel->getListOfRules()->size();
const Rule* pRule = NULL;
for (i = 0; i < iMax; ++i)
{
pRule = pSBMLModel->getRule(i);
示例2: iss
void test000009::test_references_to_species()
{
// load the CPS file
// export to SBML
// check the resulting SBML model
CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
std::istringstream iss(test000009::MODEL_STRING);
CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
CPPUNIT_ASSERT(pDocument != NULL);
Model* pModel = pDocument->getModel();
CPPUNIT_ASSERT(pModel != NULL);
// assert that there is only one compartment and
// assert the compartment is constant
CPPUNIT_ASSERT(pModel->getNumCompartments() == 1);
Compartment* pCompartment = pModel->getCompartment(0);
CPPUNIT_ASSERT(pCompartment->getConstant() == false);
CPPUNIT_ASSERT(pModel->getNumSpecies() == 2);
Species* pSpecies = pModel->getSpecies(1);
CPPUNIT_ASSERT(pSpecies->getHasOnlySubstanceUnits() == true);
pSpecies = pModel->getSpecies(0);
std::string idSpeciesA = pSpecies->getId();
CPPUNIT_ASSERT(pSpecies->getHasOnlySubstanceUnits() == true);
CPPUNIT_ASSERT(pModel->getNumRules() == 2);
// there are two rules, one is the rule for the compartment
AssignmentRule* pRule = dynamic_cast<AssignmentRule*>(pModel->getRule(0));
CPPUNIT_ASSERT(pRule != NULL);
CPPUNIT_ASSERT(pModel->getNumParameters() == 1);
Parameter* pParameter = pModel->getParameter(0);
CPPUNIT_ASSERT(pParameter != NULL);
if (pRule->getVariable() != pParameter->getId())
{
pRule = dynamic_cast<AssignmentRule*>(pModel->getRule(1));
}
CPPUNIT_ASSERT(pRule->getVariable() == pParameter->getId());
const ASTNode* pMath = pRule->getMath();
CPPUNIT_ASSERT(pMath != NULL);
// the expression should be the species divided by the volume
CPPUNIT_ASSERT(pMath->getType() == AST_DIVIDE);
CPPUNIT_ASSERT(pMath->getChild(0) != NULL);
CPPUNIT_ASSERT(pMath->getChild(0)->getType() == AST_NAME);
CPPUNIT_ASSERT(pMath->getChild(0)->getName() == pSpecies->getId());
CPPUNIT_ASSERT(pMath->getChild(1) != NULL);
CPPUNIT_ASSERT(pMath->getChild(1)->getType() == AST_NAME);
CPPUNIT_ASSERT(pMath->getChild(1)->getName() == pCompartment->getId());
CPPUNIT_ASSERT(pModel->getNumReactions() == 2);
Reaction* pReaction = pModel->getReaction(0);
// make sure this is reaction A ->
CPPUNIT_ASSERT(pReaction != NULL);
CPPUNIT_ASSERT(pReaction->getNumReactants() == 1);
CPPUNIT_ASSERT(pReaction->getNumProducts() == 0);
// check if all references in the kinetic law are unmodified
// math element must be a multiplication of the mass action term by
// the compartment volume
// the mass action term is a multiplication of the parameter node by
// the species node
// the code that multiplies the reaction by the compartments volume
// recognizes the division of the species by the compartment and cancels
// those two
CPPUNIT_ASSERT(pReaction->isSetKineticLaw() == true);
KineticLaw* pLaw = pReaction->getKineticLaw();
CPPUNIT_ASSERT(pLaw != NULL);
CPPUNIT_ASSERT(pLaw->isSetMath() == true);
pMath = pLaw->getMath();
CPPUNIT_ASSERT(pMath->getType() == AST_TIMES);
CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
CPPUNIT_ASSERT(pMath->getChild(0)->getType() == AST_NAME);
CPPUNIT_ASSERT(pMath->getChild(0)->getName() == std::string("k1"));
CPPUNIT_ASSERT(pMath->getChild(1) != NULL);
CPPUNIT_ASSERT(pMath->getChild(1)->getType() == AST_NAME);
CPPUNIT_ASSERT(pMath->getChild(1)->getName() == idSpeciesA);
pReaction = pModel->getReaction(1);
// make sure this is reaction A -> S
CPPUNIT_ASSERT(pReaction != NULL);
CPPUNIT_ASSERT(pReaction->getNumReactants() == 1);
CPPUNIT_ASSERT(pReaction->getNumProducts() == 1);
// check if all references in the kinetic law are unmodified
// math element must be a multiplication of the compartments volume with
// a function call with three arguments
// the first argument is the reference to the species
CPPUNIT_ASSERT(pReaction->isSetKineticLaw() == true);
pLaw = pReaction->getKineticLaw();
CPPUNIT_ASSERT(pLaw != NULL);
CPPUNIT_ASSERT(pLaw->isSetMath() == true);
pMath = pLaw->getMath();
CPPUNIT_ASSERT(pMath->getType() == AST_TIMES);
CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
CPPUNIT_ASSERT(pMath->getChild(0)->getType() == AST_NAME);
CPPUNIT_ASSERT(pMath->getChild(0)->getName() == pCompartment->getId());
pMath = pMath->getChild(1);
CPPUNIT_ASSERT(pMath != NULL);
CPPUNIT_ASSERT(pMath->getType() == AST_FUNCTION);
CPPUNIT_ASSERT(pMath->getNumChildren() == 3);
pMath = pMath->getChild(0);
CPPUNIT_ASSERT(pMath != NULL);
//.........这里部分代码省略.........
示例3: iss
void test000054::test_bug1002()
{
// load the CPS file
// export to SBML
// check the resulting SBML model
CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
std::istringstream iss(test000054::MODEL_STRING);
CPPUNIT_ASSERT(load_cps_model_from_stream(iss, *pDataModel) == true);
CPPUNIT_ASSERT(pDataModel->getModel() != NULL);
CPPUNIT_ASSERT(pDataModel->exportSBMLToString(NULL, 2, 3).empty() == false);
SBMLDocument* pDocument = pDataModel->getCurrentSBMLDocument();
CPPUNIT_ASSERT(pDocument != NULL);
Model* pSBMLModel = pDocument->getModel();
CPPUNIT_ASSERT(pSBMLModel != NULL);
CPPUNIT_ASSERT(pSBMLModel->getNumCompartments() == 0);
CPPUNIT_ASSERT(pSBMLModel->getNumSpecies() == 0);
CPPUNIT_ASSERT(pSBMLModel->getNumReactions() == 0);
CPPUNIT_ASSERT(pSBMLModel->getNumInitialAssignments() == 0);
CPPUNIT_ASSERT(pSBMLModel->getNumParameters() == 5);
const Parameter* pParameter1 = pSBMLModel->getParameter(0);
CPPUNIT_ASSERT(pParameter1 != NULL);
CPPUNIT_ASSERT(pParameter1->getConstant() == false);
const Parameter* pParameter2 = pSBMLModel->getParameter(1);
CPPUNIT_ASSERT(pParameter2 != NULL);
CPPUNIT_ASSERT(pParameter2->getConstant() == false);
const Parameter* pParameter3 = pSBMLModel->getParameter(2);
CPPUNIT_ASSERT(pParameter3 != NULL);
CPPUNIT_ASSERT(pParameter3->getConstant() == false);
const Parameter* pParameter4 = pSBMLModel->getParameter(3);
CPPUNIT_ASSERT(pParameter4 != NULL);
CPPUNIT_ASSERT(pParameter4->getConstant() == false);
const Parameter* pParameter5 = pSBMLModel->getParameter(4);
CPPUNIT_ASSERT(pParameter5 != NULL);
CPPUNIT_ASSERT(pParameter5->getConstant() == false);
CPPUNIT_ASSERT(pSBMLModel->getNumRules() == 5);
const Rule* pRule = pSBMLModel->getRule(0);
CPPUNIT_ASSERT(pRule != NULL);
CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
const AssignmentRule* pARule = dynamic_cast<const AssignmentRule*>(pRule);
CPPUNIT_ASSERT(pARule != NULL);
CPPUNIT_ASSERT(pARule->getVariable() == pParameter4->getId());
CPPUNIT_ASSERT(pARule->isSetMath() == true);
const ASTNode* pMath = pARule->getMath();
CPPUNIT_ASSERT(pMath != NULL);
CPPUNIT_ASSERT(pMath->getType() == AST_PLUS);
CPPUNIT_ASSERT(pMath->getNumChildren() == 2);
const ASTNode* pChild1 = pMath->getChild(0);
CPPUNIT_ASSERT(pChild1 != NULL);
CPPUNIT_ASSERT(pChild1->getType() == AST_REAL);
CPPUNIT_ASSERT(fabs((pChild1->getReal() - 2.0) / 2.0) < 1e-15);
const ASTNode* pChild2 = pMath->getChild(1);
CPPUNIT_ASSERT(pChild2 != NULL);
CPPUNIT_ASSERT(pChild2->getType() == AST_REAL);
CPPUNIT_ASSERT(fabs((pChild2->getReal() - 4.0) / 4.0) < 1e-15);
pRule = pSBMLModel->getRule(1);
CPPUNIT_ASSERT(pRule != NULL);
CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
pARule = dynamic_cast<const AssignmentRule*>(pRule);
CPPUNIT_ASSERT(pARule != NULL);
CPPUNIT_ASSERT(pARule->getVariable() == pParameter1->getId());
CPPUNIT_ASSERT(pARule->isSetMath() == true);
pMath = pARule->getMath();
CPPUNIT_ASSERT(pMath != NULL);
CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
CPPUNIT_ASSERT(pMath->getName() == pParameter4->getId());
CPPUNIT_ASSERT(pMath->getNumChildren() == 0);
pRule = pSBMLModel->getRule(2);
CPPUNIT_ASSERT(pRule != NULL);
CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
pARule = dynamic_cast<const AssignmentRule*>(pRule);
CPPUNIT_ASSERT(pARule != NULL);
CPPUNIT_ASSERT(pARule->getVariable() == pParameter3->getId());
CPPUNIT_ASSERT(pARule->isSetMath() == true);
pMath = pARule->getMath();
CPPUNIT_ASSERT(pMath != NULL);
CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
CPPUNIT_ASSERT(pMath->getName() == pParameter1->getId());
CPPUNIT_ASSERT(pMath->getNumChildren() == 0);
pRule = pSBMLModel->getRule(3);
CPPUNIT_ASSERT(pRule != NULL);
CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
pARule = dynamic_cast<const AssignmentRule*>(pRule);
CPPUNIT_ASSERT(pARule != NULL);
CPPUNIT_ASSERT(pARule->getVariable() == pParameter5->getId());
CPPUNIT_ASSERT(pARule->isSetMath() == true);
pMath = pARule->getMath();
CPPUNIT_ASSERT(pMath != NULL);
CPPUNIT_ASSERT(pMath->getType() == AST_NAME);
CPPUNIT_ASSERT(pMath->getName() == pParameter3->getId());
CPPUNIT_ASSERT(pMath->getNumChildren() == 0);
pRule = pSBMLModel->getRule(4);
CPPUNIT_ASSERT(pRule != NULL);
CPPUNIT_ASSERT(pRule->getTypeCode() == SBML_ASSIGNMENT_RULE);
pARule = dynamic_cast<const AssignmentRule*>(pRule);
CPPUNIT_ASSERT(pARule != NULL);
//.........这里部分代码省略.........