Forums

F.A.Q. F.A.Q.    Register Register    Login Login    Home Home
Search Search
SBML Discussions » jsbml-development » Problem reading history element?
Show: Today's Posts  :: Message Navigator
| Subscribe to topic 
Return to the default flat view Create a new topic Submit Reply
AuthorTopic
Andreas Dräger


Posts: 273
Registered:
June 2006
Re: Problem reading history element? 20 Mar '12 00:27 Go to previous messageGo to previous message

Am 3/20/12 5:45 AM, schrieb rbyrnes:
> Andreas-
>
> I am seeing another problem, while reading histories of non-model elements. Here is a test file, a sample program, and output. I am using a jar file that I compiled from the source code as "jsbml-1.0-a1-with-dependencies.jar".
>
> --JavaBob
>
> <?xml version='1.0' encoding='UTF-8' standalone='no'?>
> <sbml xmlns="http://www.sbml.org/sbml/level3/version1/core" level="3" version="1">
> <model id="modelid" metaid="_e86152e2-6841-47f9-adb0-434afaa1ecd6">
> <annotation>
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
> <rdf:Description rdf:about="#_e86152e2-6841-47f9-adb0-434afaa1ecd6">
> <created parseType="Resource">
> <W3CDTF>2012-03-19T17:17:33Z</W3CDTF>
> </created>
> <modified parseType="Resource">
> <W3CDTF>2012-03-19T17:17:33Z</W3CDTF>
> </modified>
> </rdf:Description>
> </rdf:RDF>
> </annotation>
> <listOfCompartments metaid="_ccf85f40-0381-46e0-b111-cba7026bf197">
> <annotation>
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:vCard="http://www.w3.org/2001/vcard-rdf/3.0#">
> <rdf:Description rdf:about="#_ccf85f40-0381-46e0-b111-cba7026bf197">
> <dc:creator>
> <Bag>
> <li parseType="Resource">
> <vCard:N rdf:parseType="Resource">
> <vCard:Family>aa</vCard:Family>
> <vCard:Given>bb</vCard:Given>
> </vCard:N>
> <vCard:EMAIL>seymour@ssss.edu</vCard:EMAIL>
> <vCard:ORG parseType="Resource">
> <vCard:Orgname>ssss</vCard:Orgname>
> </vCard:ORG>
> </li>
> </Bag>
> </dc:creator>
> </rdf:Description>
> </rdf:RDF>
> </annotation>
> <compartment id="c1" constant="true" metaid="_625b8eb4-f1f7-49fd-99ec-55a68d025df5" size="0">
> <annotation>
> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
> <rdf:Description rdf:about="#_625b8eb4-f1f7-49fd-99ec-55a68d025df5">
> </rdf:Description>
> </rdf:RDF>
> </annotation>
> </compartment>
> </listOfCompartments>
> </model>
> </sbml>
>
> import java.io.*;
> import javax.xml.stream.XMLStreamException;
> import org.sbml.jsbml.*;
>
> public class TestCompartmentHistory
> {
> public static void main( String[] args )
> {
> try
> {
> File f = null;
> SBMLDocument document = null;
> try
> {
> f = new File( "E:\\testsbml\\testcompartmenthistory.sbml" );
> document = SBMLReader.read( f );
> Model m = document.getModel( );
> History c1History = m.getListOfCompartments( ).get( 0 ).getHistory( );
> java.util.List<Creator> list = (java.util.List<Creator>) c1History.getListOfCreators( );
> System.out.println( "Number of creators: " + list.size( ) );
> }
> catch( java.util.EmptyStackException e )
> {
> throw new IOException( e.getMessage( ) );
> }
> catch( XMLStreamException x )
> {
> throw new IOException( x.getMessage( ) );
> }
> }
> catch( Exception ex )
> {
> ex.printStackTrace( );
> }
> System.out.println( "Done" );
> }
> }
>
> WARN (VCardParser.java:250) - Lost Information : the element 'N' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:131) - Lost Information : the characters '
> ' on the element 'N' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:250) - Lost Information : the element 'Family' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:131) - Lost Information : the characters 'aa' on the element 'Family' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:250) - Lost Information : the element 'Given' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:131) - Lost Information : the characters 'bb' on the element 'Given' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:250) - Lost Information : the element 'EMAIL' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:131) - Lost Information : the characters 'seymour@ssss.edu' on the element 'EMAIL' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:250) - Lost Information : the element 'ORG' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:131) - Lost Information : the characters '
> ' on the element 'ORG' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:250) - Lost Information : the element 'Orgname' might be lost as the context object is not a Creator.
> WARN (VCardParser.java:131) - Lost Information : the characters 'ssss' on the element 'Orgname' might be lost as the context object is not a Creator.
> Number of creators: 0
> Done
>
>

Hi Robert,

You are right. It seems there is a bug. I modified your program a little
bit and tried to directly read a newly created SBMLDocument again.
Writing works, but reading fails at the moment. It seems there is
something wrong with the history parsing:

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import javax.xml.stream.XMLStreamException;

import org.sbml.jsbml.Creator;
import org.sbml.jsbml.History;
import org.sbml.jsbml.Model;
import org.sbml.jsbml.SBMLDocument;
import org.sbml.jsbml.SBMLReader;
import org.sbml.jsbml.SBMLWriter;

public class TestCompartmentHistory {

public static void main(String[] args) {
try {
SBMLDocument document = new SBMLDocument(3, 1);
Creator creator = new Creator("Andreas", "Draeger", "University
of Tuebingen", "andreas.draeger@uni-tuebingen.de");
document.getHistory().addCreator(creator);
document.createModel("m").getHistory().addCreator(creator.clone());
ByteArrayOutputStream stream = new ByteArrayOutputStream();
SBMLWriter.write(document, stream, ' ', (short) 2);
stream.flush();
System.out.println(stream.toString());
try {
document = SBMLReader.read(stream.toString());
Model m = document.getModel();
History c1History = m.getListOfCompartments().get(0).getHistory();
java.util.List<Creator> list = (java.util.List<Creator>)
c1History.getListOfCreators();
System.out.println("Number of creators: " + list.size());
} catch (java.util.EmptyStackException e) {
throw new IOException(e.getMessage());
} catch (XMLStreamException x) {
throw new IOException(x.getMessage());
}
} catch (Exception ex) {
ex.printStackTrace();
}
System.out.println("Done");
}

}

I suggest to wait for an answer by Nicolas Rodriguez, who implemented
the parsing methods together with Marine Dumousseau.

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

      

SubjectPosterDate
Read Message   Problem reading history element? rbyrnes15 Mar '12 14:58
Read Message   Re: Problem reading history element? Andreas Dräger19 Mar '12 00:50
Read Message   Re: Problem reading history element? rbyrnes19 Mar '12 09:19
Read Message   Re: Problem reading history element? rbyrnes19 Mar '12 12:18
Read Message   Re: Problem reading history element? Andreas Dräger19 Mar '12 23:46
Read Message   Re: Problem reading history element? rbyrnes19 Mar '12 10:49
Read Message   Re: Problem reading history element?  Andreas Dräger20 Mar '12 00:27
Read Message   Re: Problem reading history element? rodrigue22 Mar '12 08:09
Previous Topic:SBML namespace in math elements
Next Topic:Units inheritance in Level 3
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.