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


C++ SpeciesReference类代码示例

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


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

示例1: writeMathML

/*
 * Subclasses should override this method to write out their contained
 * SBML objects as XML elements.  Be sure to call your parents
 * implementation of this method as well.
 */
void
SpeciesReference::writeElements (XMLOutputStream& stream) const
{
  if ( mNotes != NULL ) stream << *mNotes;
  SpeciesReference * sr = const_cast <SpeciesReference *> (this);
  sr->syncAnnotation();
  if ( mAnnotation != NULL ) stream << *mAnnotation;

  if (getLevel() == 2)
  {
    if (mStoichiometryMath || mDenominator != 1)
    {
      if (mStoichiometryMath != NULL) 
      {
        mStoichiometryMath->write(stream);
      }
      else
      {
        ASTNode node;
        node.setValue(static_cast<long>(mStoichiometry), mDenominator);

        stream.startElement("stoichiometryMath");
        writeMathML(&node, stream);
        stream.endElement("stoichiometryMath");
      }
    }
  }

  //
  // (EXTENSION)
  //
  SBase::writeExtensionElements(stream);

}
开发者ID:sbmlteam,项目名称:python-libsbml,代码行数:39,代码来源:SpeciesReference.cpp

示例2: SpeciesReference

// #######################################################################
SpeciesReference* SBML_formatter::species2SpeciesReference(const Species* species, const Reaction* rxn, string addToSpeciesID){
  string value = species->getId(); 
  
  SpeciesReference* SR = new SpeciesReference(species->getLevel(), species->getVersion());
  
  value = species->getId();

  if (addToSpeciesID != ""){
    // sets the species name, as 
    value.append(addToSpeciesID);
  }
  
  SR->setSpecies(value);
  
  SR->setStoichiometry(1);
  SR->setId((value.append("_ref_")).append(dtostr(unique)));
  value.clear();
  value.append(species->getId());
  SR->setName((value.append("_in_rxn_")).append(rxn->getId()));
  // unique is a static variable which allows anything that needs a modelwide unique value to get
  // one;
  unique++;

  return SR;
}
开发者ID:alexholehouse,项目名称:SBMLIntegrator,代码行数:26,代码来源:sbml_formatter.cpp

示例3: START_TEST

END_TEST


START_TEST ( test_Reaction_parent_NULL )
{
    SBMLDocument *d = new SBMLDocument();
    Model *m = d->createModel();
    Reaction *c = m->createReaction();
    SpeciesReference *sr = c->createReactant();
    KineticLaw *kl = c->createKineticLaw();

    fail_unless(c->getAncestorOfType(SBML_MODEL) == m);
    fail_unless (c->getSBMLDocument() == d);
    fail_unless(sr->getAncestorOfType(SBML_REACTION) == c);
    fail_unless(kl->getAncestorOfType(SBML_REACTION) == c);

    Reaction *c1 = c->clone();
    delete d;

    fail_unless(c1->getAncestorOfType(SBML_MODEL) == NULL);
    fail_unless(c1->getParentSBMLObject() == NULL);
    fail_unless (c1->getSBMLDocument() == NULL);

    SpeciesReference *sr1 = c1->getReactant(0);
    fail_unless(sr1->getAncestorOfType(SBML_MODEL) == NULL);
    fail_unless(sr1->getAncestorOfType(SBML_REACTION) == c1);
    fail_unless (sr1->getSBMLDocument() == NULL);

    fail_unless(c1->getKineticLaw()->getAncestorOfType(SBML_MODEL) == NULL);
    fail_unless(c1->getKineticLaw()->getAncestorOfType(SBML_REACTION) == c1);
    fail_unless (c1->getKineticLaw()->getSBMLDocument() == NULL);


    delete c1;
}
开发者ID:alexholehouse,项目名称:SBMLIntegrator,代码行数:35,代码来源:TestSBMLParentObject.cpp

示例4: getParentSBMLObject

int StoichiometryMath::removeFromParentAndDelete()
{
  SBase* parent = getParentSBMLObject();
  if (parent==NULL) return LIBSBML_OPERATION_FAILED;
  SpeciesReference* parentSR = static_cast<SpeciesReference*>(parent);
  if (parentSR == NULL) return LIBSBML_OPERATION_FAILED;
  return parentSR->unsetStoichiometryMath();
}
开发者ID:0u812,项目名称:libsbml.js.frozen,代码行数:8,代码来源:StoichiometryMath.cpp

示例5: variesIn

bool variesIn(string id, ListOfSpeciesReferences* srs,  const map<string, vector<double> >& results)
{
  if (variesIn(id, results)) return true;
  for (unsigned long sr=0; sr<srs->size(); sr++) {
    SpeciesReference* spref = static_cast<SpeciesReference*>(srs->get(sr));
    if (spref->getSpecies() == id) return true;
  }
  return false;
}
开发者ID:sbmlteam,项目名称:test-suite,代码行数:9,代码来源:testSuiteUtil.cpp

