SynBioDex / pySBOL2

A pure Python implementation of the SBOL standard.
Apache License 2.0
20 stars 6 forks source link

SBOL Output as XML #400

Closed JMante1 closed 3 years ago

JMante1 commented 3 years ago

I am having trouble as the same steps to create an sbol document won't necessarily output the same document literally, so I am not sure how to compare two documents and check they are the same. This might also be easier if output to json serilialisation rather than xml serialisation of sbol was possible.

jakebeal commented 3 years ago

These are both issues that are addressed by the upgrade from SBOL2 to SBOL3. There is no JSON serialization defined for SBOL 2 --- it is only RDF/XML, and the non-guarantee of ordering is also inherent to the serialization. The only way to reliably test for semantic equality between two SBOL documents is to load them into member as SBOL objects and compare those objects.

If you are able to shift from SBOL2 to SBOL3, then there is both a JSON serialization (although this cannot guarantee ordering) and a guaranteed order serialization in the form of sorted N-triples.

tcmitchell commented 3 years ago

Hi @JMante1 , as @jakebeal points out, there isn't a way to do what you're asking directly. SBOL2 has no JSON serialization and RDF-XML has no inherent ordering or canonicalization. The pySBOL2 unit tests work around this in the round trip testing by loading the files into rdflib (not SBOL) and comparing the resulting graphs. If the graphs are the same then the files are considered the same even though there might be textual differences between the files.

See https://github.com/SynBioDex/pySBOL2/blob/master/test/test_roundtrip.py#L53-L71 for the comparison of two different files using rdflib's ability to compare graphs.

SBOL3 allows serialization in any RDF format. pySBOL3 defines an ordered ntriples format so that SBOL3 documents can be serialized in an ordered way and thus compared textually. This is the only RDF serialization format that would allow textual comparison that I am aware of.

JMante1 commented 3 years ago

Hi @tcmitchell, thank yo the rdflib code was very helpful. I didn't need an exact text match just a graph match. Do you know when the pySBOL3 will be at a point that I could substitute that into my project? Will pySBOL3 also maintain the ability to output pySBOL2 if/as needed?

tcmitchell commented 3 years ago

Do you know when the pySBOL3 will be at a point that I could substitute that into my project?

It depends on what features you need. Several projects (sbol_factory, opil, paml, and intent parser) have been using pySBOL3 for several months and have helped to shake out bugs. It is worth trying it out and letting us know if you have problems or if features you need are not yet implemented.

Will pySBOL3 also maintain the ability to output pySBOL2 if/as needed?

This is the first issue we opened on the pySBOL3 repository. We'd like to use a shared resource to do the translation so that the various SBOL3 libraries can share a single common implementation if they don't want to reinvent the wheel. The JavaScript library has a nascent capability but development ebbs and flows so we don't know when or if that path will lead to a shared translator. If this is a requirement of your project it might make a good area for contributions to an SBOL3 library of your choosing or for cajoling the JavaScript implementation along by taking it for a test drive. @udp had suggested at one point that the JavaScript implementation could theoretically be set up as a web service for translating between SBOL2 and SBOL3.

tcmitchell commented 3 years ago

@JMante1 have you had a chance to give pySBOL3 with your project? Is there anything we can do to help with that?

tcmitchell commented 3 years ago

@JMante1 It's been two weeks since we've heard from you on this. I'm going to assume that you are doing well with your work. If you need additional help, feel free to reopen this issue or to open new issues at pySBOL3.