当前位置: 首页>>代码示例>>C++>>正文


C++ CCompartment类代码示例

本文整理汇总了C++中CCompartment的典型用法代码示例。如果您正苦于以下问题:C++ CCompartment类的具体用法?C++ CCompartment怎么用?C++ CCompartment使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CCompartment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

CMetab * CMetabNameInterface::getMetabolite(const CModel* model,
    const std::string & metabolite,
    const std::string & compartment)
{
  unsigned C_INT32 Index;

  if (compartment != "")
    {
      Index = model->getCompartments().getIndex(compartment);
      if (Index != C_INVALID_INDEX)
        {
          CCompartment *pCompartment = model->getCompartments()[Index];

          Index = pCompartment->getMetabolites().getIndex(metabolite);
          if (Index != C_INVALID_INDEX)
            return pCompartment->getMetabolites()[Index];
        }

      return NULL;
    }

  Index = model->findMetabByName(metabolite);

  if (Index != C_INVALID_INDEX)
    return model->getMetabolites()[Index];

  return NULL;
}
开发者ID:mgaldzic,项目名称:copasi_api,代码行数:28,代码来源:CMetabNameInterface.cpp

示例2: QModelIndex

void InsertCompartmentRowsCommand::redo()
{
  if (firstTime)
    {
      mpCompartmentDM->insertNewCompartmentRow(mPosition, mRows, QModelIndex());
      assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
      CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
      assert(pDataModel != NULL);
      CModel * pModel = pDataModel->getModel();
      assert(pModel != NULL);

      CCompartment *pCompartment = pModel->getCompartments()[mPosition];
      mpCompartmentData->setName(pCompartment->getObjectName());
      mpCompartmentData->setStatus(pCompartment->getStatus());
      mpCompartmentData->setInitialValue(pCompartment->getInitialValue());
      firstTime = false;
    }
  else
    {
      mpCompartmentDM->addCompartmentRow(mpCompartmentData);
    }

  setUndoState(true);
  setAction("Add to list");
  setName(mpCompartmentData->getName());
}
开发者ID:PriKalra,项目名称:COPASI,代码行数:26,代码来源:InsertCompartmentRowsCommand.cpp

示例3: addCompartments

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;
}
开发者ID:jonasfoe,项目名称:COPASI,代码行数:29,代码来源:CModelMerging.cpp

示例4: replaceInModelEntity

void CModelExpansion::replaceInMetab(CMetab* pX, const ElementsMap & emap)
{
  replaceInModelEntity(pX, emap);

  //is the metab in a compartment that needs to be replaced?
  if (emap.exists(pX->getCompartment()))
    {
      //move the metab to the new compartment
      CCompartment* oldComp = const_cast<CCompartment*>(pX->getCompartment());
      CCompartment* newComp = dynamic_cast<CCompartment*>(emap.getDuplicatePtr(pX->getCompartment()));
      bool success = false;

      do
        {
          success = newComp->addMetabolite(pX);

          if (success)
            {
              oldComp->getMetabolites().remove(pX->getObjectName());
              mpModel->setCompileFlag();
              mpModel->initializeMetabolites();
            }
          else
            {
              //rename the metab so that it can be added to the new compartment
              pX->setObjectName(pX->getObjectName() + "_");
              //TODO: check if the renaming actually worked
            }
        }
      while (!success);
    }
}
开发者ID:PriKalra,项目名称:COPASI,代码行数:32,代码来源:CModelExpansion.cpp

示例5: GET_MODEL_OR_RETURN

void CQSpecieDM::deleteSpecieRow(UndoSpeciesData *pSpecieData)
{
  GET_MODEL_OR_RETURN(pModel);

  switchToWidget(CCopasiUndoCommand::SPECIES);

  CMetab * pSpecies = dynamic_cast< CMetab * >(pSpecieData->getObject(pModel));

  if (pSpecies == NULL) return;

  size_t Index = pModel->getMetabolites().getIndex(pSpecies);

  removeRow((int) Index);

  if (!pSpecieData->getCreatedCompartment()) return;

  Index = pModel->getCompartments().getIndex(pSpecieData->getCompartment());

  if (Index == C_INVALID_INDEX) return;

  CCompartment* pComp = &pModel->getCompartments()[Index];

  if (pComp == NULL) return;

  std::string key = pComp->getKey();
  pModel->removeCompartment(Index);
  emit notifyGUI(ListViews::COMPARTMENT, ListViews::DELETE, key);
}
开发者ID:jonasfoe,项目名称:COPASI,代码行数:28,代码来源:CQSpecieDM.cpp

