Open aram148 opened 3 years ago
bqbiol:hasTaxon taxon:9895
(using the namespace as is being defined in the annotation file/graph)
Do you have a code example that demonstrates where libOmexMeta uses long form where it should use short? This can be used as the basis of a new test.
from pyomexmeta import RDF, Editor
import tellurium as te
r = te.loada("""
R1: S1 => S2; k1*S1;
R2: S2 => S2; k2*S2
k1 = 0.1;
k2 = 0.3
S1 = 5;
S1 = 3
""")
sbml = r.getSBML()
rdf = RDF()
editor = rdf.to_editor(sbml, True, False)
editor.add_taxon("9896")
print(rdf)
produces
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix bqbiol: <http://biomodels.net/biology-qualifiers/> .
@prefix NCBI_Taxon: <https://identifiers.org/taxonomy:> .
@prefix OMEXlib: <http://omex-library.org/> .
@prefix local: <http://omex-library.org/NewOmex.omex/NewModel.rdf#> .
<http://omex-library.org/NewOmex.omex/NewModel.xml>
bqbiol:hasTaxon <https://identifiers.org/taxonomy:9896> .
Where it should produce
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix bqbiol: <http://biomodels.net/biology-qualifiers/> .
@prefix NCBI_Taxon: <https://identifiers.org/taxonomy:> .
@prefix OMEXlib: <http://omex-library.org/> .
@prefix local: <http://omex-library.org/NewOmex.omex/NewModel.rdf#> .
<http://omex-library.org/NewOmex.omex/NewModel.xml>
bqbiol:hasTaxon NCBI_Taxon:9896 .
This appears to be a bug, as it should already be using the NCBI_Taxon prefix.
@nickerso @jhgennari @maxneal @hsauro Okay, so whether this is a bug in the redland libraries or a bug in the spec, I don't know; but its seems that prefixes do not get used in Turtle syntax if the subsequent uri portion begins with a number.
For example, the following code works as expected. I've used the low level libOmexMeta interface for directly creating nodes, triples and adding a namespace:
LibrdfNode subject = LibrdfNode::fromUriString("http://omex-library.org/NewOmex.omex/NewModel.xml#model0000");
LibrdfNode predicate = LibrdfNode::fromUriString("http://biomodels.net/biology-qualifiers/hasTaxon");
LibrdfNode resource = LibrdfNode::fromUriString("https://identifiers.org/taxonomy:AnIdThatDoesNotStartWithANumber"); // <-- important line
RDF rdf;
Editor editor = rdf.toEditor(SBMLFactory::getSBML(SBML_NOT_ANNOTATED2), true, false); // arbitrary sbml model, contents not relevant here.
SingularAnnotation singularAnnotation = editor.newSingularAnnotation();
singularAnnotation.setSubject(subject.getWithoutIncrement()); // get* returns a raw librdf_node* pointer. No reference counter incremented
singularAnnotation.setPredicate(predicate.getWithoutIncrement());/ get* returns a raw librdf_node* pointer. No reference counter incremented
singularAnnotation.setResource(resource.getWithoutIncrement());/ get* returns a raw librdf_node* pointer. No reference counter incremented
editor.addSingleAnnotation(singularAnnotation);
editor.addNamespace("https://identifiers.org/taxonomy:", "NCBI_Taxon"); // Manually add the namespace
std::cout << rdf.toString("turtle") << std::endl;
As we expect, this will output:
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix bqbiol: <http://biomodels.net/biology-qualifiers/> .
@prefix NCBI_Taxon: <https://identifiers.org/taxonomy:> .
@prefix OMEXlib: <http://omex-library.org/> .
@prefix local: <http://omex-library.org/NewOmex.omex/NewModel.rdf#> .
<http://omex-library.org/NewOmex.omex/NewModel.xml#model0000>
bqbiol:hasTaxon NCBI_Taxon:AnIdThatDoesNotStartWithANumber .
But if we instead use a number, i.e. an actual taxon id:
LibrdfNode subject = LibrdfNode::fromUriString("http://omex-library.org/NewOmex.omex/NewModel.xml#model0000");
LibrdfNode predicate = LibrdfNode::fromUriString("http://biomodels.net/biology-qualifiers/hasTaxon");
LibrdfNode resource = LibrdfNode::fromUriString("https://identifiers.org/taxonomy:9696");
RDF rdf;
Editor editor = rdf.toEditor(SBMLFactory::getSBML(SBML_NOT_ANNOTATED2), true, false);
SingularAnnotation singularAnnotation = editor.newSingularAnnotation();
singularAnnotation.setSubject(subject.getWithoutIncrement());
singularAnnotation.setPredicate(predicate.getWithoutIncrement());
singularAnnotation.setResource(resource.getWithoutIncrement());
editor.addSingleAnnotation(singularAnnotation);
editor.addNamespace("https://identifiers.org/taxonomy:", "NCBI_Taxon");
std::cout << rdf.toString("turtle") << std::endl;
we get
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix bqbiol: <http://biomodels.net/biology-qualifiers/> .
@prefix NCBI_Taxon: <https://identifiers.org/taxonomy:> .
@prefix OMEXlib: <http://omex-library.org/> .
@prefix local: <http://omex-library.org/NewOmex.omex/NewModel.rdf#> .
<http://omex-library.org/NewOmex.omex/NewModel.xml#model0000>
bqbiol:hasTaxon <https://identifiers.org/taxonomy:9696> .
In the past, there was a mistake in the spec regarding the prefix for "myOmexLib" and I spent a lot of effort trying to figure out why we couldn't get the turtle serializer to use the prefix, when the actual problem was that we had a subtle syntax error in the spec.
So, is this a bug in the redland libraries or a bug in the spec? If its a problem with the redland libraries, it may be possible for me to go digging around in the C
code but this could be a can of worms.
Begin PR #61 for this issue
@CiaranWelsh - this is sounding like a non-urgent issue and we can stick with the full URI version of the taxon annotations for now. And then loop back to this one in future.
Suggested that compact forms be used where possible. For example:
bqbiol:hasTaxon https://identifiers.org/taxonomy:9895 ;
should be
bqbiol:hasTaxon 9895 or something similar