| Author | Topic |
Posts: 10
Registered: April 2011
|
|
|
Posts: 961
Registered: October 2003
|
|
|
Posts: 273
Registered: June 2006
|
|
Re: create compartment is missing id
|
18 Apr '11 09:28

|
 |
|
Hi Spike,
It is really not obvious why you create an invalid model here.
>> final SBMLDocument document = new SBMLDocument(2, 4);
>> document.createModel("MyModel");
>> Compartment compartment = new Compartment();
Here is the problem. You didn't specifiy the Level/Version combination
for your compartment.
>> compartment.setId("SPIKE_cell");
>> compartment.setName("SPIKE_cell");
>> compartment.setMetaId("meta_" + compartment.getId());
>> ListOf<Compartment> listOfCompartments = new ListOf<Compartment>();
You also didn't specify the Level/Version of this list. Actually, it
should not be possible to set a list with undefined Level/Version
combination for a model that obviously has a defined LV configuration.
I'll check this problem.
>> listOfCompartments.add(compartment );
>> document.getModel().setListOfCompartments(listOfCompartments );
What happens is that when writing this model to XML the writer does
not know that you desire to write a compartment of Level 2, it
therefore only writes the name as this is done in Level 1. I'll change
this slightly to avoid this behavior, but please change your code as
follows:
final SBMLDocument document = new SBMLDocument(2, 4);
Model model = document.createModel("MyModel");
Compartment compartment = model.createCompartment();
compartment.addChangeListener(new SimpleSBaseChangeListener());
compartment.setId("SPIKE_cell");
compartment.setName("SPIKE_cell");
compartment.setMetaId("meta_" + compartment.getId());
(new SBMLWriter()).write(document, System.out);
Cheers
Andreas
--
Dr. Andreas Dräger
University of Tuebingen
Center for Bioinformatics Tuebingen (ZBIT)
Sand 1
72076 Tübingen
Germany
Phone: +49-7071-29-78982
Fax: +49-7071-29-5091
____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development
For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/
For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu
|
|
|
Posts: 273
Registered: June 2006
|
|
|
Posts: 9
Registered: April 2010
|
|
Re: create compartment is missing id
|
18 Apr '11 09:59

|
 |
|
I think, if something has a defined level/version, other than the
parent, throw an exception.
If level/version is undefined, change it recursively.
Clemens
Am 18.04.2011 18:56, schrieb Andreas Dräger:
> Dear all,
>
>>>> listOfCompartments.add(compartment );
>>>> document.getModel().setListOfCompartments(listOfCompartments );
>>
>> What happens is that when writing this model to XML the writer does
>> not know that you desire to write a compartment of Level 2, it
>> therefore only writes the name as this is done in Level 1.
>
> While checking this example in detail I noticed that JSBML adapts the
> Level/Version combination when adding elements to that of the parent.
> See the method setThisAsParentSBMLObject in AbstractSBase. There you
> can see that the method checkLevelAndVersionCompatibility actually
> changes the Level/Version combination of an element. This is not done
> recursively. To set L/V recursively, we have to set both at the same
> time to avoid invalid L/V combinations. However, I am asking myself if
> JSBML should be more strict and throw an exception when trying to add
> something with different L/V combination to a parent object. What do
> people think?
>
> Way 1: Silently change the L/V combination in a recursive way
> Way 2: Throw an exception.
>
> What is better?
>
> Cheers
> Andreas
>
--
Dipl.-Inform. (Bioinform.) Clemens Wrzodek
Univ. Tuebingen, WSI-CogSys, Sand 1, D-72076 Tuebingen, Germany
Phone: (+49/0) 7071 / 29 78985 Fax: (+49/0) 7071 / 29 5091
____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development
For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/
For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu
|
|
|
Posts: 307
Location: Cambridge UK
Registered: February 2005
|
|
Re: create compartment is missing id
|
18 Apr '11 10:42

|
 |
|
On 18/04/2011 12:59, Clemens Wrzodek wrote:
> I think, if something has a defined level/version, other than the
> parent, throw an exception.
> If level/version is undefined, change it recursively.
>
Yes, I think that is the best way.
Nico
> Am 18.04.2011 18:56, schrieb Andreas Dräger:
>> Dear all,
>>
>>>>> listOfCompartments.add(compartment );
>>>>> document.getModel().setListOfCompartments(listOfCompartments );
>>> What happens is that when writing this model to XML the writer does
>>> not know that you desire to write a compartment of Level 2, it
>>> therefore only writes the name as this is done in Level 1.
>> While checking this example in detail I noticed that JSBML adapts the
>> Level/Version combination when adding elements to that of the parent.
>> See the method setThisAsParentSBMLObject in AbstractSBase. There you
>> can see that the method checkLevelAndVersionCompatibility actually
>> changes the Level/Version combination of an element. This is not done
>> recursively. To set L/V recursively, we have to set both at the same
>> time to avoid invalid L/V combinations. However, I am asking myself if
>> JSBML should be more strict and throw an exception when trying to add
>> something with different L/V combination to a parent object. What do
>> people think?
>>
>> Way 1: Silently change the L/V combination in a recursive way
>> Way 2: Throw an exception.
>>
>> What is better?
>>
>> Cheers
>> Andreas
>>
____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development
For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/
For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu
|
|
|
Posts: 183
Registered: July 2008
|
|
|
Posts: 183
Registered: July 2008
|
|
|
Posts: 961
Registered: October 2003
|
|
Re: create compartment is missing id
|
18 Apr '11 20:16

