-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add SBMLNamespaces_addPackageNamespace{,s}
functions to C API
#235
Add SBMLNamespaces_addPackageNamespace{,s}
functions to C API
#235
Conversation
However I'm having a problem, here is a pure C reproducer: % cat test.c
#include <stdio.h>
#include <sbml/SBMLNamespaces.h>
#include <sbml/SBMLDocument.h>
int main(void) {
SBMLNamespaces_t *ns;
SBMLDocument_t *doc;
ns = SBMLNamespaces_create(3, 2);
SBMLNamespaces_addPackageNamespace(ns, "fbc", 2, "");
doc = SBMLDocument_createWithSBMLNamespaces(ns);
printf("%s\n", writeSBMLToString(doc));
SBMLDocument_free(doc);
SBMLNamespaces_free(ns);
return 0;
}
% ./test
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level3/version2/core" xmlns:fbc="http://www.sbml.org/sbml/level3/version1/fbc/version2" level="3" version="2"/> I'm creating the namespace with level,version,package version = 3,2,2 but then I get |
@exaexa pointed out this may be due to libsbml/src/sbml/packages/fbc/extension/FbcExtension.cpp Lines 277 to 304 in 52183c6
L3V1* , whatever is the value of sbmlVersion . Is this intentional?
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Mose
The reason the fbc uri is always l3v1vx is because it hasnt been adapted to explicitly work with l3v2 (there are subtly changes).
It can be used in an l3v2 document but the released versions of fbc are l3v1v1 and l3v1v2 so you will get one of those. The header you got is correct and perfectly acceptable by code reading an l3v2 model and the fbc package
My problem was that trying to add gene products to an fbc plugin I was getting a |
@skeating Hello! I'll rephrase the problem a bit: is there a way currently to create a L3V2 model with libsbml that contains FBC? So far everything we have tried has failed, and the downgrade to L3V1 is apparently what others also use (CobraPy in this case, which is anyway how we got the (semi-) working solution with namespaces). Any guidance on how to do this properly would be great, because apparently there has to be the way -- e.g., SBML test suite contains sbml L3V2 + fbc L3V1V2 tests. EDIT: References to hardcoded L3V1: |
Sorry to have taken so long to look into this. The following code /* create the sbml namespaces object with fbc */ SBMLNamespaces_t * sbmlns = SBMLNamespaces_create(3, 2); /* create the document */ /* set the fbc reqd attribute to false / // create the Model Model_t * model = SBMLDocument_createModel(doc); // Get a SBasePlugin_t object plugged in the model object. SBasePlugin_t * modelPlug = SBase_getPlugin((SBase_t *)(model), "fbc"); // set the fbc strict attribute // create the Compartment Compartment_t * compartment = Model_createCompartment(model); // create the Species Species_t * species = Model_createSpecies(model); // create GeneProduct GeneProduct_t *gp = GeneProduct_create(3, 1, 2); // add to model plugin /* write the file */ |
"
" |
Suggested by Sarah Keating at <sbmlteam/libsbml#235 (comment)>.
Lovely, I ported your code to Julia at LCSB-BioCore/SBML.jl#143 and it's working great! Thanks a lot!! BTW, this detour is unrelated to the PR, we just bumped into the above problem once we were able to call |
Suggested by Sarah Keating at <sbmlteam/libsbml#235 (comment)>.
wow, lovely. @skeating thanks a lot! |
Description
Motivation and Context
Functions
SBMLNamespaces::addPackageNamespace
andSBMLNamespaces::addPackageNamespaces
don't currently have counterparts in the C API. With this patch I was able to create anSBMLDocument_t
with fbc package inSBML.jl
(which only uses the C API).Types of changes
Checklist:
Testing