-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from zhlu9890/develop
add ontology_get_term_by_name query
- Loading branch information
Showing
2 changed files
with
430 additions
and
0 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
spec/stored_queries/ontology/ontology_get_term_by_name.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Get ontology term by searching name | ||
|
||
name: ontology_get_term_by_name | ||
params: | ||
type: object | ||
required: [name, ts, "@onto_terms", "@onto_edges"] | ||
properties: | ||
name: | ||
type: string | ||
title: Ontology term's name | ||
description: Name of the Ontology term you want to get | ||
examples: ["terrestrial biome"] | ||
ancestor_term: | ||
type: string | ||
title: Ancestor ontology term | ||
description: Optional ancestor ontology term | ||
examples: ["ENVO:00000428"] | ||
ts: | ||
type: integer | ||
title: Versioning timestamp | ||
"@onto_terms": | ||
type: string | ||
title: Ontology terms collection name | ||
examples: ["ENVO_terms"] | ||
"@onto_edges": | ||
type: string | ||
title: Ontology edges collection name | ||
examples: ["ENVO_edges"] | ||
query_prefix: WITH @@onto_terms | ||
query: | | ||
LET ancestor_term_null=IS_NULL(@ancestor_term) OR LENGTH(@ancestor_term) == 0 | ||
FOR t in @@onto_terms | ||
FILTER LOWER(t.name) == LOWER(@name) | ||
FILTER t.created <= @ts AND t.expired >= @ts | ||
limit 1 | ||
FOR v, e, p IN 1..100 OUTBOUND t @@onto_edges | ||
FILTER ancestor_term_null OR v.id == @ancestor_term | ||
FILTER p.edges[*].created ALL <= @ts | ||
AND p.edges[*].expired ALL >= @ts | ||
AND p.edges[*].type ALL == "is_a" | ||
RETURN DISTINCT t |
Oops, something went wrong.