diff --git a/src/webcomponents/variant/variant-browser-grid.js b/src/webcomponents/variant/variant-browser-grid.js index 71c06c42c..af891f943 100644 --- a/src/webcomponents/variant/variant-browser-grid.js +++ b/src/webcomponents/variant/variant-browser-grid.js @@ -211,7 +211,32 @@ export default class VariantBrowserGrid extends LitElement { // summary: !this.query.sample && !this.query.family, ...this.query }; - + // TASK-5791: Temporary SNP ID Search fix + if (this.query.xref) { + const snpIds = this.query.xref.split(",").filter(xref => xref.startsWith("rs")); + if (snpIds.length > 0) { + const snpRegion = []; + const request = new XMLHttpRequest(); + for (const snpId of snpIds) { + const url = `https://rest.ensembl.org/variation/human/${snpId}?content-type=application/json`; + + request.onload = event => { + if (request.status === 200) { + const restObject = JSON.parse(event.currentTarget.response); + const mapping = restObject.mappings?.find(m => m.assembly_name === "GRCh38"); + snpRegion.push(mapping.seq_region_name + ":" + mapping.start); + } + }; + request.open("GET", url, false); + request.send(); + } + if (this.filters.region) { + this.filters.region += "," + snpRegion.join(","); + } else { + this.filters.region = snpRegion.join(","); + } + } + } let variantResponse = null; this.opencgaSession.opencgaClient.variants().query(this.filters) .then(res => {