本文整理汇总了C++中ConversionProperties类的典型用法代码示例。如果您正苦于以下问题:C++ ConversionProperties类的具体用法?C++ ConversionProperties怎么用?C++ ConversionProperties使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConversionProperties类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: START_TEST
END_TEST
START_TEST (test_strip_comp)
{
std::string filename(TestDataDirectory);
std::string fileIn = filename + "package1.xml";
SBMLDocument* d = readSBMLFromFile(fileIn.c_str());
fail_unless(d != NULL);
ConversionProperties props;
props.addOption("package", "comp");
SBMLConverter* converter = new SBMLStripPackageConverter();
converter->setProperties(&props);
converter->setDocument(d);
fail_unless (converter->convert() == LIBSBML_OPERATION_SUCCESS);
std::string newModel = writeSBMLToStdString(d);
std::string fileOut = filename + "package1-comp_stripped.xml";
SBMLDocument* fdoc = readSBMLFromFile(fileOut.c_str());
string stripped = writeSBMLToStdString(fdoc);
fail_unless(stripped == newModel);
delete converter;
delete fdoc;
delete d;
}
示例2: SBMLNamespaces
ConversionProperties
SBMLLevel1Version1Converter::getDefaultProperties() const
{
static ConversionProperties prop;
static bool init = false;
if (init)
{
return prop;
}
else
{
SBMLNamespaces * sbmlns = new SBMLNamespaces(1,1); // default namespaces
prop.setTargetNamespaces(sbmlns); // this gets cloned
prop.addOption("convertToL1V1", true,
"convert the document to SBML Level 1 Version 1");
prop.addOption("changePow", false,
"change pow expressions to the (^) hat notation");
prop.addOption("inlineCompartmentSizes", false,
"if true, occurrances of compartment ids in expressions will be replaced with their initial size");
delete sbmlns;
init = true;
return prop;
}
}
示例3: SBMLNamespaces
ConversionProperties
SBMLLevelVersionConverter::getDefaultProperties() const
{
static ConversionProperties prop;
static bool init = false;
if (init)
{
return prop;
}
else
{
SBMLNamespaces * sbmlns = new SBMLNamespaces(); // default namespaces
prop.setTargetNamespaces(sbmlns); // this gets cloned
prop.addOption("strict", true,
"Whether validity should be strictly preserved");
prop.addOption("setLevelAndVersion", true,
"Convert the model to a given Level and Version of SBML");
prop.addOption("addDefaultUnits", true,
"Whether default units should be added when converting to L3");
delete sbmlns;
init = true;
return prop;
}
}
示例4: hasActualErrors
bool hasActualErrors(SBMLDocument* document)
{
document->checkConsistency();
for (unsigned int e=0; e<document->getNumErrors(); e++) {
if (document->getError(e)->getSeverity() >= LIBSBML_SEV_ERROR) return true;
}
#ifdef USE_COMP
CompModelPlugin* compmod = static_cast<CompModelPlugin*>(document->getModel()->getPlugin("comp"));
if (compmod != NULL && compmod->getNumSubmodels() > 0) {
SBMLDocument flat(*document);
ConversionProperties* props = new ConversionProperties();
props->addOption("flatten comp");
SBMLConverter* converter =
SBMLConverterRegistry::getInstance().getConverterFor(*props);
converter->setDocument(&flat);
int result = converter->convert();
flat.checkConsistency();
bool flaterrors = false;
SBMLErrorLog* errlog = document->getErrorLog();
for (unsigned int e=0; e<flat.getNumErrors(); e++) {
if (flat.getError(e)->getSeverity() >= LIBSBML_SEV_ERROR) {
flaterrors = true;
errlog->add(*(flat.getError(e)));
}
}
if (flaterrors) return true;
}
#endif
return false;
}
示例5:
ConversionProperties
CobraToFbcConverter::getDefaultProperties() const
{
static ConversionProperties prop;
prop.addOption("convert cobra", true, "convert cobra sbml to fbc");
return prop;
}
示例6:
ConversionProperties
FbcToCobraConverter::getDefaultProperties() const
{
static ConversionProperties prop;
prop.addOption("convert fbc to cobra", true, "convert FBC L3V1 to SBML L2V4 with COBRA annotation");
return prop;
}
示例7: START_TEST
END_TEST
START_TEST(test_strip_unknown_1)
{
const std::string model =
"<?xml version='1.0' encoding='UTF-8'?>\n"
"<sbml xmlns='http://www.sbml.org/sbml/level3/version1/core' level='3' version='1' "
"xmlns:pkg1='http://www.sbml.org/sbml/level3/version1/pkg1/version1' pkg1:required='true' "
"xmlns:pkg2='http://www.sbml.org/sbml/level3/version1/pkg2/version1' pkg2:required='true' "
"xmlns:pkg3='http://www.sbml.org/sbml/level3/version1/pkg3/version1' pkg3:required='false' "
">\n\t<model/>\n"
"</sbml>";
SBMLDocument* doc = readSBMLFromString(model.c_str());
fail_unless(doc->getNumUnknownPackages() == 3);
ConversionProperties props;
props.addOption("stripPackage", true);
fail_unless(doc->convert(props) == LIBSBML_OPERATION_SUCCESS);
fail_unless(doc->getNumUnknownPackages() == 3);
props.addOption("package", "pkg1,pkg3");
fail_unless(doc->convert(props) == LIBSBML_OPERATION_SUCCESS);
fail_unless(doc->getNumUnknownPackages() == 1);
delete doc;
}
示例8: main
LIBSBML_CPP_NAMESPACE_USE
int
main (int argc, char *argv[])
{
if (argc != 3)
{
cout
<< endl
<< "Usage: inlineFunctionDefintions input-filename output-filename" << endl
<< endl
<< "This program will attempt to inline all function definitions" << endl
<< "contained in the source model, and write a new SBML file."
<< endl
<< endl;
return 1;
}
const char* inputFile = argv[1];
const char* outputFile = argv[2];
// read document
SBMLDocument* document = readSBML(inputFile);
unsigned int errors = document->getNumErrors(LIBSBML_SEV_ERROR);
// stop in case of errors
if (errors > 0)
{
cerr << "Encountered the following SBML errors:" << endl;
document->printErrors(cerr);
cerr << "Conversion skipped. Please correct the problems above first."
<< endl;
return errors;
}
// create conversion object that identifies the function definition converter
ConversionProperties props;
props.addOption("expandFunctionDefinitions", true,
"Expand all function definitions in the model");
// convert
int success = document->convert(props);
if (success != LIBSBML_OPERATION_SUCCESS)
{
cerr << "Unable to perform conversion due to the following:" << endl;
document->printErrors(cerr);
return errors;
}
else
{
cout << "Conversion completed." << endl;
writeSBML(document, outputFile);
}
return 0;
}
示例9: START_TEST
END_TEST
START_TEST (test_conversion_ruleconverter_with_alg)
{
// create test model
SBMLDocument doc;
Model* model = doc.createModel();
model->setId("m");
Parameter* parameter1 = model->createParameter();
parameter1->setId("s");
parameter1->setConstant(false);
parameter1->setValue(0);
Parameter* parameter = model->createParameter();
parameter->setId("p");
parameter->setConstant(false);
parameter->setValue(0);
Parameter* parameter2 = model->createParameter();
parameter2->setId("k");
parameter2->setConstant(false);
parameter2->setValue(0);
AlgebraicRule* rule0 = model->createAlgebraicRule();
rule0->setFormula("k + 2");
rule0->setMetaId("m0");
AssignmentRule* rule1 = model->createAssignmentRule();
rule1->setVariable("s");
rule1->setFormula("p + 1");
rule1->setMetaId("m1");
AssignmentRule* rule2 = model->createAssignmentRule();
rule2->setVariable("p");
rule2->setFormula("1");
rule2->setMetaId("m2");
ConversionProperties props;
props.addOption("sortRules", true, "sort rules");
SBMLConverter* converter = new SBMLRuleConverter();
converter->setProperties(&props);
converter->setDocument(&doc);
fail_unless (converter->convert() == LIBSBML_OPERATION_SUCCESS);
fail_unless (model->getNumRules() == 3);
fail_unless (model->getRule(0)->getMetaId() == "m2");
fail_unless (model->getRule(1)->getMetaId() == "m1");
fail_unless (model->getRule(2)->getMetaId() == "m0");
delete converter;
}
示例10:
ConversionProperties
SBMLFunctionDefinitionConverter::getDefaultProperties() const
{
static ConversionProperties prop;
prop.addOption("expandFunctionDefinitions", true,
"Expand all function definitions in the model");
prop.addOption("skipIds", "",
"Comma separated list of ids to skip during expansion");
return prop;
}
示例11: START_TEST
END_TEST
START_TEST (test_comp_flatten_exchange5)
{
string filename(TestDataDirectory);
//string filename("C:\\Development\\libsbml\\src\\sbml\\packages\\comp\\util\\test\\test-data\\");
// load document
string cfile = filename + "CompTest_A.xml";
SBMLDocument* doc = readSBMLFromFile(cfile.c_str());
Model* model = doc->getModel();
// fail if there is no model (readSBMLFromFile always returns a valid document)
fail_unless(model != NULL);
// SK - since I made the flattenModel package protected
// this will no longer work
// ===========
//CompModelPlugin* cmp = static_cast<CompModelPlugin*>(model->getPlugin("comp"));
//Model* flatmod = cmp->flattenModel();
//fail_unless(flatmod != NULL);
//CompPkgNamespaces csbmlns(3,1,1,"comp");
//SBMLDocument flatdoc(&csbmlns);
//flatdoc.setPackageRequired("comp", true);
//flatdoc.setModel(flatmod);
//writeSBMLToFile(&flatdoc, "CompTest_flat_ports.xml");
//string newModel = writeSBMLToString(&flatdoc);
//===========
// replace with
ConversionProperties* props = new ConversionProperties();
props->addOption("flatten comp");
props->addOption("leavePorts", true);
SBMLConverter* converter = SBMLConverterRegistry::getInstance().getConverterFor(*props);
converter->setDocument(doc);
int result = converter->convert();
// fail if conversion was not valid
fail_unless(result == LIBSBML_OPERATION_SUCCESS);
string newModel = writeSBMLToString(doc);
string ffile = filename + "CompTest_flat_ports.xml";
SBMLDocument* fdoc = readSBMLFromFile(ffile.c_str());
string flatModel = writeSBMLToString(fdoc);
fail_unless(flatModel == newModel);
delete doc;
delete fdoc;
}
示例12: SBMLNamespaces
ConversionProperties
SBMLLevelVersionConverter::getDefaultProperties() const
{
static ConversionProperties prop;
prop.setTargetNamespaces(new SBMLNamespaces()); // default namespaces
prop.addOption("strict", true,
"Whether validity should be strictly preserved");
prop.addOption("setLevelAndVersion", true,
"Convert the model to a given Level and Version of SBML");
return prop;
}
示例13: TestFlattenedUnknownAbortNone
SBMLDocument* TestFlattenedUnknownAbortNone(string file1, string file2)
{
string filename(TestDataDirectory);
//string filename("C:\\Development\\libsbml\\src\\sbml\\packages\\comp\\util\\test\\test-data\\");
ConversionProperties props;
props.addOption("flatten comp");
props.addOption("basePath", filename);
props.addOption("performValidation", false);
props.addOption("abortIfUnflattenable", "none");
SBMLConverter* converter = SBMLConverterRegistry::getInstance().getConverterFor(props);
// load document
string cfile = filename + file1;
SBMLDocument* doc = readSBMLFromFile(cfile.c_str());
// fail if there is no model (readSBMLFromFile always returns a valid document)
fail_unless(doc->getModel() != NULL);
converter->setDocument(doc);
int result = converter->convert();
// fail if conversion was not valid
fail_unless(result == LIBSBML_OPERATION_SUCCESS);
//For use in debugging the above statement.
/*
SBMLErrorLog* errors = doc->getErrorLog();
if (errors->getNumFailsWithSeverity(LIBSBML_SEV_ERROR) != 0) {
fail_unless(false);
for (unsigned long e=0; e<errors->getNumErrors(); e++) {
const SBMLError* error = errors->getError(e);
if (error->getSeverity() == LIBSBML_SEV_ERROR) {
cout << error->getMessage() << endl;
}
}
}
*/
string newModel = writeSBMLToStdString(doc);
//string outfile = filename + "unknown_flat.xml";
//writeSBMLToFile(doc, outfile.c_str());
string ffile = filename + file2;
SBMLDocument* fdoc = readSBMLFromFile(ffile.c_str());
string flatModel = writeSBMLToStdString(fdoc);
fail_unless(flatModel == newModel);
delete fdoc;
delete converter;
return doc;
}
示例14:
ConversionProperties
SBMLIdConverter::getDefaultProperties() const
{
static ConversionProperties prop;
prop.addOption("renameSIds", true,
"Rename all SIds specified in the 'currentIds' option to the ones specified in 'newIds'");
prop.addOption("currentIds", "",
"Comma separated list of ids to rename");
prop.addOption("newIds", "",
"Comma separated list of the new ids");
return prop;
}
示例15: main
LIBSBML_CPP_NAMESPACE_USE
int
main (int argc, char* argv[])
{
if (argc != 3)
{
cout << endl << "Usage: inferUnits input-filename output-filename"
<< endl << endl;
return 2;
}
SBMLDocument *d = readSBML(argv[1]);
d->checkConsistency();
if ( d->getNumErrors(LIBSBML_SEV_ERROR) > 0)
{
d->printErrors();
}
else
{
/* create a new conversion properties structure */
ConversionProperties* props = new ConversionProperties();
/* add an option that we want to infer units */
props->addOption("inferUnits");
SBMLConverter* converter =
SBMLConverterRegistry::getInstance().getConverterFor(*props);
converter->setDocument(d);
/* perform the conversion */
if (converter->convert() != LIBSBML_OPERATION_SUCCESS)
{
cout<< "conversion failed ... " << endl;
return 3;
}
d->getErrorLog()->clearLog();
d->validateSBML();
d->printErrors(cout);
writeSBML(d, argv[2]);
}
return 0;
}