|
 |
|
Oh, shoot, sorry. That'll teach me about replying too quickly...
MH
On Apr 18, 2011, at 22:49, Lucian Smith <lpsmith@spod-central.org> wrote:
> * Michael Hucka <mhucka@caltech.edu> [2011-04-18 17:01] writes:
>>>> (5) <listOfCompartments>
>>>> (6) <compartment name="SPIKE_cell"/>
>>>> (7) </listOfCompartments>
>>>
>>>
>>> validating the resulting xml in the online validator gives an error.
>>> "Error Line 6 Column 39: (XML Error #1015) Missing a required XML
>>> attribute. The compartment attribute 'id' is required."
>>>
>>> What am i doing wrong?
>>
>> The field 'id' is a required field on compartment objects in SBML. 'name' is optional. Best thing is to read section 3.3 in the SBML L2v4 specification, available from http://precedings.nature.com/documents/2715/version/1
>
> They actually did call 'setId' earlier in the code--as it turned out
> later, it was because they were by default creating a l1v1 object, and
> that call had failed, or something.
>
> -Lucian
> ____________________________________________________________
> To manage your jsbml-development list subscription, visit
> https://utils.its.caltech.edu/mailman/listinfo/jsbml-development
>
> For a web interface to the jsbml-development mailing list, visit
> http://sbml.org/Forums/
>
> For questions or feedback about the jsbml-development list,
> contact sbml-team@caltech.edu
____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development
For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/
For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu
|
|
|
Posts: 273
Registered: June 2006
|
|
Re: create compartment is missing id
|
18 Apr '11 20:17

|
 |
|
> I would suggest that either creation of SBML objects without any arguments
> be illegal, or that they default to the *latest* level and version, not
> the first.
Hi Lucian,
Actually, there is no default Level/Version combination in JSBML at
the moment. If it is unspecified, [l, v] will be [-1, -1], i.e., kind
of invalid, just like in libSBML. The problem in this example was that
when writing SBML it was checked if the level attribute is greater
than one. If this was the case, the id was written. Locally, I changed
the check to if level != 1 write the id. In this way, the id will also
be written if the level attribute is undefined. I'm going to commit
this later on.
However, there is still the question
* if we should have a static field, maybe in SBMLDocument, for the
latest Level/Version combination and set this as default when creating
an element without specifying the Level/Version combination or
* if we should stick with setting L/V to -1, -1 in this case?
Cheers
Andreas
--
Dr. Andreas Dräger
University of Tuebingen
Center for Bioinformatics Tuebingen (ZBIT)
Sand 1
72076 Tübingen
Germany
Phone: +49-7071-29-78982
Fax: +49-7071-29-5091
____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development
For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/
For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu
|
|
|
Posts: 10
Registered: April 2011
|
|
Re: create compartment is missing id
|
19 Apr '11 01:34
|
 |
|
Thanks it's working now.
Regards,
Eyal
On Mon, Apr 18, 2011 at 7:28 PM, Andreas Dräger <
andreas.draeger@uni-tuebingen.de> wrote:
> Hi Spike,
>
> It is really not obvious why you create an invalid model here.
>
> final SBMLDocument document = new SBMLDocument(2, 4);
>>> document.createModel("MyModel");
>>> Compartment compartment = new Compartment();
>>>
>>
> Here is the problem. You didn't specifiy the Level/Version combination for
> your compartment.
>
> compartment.setId("SPIKE_cell");
>>> compartment.setName("SPIKE_cell");
>>> compartment.setMetaId("meta_" + compartment.getId());
>>> ListOf<Compartment> listOfCompartments = new ListOf<Compartment>();
>>>
>>
> You also didn't specify the Level/Version of this list. Actually, it should
> not be possible to set a list with undefined Level/Version combination for a
> model that obviously has a defined LV configuration. I'll check this
> problem.
>
> listOfCompartments.add(compartment );
>>>
>>> document.getModel().setListOfCompartments(listOfCompartments );
>>>
>>
> What happens is that when writing this model to XML the writer does not
> know that you desire to write a compartment of Level 2, it therefore only
> writes the name as this is done in Level 1. I'll change this slightly to
> avoid this behavior, but please change your code as follows:
>
> final SBMLDocument document = new SBMLDocument(2, 4);
> Model model = document.createModel("MyModel");
> Compartment compartment = model.createCompartment();
> compartment.addChangeListener(new
> SimpleSBaseChangeListener());
> compartment.setId("SPIKE_cell");
> compartment.setName("SPIKE_cell");
> compartment.setMetaId("meta_" + compartment.getId());
> (new SBMLWriter()).write(document, System.out);
>
> Cheers
> Andreas
>
> --
> Dr. Andreas Dräger
> University of Tuebingen
> Center for Bioinformatics Tuebingen (ZBIT)
> Sand 1
> 72076 Tübingen
> Germany
>
> Phone: +49-7071-29-78982
> Fax: +49-7071-29-5091
>
____________________________________________________________
To manage your jsbml-development list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/jsbml-development
For a web interface to the jsbml-development mailing list, visit
http://sbml.org/Forums/
For questions or feedback about the jsbml-development list,
contact sbml-team@caltech.edu
|
|
|