本文整理汇总了C++中Species::setCompartment方法的典型用法代码示例。如果您正苦于以下问题:C++ Species::setCompartment方法的具体用法?C++ Species::setCompartment怎么用?C++ Species::setCompartment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Species
的用法示例。
在下文中一共展示了Species::setCompartment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: equals
END_TEST
START_TEST (test_WriteL3SBML_Species_conversionFactor)
{
const char* expected =
"<species id=\"Ca2\" compartment=\"cell\""
" hasOnlySubstanceUnits=\"false\""
" boundaryCondition=\"true\" constant=\"true\""
" conversionFactor=\"p\"/>";
const char* expected1 =
"<species id=\"Ca2\" compartment=\"cell\""
" hasOnlySubstanceUnits=\"false\""
" boundaryCondition=\"true\" constant=\"true\"/>";
Species *s = D->createModel()->createSpecies();
s->setId("Ca2");
s->setCompartment("cell");
s->setBoundaryCondition(true);
s->setHasOnlySubstanceUnits(false);
s->setConstant(true);
s->setConversionFactor("p");
char* sbml = s->toSBML();
fail_unless( equals(expected, sbml) );
safe_free(sbml);
s->unsetConversionFactor();
sbml = s->toSBML();
fail_unless( equals(expected1, sbml) );
safe_free(sbml);
}
示例2: Species
END_TEST
START_TEST ( test_Species )
{
Species* s = new Species(2, 4);
fail_unless (!(s->hasRequiredAttributes()));
s->setId("s");
fail_unless (!(s->hasRequiredAttributes()));
s->setCompartment("c");
fail_unless (s->hasRequiredAttributes());
delete s;
}
示例3: Species
END_TEST
START_TEST ( test_Species_parent_add )
{
Species *ia = new Species(2, 4);
ia->setId("s");
ia->setCompartment("c");
Model *m = new Model(2, 4);
m->addSpecies(ia);
delete ia;
ListOf *lo = m->getListOfSpecies();
fail_unless(lo == m->getSpecies(0)->getParentSBMLObject());
fail_unless(m == lo->getParentSBMLObject());
}
示例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: main
LIBSBML_CPP_NAMESPACE_USE
int main(int argc,char** argv)
{
DynPkgNamespaces sbmlns;
// create the document
SBMLDocument *document = new SBMLDocument(&sbmlns);
document->setPackageRequired("dyn", true);
// create the Model
Model* model=document->createModel();
model->setId("singleCell");
// create the Compartment
Compartment* compartment = model->createCompartment();
compartment->setId("Extracellular");
compartment->setConstant(true);
compartment->setSize(8000000);
compartment->setSpatialDimensions(3.0);
compartment = model->createCompartment();
compartment->setId("PlasmaMembrane");
compartment->setConstant(true);
compartment->setSize(314);
compartment->setSpatialDimensions(2.0);
compartment = model->createCompartment();
compartment->setId("Cytosol");
compartment->setConstant(true);
compartment->setSize(523);
compartment->setSpatialDimensions(3.0);
// create the Species
Species* species = model->createSpecies();
species->setId("C_EC");
species->setCompartment("Extracellular");
species->setBoundaryCondition(false);
species->setConstant(false);
species->setHasOnlySubstanceUnits(false);
species = model->createSpecies();
species->setId("RTR_M");
species->setCompartment("PlasmaMembrane");
species->setBoundaryCondition(false);
species->setConstant(false);
species->setHasOnlySubstanceUnits(false);
species = model->createSpecies();
species->setId("RCC_M");
species->setCompartment("PlasmaMembrane");
species->setBoundaryCondition(false);
species->setConstant(false);
species->setHasOnlySubstanceUnits(false);
species = model->createSpecies();
species->setId("A_C");
species->setCompartment("Cytosol");
species->setBoundaryCondition(false);
species->setConstant(false);
species->setHasOnlySubstanceUnits(false);
species = model->createSpecies();
species->setId("AA_C");
species->setCompartment("Cytosol");
species->setBoundaryCondition(false);
species->setConstant(false);
species->setHasOnlySubstanceUnits(false);
species = model->createSpecies();
species->setId("T");
species->setCompartment("Cytosol");
species->setBoundaryCondition(false);
species->setConstant(false);
species->setInitialConcentration(10);
species->setHasOnlySubstanceUnits(false);
species = model->createSpecies();
species->setId("S");
species->setCompartment("Cytosol");
species->setBoundaryCondition(false);
species->setConstant(false);
species->setInitialConcentration(5);
species->setHasOnlySubstanceUnits(false);
// create the Reactions
Reaction* reaction = model->createReaction();
reaction->setId("r1");
reaction->setReversible(true);
reaction->setFast(false);
reaction->setCompartment("Extracellular");
SpeciesReference* reactant = reaction->createReactant();
reactant->setSpecies("RTR_M");
//.........这里部分代码省略.........
示例6: main
int main(int argc,char** argv)
{
int retval = 0;
SBMLNamespaces sbmlns(3,1,"comp",1);
// create the document
SBMLDocument *document = new SBMLDocument(&sbmlns);
//Define the external model definitions
CompSBMLDocumentPlugin* compdoc
= static_cast<CompSBMLDocumentPlugin*>(document->getPlugin("comp"));
compdoc->setRequired(true);
ExternalModelDefinition* extmod = compdoc->createExternalModelDefinition();
extmod->setId("ExtMod1");
extmod->setSource("enzyme_model.xml");
extmod->setModelRef("enzyme");
// create the main Model
Model* model=document->createModel();
// Set the submodels
CompModelPlugin* mplugin = static_cast<CompModelPlugin*>(model->getPlugin("comp"));
Submodel* submod1 = mplugin->createSubmodel();
submod1->setId("A");
submod1->setModelRef("ExtMod1");
Submodel* submod2 = mplugin->createSubmodel();
submod2->setId("B");
submod2->setModelRef("ExtMod1");
// create a replacement compartment
Compartment* comp=model->createCompartment();
comp->setSpatialDimensions((unsigned int)3);
comp->setConstant(true);
comp->setId("comp");
comp->setSize(1L);
//Tell the model that this compartment replaces both of the inside ones.
CompSBasePlugin* compartplug = static_cast<CompSBasePlugin*>(comp->getPlugin("comp"));
ReplacedElement re;
re.setIdRef("comp");
re.setSubmodelRef("A");
compartplug->addReplacedElement(&re);
re.setSubmodelRef("B");
compartplug->addReplacedElement(&re);
// create a replacement species
Species* spec = model->createSpecies();
spec->setCompartment("comp");
spec->setHasOnlySubstanceUnits(false);
spec->setConstant(false);
spec->setBoundaryCondition(false);
spec->setId("S");
//Tell the model that this species replaces both of the inside ones.
CompSBasePlugin* spp = static_cast<CompSBasePlugin*>(spec->getPlugin("comp"));
re.setIdRef("S");
re.setSubmodelRef("A");
spp->addReplacedElement(&re);
re.setSubmodelRef("B");
spp->addReplacedElement(&re);
writeSBMLToFile(document,"eg-import-external.xml");
writeSBMLToFile(document,"spec_example2.xml");
delete document;
document = readSBMLFromFile("spec_example2.xml");
if (document == NULL)
{
cout << "Error reading back in file." << endl;
retval = -1;
}
else
{
document->setConsistencyChecks(LIBSBML_CAT_UNITS_CONSISTENCY, false);
document->checkConsistency();
if (document->getErrorLog()->getNumFailsWithSeverity(2) > 0
|| document->getErrorLog()->getNumFailsWithSeverity(3) > 0)
{
stringstream errorstream;
document->printErrors(errorstream);
cout << "Errors encoutered when round-tripping SBML file: \n"
<< errorstream.str() << endl;
retval = -1;
}
writeSBMLToFile(document, "spec_example2_rt.xml");
delete document;
}
#ifdef WIN32
if (retval != 0)
{
cout << "(Press any key to exit.)" << endl;
_getch();
}
#endif
return retval;
}
示例7: main
LIBSBML_CPP_NAMESPACE_USE
int main(int argc,char** argv){
//
// Creates an SBMLNamespaces object with the given SBML level, version
// package name, package version.
//
// (NOTE) By defualt, the name of package (i.e. "groups") will be used
// if the arugment for the prefix is missing or empty. Thus the argument
// for the prefix can be added as follows:
//
// SBMLNamespaces sbmlns(3,1,"groups",1,"GROUP");
//
SBMLNamespaces sbmlns(3,1,"groups",1);
//
// (NOTES) The above code creating an SBMLNamespaces object can be replaced
// with one of the following other styles.
//
// (1) Creates an SBMLNamespace object with a SBML core namespace and then
// adds a groups package namespace to the object.
//
// SBMLNamespaces sbmlns(3,1);
// sbmlns.addPkgNamespace("groups",1);
//
// OR
//
// SBMLNamespaces sbmlns(3,1);
// sbmlns.addNamespace(GroupsExtension::XmlnsL3V1V1,"groups");
//
// (2) Creates a GroupsPkgNamespaces object (SBMLNamespace derived class for
// groups package. The class is basically used for createing an SBase derived
// objects defined in the groups package) with the given SBML level, version,
// and package version
//
// GroupsPkgNamespaces sbmlns(3,1,1);
//
// create the document
SBMLDocument *document = new SBMLDocument(&sbmlns);
// create the Model
Model* model=document->createModel();
// create the Compartment
Compartment* compartment = model->createCompartment();
compartment->setId("cytosol");
compartment->setConstant(true);
compartment=model->createCompartment();
compartment->setId("mitochon");
compartment->setConstant(true);
// create the Species
Species* species = model->createSpecies();
species->setId("ATPc");
species->setCompartment("cytosol");
species->setInitialConcentration(1);
species->setHasOnlySubstanceUnits(false);
species->setBoundaryCondition(false);
species->setConstant(false);
species = model->createSpecies();
species->setId("ATPm");
species->setCompartment("mitochon");
species->setInitialConcentration(2);
species->setHasOnlySubstanceUnits(false);
species->setBoundaryCondition(false);
species->setConstant(false);
// create the Groups
//
// Get a GroupsModelPlugin object plugged in the model object.
//
// The type of the returned value of SBase::getPlugin() function is SBasePlugin*, and
// thus the value needs to be casted for the corresponding derived class.
//
GroupsModelPlugin* mplugin = static_cast<GroupsModelPlugin*>(model->getPlugin("groups"));
//
// Creates a Group object via GroupsModelPlugin object.
//
Group* group = mplugin->createGroup();
group->setId("ATP");
group->setKind(GROUP_KIND_CLASSIFICATION);
group->setSBOTerm("SBO:0000252");
Member* member = group->createMember();
member->setIdRef("ATPc");
member = group->createMember();
//.........这里部分代码省略.........
示例8: createExampleEnzymaticReaction
//.........这里部分代码省略.........
// Sets the "size" attribute of the Compartment object.
//
// We are not setting the units on the compartment size explicitly, so
// the units of this Compartment object will be the default SBML units of
// volume, which are liters.
//
comp->setSize(1e-14);
//---------------------------------------------------------------------------
//
// Creates Species objects inside the Model object.
//
//---------------------------------------------------------------------------
// 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);
示例9: FbcPkgNamespaces
END_TEST
START_TEST(test_FbcExtension_create_and_write_L3V1V1)
{
FbcPkgNamespaces *sbmlns = new FbcPkgNamespaces(3, 1, 1);
// create the document
SBMLDocument *document = new SBMLDocument(sbmlns);
delete sbmlns;
// create the Model
Model* model = document->createModel();
// create the Compartment
Compartment* compartment = model->createCompartment();
compartment->setId("compartment");
compartment->setConstant(true);
compartment->setSize(1);
// create the Species
Species* species = model->createSpecies();
species->setId("Node1");
species->setCompartment("compartment");
species->setBoundaryCondition(false);
species = model->createSpecies();
species->setId("Node2");
species->setCompartment("compartment");
species->setBoundaryCondition(false);
Reaction* reaction = model->createReaction();
reaction->setId("J0");
reaction->setReversible(false);
SpeciesReference* reactant = reaction->createReactant();
reactant->setSpecies("Node0");
reactant->setStoichiometry(1);
SpeciesReference* product = reaction->createProduct();
product->setSpecies("Node1");
product->setStoichiometry(1);
// use fbc
FbcModelPlugin* mplugin = static_cast<FbcModelPlugin*>(model->getPlugin("fbc"));
fail_unless(mplugin != NULL);
FluxBound* bound = mplugin->createFluxBound();
bound->setId("bound1");
bound->setReaction("J0");
bound->setOperation("equal");
bound->setValue(10);
Objective* objective = mplugin->createObjective();
objective->setId("obj1");
objective->setType("maximize");
FluxObjective* fluxObjective = objective->createFluxObjective();
fluxObjective->setReaction("J0");
fluxObjective->setCoefficient(1);
string s1 = writeSBMLToStdString(document);
// check clone()
SBMLDocument* document2 = document->clone();
string s2 = writeSBMLToStdString(document2);
fail_unless(s1 == s2);
// check operator=
Model m = *(document->getModel());
document2->setModel(&m);
s2 = writeSBMLToStdString(document2);
fail_unless(s1 == s2);
delete document2;
delete document;
}
示例10: sbmlns
LIBSBML_CPP_NAMESPACE_USE
int
main (int argc, char* argv[])
{
SBMLNamespaces sbmlns(3,1,"multi",1);
// create the document
SBMLDocument *document = new SBMLDocument(&sbmlns);
// set the required attribute to true
MultiSBMLDocumentPlugin * docPlug =
static_cast<MultiSBMLDocumentPlugin*>(document->getPlugin("multi"));
docPlug->setRequired(true);
// create the Model
Model* model=document->createModel();
// create the compartments
Compartment * c = model->createCompartment();
c->setId("membrane");
c->setConstant(true);
// set the multi attribute isType via the compartmentPlugin
MultiCompartmentPlugin * compPlug =
static_cast<MultiCompartmentPlugin*>(c->getPlugin("multi"));
compPlug->setIsType(true);
// create the speciesTypes
MultiModelPlugin * modelPlug =
static_cast<MultiModelPlugin*>(model->getPlugin("multi"));
MultiSpeciesType * st = modelPlug->createMultiSpeciesType();
st->setId("stX");
st->setCompartment("membrane");
// create species
Species *s = model->createSpecies();
s->setId("s1");
s->setCompartment("membrane");
s->setBoundaryCondition(false);
s->setHasOnlySubstanceUnits(false);
s->setConstant(false);
// set the multi attribute speciesType via the compartmentPlugin
MultiSpeciesPlugin * spPlug =
static_cast<MultiSpeciesPlugin*>(s->getPlugin("multi"));
spPlug->setSpeciesType("stX");
// create species feature
SpeciesFeature *sf = spPlug->createSpeciesFeature();
sf->setSpeciesFeatureType("a");
sf->setOccur(1);
sf->setComponent("b");
SpeciesFeatureValue *sfv = sf->createSpeciesFeatureValue();
sfv->setValue("c");
// create a subListOfSpeciesFeatures
SubListOfSpeciesFeatures* subloSF = spPlug->createSubListOfSpeciesFeatures();
subloSF->setRelation(Relation_fromString("and"));
// add speciesFeatures to the subList
SpeciesFeature *sf1 = new SpeciesFeature(3, 1, 1);
sf1->setSpeciesFeatureType("a1");
sf1->setOccur(1);
sf1->setComponent("b1");
SpeciesFeatureValue *sfv1 = sf1->createSpeciesFeatureValue();
sfv1->setValue("c1");
subloSF->appendAndOwn(sf1);
sf1 = new SpeciesFeature(3, 1, 1);
sf1->setSpeciesFeatureType("a2");
sf1->setOccur(1);
sf1->setComponent("b2");
sfv1 = sf1->createSpeciesFeatureValue();
sfv1->setValue("c2");
subloSF->appendAndOwn(sf1);
// create a second subListOfSpeciesfeatures
subloSF = spPlug->createSubListOfSpeciesFeatures();
subloSF->setRelation(Relation_fromString("or"));
sf1 = new SpeciesFeature(3, 1, 1);
sf1->setSpeciesFeatureType("a3");
sf1->setOccur(1);
sf1->setComponent("b3");
sfv1 = sf1->createSpeciesFeatureValue();
sfv1->setValue("c3");
//.........这里部分代码省略.........
示例11: 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
//.........这里部分代码省略.........
示例12: main
//.........这里部分代码省略.........
param->setValue(2);
param = model->createParameter();
param->initDefaults();
param->setId("q4_Y");
param->setValue(2);
// create SubModels
CompModelPlugin* mplugin =
static_cast<CompModelPlugin*>(model->getPlugin("comp"));
Submodel* submodel = mplugin->createSubmodel();
submodel->setId("GRID_1_1_cell");
submodel->setModelRef("Cell");
submodel = mplugin->createSubmodel();
submodel->setId("GRID_1_2_cell");
submodel->setModelRef("Cell");
submodel = mplugin->createSubmodel();
submodel->setId("GRID_2_1_cell");
submodel->setModelRef("Cell");
submodel = mplugin->createSubmodel();
submodel->setId("GRID_2_2_cell");
submodel->setModelRef("Cell");
// create the ModelDefinition
CompSBMLDocumentPlugin* dplugin =
static_cast<CompSBMLDocumentPlugin*>(document->getPlugin("comp"));
ModelDefinition* mdef = dplugin->createModelDefinition();
mdef->setId("Cell");
compartment = mdef->createCompartment();
compartment->initDefaults();
compartment->setId("C");
compartment->setSpatialDimensions(2.0);
compartment->setSize(1.0);
Species* species = mdef->createSpecies();
species->setId("R");
species->setCompartment("C");
species->setHasOnlySubstanceUnits(false);
species->setBoundaryCondition(false);
species->setConstant(false);
species = mdef->createSpecies();
species->setId("S");
species->setCompartment("C");
species->setHasOnlySubstanceUnits(false);
species->setBoundaryCondition(false);
species->setConstant(false);
Reaction* reaction = mdef->createReaction();
reaction->setId("Degradation_R");
reaction->setReversible(false);
reaction->setFast(false);
reaction->setCompartment("C");
SpeciesReference* reactant = reaction->createReactant();
reactant->setSpecies("R");
reactant->setStoichiometry(1);
reactant->setConstant(true);
reaction = mdef->createReaction();
reaction->setId("Degradation_S");
reaction->setReversible(false);
reaction->setFast(false);
reaction->setCompartment("C");
reactant = reaction->createReactant();
reactant->setSpecies("S");
reactant->setStoichiometry(1);
reactant->setConstant(true);
document->checkConsistency();
Event* event = mdef->createEvent();
event->setId("event0");
event->setUseValuesFromTriggerTime(false);
DynEventPlugin* eplugin =
static_cast<DynEventPlugin*>(event->getPlugin("dyn"));
eplugin->setApplyToAll(true);
eplugin->setCboTerm("http://cbo.biocomplexity.indiana.edu/svn/cbo/trunk/CBO_1_0.owl#CellDivision");
Trigger* trigger = event->createTrigger();
trigger->setInitialValue(false);
trigger->setPersistent(false);
trigger->setMath(SBML_parseFormula("true"));
if (document->getNumErrors(LIBSBML_SEV_ERROR) > 0)
document->printErrors();
writeSBML(document,"dyn_example2.xml");
delete document;
}
示例13: main
LIBSBML_CPP_NAMESPACE_USE
int main(int argc,char** argv)
{
SBMLNamespaces sbmlns(3,1,"fbc",1);
// create the document
SBMLDocument *document = new SBMLDocument(&sbmlns);
document->setPackageRequired("fbc", false);
// create the Model
Model* model=document->createModel();
// create the Compartment
Compartment* compartment = model->createCompartment();
compartment->setId("compartment");
compartment->setConstant(true);
compartment->setSize(1);
// create the Species
Species* species = model->createSpecies();
species->setId("Node1");
species->setCompartment("compartment");
species->setBoundaryCondition(false);
species->setConstant(false);
species->setHasOnlySubstanceUnits(false);
species = model->createSpecies();
species->setId("Node2");
species->setCompartment("compartment");
species->setBoundaryCondition(false);
species->setConstant(false);
species->setHasOnlySubstanceUnits(false);
species = model->createSpecies();
species->setId("Node3");
species->setCompartment("compartment");
species->setBoundaryCondition(false);
species->setConstant(false);
species->setHasOnlySubstanceUnits(false);
species = model->createSpecies();
species->setId("Node4");
species->setCompartment("compartment");
species->setBoundaryCondition(false);
species->setConstant(false);
species->setHasOnlySubstanceUnits(false);
species = model->createSpecies();
species->setId("Node5");
species->setCompartment("compartment");
species->setBoundaryCondition(false);
species->setConstant(false);
species->setHasOnlySubstanceUnits(false);
species = model->createSpecies();
species->setId("Node6");
species->setCompartment("compartment");
species->setBoundaryCondition(false);
species->setConstant(false);
species->setHasOnlySubstanceUnits(false);
species = model->createSpecies();
species->setId("Node7");
species->setCompartment("compartment");
species->setBoundaryCondition(false);
species->setConstant(false);
species->setHasOnlySubstanceUnits(false);
species = model->createSpecies();
species->setId("Node8");
species->setCompartment("compartment");
species->setBoundaryCondition(false);
species->setConstant(false);
species->setHasOnlySubstanceUnits(false);
species = model->createSpecies();
species->setId("Node0");
species->setCompartment("compartment");
species->setBoundaryCondition(true);
species->setConstant(false);
species->setHasOnlySubstanceUnits(false);
species = model->createSpecies();
species->setId("Node9");
species->setCompartment("compartment");
species->setBoundaryCondition(true);
species->setConstant(false);
species->setHasOnlySubstanceUnits(false);
Reaction* reaction = model->createReaction();
reaction->setId("J0");
reaction->setReversible(false);
reaction->setFast(false);
SpeciesReference* reactant = reaction->createReactant();
reactant->setSpecies("Node0");
//.........这里部分代码省略.........
示例14: createExampleInvolvingFunctionDefinitions
/**
*
* Creates an SBML model represented in "7.8 Example involving function definitions"
* in the SBML Level 2 Version 4 Specification.
*
*/
SBMLDocument* createExampleInvolvingFunctionDefinitions()
{
const unsigned int level = Level;
const unsigned int version = Version;
//---------------------------------------------------------------------------
//
// Creates an SBMLDocument object
//
//---------------------------------------------------------------------------
SBMLDocument* sbmlDoc = new SBMLDocument(level,version);
//---------------------------------------------------------------------------
//
// Creates a Model object inside the SBMLDocument object.
//
//---------------------------------------------------------------------------
Model* model = sbmlDoc->createModel();
model->setId("functionExample");
//---------------------------------------------------------------------------
//
// Creates a FunctionDefinition object inside the Model object.
//
//---------------------------------------------------------------------------
FunctionDefinition* fdef = model->createFunctionDefinition();
fdef->setId("f");
// Sets a math (ASTNode object) to the FunctionDefinition object.
string mathXMLString = "<math xmlns=\"http://www.w3.org/1998/Math/MathML\">"
" <lambda>"
" <bvar>"
" <ci> x </ci>"
" </bvar>"
" <apply>"
" <times/>"
" <ci> x </ci>"
" <cn> 2 </cn>"
" </apply>"
" </lambda>"
"</math>";
ASTNode* astMath = readMathMLFromString(mathXMLString.c_str());
fdef->setMath(astMath);
delete astMath;
//---------------------------------------------------------------------------
//
// Creates a Compartment object inside the Model object.
//
//---------------------------------------------------------------------------
Compartment* comp;
const string compName = "compartmentOne";
// Creates a Compartment object ("compartmentOne")
comp = model->createCompartment();
comp->setId(compName);
// Sets the "size" attribute of the Compartment object.
//
// The units of this Compartment object is the default SBML
// units of volume (litre), and thus we don't have to explicitly invoke
// setUnits("litre") function to set the default units.
//
comp->setSize(1);
//---------------------------------------------------------------------------
//
// Creates Species objects inside the Model object.
//
//---------------------------------------------------------------------------
Species* sp;
//---------------------------------------------------------------------------
// (Species1) Creates a Species object ("S1")
//---------------------------------------------------------------------------
sp = model->createSpecies();
sp->setId("S1");
// Sets the "compartment" attribute of the Species object to identify the
// compartnet in which the Species object located.
sp->setCompartment(compName);
//.........这里部分代码省略.........
示例15: document
END_TEST
START_TEST(test_FbcExtension_create_and_write_new_geneassociation
)
{
FbcPkgNamespaces *sbmlns = new FbcPkgNamespaces(3, 1, 2);
// create the document
SBMLDocument document(sbmlns);
document.setConsistencyChecks(LIBSBML_CAT_UNITS_CONSISTENCY, false);
document.setConsistencyChecks(LIBSBML_CAT_MODELING_PRACTICE, false);
// create the Model
Model* model = document.createModel();
// create the Compartment
Compartment* compartment = model->createCompartment();
compartment->setId("compartment");
compartment->setConstant(true);
compartment->setSize(1);
// create the Species
Species* species = model->createSpecies();
species->setId("Node1");
species->setCompartment("compartment");
species->setBoundaryCondition(false);
species = model->createSpecies();
species->setId("Node2");
species->setCompartment("compartment");
species->setBoundaryCondition(false);
Reaction* reaction = model->createReaction();
reaction->setId("J0");
reaction->setReversible(false);
SpeciesReference* reactant = reaction->createReactant();
reactant->setSpecies("Node0");
reactant->setStoichiometry(1);
SpeciesReference* product = reaction->createProduct();
product->setSpecies("Node1");
product->setStoichiometry(1);
// use fbc
FbcModelPlugin* mplugin = static_cast<FbcModelPlugin*>(model->getPlugin("fbc"));
fail_unless(mplugin != NULL);
FluxBound* bound = mplugin->createFluxBound();
bound->setId("bound1");
bound->setReaction("J0");
bound->setOperation("equal");
bound->setValue(10);
Objective* objective = mplugin->createObjective();
objective->setId("obj1");
objective->setType("maximize");
FluxObjective* fluxObjective = objective->createFluxObjective();
fluxObjective->setReaction("J0");
fluxObjective->setCoefficient(1);
FbcReactionPlugin* rplug = dynamic_cast<FbcReactionPlugin*>(reaction->getPlugin("fbc"));
fail_unless(rplug != NULL);
GeneProductAssociation * ga = rplug->createGeneProductAssociation();
ga->setId("ga1");
ga->setAssociation("MG_077 AND MG_321 AND MG_080 AND MG_078 AND MG_079");
fail_unless(ga->getAssociation() != NULL);
fail_unless(mplugin->getNumGeneProducts() == 5);
ga->setAssociation("MG_077 AND MG_321 AND MG_080 AND MG_078 AND MG_079");
fail_unless(ga->getAssociation() != NULL);
fail_unless(mplugin->getNumGeneProducts() == 5);
delete sbmlns;
}