本文整理汇总了C++中Species::setCharge方法的典型用法代码示例。如果您正苦于以下问题:C++ Species::setCharge方法的具体用法?C++ Species::setCharge怎么用?C++ Species::setCharge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Species
的用法示例。
在下文中一共展示了Species::setCharge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: prop
int
FbcToCobraConverter::convert()
{
int result = LIBSBML_OPERATION_FAILED;
if (mDocument == NULL)
{
return LIBSBML_INVALID_OBJECT;
}
Model* mModel = mDocument->getModel();
if (mModel == NULL)
{
return LIBSBML_INVALID_OBJECT;
}
FbcModelPlugin *plugin =
static_cast<FbcModelPlugin*>(mDocument->getModel()->getPlugin("fbc"));
// if we have don't have a fbc model we cannot do the conversion
if (plugin == NULL || mDocument->getLevel() != 3)
{
return LIBSBML_OPERATION_FAILED;
}
// collect information
Model* model = mDocument->getModel();
map<const string, int> chargeMap;
map<const string, string> formulaMap;
for (unsigned int i = 0; i < model->getNumSpecies(); ++i)
{
Species* current = model->getSpecies(i);
const string& currentId = current->getId();
FbcSpeciesPlugin *splugin = static_cast<FbcSpeciesPlugin*>(current->getPlugin("fbc"));
if (splugin == NULL)
continue;
if (splugin->isSetCharge())
{
chargeMap[currentId] = splugin->getCharge();
}
if (splugin->isSetChemicalFormula())
{
formulaMap[currentId] = splugin->getChemicalFormula();
}
}
// create KineticLaw
for (unsigned int i = 0; i < model->getNumReactions(); ++i)
{
Reaction* reaction = model->getReaction(i);
if (reaction == NULL)
continue;
createKineticLawForReaction(reaction);
}
// update kinetic law from bounds
for (unsigned int i = 0; i < plugin->getNumFluxBounds(); ++i)
{
FluxBound *current = plugin->getFluxBound(i);
if (current == NULL)
continue;
Reaction* reaction = model->getReaction(current->getReaction());
if (reaction == NULL)
continue;
updateKineticLawFromBound(reaction, current);
}
setObjectiveCoefficient(plugin, model);
// disable package
mDocument->enablePackage("http://www.sbml.org/sbml/level3/version1/fbc/version1", "fbc",false);
// convert model to L2V1 (as L2V2 is the last model that had charge)
mDocument->setConversionValidators(AllChecksON & UnitsCheckOFF);
ConversionProperties prop(new SBMLNamespaces(2,1));
prop.addOption("strict", false, "should validity be preserved");
prop.addOption("ignorePackages", true, "convert even if packages are used");
prop.addOption("setLevelAndVersion", true, "convert the document to the given level and version");
int conversionResult = mDocument->convert(prop);
if (conversionResult != LIBSBML_OPERATION_SUCCESS)
return conversionResult;
// set charge on species
for (unsigned int i = 0; i < model->getNumSpecies(); ++i)
{
Species* current = model->getSpecies(i);
const string currentId = current->getId();
int charge = chargeMap[currentId];
if (charge != 0)
current->setCharge(charge);
const string formula = formulaMap[currentId];
//.........这里部分代码省略.........