示例6: beginInsertRows

void CQCompartmentDM::insertNewRows(int position, int rows, int column, const QVariant & value)
{
  beginInsertRows(QModelIndex(), position, position + rows - 1);

  for (int row = 0; row < rows; ++row)
    {
      QString name = createNewName(column == COL_NAME_COMPARTMENTS ? value.toString() : "compartment", COL_NAME_COMPARTMENTS);

      CCompartment * pComp = mpDataModel->getModel()->createCompartment(TO_UTF8(name));

      if (pComp == NULL)
        continue;

      if (column == COL_TYPE_COMPARTMENTS)
        {
          pComp->setStatus(CModelEntity::StatusName.toEnum(TO_UTF8(value.toString())));
        }

      if (column == COL_IVOLUME)
        {
          pComp->setInitialValue(value.toDouble());
        }

      CUndoData UndoData(CUndoData::Type::INSERT, pComp);
      ListViews::addUndoMetaData(this, UndoData);
      emit signalNotifyChanges(mpDataModel->recordData(UndoData));
    }

  endInsertRows();
}
开发者ID:copasi,项目名称:COPASI,代码行数:30,代码来源:CQCompartmentDM.cpp

示例7: GET_MODEL_OR

QList <UndoSpeciesData *> CQSpecieDM::insertNewSpecieRow(int position, int rows, const QModelIndex&index, const QVariant& value)
{
  QList <UndoSpeciesData *> result;
  GET_MODEL_OR(pModel, return result);

  bool createdCompartment = false;

  if (pModel->getCompartments().size() == 0)
    {
      CCompartment* pComp = pModel->createCompartment("compartment");
      createdCompartment = true;

      if (mNotify)
        {
          emit notifyGUI(ListViews::COMPARTMENT, ListViews::ADD, pComp->getKey());
        }
    }

  beginInsertRows(QModelIndex(), position, position + rows - 1);

  int column = index.column();

  for (int row = 0; row < rows; ++row)
    {
      QString name = createNewName(index.isValid() && column == COL_NAME_SPECIES ? value.toString() : "species", COL_NAME_SPECIES);

      QString compartment = index.isValid() && column == COL_COMPARTMENT ? value.toString() : "";

      double initial = index.isValid() && column == COL_ICONCENTRATION ? value.toDouble() : 1.0;

      CModelEntity::Status status = index.isValid() && column == COL_TYPE_SPECIES ?
                                    (CModelEntity::Status) mItemToType[value.toInt()] : CModelEntity::REACTIONS;

      mpSpecies =
        pModel->createMetabolite(TO_UTF8(name), TO_UTF8(compartment), initial, status);

      if (mpSpecies == NULL)
        continue;

      if (mNotify)
        {
          emit notifyGUI(ListViews::METABOLITE, ListViews::ADD, mpSpecies->getKey());
        }

      UndoSpeciesData* data = new UndoSpeciesData(mpSpecies);
      data->setCreatedCompartment(row == 0 && createdCompartment);
      result.append(data);
    }

  endInsertRows();
  return result;
}
开发者ID:jonasfoe,项目名称:COPASI,代码行数:52,代码来源:CQSpecieDM.cpp

示例8: createDependentObjects

void UndoDependentData::createDependentObjects(CModel *pModel, QList<UndoCompartmentData *> *pCompartmentData)
{
  if (pModel == NULL || pCompartmentData == NULL || pCompartmentData->empty())
    return;

  //reaction may further has dependencies, these must be taken care of
  QList <UndoCompartmentData *>::const_iterator rs;

  for (rs = pCompartmentData->begin(); rs != pCompartmentData->end(); ++rs)
    {
      UndoCompartmentData * data = *rs;

      CCompartment* pCompartment = data->createObjectIn(pModel);

      if (pCompartment == NULL)
        continue;

      updateGUI(ListViews::COMPARTMENT, ListViews::ADD, pCompartment->getKey());
    }
}
开发者ID:jonasfoe,项目名称:COPASI,代码行数:20,代码来源:UndoDependentData.cpp

