|
> ============
> Compartment *c = new Compartment(3,1);
>
> c->setUnits("metre");
> =============
>
> Since the user has made no explicit declaration about the
> spatialDimensions, if the spatialDimensions defaults to 3, this
> creates
> an invalid internal representation of a compartment - something
> libSBML-4 tries very very hard to avoid doing blindly.
>
I'm not sure I see the difference between the above and the following:
Compartment *c = new Compartment(3,1);
c->setSpatialDimensions(3);
c->setUnits("metre");
In either case, the result is either an invalid internal
representation or throwing an exception on the setUnits call. Also,
for the one above, if there are no defaults than the internal
representation is still invalid as it has units set to a compartment
which has no known spatial dimensions. I think that tools need to
take some of the responsibility to not produce invalid SBML. In our
tool, for example, when a new compartment is created, the default
spatial dimensions is 3, so the user is prohibited from selecting any
units that are not compatible with this. If you change the spatial
dimensions to 1, then the units will be changed to none and the user
is given the option of setting it to units compatible with spatial
dimensions of 1. In this case, I'm pretty sure that our code does not
assume that defaults are provided but instead provides them. However,
in other cases, I believe we have set defaults to match those
specified for level 2 SBML. Therefore, in those cases, we would need
to add code to add explicit values which may be a pain to track down.
> Also consider this code:
>
> ===============
> Model *m = new Model(3,1);
> m->setVolumeUnits("whatever");
>
> Compartment *c = m->createCompartment();
> ===============
>
> Again, implicitly compartment c has units of "whatever" - since by
> default the spatialDimensions are 3.
>
> SBML Level 3 core removed defaults so that these sorts of implicit
> declarations were removed !!
>
The SBML file generated though would not have any implicit
declarations as the spatial units in the file would be explicitly set.
One "feature" of libsbml using defaults is that it can make invalid
SBML (one missing required elements) to be valid. For example, if you
are given a file that is missing the "hasOnlySubstanceUnits" field,
then libsbml w/defaults would fill this in allowing the file to be
read. If the file is then saved, it is now valid SBML. If libsbml
does not allow defaults, then I see two possible behaviors:
1) Throw an exception and not load the SBML file. This is bad because
the user cannot fix the file if it is not loaded.
2) Load the invalid SBML file. This is also bad because now you have
an invalid SBML file.
I guess a compromise would to be add a second readSBML function that
fills in defaults for missing required elements in a SBML file. An
ideal program would read the file without filling in defaults, catch
the exception when required elements are missing, then ask the user if
he/she would like to read the file filling in the required elements
with defaults perhaps opening a window showing which defaults have
been set.
Chris
____________________________________________________________
To manage your libsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/libsbml-development
For a web interface to the libsbml-development mailing list, visit
http://sbml.org/Forums/
For questions or feedback about the libsbml-development list,
contact sbml-team@caltech.edu
|