|
This is really useful - thanks for all the information - I feel that I
understand the whole process of retrieving, creating, and updating sbml
objects much better now.
thanks :)
2009/1/22 Sarah Keating <skeating@caltech.edu>
> Hi Guys
>
> Just to add to this discussion.
>
> As has been demonstrated, when you use an addXXX function on a model;
> the model creates its own copy of the object. Thus, in order to change
> that object you need to retrieve a pointer to it using a getXXX function.
>
> final Species species1 = new Species( "Newcastle" );
> final SBMLDocument document = new SBMLDocument();
> document.createModel();
>
> document.getModel().addSpecies( species1 );
>
> final Species species2 = document.getModel().getSpecies(
> "Newcastle" );
>
> i.e. species1 and species2 do indeed point to 2 different objects;
> species1 is the Species you created and species2 is the Species within
> the model.
>
> This use of multiple objects could all be avoided :-)
>
> When you use a createXXX function the object is created within the
> parent object and the function will return a reference to the child
> object; so you interact directly with the object that is contained
> within the parent.
>
> So
>
> final SBMLDocument document = new SBMLDocument();
> final Model model = document.createModel();
>
> final Species species3 = model.createSpecies();
>
> means that species3 references the species inside your model and thus
> any function you perform on it will be output by your model.
>
> So
> species3.setId("Sarah");
>
> System.out.println( document.toSBML() );
>
> will output
>
> <sbml xmlns="http://www.sbml.org/sbml/level2/version4" level="2"
> version="4">
> <model>
> <listOfSpecies>
> <species id="Sarah"/>
> </listOfSpecies>
> </model>
> </sbml>
>
> There are createXXX functions for any child element that might exist
> within a parent e.g.
>
> Reaction - createProduct
> UnitDefinition - createUnit
>
> etc...
>
> Sarah
>
> ********************
>
> ASIDE: My model is L2V4 because libsbml-3.3.0 uses this level and
> version as default.
> To use an older level/version you would need to explicitly tell the
> document by either using level and version arguments in the constructor
> or applying the setLevelAndVersion function to the document once created.
>
>
>
>
> Akiya Jouraku wrote:
> > Hi Allyson,
> >
> > Allyson Lister <a.l.lister@newcastle.ac.uk> wrote
> >> Hi Alejandro,
> >>
> >> Your explanation is clear - thanks. I think it will actually lead me to
> a
> >> solution. The first responder mentioned how you can add duplicate
> species.
> >> You have added that you've noticed that an update or removal of a
> species
> >> doesn't affect the rest of the model, and that this must all be done
> >> manually. While I agree that this is a pain, it does mean that one
> solution
> >> for my problem would be:
> >>
> >>
> >> 1. get a copy of the original species with getSpecies (id)
> >> 2. modify it locally
> >> 3. delete the original species from the model completely
> >> 4. add the modified species to the model
> >
> > The getSpecies(id or index) method returns a *reference* (not copy) to
> the
> > underlying Species object as Frank indicated in his reply.
> > This means that the underlying Species object in the Model object can be
> modified
> > just by invoking functions, which modify the Species object (e.g. setId,
> setName,
> > setAnnotation, and etc.), via the returned Species object.
> >
> > For example, if you want to add an annotation to the underlying Species
> object
> > whose id is "sp" in the model object, this can be implemented as follows:
> >
> >
> > // (a) get the underlying Species object (id is "sp") from the model
> object (Model model)
> >
> > Species spc = model.getSpecies("sp"); // "spc" is a reference to
> the underlying
> > // Species object in the
> Model object
> >
> > // (b) check if "spc" is not null (try..catch block may alternatively
> be used )
> >
> > if ( spc != null )
> > {
> > // (c) set an annotation (by string) to the Species object
> >
> > spc.setAnnotation("<annotation>..*snip*...</annotation>");
> > }
> >
> >
> > So, you don't have to do the step 3. (delete the original species) and 4.
> (add the modified
> > species) to modify the underlying Species object.
> > This behaviour is also true for other Model.getXXXXX functions.
> >
> > Hope this helps.
> >
> > Thanks,
> >
> > Akiya
> >
> >> Since you say deleting a species doesn't affect everything it's linked
> to
> >> (my original worry) then I can happily delete and then immediately add
> back.
> >>
> >> Thanks for your help! :)
> >>
> >> 2009/1/21 Alejandro <hadeshell@gmail.com>
> >>
> >>> Hello.
> >>>
> >>> When you add a new specie with the same id that an existant specie, it
> >>> doesn't detect it and add two species with the same id (and
> 3,4...infinite)
> >>> I think it could be solved using Exception throwing. (to catch the
> problem
> >>> and solve in code on a easy way).
> >>>
> >>> Another Problem (in my point of view) is when you delete, or change the
> ID
> >>> of an existant specie. it doesnt erase or refresh this specie of the
> species
> >>> reference list (of a reaccion for example), and also occurs when a
> specie is
> >>> referenced in a kineticLaw.
> >>>
> >>> is my anwser able to solve your question?
> >>>
> >>> Sorry for my English :) I'm untrained.
> >>>
> >>> Cheers,
> >>> Alejandro
> >>> ____________________________________________________________
> >>> To manage your sbml-interoperability list subscription, visit
> >>> https://utils.its.caltech.edu/mailman/listinfo/sbml-interoperability
> >>>
> >>> For a web interface to the sbml-interoperability mailing list, visit
> >>> http://sbml.org/Forums/
> >>>
> >>> For questions or feedback about the sbml-interoperability list,
> >>> contact sbml-team@caltech.edu
> >>>
> >>
> >>
> >> --
> >>
> >> Allyson Lister
> >> http://lurena.vox.com
> >>
> >> CISBAN, http://www.cisban.ac.uk
> >> Newcastle University
> >> ____________________________________________________________
> >> To manage your sbml-interoperability list subscription, visit
> >> https://utils.its.caltech.edu/mailman/listinfo/sbml-interoperability
> >>
> >> For a web interface to the sbml-interoperability mailing list, visit
> >> http://sbml.org/Forums/
> >>
> >> For questions or feedback about the sbml-interoperability list,
> >> contact sbml-team@caltech.edu
> > ____________________________________________________________
> > To manage your sbml-interoperability list subscription, visit
> > https://utils.its.caltech.edu/mailman/listinfo/sbml-interoperability
> >
> > For a web interface to the sbml-interoperability mailing list, visit
> > http://sbml.org/Forums/
> >
> > For questions or feedback about the sbml-interoperability list,
> > contact sbml-team@caltech.edu
> >
>
> ____________________________________________________________
> To manage your sbml-interoperability list subscription, visit
> https://utils.its.caltech.edu/mailman/listinfo/sbml-interoperability
>
> For a web interface to the sbml-interoperability mailing list, visit
> http://sbml.org/Forums/
>
> For questions or feedback about the sbml-interoperability list,
> contact sbml-team@caltech.edu
>
--
Allyson Lister
http://lurena.vox.com
CISBAN, http://www.cisban.ac.uk
Newcastle University
____________________________________________________________
To manage your sbml-interoperability list subscription, visit
https://utils.its.caltech.edu/mailman/listinfo/sbml-interoperability
For a web interface to the sbml-interoperability mailing list, visit
http://sbml.org/Forums/
For questions or feedback about the sbml-interoperability list,
contact sbml-team@caltech.edu
|