-
Notifications
You must be signed in to change notification settings - Fork 1
/
URLBuilder.js
98 lines (86 loc) · 3.34 KB
/
URLBuilder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/**
* This class is used to create 2 different types of URLs:
* (1) Navigation URLs, where the result is a URL to a specific web page.
* (2) REST URLs, where the result is the URL for a specific REST endpoint.
*/
class URLBuilder {
constructor() {
this.navUrlMap = new Map([
["biocarta", "https://cgap.nci.nih.gov/Pathways/BioCarta/"],
["clinicaltrials", "https://clinicaltrials.gov/ct2/show/"],
["ensembl", "http://www.ensembl.org/id/"],
["entrezgene", "http://www.ncbi.nlm.nih.gov/gene/"],
["go", "http://amigo.geneontology.org/amigo/search/annotation?q="],
[
"hgnc",
"http://www.genenames.org/cgi-bin/gene_symbol_report?hgnc_id=HGNC:"
],
[
"humancyc",
"https://humancyc.org/HUMAN/NEW-IMAGE?type=NIL&redirect=T&object="
][("kegg", "http://www.genome.jp/kegg-bin/show_pathway?")],
["interpro", "https://www.ebi.ac.uk/interpro/entry/"],
["netpath", "http://www.netpath.org/pathways?path_id="],
["omim", "http://omim.org/entry/"],
["pfam", "https://pfam.xfam.org/family/"],
["pharmgkb", "https://www.pharmgkb.org/gene/"],
[
"pid",
"http://www.ndexbio.org/#/search?searchType=All&searchString=labels:"
],
["pir", "https://pir.georgetown.edu/cgi-bin/ipcEntry?id="],
["pubmed", "http://www.ncbi.nlm.nih.gov/pubmed/"],
["reactome", "http://www.reactome.org/content/query?cluster=true&q="],
[
"unigene",
"https://www.ncbi.nlm.nih.gov/UniGene/clust.cgi?UGID=720192&TAXID=9606&SEARCH="
],
["uniprot", "http://www.uniprot.org/uniprot/"],
["wikipedia", "https://en.wikipedia.org/wiki/"],
["wikipathways", "http://www.wikipathways.org/index.php/Pathway:"]
]);
this.restUrlMap = new Map([
[
"pubmed",
"https://www.ebi.ac.uk/europepmc/webservices/rest/search?format=json&resulttype=core&query=+src:med+ext_id:"
],
[
"mygene",
"https://mygene.info/v3/query?fields=entrezgene,name,alias,symbol,summary,hgnc,MIM,go,interpro,pathway,pdb,pfam,pharmgkb,pir,refseq,uniprot&species=human&q=symbol:"
]
]);
}
/**
* This method builds a URL for a specified database, and a given ID.
* @param {String} databaseName The name of the database whose URL you want to retrieve
* @param {String} id The ID of the record you want to retrieve
*/
buildNavUrl(databaseName, id) {
return this.__buildUrl(this.navUrlMap, databaseName, id);
}
/**
* This method builds a URL for a specific database, and a given ID. The result is a URL
* suitable for use in a REST call.
* @param {String} databaseName The name of the database whose URL you want to retrieve
* @param {String} id The ID of the record you want to retrieve
*/
buildRestUrl(databaseName, id) {
return this.__buildUrl(this.restUrlMap, databaseName, id);
}
/**
* This method builds a URL.
* @param {Map} map The map whose keys are database names, and whose values are URLs
* @param {String} databaseName The name of the database
* @param {String} id The ID of the record you want to retrieve
*/
__buildUrl(map, databaseName, id) {
let url = map.get(databaseName);
let newUrl = "";
if (url) {
newUrl = url + id;
} else {
throw "Unable to find URL for database: " + databaseName;
}
return newUrl;
}
}