sdsc-ordes / modos-api

Python API to manage multi-omics digital objects
https://sdsc-ordes.github.io/modos-api
Apache License 2.0
0 stars 0 forks source link

fix: consistent ids #70

Closed almutlue closed 2 months ago

almutlue commented 2 months ago

Aim:

Use consistent ids across modos-api.

Changes:

almutlue commented 2 months ago

The changes look good overall, but could it be that there is an issue with the / changes?

When running modos publish data/ex, URI objects in the graph are missing a slash:

<file://ex/data/demo1> a modos:DataEntity ;
    schema1:description "Dummy data for tests" ;
    schema1:name "Demo 1" ;
    modos:data_format EDAM:format_3462 ;
    modos:data_path "file://exdemo1.cram" ;
    modos:has_reference <file://exreference1> ;
    modos:has_sample <file://exsample1> .
[...]

Note that this also happens when explicitely specifying a base URI:

$ modos publish --base-uri http://example.org/ data/ex
<http://example.org//assay/assay1> a modos:Assay ;
    schema1:description "Dummy assay for tests." ;
    schema1:name "Assay 1" ;
    modos:has_data <http://example.org/data/calls1>,
        <http://example.org/demo1> ;
    modos:has_sample <http://example.org/sample1> ;
    modos:omics_type NCIT:C84343 .
[...]

I However, I think the issue here is that there is an extraneous slash in the subject (not missing in the object):

* afaik, a prefix should always end in # or /

* when expanding with base-uri, we just do prefix+id

That is a very good point @cmdoret! I think this is a mix of problems:

  1. If the prefix ends with / and our long ids start with / (e.g. /sample/sample1), prefix+id will have // as in:

    http://example.org//assay/assay1> a modos:Assay ;

    Because of this I had removed the / from the default prefix in modo.knowledgegraph. But as you pointed out this causes inconsistencies with the modo itself, which has an id without starting / and is bad practice for the prefix itself. So ids without a starting / would be more coherent with modos publish/modo.knowledge_graph()? I could update everything to long_ids = element_type/short_id? What do you think?

  2. I think the inconsistencies with objects and subjects in modos publish data/ex are partly caused by not updated has_part attributes in data/ex. I will update data/ex once we decided for long ids with or without starting /

cmdoret commented 2 months ago

Thanks for clarifying! Based on these findings, I agree that ids should not start with /: the separator between prefix and ID is normally defined as part of the prefix.

almutlue commented 2 months ago

I hope this should be fine now! Last changes:

modos publish should work as expected now:


modos publish data/ex
@prefix EDAM: <http://edamontology.org/> .
@prefix NCIT: <http://purl.obolibrary.org/obo/NCIT_> .
@prefix modos: <https://w3id.org/sdsc-ordes/modos-schema/> .
@prefix schema1: <http://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<file://ex/ex> a modos:MODO ;
    schema1:description "Dummy modo for tests." ;
    schema1:name "Example MODO" ;
    modos:creation_date "2024-02-19T00:00:00"^^xsd:dateTime ;
    modos:has_assay <file://ex/assay/assay1> ;
    modos:last_update_date "2024-02-19T00:00:00"^^xsd:dateTime ;
    modos:source_uri "http://example.org/ex"^^xsd:anyURI .

<file://ex/assay/assay1> a modos:Assay ;
    schema1:description "Dummy assay for tests." ;
    schema1:name "Assay 1" ;
    modos:has_data <file://ex/data/calls1>,
        <file://ex/data/demo1> ;
    modos:has_sample <file://ex/sample/sample1> ;
    modos:omics_type NCIT:C84343 .
...
``