本文整理汇总了C++中CCopasiObjectName类的典型用法代码示例。如果您正苦于以下问题:C++ CCopasiObjectName类的具体用法?C++ CCopasiObjectName怎么用?C++ CCopasiObjectName使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CCopasiObjectName类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CPPUNIT_ASSERT
void test000047::test_delay()
{
CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING));
CModel* pModel = pDataModel->getModel();
CPPUNIT_ASSERT(pModel != NULL);
CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CUnit::mMol);
CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CUnit::ml);
CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CUnit::s);
CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
const CCompartment* pCompartment = pModel->getCompartments()[0];
CPPUNIT_ASSERT(pCompartment != NULL);
CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
const CMetab* pB = pModel->getMetabolites()[1];
CPPUNIT_ASSERT(pB != NULL);
CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::FIXED);
CMetab* pA = pModel->getMetabolites()[0];
CPPUNIT_ASSERT(pA != NULL);
CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::ASSIGNMENT);
const CExpression* pExpr = pA->getExpressionPtr();
CPPUNIT_ASSERT(pExpr != NULL);
const CEvaluationNode* pNode = pExpr->getRoot();
CPPUNIT_ASSERT(pNode != NULL);
const CEvaluationNodeDelay* pDelayNode = dynamic_cast<const CEvaluationNodeDelay*>(pNode);
CPPUNIT_ASSERT(pDelayNode != NULL);
const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pDelayNode->getChild());
CPPUNIT_ASSERT(pObjectNode != NULL);
CCopasiObjectName objectCN = pObjectNode->getObjectCN();
CPPUNIT_ASSERT(!objectCN.empty());
std::vector<CCopasiContainer*> listOfContainers;
listOfContainers.push_back(pModel);
const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
CPPUNIT_ASSERT(pObject != NULL);
CPPUNIT_ASSERT(pObject->isReference() == true);
CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Concentration"));
CPPUNIT_ASSERT(pObject->getObjectParent() == pB);
const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pObjectNode->getSibling());
CPPUNIT_ASSERT(pNumberNode != NULL);
CPPUNIT_ASSERT(((CEvaluationNodeNumber::SubType)CEvaluationNode::subType(pNumberNode->getType())) == CEvaluationNodeNumber::DOUBLE);
CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 0.5) / 0.5) < 1e-3);
CPPUNIT_ASSERT(pNumberNode->getSibling() == NULL);
CPPUNIT_ASSERT(pModel->getModelValues().size() == 1);
const CModelValue* pModelValue = pModel->getModelValues()[0];
CPPUNIT_ASSERT(pModelValue != NULL);
CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::FIXED);
CPPUNIT_ASSERT(pModel->getReactions().size() == 0);
//CPPUNIT_ASSERT(CCopasiMessage::size() == 2);
CCopasiMessage message = CCopasiMessage::getLastMessage();
CPPUNIT_ASSERT(message.getType() == CCopasiMessage::WARNING);
std::string s = message.getText();
CPPUNIT_ASSERT(!s.empty());
CPPUNIT_ASSERT(s.find(std::string("COPASI does not support time delays. Calculations on this model will most likely lead to unusable results.")) != std::string::npos);
// right now, we don't care about the last message since it is a units
// warning from libSBML
}
示例2: CPPUNIT_ASSERT
void test000052::test_bug988()
{
CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING));
CModel* pModel = pDataModel->getModel();
CPPUNIT_ASSERT(pModel != NULL);
CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CModel::mMol);
CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CModel::ml);
CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CModel::s);
CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
const CCompartment* pCompartment = pModel->getCompartments()[0];
CPPUNIT_ASSERT(pCompartment != NULL);
CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
CPPUNIT_ASSERT(pModel->getMetabolites().size() == 1);
CMetab* pA = pModel->getMetabolites()[0];
CPPUNIT_ASSERT(pA != NULL);
CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::ASSIGNMENT);
const CExpression* pExpr = pA->getExpressionPtr();
// check the expression
const CEvaluationNode* pNode = pExpr->getRoot();
CPPUNIT_ASSERT(pNode != NULL);
const CEvaluationNodeChoice* pChoiceNode = dynamic_cast<const CEvaluationNodeChoice*>(pNode);
CPPUNIT_ASSERT(pChoiceNode != NULL);
pNode = dynamic_cast<const CEvaluationNode*>(pChoiceNode->getChild());
CPPUNIT_ASSERT(pNode != NULL);
const CEvaluationNodeLogical* pLogicalNode = dynamic_cast<const CEvaluationNodeLogical*>(pNode);
CPPUNIT_ASSERT(pLogicalNode != NULL);
CPPUNIT_ASSERT(((CEvaluationNodeLogical::SubType)CEvaluationNode::subType(pLogicalNode->getType())) == CEvaluationNodeLogical::LT);
const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pLogicalNode->getChild());
CPPUNIT_ASSERT(pObjectNode != NULL);
CCopasiObjectName objectCN = pObjectNode->getObjectCN();
CPPUNIT_ASSERT(!objectCN.empty());
std::vector<CCopasiContainer*> listOfContainers;
listOfContainers.push_back(pModel);
const CCopasiObject* pObject = pCOPASIDATAMODEL->ObjectFromName(listOfContainers, objectCN);
CPPUNIT_ASSERT(pObject != NULL);
CPPUNIT_ASSERT(pObject->isReference() == true);
CPPUNIT_ASSERT(pObject->getObjectName() == std::string("Time"));
CPPUNIT_ASSERT(pObject->getObjectParent() == pModel);
const CEvaluationNodeNumber* pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pObjectNode->getSibling());
CPPUNIT_ASSERT(pNumberNode != NULL);
CPPUNIT_ASSERT(((CEvaluationNodeNumber::SubType)CEvaluationNode::subType(pNumberNode->getType())) == CEvaluationNodeNumber::DOUBLE);
CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 5.0) / 5.0) < 1e-3);
pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pLogicalNode->getSibling());
CPPUNIT_ASSERT(pNumberNode != NULL);
CPPUNIT_ASSERT(((CEvaluationNodeNumber::SubType)CEvaluationNode::subType(pNumberNode->getType())) == CEvaluationNodeNumber::DOUBLE);
CPPUNIT_ASSERT(pNumberNode->getValue() < 1e-3);
pNumberNode = dynamic_cast<const CEvaluationNodeNumber*>(pNumberNode->getSibling());
CPPUNIT_ASSERT(pNumberNode != NULL);
CPPUNIT_ASSERT(((CEvaluationNodeNumber::SubType)CEvaluationNode::subType(pNumberNode->getType())) == CEvaluationNodeNumber::DOUBLE);
CPPUNIT_ASSERT(fabs((pNumberNode->getValue() - 10.0) / 10.0) < 1e-3);
CPPUNIT_ASSERT(pModel->getModelValues().size() == 0);
CPPUNIT_ASSERT(pModel->getReactions().size() == 0);
}
示例3: getInitialExpression
// virtual
void CModelParameterReactionParameter::compile()
{
CModelParameter::compile();
mGlobalQuantityCN = std::string();
std::string Infix = getInitialExpression();
if (Infix.length() > 2)
{
// Infix: <CN,Reference=InitialValue> or <CN,Reference=Value>
CCopasiObjectName Tmp = Infix.substr(1, Infix.length() - 2);
std::string Separator = "";
for (; Tmp != ""; Tmp = Tmp.getRemainder())
{
CCopasiObjectName Primary = Tmp.getPrimary();
if (Primary.getObjectType() == "Reference")
{
break;
}
mGlobalQuantityCN += Separator + Primary;
Separator = ",";
}
setSimulationType(CModelEntity::ASSIGNMENT);
}
else
{
setSimulationType(CModelEntity::FIXED);
}
mpGlobalQuantity = this->getSet()->getModelParameter(mGlobalQuantityCN);
if (mpGlobalQuantity != NULL)
{
mValue = mpGlobalQuantity->getValue(ParticleNumbers);
}
std::vector< CCopasiContainer * > ListOfContainer;
CModel * pModel = getModel();
ListOfContainer.push_back(pModel);
mpReaction = static_cast< CReaction * >(pModel->getObjectDataModel()->ObjectFromName(ListOfContainer, mpParent->getCN()));
}
示例4: nameFromCN
// static
std::string CModelParameter::nameFromCN(const CCopasiObjectName & cn)
{
CCopasiObjectName Primary = cn.getPrimary();
CCopasiObjectName Remainder = cn.getRemainder();
while (Remainder != "")
{
Primary = Remainder.getPrimary();
Remainder = Remainder.getRemainder();
}
std::string Name = Primary.getElementName(0);
if (Name != "")
{
return Name;
}
return Primary.getObjectName();
}
示例5: setCN
// virtual
void CModelParameterSpecies::setCN(const CCopasiObjectName & cn)
{
CModelParameter::setCN(cn);
// Determine the CN for the compartment.
// "CN=Root,Model=New Model,Vector=Compartments[compartment],Vector=Metabolites[A]"
CCopasiObjectName Tmp = mCN;
std::string Separator = "";
for (; Tmp != ""; Tmp = Tmp.getRemainder())
{
CCopasiObjectName Primary = Tmp.getPrimary();
mCompartmentCN += Separator + Primary;
Separator = ",";
if (Primary.getObjectType() == "Vector" &&
Primary.getObjectName() == "Compartments")
{
break;
}
}
}
示例6: CPPUNIT_ASSERT
void test000027::test_hasOnlySubstanceUnits()
{
CCopasiDataModel* pDataModel = pCOPASIDATAMODEL;
CPPUNIT_ASSERT(pDataModel->importSBMLFromString(MODEL_STRING));
CModel* pModel = pDataModel->getModel();
CPPUNIT_ASSERT(pModel != NULL);
CPPUNIT_ASSERT(pModel->getQuantityUnitEnum() == CUnit::mMol);
CPPUNIT_ASSERT(pModel->getVolumeUnitEnum() == CUnit::ml);
CPPUNIT_ASSERT(pModel->getTimeUnitEnum() == CUnit::s);
CPPUNIT_ASSERT(pModel->getCompartments().size() == 1);
const CCompartment* pCompartment = pModel->getCompartments()[0];
CPPUNIT_ASSERT(pCompartment != NULL);
CPPUNIT_ASSERT(pCompartment->getStatus() == CModelEntity::FIXED);
CPPUNIT_ASSERT(pModel->getMetabolites().size() == 2);
CMetab* pA = pModel->getMetabolites()[0];
CPPUNIT_ASSERT(pA != NULL);
CPPUNIT_ASSERT(pA->getStatus() == CModelEntity::REACTIONS);
const CMetab* pB = pModel->getMetabolites()[1];
CPPUNIT_ASSERT(pB != NULL);
CPPUNIT_ASSERT(pB->getStatus() == CModelEntity::REACTIONS);
CPPUNIT_ASSERT(pModel->getModelValues().size() == 2);
// check the kinetic law
const CModelValue* pFactor = pModel->getModelValues()[1];
CPPUNIT_ASSERT(pFactor != NULL);
CPPUNIT_ASSERT(pFactor->getStatus() == CModelEntity::FIXED);
CPPUNIT_ASSERT(fabs((pFactor->getInitialValue() - pModel->getQuantity2NumberFactor()) / pModel->getQuantity2NumberFactor()) < 1e-3);
const CModelValue* pModelValue = pModel->getModelValues()[0];
CPPUNIT_ASSERT(pModelValue != NULL);
CPPUNIT_ASSERT(pModelValue->getStatus() == CModelEntity::ASSIGNMENT);
const CExpression* pExpr = pModelValue->getExpressionPtr();
// check the expression
const CEvaluationNode* pNode = pExpr->getRoot();
CPPUNIT_ASSERT(pNode != NULL);
const CEvaluationNodeObject* pObjectNode = dynamic_cast<const CEvaluationNodeObject*>(pNode);
CPPUNIT_ASSERT(pObjectNode != NULL);
CCopasiObjectName objectCN = pObjectNode->getObjectCN();
CPPUNIT_ASSERT(!objectCN.empty());
CObjectInterface::ContainerList listOfContainers;
listOfContainers.push_back(pModel);
const CCopasiObject* pObject = CObjectInterface::DataModel(pCOPASIDATAMODEL->getObjectFromCN(listOfContainers, objectCN));
CPPUNIT_ASSERT(pObject != NULL);
CPPUNIT_ASSERT(pObject->isReference() == true);
CPPUNIT_ASSERT(pObject->getObjectName() == std::string("ParticleNumber"));
CPPUNIT_ASSERT(pObject->getObjectParent() == pA);
CPPUNIT_ASSERT(pModel->getReactions().size() == 2);
const CReaction* pReaction1 = pModel->getReactions()[0];
CPPUNIT_ASSERT(pReaction1 != NULL);
CPPUNIT_ASSERT(pReaction1->isReversible() == false);
const CFunction* pKineticFunction = pReaction1->getFunction();
CPPUNIT_ASSERT(pKineticFunction != NULL);
const CMassAction* pMassAction = dynamic_cast<const CMassAction*>(pKineticFunction);
//FTB: this no longer is recognized as mass action reaction because of the
// special case of a species with hOSU
CPPUNIT_ASSERT(pMassAction == NULL);
const CChemEq* pChemEq = &pReaction1->getChemEq();
CPPUNIT_ASSERT(pChemEq != NULL);
CPPUNIT_ASSERT(pChemEq->getCompartmentNumber() == 1);
CPPUNIT_ASSERT(pChemEq->getSubstrates().size() == 1);
const CChemEqElement* pElement = pChemEq->getSubstrates()[0];
CPPUNIT_ASSERT(pElement != NULL);
CPPUNIT_ASSERT(fabs(pElement->getMultiplicity() - 1.0) < 1e-3);
CPPUNIT_ASSERT(pElement->getMetabolite() == pA);
CPPUNIT_ASSERT(pChemEq->getProducts().size() == 0);
CPPUNIT_ASSERT(pChemEq->getModifiers().size() == 0);
const CReaction* pReaction2 = pModel->getReactions()[1];
CPPUNIT_ASSERT(pReaction2 != NULL);
CPPUNIT_ASSERT(pReaction2->isReversible() == false);
// check the kinetic law
pKineticFunction = pReaction2->getFunction();
CPPUNIT_ASSERT(pKineticFunction != NULL);
CPPUNIT_ASSERT(pKineticFunction->getObjectName() == std::string("Henri-Michaelis-Menten (irreversible)"));
// check the function parameters one should be the reference to the substrate
pChemEq = &pReaction2->getChemEq();
CPPUNIT_ASSERT(pChemEq != NULL);
CPPUNIT_ASSERT(pChemEq->getCompartmentNumber() == 1);
CPPUNIT_ASSERT(pChemEq->getSubstrates().size() == 1);
pElement = pChemEq->getSubstrates()[0];
CPPUNIT_ASSERT(pElement != NULL);
CPPUNIT_ASSERT(fabs(pElement->getMultiplicity() - 1.0) < 1e-3);
CPPUNIT_ASSERT(pElement->getMetabolite() == pA);
CPPUNIT_ASSERT(pChemEq->getProducts().size() == 1);
pElement = pChemEq->getProducts()[0];
CPPUNIT_ASSERT(pElement != NULL);
CPPUNIT_ASSERT(fabs(pElement->getMultiplicity() - 1.0) < 1e-3);
CPPUNIT_ASSERT(pElement->getMetabolite() == pB);
CPPUNIT_ASSERT(pChemEq->getModifiers().size() == 0);
const std::vector<std::vector<std::string> > parameterMappings = pReaction2->getParameterMappings();
CPPUNIT_ASSERT(parameterMappings.size() == 3);
CPPUNIT_ASSERT(parameterMappings[0].size() == 1);
const std::string parameterKey = parameterMappings[0][0];
CPPUNIT_ASSERT(parameterKey == pA->getKey());
}
示例7: updateExpression
void CModelExpansion::updateExpression(CExpression* exp, const std::string & index, const SetOfModelElements & sourceSet, ElementsMap & emap)
{
if (!exp)
return;
//we loop through the complete expression
std::vector< CEvaluationNode * >::const_iterator it = exp->getNodeList().begin();
std::vector< CEvaluationNode * >::const_iterator end = exp->getNodeList().end();
for (; it != end; ++it)
{
CEvaluationNodeObject * node = dynamic_cast<CEvaluationNodeObject*>(*it);
if (!node)
continue;
//std::cout << node->getData() << std::endl;
const CCopasiObject * pObj = dynamic_cast<const CCopasiObject*>(node->getObjectInterfacePtr());
std::string refname = "";
std::string reftype = "";
//when copying between models, pObj=NULL. This is because the expression could not be compiled
//if it points to an object in a different model.
//We try to fix this now:
if (!pObj && mpSourceModel)
{
CCopasiObjectName cn = node->getObjectCN();
while (cn.getPrimary().getObjectType() != "Model" && !cn.empty())
{
cn = cn.getRemainder();
}
pObj = dynamic_cast<const CCopasiObject*>(mpSourceModel->getObject(cn));
}
if (pObj)
{
refname = pObj->getObjectName();
reftype = pObj->getObjectType();
pObj = pObj->getObjectParent();
}
//is the object one that is/should be copied?
if (sourceSet.contains(pObj))
{
if (!emap.exists(pObj))
{
//we have to create the duplicate
std::cout << "!!!" << std::endl;
if (dynamic_cast<const CCompartment*>(pObj))
duplicateCompartment(dynamic_cast<const CCompartment*>(pObj), index, sourceSet, emap);
if (dynamic_cast<const CMetab*>(pObj))
duplicateMetab(dynamic_cast<const CMetab*>(pObj), index, sourceSet, emap);
if (dynamic_cast<const CModelValue*>(pObj))
duplicateGlobalQuantity(dynamic_cast<const CModelValue*>(pObj), index, sourceSet, emap);
if (dynamic_cast<const CReaction*>(pObj))
duplicateReaction(dynamic_cast<const CReaction*>(pObj), index, sourceSet, emap);
}
//find the duplicate
const CCopasiObject* duplicate = emap.getDuplicatePtr(pObj);
if (duplicate)
{
//get the reference object
const CCopasiObject* pRef = dynamic_cast<const CCopasiObject*>(duplicate->getObject(reftype + "=" + refname));
//update the node
if (pRef)
node->setData("<" + pRef->getCN() + ">");
//std::cout << node->getData() << std::endl;
}
}
}
}