示例6: START_TEST

END_TEST

START_TEST ( test_SpeciesReference )
{
  SpeciesReference* sr = new SpeciesReference(2, 4);
  
  fail_unless (sr->hasRequiredElements());

  delete sr;
}
开发者ID:kirichoi,项目名称:roadrunner,代码行数:10,代码来源:TestRequiredElements.cpp

示例7: START_TEST

END_TEST

START_TEST ( test_SpeciesReference )
{
  SpeciesReference* sr = new SpeciesReference(2, 4);
  
  fail_unless (!(sr->hasRequiredAttributes()));

  sr->setSpecies("sr");

  fail_unless (sr->hasRequiredAttributes());

  delete sr;
}
开发者ID:alexholehouse,项目名称:SBMLIntegrator,代码行数:14,代码来源:TestRequiredAttributes.cpp

示例8: createParameterAsRateRule

void
createParameterAsRateRule(Model &m, SpeciesReference &sr, Rule &rr, 
                          unsigned int idCount)
{
  char newid[15];
  std::string id;

  // create parameter as variable of rate rule 
  // and use stoichiometryMath to point to this
  sprintf(newid, "parameterId_%u", idCount);
  id.assign(newid);

  Parameter *p = m.createParameter();
  p->setId(id);
  p->setConstant(false);

  rr.setVariable(id);
  
  StoichiometryMath *sm = sr.createStoichiometryMath();
  if (sm != NULL)
  {
    ASTNode *ast = SBML_parseFormula(id.c_str());
    sm->setMath(ast);
  }
}
开发者ID:TotteKarlsson,项目名称:roadrunner,代码行数:25,代码来源:SBMLConvert.cpp

示例9: SimpleSpeciesReference

/*
 * Copy constructor. Creates a copy of this SpeciesReference.
 */
SpeciesReference::SpeciesReference (const SpeciesReference& orig) :
   SimpleSpeciesReference( orig                )
 , mStoichiometryMath    ( NULL                   )
{
  if (&orig == NULL)
  {
    throw SBMLConstructorException("Null argument to copy constructor");
  }
  else
  {
    mStoichiometry = orig.mStoichiometry ;
    mDenominator = orig.mDenominator   ;
    mConstant = orig.mConstant;
    mIsSetConstant = orig.mIsSetConstant;
    mIsSetStoichiometry = orig.mIsSetStoichiometry;
    mExplicitlySetStoichiometry = orig.mExplicitlySetStoichiometry;
    mExplicitlySetDenominator = orig.mExplicitlySetDenominator;

    if (orig.mStoichiometryMath != NULL)
    {
      mStoichiometryMath = new StoichiometryMath(*orig.getStoichiometryMath());
    mStoichiometryMath->connectToParent(this);
    }
  }
}
开发者ID:0u812,项目名称:roadrunner-backup,代码行数:28,代码来源:SpeciesReference.cpp

示例10: START_TEST

END_TEST


START_TEST (test_WriteL3SBML_SpeciesReference)
{
  const char* expected = "<speciesReference species=\"s\""
    " stoichiometry=\"3\" constant=\"true\"/>";


  SpeciesReference *sr = D->createModel()->createReaction()->createReactant();
  sr->setSpecies("s");
  sr->setStoichiometry(3);
  sr->setConstant(true);

  char* sbml = sr->toSBML();
  fail_unless( equals(expected, sbml) );
  safe_free(sbml);
}
开发者ID:sn248,项目名称:Rcppsbml,代码行数:18,代码来源:TestWriteL3SBML.cpp

示例11: fixMissingStoich

std::string fixMissingStoich(const std::string sbml) {
    SBMLDocument *doc = NULL;

    try {
        doc =  readSBMLFromString (sbml.c_str());

        Model *m = doc->getModel();

        for (int j = 0; j<m->getNumReactions(); ++j) {
            Reaction* r = m->getReaction(j);
            if (!r)
                throw std::runtime_error("No reaction");

            // check stoich defined on reactants / products
            for (int k = 0; k<r->getNumReactants(); ++k) {
                SpeciesReference* s = r->getReactant(k);
                if (!isStoichDefined(s))
                    if (s->setStoichiometry(1.) != LIBSBML_OPERATION_SUCCESS)
                        throw std::runtime_error("Unable to set stoichiometry");
            }

            for (int k = 0; k<r->getNumProducts(); ++k) {
                SpeciesReference* s = r->getProduct(k);
                if (!isStoichDefined(s))
                    if (s->setStoichiometry(1.) != LIBSBML_OPERATION_SUCCESS)
                        throw std::runtime_error("Unable to set stoichiometry");
            }

            // modifiers have no stoichiometry
        }

    } catch(...) {
        delete doc;
        throw;
    }

    SBMLWriter writer;

    char* sbml_cstr = writer.writeSBMLToString(doc);
    delete doc;
    std::string result(sbml_cstr);
    free(sbml_cstr);
    return result;
}
开发者ID:sys-bio,项目名称:roadrunner,代码行数:44,代码来源:SBMLValidator.cpp

