Skip to content

Commit

Permalink
Jim's improved query for models/gp w/ grouping handled in API. For #2
Browse files Browse the repository at this point in the history
  • Loading branch information
dustine32 committed Jan 5, 2022
1 parent 3f2e995 commit 5fe0a4b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
6 changes: 5 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ app.get('/models/gp', function(req, res) {
gocams = utils.splitTrim(gocams, ",", "<http://model.geneontology.org/", ">");
utils.fetchAndSend(res, sparqlModels.ModelsGPs(gocams), false, keysArrayGPs);
} else {
utils.fetchAndSend(res, sparqlModels.AllModelsGPs(), false, keysArrayGPs);
// Must combine the results per gocam
utils.fetchData(sparqlModels.AllModelsGPs(), keysArrayGPs, (error, data) => {
utils.addCORS(res);
res.send(utils.mergeResults(data, "gocam"));
});
}
});

Expand Down
24 changes: 12 additions & 12 deletions queries/sparql-models.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,32 +262,32 @@ module.exports = {
AllModelsGPs() {
// Transform the array in string
var encoded = encodeURIComponent(`
PREFIX prov: <http://www.w3.org/ns/prov#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX metago: <http://model.geneontology.org/>
PREFIX enabled_by: <http://purl.obolibrary.org/obo/RO_0002333>
PREFIX in_taxon: <http://purl.obolibrary.org/obo/RO_0002162>
SELECT ?gocam (GROUP_CONCAT(distinct ?identifier;separator="` + separator + `") as ?gpids)
(GROUP_CONCAT(distinct ?name;separator="` + separator + `") as ?gpnames)
SELECT DISTINCT ?gocam ?gpids ?gpnames
WHERE
{
GRAPH ?gocam {
?gocam metago:graphType metago:noctuaCam .
}
FILTER NOT EXISTS {
?gocam prov:wasDerivedFrom ?asserted_cam .
}
GRAPH ?gocam {
?s enabled_by: ?gpnode .
?gpnode rdf:type ?identifier .
FILTER(?identifier != owl:NamedIndividual) .
FILTER(!contains(str(?gocam), "_inferred"))
?gpnode rdf:type ?gpids .
FILTER(?gpids != owl:NamedIndividual) .
}
optional {
?identifier rdfs:label ?name
OPTIONAL {
?gpids rdfs:label ?label
}
BIND(IF(bound(?name), ?name, ?identifier) as ?name)
BIND(COALESCE(?label, ?gpids) AS ?gpnames)
}
GROUP BY ?gocam
`);
return "?query=" + encoded;
},
Expand Down

0 comments on commit 5fe0a4b

Please sign in to comment.