示例#1
0
bool CModelAdd::addCompartments(std::string name)
{

  size_t i, imax = mmModel->getCompartments().size();

  for (i = 0; i < imax; ++i)
    {
      const CCompartment* sourceComp = &mmModel->getCompartments()[i];

      if (!sourceComp) return false;

      //create new compartment

      std::string newName = sourceComp->getObjectName() + "_" + name;

      CCompartment* newComp = mpModel->createCompartment(newName, sourceComp->getInitialValue());

      if (!newComp) return false;

      newComp->setStatus(sourceComp->getStatus());

      newComp->setDimensionality(sourceComp->getDimensionality());

      keyMap[sourceComp->getKey()] = newComp->getKey();
      nameMap[sourceComp->getObjectName()] = newName;
    }

  return true;
}
示例#2
0
void CModelExpansion::duplicateCompartment(const CCompartment* source, const std::string & index, const SetOfModelElements & sourceSet, ElementsMap & emap)
{
  //if the source object has already been duplicated: do nothing
  if (emap.exists(source))
    return;

  //try creating the object until we find a name that is not yet used
  CCompartment* newObj;
  std::ostringstream infix;

  do
    {
      std::ostringstream name;
      name << source->getObjectName() << infix.str() << index;
      newObj = mpModel->createCompartment(name.str(), source->getInitialValue());
      infix << "_";
    }
  while (!newObj);

  //add duplicated object to the map
  emap.add(source, newObj);

  //now copy the contents of the object
  newObj->setDimensionality(source->getDimensionality());

  //status
  newObj->setStatus(source->getStatus());

  //expression (for assignment or ODE)
  newObj->setExpression(source->getExpression());
  updateExpression(newObj->getExpressionPtr(), index, sourceSet, emap);

  //initial expression
  newObj->setInitialExpression(source->getInitialExpression());
  updateExpression(newObj->getInitialExpressionPtr(), index, sourceSet, emap);

  newObj->setNotes(source->getNotes());
  newObj->setMiriamAnnotation(source->getMiriamAnnotation(), newObj->getKey(), source->getKey());
}