Forums

F.A.Q. F.A.Q.    Register Register    Login Login    Home Home
Search Search
SBML Discussions » jsbml-development » create compartment is missing id
Show: Today's Posts  :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
AuthorTopic
spike


Posts: 10
Registered:
April 2011
create compartment is missing id 18 Apr '11 02:57 Go to next message

Hi all

I am using jsbml jar to export our model.

This is the code that I am using:

Quote:


final SBMLDocument document = new SBMLDocument(2, 4);
document.createModel("MyModel");
Compartment compartment = new Compartment();
compartment.setId("SPIKE_cell");
compartment.setName("SPIKE_cell");
compartment.setMetaId("meta_" + compartment.getId());
ListOf<Compartment> listOfCompartments = new ListOf<Compartment>();
listOfCompartments.add(compartment );
document.getModel().setListOfCompartments(listOfCompartments );



The outcome of this code is:

Quote:


(1)<?xml version='1.0' encoding='UTF-8' standalone='no'?>
(2)<!-- Created by SBMLWriterTest version ? on 2011-04-17 17:24 with jsbml version 0.8-b1. -->
(3)<sbml xmlns="http://www.sbml.org/sbml/level2/version4" level="2" version="4">
(4) <model id="MyModel">
(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?

Regards,
Eyal

      
Mike Hucka


Posts: 961
Registered:
October 2003
Re: create compartment is missing id 18 Apr '11 09:00 Go to previous messageGo to next message

>> (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

Best regards,
MH
____________________________________________________________
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

      
Andreas Dräger


Posts: 273
Registered:
June 2006
Re: create compartment is missing id 18 Apr '11 09:28 Go to previous messageGo to next message

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

      
Andreas Dräger


Posts: 273
Registered:
June 2006
Re: create compartment is missing id 18 Apr '11 09:56 Go to previous messageGo to next message

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

--
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

      
Clemens Wrzodek


Posts: 9
Registered:
April 2010
Re: create compartment is missing id 18 Apr '11 09:59 Go to previous messageGo to next message

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

      
rodrigue


Posts: 307
Location:
Cambridge UK
Registered:
February 2005
Re: create compartment is missing id 18 Apr '11 10:42 Go to previous messageGo to next message

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

      
Lucian Smith


Posts: 183
Registered:
July 2008
Re: create compartment is missing id 18 Apr '11 19:49 Go to previous messageGo to next message

* 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

      
Lucian Smith


Posts: 183
Registered:
July 2008
Re: create compartment is missing id 18 Apr '11 19:50 Go to previous messageGo to next message

* Andreas Drger <andreas.draeger@uni-tuebingen.de> [2011-04-18 17:29] writes:
> 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.

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.

-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

      
Mike Hucka


Posts: 961
Registered:
October 2003
Re: create compartment is missing id 18 Apr '11 20:16 Go to previous messageGo to next message

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

      
Andreas Dräger


Posts: 273
Registered:
June 2006
Re: create compartment is missing id 18 Apr '11 20:17 Go to previous messageGo to next message

> 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

      
spike


Posts: 10
Registered:
April 2011
Re: create compartment is missing id 19 Apr '11 01:34 Go to previous message

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

      
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic:how to represent a family of proteins
Next Topic:Write to SBML
Go to forum:
-=] Back to Top [=-

Powered by FUDforum. (Copyright Advanced Internet Designs Inc.)

Please use our issue tracking system for any questions or suggestions about this website.