示例12: useStoichMath

void
useStoichMath(Model & m, SpeciesReference &sr, bool isRule)
{
  // use stoichiometryMath instead
  StoichiometryMath *sm = sr.createStoichiometryMath();
  if (sm != NULL)
  {
    if (isRule == true)
    {
      sm->setMath(m.getRule(sr.getId())->getMath());
      m.removeRule(sr.getId());
    }
    else
    {
      sm->setMath(m.getInitialAssignment(sr.getId())->getMath());
      m.removeInitialAssignment(sr.getId());
    }
  }
}
开发者ID:TotteKarlsson,项目名称:roadrunner,代码行数:19,代码来源:SBMLConvert.cpp

示例13: SimpleSpeciesReference

/*
 * Copy constructor. Creates a copy of this SpeciesReference.
 */
SpeciesReference::SpeciesReference (const SpeciesReference& orig)
 : SimpleSpeciesReference( orig                )
 , mStoichiometry        ( orig.mStoichiometry )
 , mDenominator          ( orig.mDenominator   )
 , mStoichiometryMath    ( NULL                )
 , mConstant             ( orig.mConstant)
 , mIsSetConstant        ( orig.mIsSetConstant)
 , mIsSetStoichiometry   ( orig.mIsSetStoichiometry)
 , mExplicitlySetStoichiometry ( orig.mExplicitlySetStoichiometry)
 , mExplicitlySetDenominator   ( orig.mExplicitlySetDenominator)
{
  if (orig.mStoichiometryMath != NULL)
  {
    mStoichiometryMath = new StoichiometryMath(*orig.getStoichiometryMath());
    mStoichiometryMath->connectToParent(this);
  }
}
开发者ID:sbmlteam,项目名称:python-libsbml,代码行数:20,代码来源:SpeciesReference.cpp

示例14: createNoValueStoichMath

void
createNoValueStoichMath(Model & m, SpeciesReference & sr, unsigned int idCount)
{
  char newid[15];
  std::string id;

  // no stoichiometry and no id to set the stoichiometry
  // replace with stoichiometryMath using a parameter with no value

  sprintf(newid, "parameterId_%u", idCount);
  id.assign(newid);

  Parameter *p = m.createParameter();
  p->setId(id);
  p->setConstant(false);

  StoichiometryMath *sm = sr.createStoichiometryMath();
  if (sm != NULL)
  {
    ASTNode *ast = SBML_parseFormula(id.c_str());
    sm->setMath(ast);
  }
}
开发者ID:TotteKarlsson,项目名称:roadrunner,代码行数:23,代码来源:SBMLConvert.cpp

示例15: dealWithAssigningL1Stoichiometry

void dealWithAssigningL1Stoichiometry(Model & m, bool l2)
{
  //char newid[15];
  std::string id;

  for (unsigned int i = 0; i < m.getNumReactions(); i++)
  {
    Reaction *r = m.getReaction(i);
    unsigned int j;

    for (j = 0; j < r->getNumReactants(); j++)
    {
      SpeciesReference *sr = r->getReactant(j);
      // we do not get here unless the stoichiometryMath is an integer
      // or a rational 
      if (l2 == true && sr->isSetStoichiometryMath() == true)
      {
        const ASTNode* ast = sr->getStoichiometryMath()->getMath();
        if (ast->isInteger())
        {
          int num = ast->getInteger();
          sr->setStoichiometry(num);
          sr->setDenominator(1);
        }
        else
        {
          int num = ast->getNumerator();
          int denom = ast->getDenominator();
          sr->setStoichiometry(num);
          sr->setDenominator(denom);
        }
        sr->unsetStoichiometryMath();
      }
      else
      {
        sr->setStoichiometry(sr->getStoichiometry());
        sr->setDenominator(1);
      }
    }
    for (j = 0; j < r->getNumProducts(); j++)
    {
      SpeciesReference *sr = r->getProduct(j);
      // we do not get here unless the stoichiometryMath is an integer
      // or a rational 
      if (l2 == true && sr->isSetStoichiometryMath() == true)
      {
        const ASTNode* ast = sr->getStoichiometryMath()->getMath();
        if (ast->isInteger())
        {
          int num = ast->getInteger();
          sr->setStoichiometry(num);
          sr->setDenominator(1);
        }
        else
        {
          int num = ast->getNumerator();
          int denom = ast->getDenominator();
          sr->setStoichiometry(num);
          sr->setDenominator(denom);
        }
        sr->unsetStoichiometryMath();
      }
      else
      {
        sr->setStoichiometry(sr->getStoichiometry());
        sr->setDenominator(1);
      }
    }
  }
}
开发者ID:TotteKarlsson,项目名称:roadrunner,代码行数:70,代码来源:SBMLConvert.cpp


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