How to report path length?

I would like to determine how semantically specific a MonDO disease is, using the distance from the disease root as a proxy.

Right now I'm doing

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX mydata: <http://example.com/resource/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
select *
where {
    graph <http://purl.obolibrary.org/obo/mondo.owl> {
        ?mid 
            a owl:Class ;
            rdfs:subClassOf+ <http://purl.obolibrary.org/obo/MONDO_0000001> .
        ?leaf 
            rdfs:subClassOf* ?mid .
        filter(isuri(?mid))
    }
}

But the results look funny to me, like the number of ?mids could be the sum over multiple different (not necessarily shortest) paths.

I'd like to try the Stardog path notation, but I feel like I have seen at least two styles:

from https://www.stardog.com/docs/#_path_queries

PATHS START ?x = :Alice END ?y = :Charlie VIA ?p

from https://www.stardog.com/blog/a-path-of-our-own/

PATH ?p FROM ([startNode AS] ?s) TO ([endNode AS] ?e) {
   GRAPH PATTERN
}
[ORDER BY condition]
[LIMIT int]

Are both of these still functional?

Can either be used to report the lenght of the shortest path?

Hey Mark,

The syntax from the documentation is the supported syntax. The blog post was an initial version which was refined in the final design.

Regarding the path lengths, you can do this in the API with the Path result instances in the PathQueryResult. The size of the edges sequence is the length of the path.

Jess

Thanks. Does that mean I would have to write something in a JVM language to access it? Is there a REST API?

You will have to write a little bit of code to piece the paths back together. The general format is described in the thread PATHS queries via HTTP API?.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.