示例9: assert

void CQCompartment::deleteCompartment(UndoCompartmentData *pCompartmentData)
{
  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
  assert(pDataModel != NULL);

  CModel * pModel = pDataModel->getModel();
  assert(pModel != NULL);

  CCompartment * pCompartment = pModel->getCompartments()[pCompartmentData->getName()];
  std::string key = pCompartment->getKey();
  pModel->removeCompartment(key);
  mpCompartment = NULL;

#undef DELETE
  protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, key);
  protectedNotify(ListViews::COMPARTMENT, ListViews::DELETE, "");//Refresh all as there may be dependencies.

  mpListView->switchToOtherWidget(111, "");
}
开发者ID:PriKalra,项目名称:COPASI,代码行数:20,代码来源:CQCompartment.cpp

示例10: duplicateCompartment

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());
}
开发者ID:PriKalra,项目名称:COPASI,代码行数:39,代码来源:CModelExpansion.cpp

示例11: removeRows

bool CQCompartmentDM::removeRows(QModelIndexList rows, const QModelIndex& index)
{
  if (rows.isEmpty())
    return false;

  // Build the list of pointers to items to be deleted
  // before actually deleting any item.
  QList <CCompartment *> Compartments;
  QModelIndexList::const_iterator i;

  for (i = rows.begin(); i != rows.end(); ++i)
    if (!isDefaultRow(*i) &&
        &mpCompartments->operator[](i->row()) != NULL)
      {
        Compartments.append(&mpCompartments->operator[](i->row()));
      }

  QList< CCompartment * >::const_iterator j;

  for (j = Compartments.begin(); j != Compartments.end(); ++j)
    {
      CCompartment * pCompartment = *j;

      QMessageBox::StandardButton choice =
        CQMessageBox::confirmDelete(NULL, "compartment",
                                    FROM_UTF8(pCompartment->getObjectName()),
                                    pCompartment);

      if (choice == QMessageBox::Ok)
        {
          removeRows(mpCompartments->getIndex(pCompartment->getObjectName()), 1);
        }
    }

  return true;
}
开发者ID:copasi,项目名称:COPASI,代码行数:36,代码来源:CQCompartmentDM.cpp

示例12: switch


//.........这里部分代码省略.........

      switch (metab->getStatus())
        {
          case CModelEntity::FIXED:
          case CModelEntity::REACTIONS:

            break;

          case CModelEntity::ASSIGNMENT:

            if (!mergeInExpression(toKey, key, metab->getExpressionPtr())) return info;

            break;

          case CModelEntity::ODE:

            if (!mergeInExpression(toKey, key, metab->getExpressionPtr())) return info;

            if (metab->getInitialExpression() != "")
              if (!mergeInExpression(toKey, key, metab->getInitialExpressionPtr())) return info;

            break;

          default:
            return info;
            break;
        }
    }

  imax = mpModel->getCompartments().size();

  for (i = 0; i < imax; ++i)
    {
      CCompartment* comp = &mpModel->getCompartments()[i];

      if (!comp) return info;

      switch (comp ->getStatus())
        {
          case CModelEntity::FIXED:

            break;

          case CModelEntity::ASSIGNMENT:

            if (!mergeInExpression(toKey, key, comp->getExpressionPtr())) return info;

            break;

          case CModelEntity::ODE:

            if (!mergeInExpression(toKey, key, comp->getExpressionPtr())) return info;

            if (comp->getInitialExpression() != "")
              if (!mergeInExpression(toKey, key, comp->getInitialExpressionPtr())) return info;

            break;

          default:
            return info;
            break;
        }
    }

  imax = mpModel->getModelValues().size();
开发者ID:jonasfoe,项目名称:COPASI,代码行数:66,代码来源:CModelMerging.cpp

示例13: assert

