sys-bio / libOmexMeta

libOmexMeta is a library aimed at providing developer-level support for reading, writing, editing and managing semantic annotations for biosimulation models.
https://sys-bio.github.io/libOmexMeta/
Apache License 2.0
8 stars 6 forks source link

Discussion on local and model uri user interface #53

Closed jhgennari closed 3 years ago

jhgennari commented 3 years ago

I've just noticed the libOmexMeta always uses exactly the same local definition, regardless of model file name:

@prefix local: http://omex-library.org/NewOmex.omex/NewModel.rdf# .

Instead, this should be dependent on the name of the model. In the above, the model might be named "NewModel.cellml" or "NewModel.xml". However, if you are reading from a file called "BIOM0000382.xml", then the path should be

@prefix local: http://omex-library.org/BIOM0000382.omex/BIOM0000382.rdf# .

I'm not exactly sure what to do if you are dynamically creating a new model, but there should always be some indication of the model name. Unfortunately, the sbml tag usually has a much longer name than is appropriate for filenames, so I don't think that works.

But at least there's an easy fix for the case where you are doing a call to RDF.from_file()

jhgennari commented 3 years ago

Ah wait a second. David N pointed out that there are methods such as setModelURI() for RDF objects, so that we can set the model and annotation file names correctly. We still definitely need to test this with BioModels files, so that they get the right URIs.

CiaranWelsh commented 3 years ago

Yes that's right. I remember mulling over this problem when designing the API.

What we actually have here is a design choice. A problem I wrestled with for a while was what to use for the model / local uri by default. When reading from a file with RDF.from_file(...), we could just use the filename. But then, what should be the behaviour when adding to the graph with rdf_graph.add_from_file(...)? We could equally use the model name, extracted from the sbml. But how does this work with CellML, or another language that we want to support in future? Also, the model name can have spaces or non ascii characters which will almost definitely cause problems *somewhere down the line. In the end I chose to have a one size fits all default model/local uri and let users choose the defaults for the tools they are implementing (remembering of course our main user base will be embedded within other tools).

This behaviour is of course customizable, so whatever you guys want here we can have. (Side note: the only way to unambiguously describe the behaviour is to write code). The current behaviour is the following:

In [18]: import pyomexmeta as pyo
In [19]: rdf = pyo.RDF.from_file("BIOMD0000000385.xml", "rdfxml")
In [20]: rdf.get_local_uri()
Out[20]: 'http://omex-library.org/NewOmex.omex/NewModel.rdf#' 

In [21]: rdf.set_archive_uri("cheese")
In [22]: rdf.get_archive_uri()
Out[23]: 'http://omex-library.org/cheese/'
In [24]: rdf.get_local_uri()
Out[24]: 'http://omex-library.org/cheese/NewModel.rdf#'

In [25]: rdf.set_model_uri("chedder")
In [26]: rdf.get_model_uri()
Out[26]: 'http://omex-library.org/cheese/chedder.xml#'
In [27]: rdf.get_local_uri()
Out[27]: 'http://omex-library.org/cheese/chedder.rdf#'

Notice, that there is currently no rdf.set_local_uri(), it is instead linked to the model uri. This is because of the link that is implicit between an xml and its corresponding rdf file. With no rdf.set_local_uri the user cannot inadvertently break this link.

CiaranWelsh commented 3 years ago

Closing since this issue has gone stale. Feel free to reopen.