本文整理汇总了C++中Species::setInitialAmount方法的典型用法代码示例。如果您正苦于以下问题:C++ Species::setInitialAmount方法的具体用法?C++ Species::setInitialAmount怎么用?C++ Species::setInitialAmount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Species
的用法示例。
在下文中一共展示了Species::setInitialAmount方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Species
END_TEST
START_TEST ( test_Species_L1 )
{
Species* s = new Species(1, 2);
fail_unless (!(s->hasRequiredAttributes()));
s->setId("s");
fail_unless (!(s->hasRequiredAttributes()));
s->setCompartment("c");
fail_unless (!(s->hasRequiredAttributes()));
s->setInitialAmount(2);
fail_unless (s->hasRequiredAttributes());
delete s;
}
示例2: equals
END_TEST
START_TEST (test_WriteL3SBML_Species)
{
const char* expected =
"<species id=\"Ca2\" compartment=\"cell\" initialAmount=\"0.7\""
" substanceUnits=\"mole\" hasOnlySubstanceUnits=\"false\""
" boundaryCondition=\"true\" constant=\"true\"/>";
Species *s = D->createModel()->createSpecies();
s->setId("Ca2");
s->setCompartment("cell");
s->setInitialAmount(0.7);
s->setUnits("mole");
s->setBoundaryCondition(true);
s->setHasOnlySubstanceUnits(false);
s->setConstant(true);
char* sbml = s->toSBML();
fail_unless( equals(expected, sbml) );
safe_free(sbml);
}
示例3: createExampleEnzymaticReaction
//.........这里部分代码省略.........
// Temporary pointer (reused more than once below).
Species *sp;
//---------------------------------------------------------------------------
// (Species1) Creates a Species object ("ES")
//---------------------------------------------------------------------------
// Create the Species objects inside the Model object.
sp = model->createSpecies();
sp->setId("ES");
sp->setName("ES");
// Sets the "compartment" attribute of the Species object to identify the
// compartment in which the Species object is located.
sp->setCompartment(compName);
// Sets the "initialAmount" attribute of the Species object.
//
// In SBML, the units of a Species object's initial quantity are
// determined by two attributes, "substanceUnits" and
// "hasOnlySubstanceUnits", and the "spatialDimensions" attribute
// of the Compartment object ("cytosol") in which the species
// object is located. Here, we are using the default values for
// "substanceUnits" (which is "mole") and "hasOnlySubstanceUnits"
// (which is "false"). The compartment in which the species is
// located uses volume units of liters, so the units of these
// species (when the species appear in numerical formulas in the
// model) will be moles/liters.
//
sp->setInitialAmount(0);
//---------------------------------------------------------------------------
// (Species2) Creates a Species object ("P")
//---------------------------------------------------------------------------
sp = model->createSpecies();
sp->setCompartment(compName);
sp->setId("P");
sp->setName("P");
sp->setInitialAmount(0);
//---------------------------------------------------------------------------
// (Species3) Creates a Species object ("S")
//---------------------------------------------------------------------------
sp = model->createSpecies();
sp->setCompartment(compName);
sp->setId("S");
sp->setName("S");
sp->setInitialAmount(1e-20);
//---------------------------------------------------------------------------
// (Species4) Creates a Species object ("E")
//---------------------------------------------------------------------------
sp = model->createSpecies();
sp->setCompartment(compName);
sp->setId("E");
sp->setName("E");
sp->setInitialAmount(5e-21);
示例4: FbcPkgNamespaces
END_TEST
START_TEST(test_FbcExtension_read_and_validate_chemicals)
{
FbcPkgNamespaces *ns = new FbcPkgNamespaces();
SBMLDocument*doc = new SBMLDocument(ns);
doc->setPackageRequired("fbc", false);
Model* model = doc->createModel();
Compartment* comp = model->createCompartment();
comp->initDefaults();
comp->setId("comp");
comp->setSize(1);
Species *s = model->createSpecies();
s->initDefaults();
s->setId("s1");
s->setCompartment("comp");
s->setInitialAmount(1);
FbcSpeciesPlugin* splugin = static_cast<FbcSpeciesPlugin*>(s->getPlugin("fbc"));
fail_unless(splugin != NULL);
// valid
splugin->setChemicalFormula("H2O");
doc->checkInternalConsistency();
fail_unless(!doc->getErrorLog()->contains(FbcSpeciesFormulaMustBeString));
// valid
doc->getErrorLog()->clearLog();
splugin->setChemicalFormula("HO");
doc->checkInternalConsistency();
fail_unless(!doc->getErrorLog()->contains(FbcSpeciesFormulaMustBeString));
// valid
doc->getErrorLog()->clearLog();
splugin->setChemicalFormula("");
doc->checkInternalConsistency();
fail_unless(!doc->getErrorLog()->contains(FbcSpeciesFormulaMustBeString));
// invalid
doc->getErrorLog()->clearLog();
splugin->setChemicalFormula("hO");
doc->checkInternalConsistency();
fail_unless(doc->getErrorLog()->contains(FbcSpeciesFormulaMustBeString));
// invalid
doc->getErrorLog()->clearLog();
splugin->setChemicalFormula("h1O");
doc->checkInternalConsistency();
fail_unless(doc->getErrorLog()->contains(FbcSpeciesFormulaMustBeString));
// invalid
doc->getErrorLog()->clearLog();
splugin->setChemicalFormula("1hO");
doc->checkInternalConsistency();
fail_unless(doc->getErrorLog()->contains(FbcSpeciesFormulaMustBeString));
// invalid
doc->getErrorLog()->clearLog();
splugin->setChemicalFormula("hO");
doc->checkInternalConsistency();
fail_unless(doc->getErrorLog()->contains(FbcSpeciesFormulaMustBeString));
// invalid
doc->getErrorLog()->clearLog();
splugin->setChemicalFormula("_hO");
doc->checkInternalConsistency();
fail_unless(doc->getErrorLog()->contains(FbcSpeciesFormulaMustBeString));
// invalid
doc->getErrorLog()->clearLog();
splugin->setChemicalFormula("H 2 O");
doc->checkInternalConsistency();
fail_unless(doc->getErrorLog()->contains(FbcSpeciesFormulaMustBeString));
// invalid
doc->getErrorLog()->clearLog();
splugin->setChemicalFormula("H*_)(++2 O");
doc->checkInternalConsistency();
fail_unless(doc->getErrorLog()->contains(FbcSpeciesFormulaMustBeString));
delete doc;
}
示例5: writeSBML
/**
* Save the gene network to an SBML file. If the argument is null, use the network id.
* @param filename URL to the file describing the network to load
* @throws IOException
*/
void GeneNetwork::writeSBML(const char *filename) {
ofstream data_file(filename);
if (!data_file.is_open()) {
std::cerr << "Failed to open file " << filename << std::endl;
exit(1);
}
data_file.close();
::logging::log::emit<Info>() << "Writing file " << filename <<
::logging::log::endl;
SBMLDocument *sbmlDoc = new SBMLDocument(3, 1);
Model *model = sbmlDoc->createModel();
model->setId(id_);
//model.getNotes ().add (comment_); // save network description
int size = getSize();
Compartment *comp = model->createCompartment();
comp->setId("cell");
comp->setSize(1);
std::vector<Species*> all_sp;
Species *sp;
for (int s=0; s < size; s++) { // save gene as species
// species[s] = new Species(nodeIds_.get(s), nodeIds_.get(s));
sp = model->createSpecies();
sp->setCompartment("cell");
sp->setId((nodes_.at(s)).getLabel());
all_sp.push_back(sp);
//species[s].setInitialAmount(?); // maybe save the wild-type steady state?
//model.addSpecies(species[s]);
}
// create the void species
sp = model->createSpecies();
sp->setCompartment("cell");
sp->setId("_void_");
sp->setInitialAmount(0);
sp->setBoundaryCondition(true);
sp->setConstant(true);
all_sp.push_back(sp);
//model.addSpecies(species[size]);
// SET SYNTHESIS AND DEGRADATION REACTIONS FOR EVERY GENE
for (int i=0; i<size; i++) {
//::logging::log::emit<Info>() << ::logging::log::dec << i <<
//::logging::log::endl;
// the ID of gene i
// String currentGeneID = nodeIds_.get(i);
string currentGeneID = (nodes_.at(i)).getLabel();
// The modifiers (regulators) of gene i
std::vector<std::string> inputGenes = (nodes_.at(i)).getInputGenes();
// SYNTHESIS REACTION
std::string reactionId = currentGeneID + "_synthesis";
Reaction *reaction = model->createReaction();
KineticLaw *kineticLaw = reaction->createKineticLaw();
SpeciesReference *spr;
ModifierSpeciesReference *msr;
reaction->setId(reactionId);
reaction->setReversible (false);
spr = reaction->createReactant();
spr->setSpecies(sp->getId());
spr = reaction->createProduct();
spr->setSpecies((all_sp.at(i))->getId());
std::stringstream ss;
ss << inputGenes.size();
//::logging::log::emit<Debug>() << "node = " << nodes_.at(i).getLabel().c_str() << " #inputs = " << ss.str().c_str() << ::logging::log::endl;
for (unsigned int r=0; r<inputGenes.size(); r++) {// set gene modifiers
// reaction.addModifier(species[inputIndexes.get(r)]);
//log.log(Level.INFO, "i = " + size);
msr = reaction->createModifier();
msr->setSpecies((all_sp.at(getIndexOfNode(inputGenes.at(r))))->getId());
}
//std::vector<RegulatoryModule> modules = (nodes_.at(i)).getRegulatoryModules();
//log.log(Level.INFO, "size = " + modules.size());
std::map<std::string, double> *params = new std::map<std::string, double>();
(nodes_.at(i)).compileParameters(*params);
//char buf[256];
//sprintf(buf, "%f", nodes_.at(i).getDelta());
//::logging::log::emit<Info>() << buf << ::logging::log::endl;
//::logging::log::emit<Info>() << ::logging::log::dec << nodes_.at(i).getAlpha().size() <<
// ::logging::log::endl;
Parameter *para;
//.........这里部分代码省略.........
示例6: CreateSBMLModel
void Module::CreateSBMLModel()
{
Model* sbmlmod = m_sbml.createModel();
sbmlmod->setId(m_modulename);
sbmlmod->setName(m_modulename);
sbmlmod->setNotes("<body xmlns=\"http://www.w3.org/1999/xhtml\"><p> Originally created by libAntimony " VERSION_STRING " (using libSBML " LIBSBML_DOTTED_VERSION ") </p></body>");
char cc = g_registry.GetCC();
//User-defined functions
for (size_t uf=0; uf<g_registry.GetNumUserFunctions(); uf++) {
const UserFunction* userfunction = g_registry.GetNthUserFunction(uf);
assert(userfunction != NULL);
FunctionDefinition* fd = sbmlmod->createFunctionDefinition();
fd->setId(userfunction->GetModuleName());
ASTNode* math = parseStringToASTNode(userfunction->ToSBMLString());
fd->setMath(math);
delete math;
}
//Compartments
Compartment* defaultCompartment = sbmlmod->createCompartment();
defaultCompartment->setId(DEFAULTCOMP);
defaultCompartment->setConstant(true);
defaultCompartment->setSize(1);
defaultCompartment->setSBOTerm(410); //The 'implicit compartment'
size_t numcomps = GetNumVariablesOfType(allCompartments);
for (size_t comp=0; comp<numcomps; comp++) {
const Variable* compartment = GetNthVariableOfType(allCompartments, comp);
Compartment* sbmlcomp = sbmlmod->createCompartment();
sbmlcomp->setId(compartment->GetNameDelimitedBy(cc));
if (compartment->GetDisplayName() != "") {
sbmlcomp->setName(compartment->GetDisplayName());
}
sbmlcomp->setConstant(compartment->GetIsConst());
formula_type ftype = compartment->GetFormulaType();
assert (ftype == formulaINITIAL || ftype==formulaASSIGNMENT || ftype==formulaRATE);
if (ftype != formulaINITIAL) {
sbmlcomp->setConstant(false);
}
const Formula* formula = compartment->GetFormula();
if (formula->IsDouble()) {
sbmlcomp->setSize(atof(formula->ToSBMLString().c_str()));
}
SetAssignmentFor(sbmlmod, compartment);
}
//Species
size_t numspecies = GetNumVariablesOfType(allSpecies);
for (size_t spec=0; spec < numspecies; spec++) {
const Variable* species = GetNthVariableOfType(allSpecies, spec);
Species* sbmlspecies = sbmlmod->createSpecies();
sbmlspecies->setId(species->GetNameDelimitedBy(cc));
if (species->GetDisplayName() != "") {
sbmlspecies->setName(species->GetDisplayName());
}
sbmlspecies->setConstant(false); //There's no need to try to distinguish between const and var for species.
if (species->GetIsConst()) {
sbmlspecies->setBoundaryCondition(true);
}
else {
sbmlspecies->setBoundaryCondition(false);
}
const Variable* compartment = species->GetCompartment();
if (compartment == NULL) {
sbmlspecies->setCompartment(defaultCompartment->getId());
}
else {
sbmlspecies->setCompartment(compartment->GetNameDelimitedBy(cc));
}
const Formula* formula = species->GetFormula();
if (formula->IsDouble()) {
sbmlspecies->setInitialConcentration(atof(formula->ToSBMLString().c_str()));
}
else if (formula->IsAmountIn(species->GetCompartment())) {
sbmlspecies->setInitialAmount(formula->ToAmount());
}
SetAssignmentFor(sbmlmod, species);
}
//Formulas
size_t numforms = GetNumVariablesOfType(allFormulas);
for (size_t form=0; form < numforms; form++) {
const Variable* formvar = GetNthVariableOfType(allFormulas, form);
const Formula* formula = formvar->GetFormula();
Parameter* param = sbmlmod->createParameter();
param->setId(formvar->GetNameDelimitedBy(cc));
if (formvar->GetDisplayName() != "") {
param->setName(formvar->GetDisplayName());
}
param->setConstant(formvar->GetIsConst());
if (formula->IsDouble()) {
param->setValue(atof(formula->ToSBMLString().c_str()));
}
SetAssignmentFor(sbmlmod, formvar);
formula_type ftype = formvar->GetFormulaType();
assert (ftype == formulaINITIAL || ftype==formulaASSIGNMENT || ftype==formulaRATE);
if (ftype != formulaINITIAL) {
param->setConstant(false);
}
}
//Reactions
//.........这里部分代码省略.........