void CQEventWidget1::addEvent(UndoEventData *pSData)
{
  assert(CCopasiRootContainer::getDatamodelList()->size() > 0);
  CCopasiDataModel* pDataModel = (*CCopasiRootContainer::getDatamodelList())[0];
  assert(pDataModel != NULL);

  CModel * pModel = pDataModel->getModel();
  assert(pModel != NULL);

  //reinsert the Event
  CEvent *pEvent =  pModel->createEvent(pSData->getName());

  //set the expressions
  pEvent->setTriggerExpression(pSData->getTriggerExpression());
  pEvent->setDelayExpression(pSData->getDelayExpression());
  pEvent->setPriorityExpression(pSData->getPriorityExpression());

  QList <UndoEventAssignmentData *> *assignmentData = pSData->getEventAssignmentData();
  QList <UndoEventAssignmentData *>::const_iterator i;

  for (i = assignmentData->begin(); i != assignmentData->end(); ++i)
    {
      UndoEventAssignmentData * assignData = *i;

      CCopasiObject * pObject = NULL;
      bool speciesExist = false;
      size_t ci;

      for (ci = 0; ci < pModel->getCompartments().size(); ci++)
        {
          CCompartment * pCompartment = pModel->getCompartments()[ci];

          if (pCompartment->getMetabolites().getIndex(assignData->getName()) != C_INVALID_INDEX)
            speciesExist = true;
        }

      if (speciesExist)
        {
          size_t index = pModel->findMetabByName(assignData->getName());
          pObject =  pModel->getMetabolites()[index];
        }
      else if (pModel->getModelValues().getIndex(assignData->getName()) != C_INVALID_INDEX)
        {
          pObject = pModel->getModelValues()[assignData->getName()];
        }
      else if (pModel->getReactions().getIndex(assignData->getName()) != C_INVALID_INDEX)
        {
          pObject = pModel->getReactions()[assignData->getName()];
        }

      const CModelEntity * pEntity = dynamic_cast< const CModelEntity * >(pObject);
      CEventAssignment *eventAssign = new CEventAssignment(pObject->getKey(), pEvent->getObjectParent());
      eventAssign->setExpression(assignData->getExpression());
      eventAssign->getExpressionPtr()->compile();
      pEvent->getAssignments().add(eventAssign);
    }

  std::string key = pEvent->getKey();
  protectedNotify(ListViews::EVENT, ListViews::ADD, key);

  mpListView->switchToOtherWidget(C_INVALID_INDEX, key);
}
开发者ID:PriKalra,项目名称:COPASI,代码行数:62,代码来源:CQEventWidget1.cpp

示例14: setReservedNames

bool CODEExporterC::preprocess(const CModel* copasiModel)

