Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.sbml.jsbml.xml.XMLNode cannot be cast to org.sbml.jsbml.Annotation #264

Open
ntung opened this issue Dec 10, 2024 · 7 comments
Open

Comments

@ntung
Copy link

ntung commented Dec 10, 2024

Dear The JSBML Developers Team,

BioModels has some curated models with the issue. These models were curated for a while but they run into this problem. The problem broke down our index pipeline. Would you be able to escalate the problem?
BIOMD0000000596, BIOMD0000000794, BIOMD0000000849, BIOMD0000000925, BIOMD0000000965.

java.lang.ClassCastException: org.sbml.jsbml.xml.XMLNode cannot be cast to org.sbml.jsbml.Annotation
	at org.sbml.jsbml.xml.stax.SBMLReader.readXMLFromXMLEventReader(SBMLReader.java:851)
	at org.sbml.jsbml.xml.stax.SBMLReader.readSBMLFromStream(SBMLReader.java:554)
	at org.sbml.jsbml.xml.stax.SBMLReader.readSBMLFromStream(SBMLReader.java:564)
	at org.sbml.jsbml.SBMLReader.readSBMLFromStream(SBMLReader.java:251)
	at org.sbml.jsbml.SBMLReader$readSBMLFromStream.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:128)
	at net.biomodels.jummp.indexing.indexer.SBMLIndexer.extractFileContent(SBMLIndexer.groovy:129)

I have seen another user reporting the problem at #263.

@Schmoho
Copy link

Schmoho commented Dec 11, 2024

Hi! I am not a JSBML dev, but I looked into your issue because I am also encountering it.

The model annotation (on the <model> element) of this file is invalid SBML, because the layout-information is within the annotation object. This looks like an error (not adherent to the layout-package spec) likely introduced by COPASI. Moving the <layout:listOfLayouts> tag out of the <annotation> tag "solves" the issue apparently.

However, I would still consider this a bug in JSBML; at the very least, this should have a more informative error message.

@Schmoho
Copy link

Schmoho commented Dec 11, 2024

I just realized, the SBML is not actually invalid:

  1. SBML 2.4 did not know packages, so the use of the <layout:listOfLayouts> container on the <model> level would not actually be valid and that also means that the layout information in this model is not actually subject to the SBML layout-package spec.
  2. The SBML spec does not seem to actually specify that an annotation cannot contain another annotation, so JSBML expecting this is divergent from the spec.

@fbergmann
Copy link
Member

Layout and render specify precisely how to deal with it in case of SBML Level 2 documents:

https://raw.githubusercontent.com/combine-org/combine-specifications/main/specifications/files/sbml.level-3.version-1.layout.version-1.release-1.pdf

The file has been modified after being exported by COPASI. The layout element is in the wrong namespace. I can attach a valid l2v4 and l3v1 example.
LeBeau1999_Phosphorylation_CCK.xml.l2v4.txt
LeBeau1999_Phosphorylation_CCK_l3v1.xml.l3v1.txt

@Schmoho
Copy link

Schmoho commented Dec 11, 2024

I see.
As far as I understand it though, this doesn't change that the SBML is valid in principle (because you can put arbitrary stuff in an annotation), which kind of raises the question if the way JSBML fails on this is not needlessly confusing for a user that is not familiar with the specs.

Also the models that are affected range from 2015 to 2019 and across a number of working groups - this strongly suggests to me that some software agent and not manual manipulation is responsible for this.

@fbergmann
Copy link
Member

Indeed and regardless how those files came to be, JSBML should log it as error but still proceed with the parsing of the files. It would be simple enough to check the type before the cast.

@ntung
Copy link
Author

ntung commented Dec 11, 2024

Thank you @Schmoho for pointing out the actual root cause. It seems that we can update SBML documents to sort the problem out. I completely agree with @fbergmann in term of developer's perspective.

@ntung
Copy link
Author

ntung commented Dec 17, 2024

Indeed and regardless how those files came to be, JSBML should log it as error but still proceed with the parsing of the files. It would be simple enough to check the type before the cast.

@fbergmann Could you suggest a feasible solution to fix it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants