Skip to content

Commit

Permalink
Merge pull request #243 from sbmlteam/fbc-v3-fix
Browse files Browse the repository at this point in the history
 #241:issues with fbc v3
  • Loading branch information
fbergmann committed Jul 15, 2022
2 parents 8344b88 + 71396f9 commit cb42f00
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 171 deletions.
2 changes: 1 addition & 1 deletion VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.19.5
5.19.6
18 changes: 9 additions & 9 deletions configure
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#! /bin/sh
# From configure.ac Revision.
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for libSBML 5.19.5.
# Generated by GNU Autoconf 2.69 for libSBML 5.19.6.
#
# Report bugs to <libsbml-team@googlegroups.com>.
#
Expand Down Expand Up @@ -735,8 +735,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libSBML'
PACKAGE_TARNAME='libsbml'
PACKAGE_VERSION='5.19.5'
PACKAGE_STRING='libSBML 5.19.5'
PACKAGE_VERSION='5.19.6'
PACKAGE_STRING='libSBML 5.19.6'
PACKAGE_BUGREPORT='libsbml-team@googlegroups.com'
PACKAGE_URL='http://sbml.org/Software/libSBML'

Expand Down Expand Up @@ -1629,7 +1629,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures libSBML 5.19.5 to adapt to many kinds of systems.
\`configure' configures libSBML 5.19.6 to adapt to many kinds of systems.

Usage: $0 [OPTION]... [VAR=VALUE]...

Expand Down Expand Up @@ -1695,7 +1695,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of libSBML 5.19.5:";;
short | recursive ) echo "Configuration of libSBML 5.19.6:";;
esac
cat <<\_ACEOF

Expand Down Expand Up @@ -1851,7 +1851,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
libSBML configure 5.19.5
libSBML configure 5.19.6
generated by GNU Autoconf 2.69

Copyright (C) 2012 Free Software Foundation, Inc.
Expand Down Expand Up @@ -2570,7 +2570,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by libSBML $as_me 5.19.5, which was
It was created by libSBML $as_me 5.19.6, which was
generated by GNU Autoconf 2.69. Invocation command line was

$ $0 $@
Expand Down Expand Up @@ -27754,7 +27754,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by libSBML $as_me 5.19.5, which was
This file was extended by libSBML $as_me 5.19.6, which was
generated by GNU Autoconf 2.69. Invocation command line was

CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -27817,7 +27817,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\
libSBML config.status 5.19.5
libSBML config.status 5.19.6
configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\"

Expand Down
2 changes: 1 addition & 1 deletion src/sbml/common/libsbml-version.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
*
* A version string of the form "1.2.3".
*/
#define LIBSBML_DOTTED_VERSION "5.19.5"
#define LIBSBML_DOTTED_VERSION "5.19.6"


/**
Expand Down
171 changes: 89 additions & 82 deletions src/sbml/packages/fbc/extension/FbcSBasePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ FbcSBasePlugin::createKeyValuePair()

try
{
FBC_CREATE_NS(fbcns, getSBMLNamespaces());
FBC_CREATE_NS_WITH_VERSION(fbcns, getSBMLNamespaces(), getPackageVersion());
kvp = new KeyValuePair(fbcns);
delete fbcns;
}
Expand Down Expand Up @@ -872,87 +872,94 @@ FbcSBasePlugin::createObject(XMLInputStream& stream)

/** @endcond */

/** @cond doxygenLibsbmlInternal */
/**
* Synchronizes the annotation of this SBML object.
*
* Annotation element (XMLNode* mAnnotation) is synchronized with the
* current CVTerm objects (List* mCVTerm).
* Currently, this method is called in getAnnotation, isSetAnnotation,
* and writeElements methods.
*/
void
FbcSBasePlugin::writeKeyValuePairsAnnotation(SBase* parentObject) const
{
if (parentObject == NULL) return;


XMLNode *parentAnnotation = parentObject->getAnnotation();
if (parentAnnotation != NULL && parentAnnotation->getNumChildren() > 0)
{
// deleteFbcAnnotation(parentAnnotation);
}

XMLToken ann_token = XMLToken(XMLTriple("annotation", "", ""), XMLAttributes());
XMLNode* annt = new XMLNode(ann_token);



if (mKeyValuePairs.size() > 0)
{
XMLAttributes loga_attr = XMLAttributes();
loga_attr.add("xmlns", FbcExtension::getXmlnsL3V1V3());
XMLToken loga_token = XMLToken(XMLTriple("listOfKeyValuePairs", FbcExtension::getXmlnsL3V1V1(), ""), loga_attr);
XMLNode loga = XMLNode(loga_token);

for (unsigned int i = 0; i < mKeyValuePairs.size(); ++i)
loga.addChild(mKeyValuePairs.get(i)->toXML());

// then add the ones toXML()
annt->addChild(loga);
}


if (annt && annt->getNumChildren() > 0)
{
parentObject->appendAnnotation(annt);
}
delete annt;
}
/** @endcond */


/** @cond doxygenLibsbmlInternal */
/**
* Parse L2 annotation if supported
*
*/
void
FbcSBasePlugin::parseAnnotation(SBase *parentObject, XMLNode *pAnnotation)
{
mKeyValuePairs.setSBMLDocument(mSBML);
// don't read if we have an invalid node or already a gene associations object
if (pAnnotation == NULL || mKeyValuePairs.size() > 0)
return;

// annotation element has been parsed by the parent element
// (Model) of this plugin object, thus the annotation element
// set to the above pAnnotation variable is parsed in this block.

XMLNode& listOfKeyValuePairs = pAnnotation->getChild("listOfKeyValuePairs");
if (listOfKeyValuePairs.getNumChildren() == 0)
return;

// read the xml node, overriding that all errors are flagged as
// warnings
mKeyValuePairs.read(listOfKeyValuePairs, LIBSBML_OVERRIDE_WARNING);
// remove listOfLayouts annotation
parentObject->removeTopLevelAnnotationElement("listOfKeyValuePairs", "", false);

}
/** @endcond */


/** @cond doxygenLibsbmlInternal */
/**
* Synchronizes the annotation of this SBML object.
*
* Annotation element (XMLNode* mAnnotation) is synchronized with the
* current CVTerm objects (List* mCVTerm).
* Currently, this method is called in getAnnotation, isSetAnnotation,
* and writeElements methods.
*/
void
FbcSBasePlugin::writeKeyValuePairsAnnotation(SBase* parentObject) const
{
if (parentObject == NULL) return;


XMLNode *parentAnnotation = parentObject->getAnnotation();
if (parentAnnotation != NULL && parentAnnotation->getNumChildren() > 0)
{
// deleteFbcAnnotation(parentAnnotation);
}

XMLToken ann_token = XMLToken(XMLTriple("annotation", "", ""), XMLAttributes());
XMLNode* annt = new XMLNode(ann_token);



if (mKeyValuePairs.size() > 0)
{
XMLAttributes loga_attr = XMLAttributes();
loga_attr.add("xmlns", mKeyValuePairs.getXmlns());
XMLToken loga_token = XMLToken(XMLTriple("listOfKeyValuePairs", mKeyValuePairs.getXmlns(), ""), loga_attr);
XMLNode loga = XMLNode(loga_token);

for (unsigned int i = 0; i < mKeyValuePairs.size(); ++i)
loga.addChild(mKeyValuePairs.get(i)->toXML());

// then add the ones toXML()
annt->addChild(loga);
}


if (annt && annt->getNumChildren() > 0)
{
parentObject->appendAnnotation(annt);
}
delete annt;
}
/** @endcond */


/** @cond doxygenLibsbmlInternal */
/**
* Parse L2 annotation if supported
*
*/
void
FbcSBasePlugin::parseAnnotation(SBase *parentObject, XMLNode *pAnnotation)
{
mKeyValuePairs.setSBMLDocument(mSBML);
// don't read if we have an invalid node or already a gene associations object
if (pAnnotation == NULL || mKeyValuePairs.size() > 0)
return;

// annotation element has been parsed by the parent element
// (Model) of this plugin object, thus the annotation element
// set to the above pAnnotation variable is parsed in this block.

XMLNode& listOfKeyValuePairs = pAnnotation->getChild("listOfKeyValuePairs");
if (listOfKeyValuePairs.getNumChildren() == 0)
return;

XMLNamespaces oldNs = listOfKeyValuePairs.getNamespaces();

// read the xml node, overriding that all errors are flagged as
// warnings
mKeyValuePairs.read(listOfKeyValuePairs, LIBSBML_OVERRIDE_WARNING);

// unfortunately the namespaces are overwritten at that point with the one from the
// document, so restore it
mKeyValuePairs.setXmlns(&oldNs, listOfKeyValuePairs.getPrefix());

// remove listOfLayouts annotation
parentObject->removeTopLevelAnnotationElement("listOfKeyValuePairs", "", false);

}
/** @endcond */





Expand Down
10 changes: 7 additions & 3 deletions src/sbml/packages/fbc/extension/test/TestWriteFbcExtension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,14 @@ START_TEST(test_FbcExtension_create_and_write_L3V1V3)

FbcSBasePlugin* sbaseplugin3 = dynamic_cast<FbcSBasePlugin*>(objective->getPlugin("fbc"));

ListOfKeyValuePairs *kvp_list = sbaseplugin3->getListOfKeyValuePairs();
fail_unless(kvp_list->isSetXmlns());
fail_unless(kvp_list->getXmlns() == "http://sbml.org/fbc/keyvaluepair");

KeyValuePair * kvp3 = sbaseplugin3->createKeyValuePair();
kvp3->setKey("key3");
kvp3->setUri("my_annotation");
kvp3->setValue("objective-value");
fail_unless(kvp3->setKey("key3") == LIBSBML_OPERATION_SUCCESS);
fail_unless(kvp3->setUri("my_annotation") == LIBSBML_OPERATION_SUCCESS);
fail_unless(kvp3->setValue("objective-value") == LIBSBML_OPERATION_SUCCESS);

//FbcSBasePlugin* sbaseplugin4 = dynamic_cast<FbcSBasePlugin*>(document->getPlugin("fbc"));
//// this dynamic cast is null
Expand Down
17 changes: 4 additions & 13 deletions src/sbml/packages/fbc/extension/test/test-data/fbc_example2_v3.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" xmlns:fbc="http://www.sbml.org/sbml/level3/version1/fbc/version3" level="3" version="1" fbc:required="false">
<!-- <annotation>
<listOfKeyValuePairs xlns="http://www.sbml.org/sbml/level3/version1/fbc/version3">
<keyValuePair key="key4" value="doc-value" uri="my_annotation"/>
</listOfKeyValuePairs>
</annotation>
-->
<model id="m" fbc:strict="true">
<annotation>
<listOfKeyValuePairs xlns="http://www.sbml.org/sbml/level3/version1/fbc/version3">
<listOfKeyValuePairs xmlns="http://sbml.org/fbc/keyvaluepair">
<keyValuePair key="key2" value="model-value" uri="my_annotation"/>
</listOfKeyValuePairs>
</annotation>
<listOfCompartments>
<compartment id="comp" spatialDimensions="3" size="1" constant="true">
<annotation>
<listOfKeyValuePairs xlns="http://www.sbml.org/sbml/level3/version1/fbc/version3">
<listOfKeyValuePairs xmlns="http://sbml.org/fbc/keyvaluepair">
<keyValuePair key="key" value="comp-value" uri="my_annotation"/>
</listOfKeyValuePairs>
</annotation>
Expand All @@ -24,7 +18,7 @@
<listOfSpecies>
<species id="S" compartment="comp" boundaryCondition="false" fbc:charge="2.5">
<annotation>
<listOfKeyValuePairs xlns="http://www.sbml.org/sbml/level3/version1/fbc/version3">
<listOfKeyValuePairs xmlns="http://sbml.org/fbc/keyvaluepair">
<keyValuePair key="key1" value="species-value" uri="my_annotation"/>
</listOfKeyValuePairs>
</annotation>
Expand All @@ -33,7 +27,7 @@
<fbc:listOfObjectives fbc:activeObjective="obj1">
<fbc:objective fbc:id="obj1" fbc:type="maximize">
<annotation>
<listOfKeyValuePairs xlns="http://www.sbml.org/sbml/level3/version1/fbc/version3">
<listOfKeyValuePairs xmlns="http://sbml.org/fbc/keyvaluepair">
<keyValuePair key="key3" value="objective-value" uri="my_annotation"/>
</listOfKeyValuePairs>
</annotation>
Expand All @@ -44,13 +38,10 @@
</fbc:listOfObjectives>
<fbc:listOfUserDefinedConstraints>
<fbc:userDefinedConstraint fbc:id="uc2" fbc:lowerBound="uc2lb" fbc:upperBound="uc2ub">

<fbc:listOfUserDefinedConstraintComponents>

<fbc:userDefinedConstraintComponent fbc:coefficient="2" fbc:variable="Avar" fbc:variableType="linear"/>
</fbc:listOfUserDefinedConstraintComponents>
</fbc:userDefinedConstraint>
</fbc:listOfUserDefinedConstraints>

</model>
</sbml>
Loading

0 comments on commit cb42f00

Please sign in to comment.