{
  size_t n[3] = {0, 0, 0};
  size_t n_c[3] = {0, 0, 0};
  size_t i, j;
  size_t dependent;

  setReservedNames();

  NameMap[timeKey] = translateTimeVariableName();

  const CCopasiVector< CMetab > & metabs = copasiModel->getMetabolitesX();
  size_t metabs_size = metabs.size();

  for (i = 0; i < metabs_size; i++)
    {
      CMetab * metab = metabs[i];

      //if (metab->isUsed())
      {
        std::string smname;
        std::string name;
        dependent = metab->isDependent();

        smname = setExportName(metab->getStatus(), n, dependent);
        name = setConcentrationName(metab->getStatus(), n_c, dependent);

        NameMap[metab->getKey()] = name;

        std::ostringstream smKey;
        smKey << "sm_" << metab->getKey();

        NameMap[smKey.str()] = smname;

        if ((metab->getStatus() == CModelEntity::REACTIONS && !metab->isDependent()) || metab->getStatus() == CModelEntity::ODE)
          {
            std::ostringstream odeKey;
            odeKey << "ode_" << metab->getKey();

            NameMap[odeKey.str()] = setODEName(smname);
          }
      }
    }

  size_t comps_size = copasiModel->getCompartments().size();
  const CCopasiVector< CCompartment > & comps = copasiModel->getCompartments();

  for (i = 0; i < comps_size; i++)
    {
      CCompartment * comp = comps[i];

      std::string name;
      dependent = 0;

      name = setExportName(comp->getStatus(), n, dependent);
      NameMap[comp->getKey()] = name;

      if (comp->getStatus() == CModelEntity::ODE)
        {
          std::ostringstream odeKey;
          odeKey << "ode_" << comp->getKey();

          NameMap[odeKey.str()] = setODEName(name);
        }
    }

  size_t modvals_size = copasiModel->getModelValues().size();
  const CCopasiVector< CModelValue > & modvals = copasiModel->getModelValues();

  for (i = 0; i < modvals_size; i++)
    {
      CModelValue* modval = modvals[i];
      std::string name = setExportName(modval->getStatus(), n, 0);
      NameMap[modval->getKey()] = name;

      if (modval->getStatus() == CModelEntity::ODE)
        {
          std::ostringstream odeKey;
          odeKey << "ode_" << modval->getKey();
          NameMap[odeKey.str()] = setODEName(name);
        }
    }

  size_t reacs_size = copasiModel->getReactions().size();

  const CCopasiVector< CReaction > & reacs = copasiModel->getReactions();

  std::set<std::string> tmpset;

  for (i = 0; i < reacs_size; ++i)
    {
      size_t params_size;

      params_size = reacs[i]->getParameters().size();

      for (j = 0; j < params_size; ++j)
        {
          if (!reacs[i]->isLocalParameter(reacs[i]->getParameters().getParameter(j)->getObjectName()))
            continue;
//.........这里部分代码省略.........
开发者ID:sachiinb,项目名称:COPASI,代码行数:101,代码来源:CODEExporterC.cpp

示例15: main

int main()
{
  // initialize the backend library
  // since we are not interested in the arguments
  // that are passed to main, we pass 0 and NULL to
  // init
  CCopasiRootContainer::init(0, NULL);
  assert(CCopasiRootContainer::getRoot() != NULL);
  // create a new datamodel
  CCopasiDataModel* pDataModel = CCopasiRootContainer::addDatamodel();
  assert(CCopasiRootContainer::getDatamodelList()->size() == 1);
  // get the model from the datamodel
  CModel* pModel = pDataModel->getModel();
  assert(pModel != NULL);
  // set the units for the model
  // we want seconds as the time unit
  // microliter as the volume units
  // and nanomole as the substance units
  pModel->setTimeUnit(CModel::s);
  pModel->setVolumeUnit(CModel::microl);
  pModel->setQuantityUnit(CModel::nMol);

  // we have to keep a set of all the initial values that are changed during
  // the model building process
  // They are needed after the model has been built to make sure all initial
  // values are set to the correct initial value
  std::set<const CCopasiObject*> changedObjects;

  // create a compartment with the name cell and an initial volume of 5.0
  // microliter
  CCompartment* pCompartment = pModel->createCompartment("cell", 5.0);
  const CCopasiObject* pObject = pCompartment->getValueReference();
  assert(pObject != NULL);
  changedObjects.insert(pObject);
  assert(pCompartment != NULL);
  assert(pModel->getCompartments().size() == 1);
  // create a new metabolite with the name S and an inital
  // concentration of 10 nanomol
  // the metabolite belongs to the compartment we created and is is to be
  // fixed
  CMetab* pS = pModel->createMetabolite("S", pCompartment->getObjectName(), 10.0, CMetab::FIXED);
  pObject = pS->getInitialConcentrationReference();
  assert(pObject != NULL);
  changedObjects.insert(pObject);
  assert(pCompartment != NULL);
  assert(pS != NULL);
  assert(pModel->getMetabolites().size() == 1);
  // create a second metabolite called P with an initial
  // concentration of 0. This metabolite is to be changed by reactions
  CMetab* pP = pModel->createMetabolite("P", pCompartment->getObjectName(), 0.0, CMetab::REACTIONS);
  assert(pP != NULL);
  pObject = pP->getInitialConcentrationReference();
  assert(pObject != NULL);
  changedObjects.insert(pObject);
  assert(pModel->getMetabolites().size() == 2);
  // now we create a reaction
  CReaction* pReaction = pModel->createReaction("reaction");
  assert(pReaction != NULL);
  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);
//.........这里部分代码省略.........
开发者ID:ShuoLearner,项目名称:COPASI,代码行数:101,代码来源:example7.cpp


注:本文中的CCompartment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。