libsbml
libsbml copied to clipboard
missing C API for association expressions
Is there a C API for retrieving the structured gene association expression contents, in particular the tree of FbcAnd, FbcOr and GeneProductRef stuff that is held by Association (or Association_t in C API), in particular the elements of the Association::mAssociations vector?
I have found there's a (c++) function for getNumAssociations (which doesn't have any C counterpart at http://sbml.org/Software/libSBML/docs/c-api/class_association__t.html), and nothing to actually access the child association elements.
I guess that it would be great to have a similar API as with all other collections, i.e. say unsigned Association_getNumChildAssociations(Association_t*) and Association_t* Association_getChildAssociation(Association_t*, unsigned).
Thanks!
Cc @stelmo @laurentheirendt
in Fbc v1, those associations where not really supported (we just had them as unofficial annotation). Please use the FbcAssociation_t class and Fbc v2 to ensure it is exchanged with most tools. There you will find the methods in the underlying FbcAnd_t and FbcOr_t types. Where you can get and set them.
Aaah okay, good. So I should get the FbcAssociation_t from the GeneProductAssociation_t, and that can be downcasted to FbcAnd_t or FbcOr_t. These have the subexpression lists so that shold work.
Thanks for quick answer, we'll try that and see! Closing the issue for now.
Still no success, reopening. What's the proper C-only way to safely "downcast" the FbcAssociation_t to FbcAnd_t and others?
To me it seems that a C API functions like FbcAssociation_isFbcAnd are really missing.
Indeed, it would seem that the methods ended up in the wrong association file. The save way to do it now (without waiting for a new release) would be to check the type code of the object using
SBase_getTypeCode() with the association_t ptr. If the result is SBML_FBC_AND then a cast to FbcAnd_t is safe. These are defined in sbml/packages/fbc/extension/FbcExtension.h.
OK, great, thanks for confirmation and workaround :]
Should I leave this open for tracking? (perhaps I'll make a patch, but I haven't been finding much free time lately)
yes, lets leave it open. We have a hackathon coming up next week, maybe we'll find some time.But it would probably still be a while until a new stable release, so i'd recommend using the typecode for now.