BioModels retreiver just recognises MIRIAM URNs, not URLs.
Use the URLResourceRetriever for URLs
This URL is actually used in test URLResourceRetrieverTest#testGetModelXMLReturnSBML() and works fine.
if you don't know in advance what are the sources of the models, use the ModelRetriever class and register all the IModelRetrieves you think you'll need.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here are some more details about this one (see below). I get the document as a String, then when I’m reading the String, I get the exception below. This does not happen though for the biomodelsModelsRetriever.
com.ctc.wstx.exc.WstxUnexpectedCharException: Illegal character (NULL, unicode 0) encountered: not valid in any content
at [row,col {unknown-source}]: [179,24]
at com.ctc.wstx.sr.StreamScanner.constructNullCharException(StreamScanner.java:642)
at com.ctc.wstx.sr.StreamScanner.throwInvalidSpace(StreamScanner.java:672)
at com.ctc.wstx.sr.StreamScanner.throwInvalidSpace(StreamScanner.java:663)
at com.ctc.wstx.sr.StreamScanner.getNextInCurrAfterWS(StreamScanner.java:891)
at com.ctc.wstx.sr.BasicStreamReader.handleNsAttrs(BasicStreamReader.java:3102)
at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:3036)
at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2912)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1115)
at org.codehaus.stax2.ri.Stax2EventReaderImpl.nextEvent(Stax2EventReaderImpl.java:255)
at org.sbml.jsbml.xml.stax.SBMLReader.readXMLFromXMLEventReader(SBMLReader.java:568)
at org.sbml.jsbml.xml.stax.SBMLReader.readXMLFromStream(SBMLReader.java:533)
at org.sbml.jsbml.xml.stax.SBMLReader.readSBMLFromString(SBMLReader.java:834)
at org.sbml.jsbml.xml.stax.SBMLReader.readSBMLFromString(SBMLReader.java:848)
at org.sbml.jsbml.SBMLReader.readSBMLFromString(SBMLReader.java:267)
at org.sbml.jsbml.SBMLReader.read(SBMLReader.java:143)
at main.Gui.importModels(Gui.java:5427)
at main.Gui.importSEDMLDocument(Gui.java:5639)
at main.Gui.importSEDML(Gui.java:5720)
at main.Gui.actionPerformed(Gui.java:3660)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at com.apple.laf.ScreenMenuItem.actionPerformed(ScreenMenuItem.java:128)
at java.awt.MenuItem.processActionEvent(MenuItem.java:669)
at java.awt.MenuItem.processEvent(MenuItem.java:628)
at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:351)
at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:339)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:738)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:708)
at java.awt.EventQueue$4.run(EventQueue.java:706)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
if you don't know in advance what are the sources of the models, use the ModelRetriever class and register all the IModelRetrieves you think you'll need.
status: wont-fix --> accepted
Comment:
OK, I could reproduce the error in the sense that XML couldn't be parsed. . Looks like some characters weren't valid XML so have added some code to strip them out, let me know if it works now for you reading into jsbml
OK, I could reproduce the error in the sense that XML couldn't be parsed. . Looks like some characters weren't valid XML so have added some code to strip them out, let me know if it works now for you reading into jsbml
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So,there are various implementations of IModelResolver that can load models from BioModels, generic URLs, files or archives.
The URL in the Sedx file is :
http://www.ebi.ac.uk/biomodels/models-main/publ/BIOMD0000000012/BIOMD0000000012.xml
BioModels retreiver just recognises MIRIAM URNs, not URLs.
Use the URLResourceRetriever for URLs
This URL is actually used in test URLResourceRetrieverTest#testGetModelXMLReturnSBML() and works fine.
if you don't know in advance what are the sources of the models, use the ModelRetriever class and register all the IModelRetrieves you think you'll need.
Here are some more details about this one (see below). I get the document as a String, then when I’m reading the String, I get the exception below. This does not happen though for the biomodelsModelsRetriever.
I’m using the following code:
if (model.getSource().startsWith("urn:miriam:biomodels.db")) {
BioModelsModelsRetriever retriever = new BioModelsModelsRetriever();
String docStr = retriever.getModelXMLFor(URI.create(model.getSource()));
SBMLDocument doc = SBMLReader.read(docStr);
newFile = importSBMLDocument("model",doc);
} else if (model.getSource().startsWith("http://")) {
URLResourceRetriever retriever = new URLResourceRetriever();
String docStr = retriever.getModelXMLFor(URI.create(model.getSource()));
SBMLDocument doc = SBMLReader.read(docStr);
newFile = importSBMLDocument("model",doc);
} else {
Here is the exception that I get:
com.ctc.wstx.exc.WstxUnexpectedCharException: Illegal character (NULL, unicode 0) encountered: not valid in any content
at [row,col {unknown-source}]: [179,24]
at com.ctc.wstx.sr.StreamScanner.constructNullCharException(StreamScanner.java:642)
at com.ctc.wstx.sr.StreamScanner.throwInvalidSpace(StreamScanner.java:672)
at com.ctc.wstx.sr.StreamScanner.throwInvalidSpace(StreamScanner.java:663)
at com.ctc.wstx.sr.StreamScanner.getNextInCurrAfterWS(StreamScanner.java:891)
at com.ctc.wstx.sr.BasicStreamReader.handleNsAttrs(BasicStreamReader.java:3102)
at com.ctc.wstx.sr.BasicStreamReader.handleStartElem(BasicStreamReader.java:3036)
at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2912)
at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1115)
at org.codehaus.stax2.ri.Stax2EventReaderImpl.nextEvent(Stax2EventReaderImpl.java:255)
at org.sbml.jsbml.xml.stax.SBMLReader.readXMLFromXMLEventReader(SBMLReader.java:568)
at org.sbml.jsbml.xml.stax.SBMLReader.readXMLFromStream(SBMLReader.java:533)
at org.sbml.jsbml.xml.stax.SBMLReader.readSBMLFromString(SBMLReader.java:834)
at org.sbml.jsbml.xml.stax.SBMLReader.readSBMLFromString(SBMLReader.java:848)
at org.sbml.jsbml.SBMLReader.readSBMLFromString(SBMLReader.java:267)
at org.sbml.jsbml.SBMLReader.read(SBMLReader.java:143)
at main.Gui.importModels(Gui.java:5427)
at main.Gui.importSEDMLDocument(Gui.java:5639)
at main.Gui.importSEDML(Gui.java:5720)
at main.Gui.actionPerformed(Gui.java:3660)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
at com.apple.laf.ScreenMenuItem.actionPerformed(ScreenMenuItem.java:128)
at java.awt.MenuItem.processActionEvent(MenuItem.java:669)
at java.awt.MenuItem.processEvent(MenuItem.java:628)
at java.awt.MenuComponent.dispatchEventImpl(MenuComponent.java:351)
at java.awt.MenuComponent.dispatchEvent(MenuComponent.java:339)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:738)
at java.awt.EventQueue.access$200(EventQueue.java:103)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:692)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
at java.awt.EventQueue$4.run(EventQueue.java:708)
at java.awt.EventQueue$4.run(EventQueue.java:706)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
Related
Bugs: #9
So not fixing as I think this is a usage issue, not an actual bug
This now works, but wonder why there were characters that could not be parsed. Were these in the original BioModel or added through the transfer.
Related
Bugs: #9
OK, I could reproduce the error in the sense that XML couldn't be parsed. . Looks like some characters weren't valid XML so have added some code to strip them out, let me know if it works now for you reading into jsbml
Don't know - the URL is different from that resolved from the URN - which is http://www.ebi.ac.uk/biomodels-main/download?mid=BIOMD0000000012
which is perhaps the official download site.
But marking this as fixed