Skip to content

Commit a0d57d6

Browse files
committed
#429 : ensure that annotations / notes of kvps are written
1 parent c47e1ec commit a0d57d6

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

src/sbml/packages/fbc/extension/test/TestWriteFbcExtension.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -432,10 +432,18 @@ START_TEST(test_FbcExtension_create_and_write_L3V1V3)
432432
// check annotations on several types
433433
FbcSBasePlugin* sbaseplugin = dynamic_cast<FbcSBasePlugin*>(compartment->getPlugin("fbc"));
434434

435+
auto* term = new CVTerm();
436+
term->setQualifierType(BIOLOGICAL_QUALIFIER);
437+
term->setBiologicalQualifierType(BQB_IS);
438+
term->addResource("MyResourceThatWillBeWrittenAndRead");
439+
435440
KeyValuePair * kvp = sbaseplugin->createKeyValuePair();
436441
kvp->setKey("key");
437442
kvp->setUri("my_annotation");
438443
kvp->setValue("comp-value");
444+
kvp->setMetaId("metaid_kvp");
445+
446+
kvp->addCVTerm(term);
439447

440448
FbcSBasePlugin* sbaseplugin1 = dynamic_cast<FbcSBasePlugin*>(species->getPlugin("fbc"));
441449

@@ -471,14 +479,17 @@ START_TEST(test_FbcExtension_create_and_write_L3V1V3)
471479
string s1 = writeSBMLToStdString(document);
472480

473481
//cout << s1 << endl;
482+
fail_unless(s1.find("MyResourceThatWillBeWrittenAndRead") != string::npos);
474483

475484
char *filename = safe_strcat(TestDataDirectory, "fbc_example2_v3.xml");
476485
SBMLDocument *document1 = readSBMLFromFile(filename);
477486
string s2 = writeSBMLToStdString(document1);
487+
fail_unless(s2.find("MyResourceThatWillBeWrittenAndRead") != string::npos);
478488

479489
//cout << endl << s2 << endl;
480490
fail_unless(s1 == s2);
481491

492+
482493
delete sbmlns;
483494
delete document;
484495
delete document1;

src/sbml/packages/fbc/extension/test/test-data/fbc_example2_v3.xml

+13-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,19 @@
1010
<compartment id="comp" spatialDimensions="3" size="1" constant="true">
1111
<annotation>
1212
<listOfKeyValuePairs xmlns="http://sbml.org/fbc/keyvaluepair">
13-
<keyValuePair key="key" value="comp-value" uri="my_annotation"/>
13+
<keyValuePair key="key" value="comp-value" uri="my_annotation">
14+
<annotation>
15+
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#" xmlns:vCard4="http://www.w3.org/2006/vcard/ns#" xmlns:bqbiol="http://biomodels.net/biology-qualifiers/" xmlns:bqmodel="http://biomodels.net/model-qualifiers/">
16+
<rdf:Description rdf:about="#metaid_kvp">
17+
<bqbiol:is>
18+
<rdf:Bag>
19+
<rdf:li rdf:resource="MyResourceThatWillBeWrittenAndRead"/>
20+
</rdf:Bag>
21+
</bqbiol:is>
22+
</rdf:Description>
23+
</rdf:RDF>
24+
</annotation>
25+
</keyValuePair>
1426
</listOfKeyValuePairs>
1527
</annotation>
1628
</compartment>

src/sbml/packages/fbc/sbml/KeyValuePair.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -1144,6 +1144,11 @@ KeyValuePair::toXML() const
11441144
XMLToken token = XMLToken(triple, att, xmlns);
11451145
XMLNode node(token);
11461146

1147+
if(mNotes) node.addChild(*this->mNotes);
1148+
const_cast <KeyValuePair *> (this)->syncAnnotation();
1149+
if(mAnnotation) node.addChild(*this->mAnnotation);
1150+
1151+
11471152
return node;
11481153
}
11491154

0 commit comments

Comments
 (0)