@geneontology/dbxrefs
Advanced tools
Comparing version 1.0.9 to 1.0.10
const axios = require('axios'); | ||
const yaml = require('js-yaml'); | ||
let URL = "https://raw.githubusercontent.com/geneontology/go-site/09eb2dbdc4c71565528a2802d0591ba6b8f45fcc/metadata/db-xrefs.yaml" | ||
// let URL = "https://raw.githubusercontent.com/geneontology/go-site/09eb2dbdc4c71565528a2802d0591ba6b8f45fcc/metadata/db-xrefs.yaml" | ||
let URL = "http://current.geneontology.org/metadata/db-xrefs.yaml"; | ||
@@ -19,9 +20,5 @@ let dbxrefs; | ||
function getURL(database, entityType, id) { | ||
if(database == "FlyBase") database = "FB"; // This is required as for instance the GO API Autocomplete / search return ids like FlyBase:FBgn0032821 | ||
let db = dbxrefs.filter(elt => (elt.database.toLowerCase() == database.toLowerCase()) || (elt.synonyms && elt.synonyms.includes(database)) ); | ||
if(!db || db.length == 0) { console.log("database " , database , " not found"); return undefined; } | ||
if(database == "WormBase") database = "WB"; // This is required as for instance the GO API Autocomplete / search return ids like WormBase:WBGene00000409 | ||
let db = dbxrefs.filter(elt => elt.database.toLowerCase() == database.toLowerCase()); | ||
if(!db) { console.log("database " , database , " not found"); return undefined; } | ||
let entity; | ||
@@ -35,4 +32,5 @@ if(entityType) { | ||
let url = entity[0].url_syntax.replace("[example_id]", ""); | ||
return url + id; | ||
entity = entity[0]; | ||
let url = entity.url_syntax.replace("[example_id]", id); | ||
return url; | ||
} | ||
@@ -59,2 +57,3 @@ | ||
dbError = false; | ||
return dbxrefs; | ||
}) | ||
@@ -65,4 +64,4 @@ .catch(error => { | ||
dbError = true; | ||
return undefined | ||
}) | ||
return dbxrefs; | ||
} | ||
@@ -73,2 +72,13 @@ | ||
init, getURL, isReady, hasError, getDBXrefs | ||
} | ||
} | ||
// For testing | ||
// init() | ||
// .then(() => { | ||
// // console.log(getURL("GO_REF", undefined, "0000037")); | ||
// // console.log(getURL("PAINT_REF", undefined, "24356")); | ||
// // console.log(getURL("FlyBase", undefined, "FBgn0032821")) | ||
// // console.log(getURL("WormBase", undefined, "WBGene00000409")); | ||
// console.log(getURL("NCBITaxon", undefined, "6239")); | ||
// }) |
{ | ||
"name": "@geneontology/dbxrefs", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "basic library to resolve link outs from database name and ID", | ||
@@ -5,0 +5,0 @@ "main": "go-dbxrefs.js", |
2572
62