Am 3/20/12 12:56 PM, schrieb Andreas Dräger:
> Hi Sarah,
>>> Yes. That's what I would like to do. It is actually very easy using a
>>> filter for listOf<UnitDefinition> that accepts the first identical
>>> UnitDefinition (using a call like
>>> UnitDefinition.areIdentical(myJustDerivedUnit, unitNumberXXfromTheList),
>>> with XX being the counter in the for-each loop).
>> My main thought about this is to consider what the user might want to
>> do with the unitDefinition returned from getDerivedUnits(). They may
>> wish to change or use it somewhere else and may not actually want it
>> to be part of the original model.
> In deed, there are two different ways to go.
> 1. The user always receives a newly created UnitDefinition and can
> manipulate it in any way, but if it is necessary to ensure that the unit
> is already part of the model, the user must add it by him/herself.
> Similarly, the user would have to filter the Model's list of units for
> an identical unit by him/herself.
> 2. The user gets a unit that may already belong to the model. A check
> can be done by asking myModel.getListOfUnits().contains(myUnit). If it
> is already in the model and the user wants to do some change, a call to
> the clone() method might be necessary.
> It now depends on what the users would prefer to have. Maybe you're
> right, and way #2 is less streightforward because the user does not know
> if the unit belongs to the model or not. In idea #1 the returned unit
> never belongs to the model.
> Are there any other opinions on that topic?
Actually, when calling getDerivedUnitsInstance() on an element such as
Species or Compartment, the user can never know if the returned
UnitDefinition object is part of the model or a newly created element.
If, for instance, there is a unit defined for the species, the method
looks the corresponding UnitDefinition up in the model and returns it.
If it is a base unit, a new UnitDefinition will be created that only
contains the base unit in its list of units. Similarly, if the species
inherits a unit from the model, also the model's inherited unit
definition object will be returned. So in some cases the user receives a
UnitDefinition that is not (yet) part of the Model, and in some cases
the returned value is a UnitDefintion from the Model's list of units.
Therfore, it seems more logical to preferably return a UnitDefinition
from the Model rather than a completely new one. The approach to search
for identical UnitDefinition objects in the model after creating some
UnitDefintion (for a base unit or something different) seems to be the
better choice, I think.
In any way, the method we use to derive units is not straightforward at
Dr. Andreas Dräger
University of Tuebingen
Center for Bioinformatics Tuebingen (ZBIT)
To manage your jsbml-development list subscription, visit
For a web interface to the jsbml-development mailing list, visit
For questions or feedback about the jsbml-development list,