-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enrich antibody with external data from SciCrunch database
- Loading branch information
Showing
4 changed files
with
129 additions
and
1 deletion.
There are no files selected for viewing
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
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,16 @@ | ||
SELECT DISTINCT ?entity | ||
WHERE { | ||
{ | ||
SELECT (?s AS ?entity) WHERE { | ||
?s ?p ?o . | ||
FILTER(STRSTARTS(STR(?s),"http://identifiers.org/rrid/RRID:")) | ||
} | ||
} | ||
UNION | ||
{ | ||
SELECT (?o AS ?entity) WHERE { | ||
?s ?p ?o . | ||
FILTER(STRSTARTS(STR(?o),"http://identifiers.org/rrid/RRID:")) | ||
} | ||
} | ||
} |
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,38 @@ | ||
import { writeFileSync } from 'fs'; | ||
import { graph, sym, lit, serialize } from 'rdflib'; | ||
|
||
|
||
export function RdfBuilder(iri) { | ||
const store = graph(); | ||
store.add( | ||
sym(iri), | ||
sym("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), | ||
sym("http://www.w3.org/2002/07/owl#Ontology")); | ||
|
||
this.add = function (subject, predicate, object) { | ||
if (subject && predicate && object) { | ||
store.add(subject, predicate, object); | ||
} | ||
return this; | ||
} | ||
|
||
this.build = function () { | ||
return serialize(null, store, null, null, (err, result) => { | ||
return result; | ||
}) | ||
} | ||
|
||
this.save = function(filePath) { | ||
serialize(null, store, null, null, (err, result) => { | ||
writeFileSync(filePath, result); | ||
}) | ||
} | ||
} | ||
|
||
export function iri(text) { | ||
return sym(text); | ||
} | ||
|
||
export function literal(text) { | ||
return lit(text); | ||
} |
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,40 @@ | ||
import fetch from 'node-fetch'; | ||
|
||
const API_BASE = "https://api.scicrunch.io/elastic/v1"; | ||
const ANTIBODY_INDEX = "RIN_Antibody_pr"; | ||
const TOOL_INDEX = "RIN_Tool_pr"; | ||
|
||
export function retrieveAntibody(rrids) { | ||
const url = `${API_BASE}/${ANTIBODY_INDEX}/_search`; | ||
const options = { | ||
method: "POST", | ||
headers: { | ||
'Content-Type': "application/json", | ||
apikey: process.env.SCICRUNCH_API_KEY | ||
}, | ||
body: JSON.stringify(createQuery(rrids)) | ||
}; | ||
return fetch(url, options).then((response) => { | ||
return response.json().then((data) => { | ||
return data.hits.hits; | ||
}); | ||
}).catch((err) => { console.log(err); }); | ||
} | ||
|
||
function createQuery(rrids) { | ||
return { | ||
size: 1000, | ||
query: { | ||
terms: { | ||
"rrid.curie": rrids | ||
} | ||
}, | ||
"_source": { | ||
includes: [ | ||
"item.identifier", | ||
"item.name", | ||
"item.description" | ||
] | ||
} | ||
} | ||
} |