Skip to content

Commit

Permalink
Merge pull request #886 from opencb/TASK-5867
Browse files Browse the repository at this point in the history
TASK-5867 - Port Patch 1.10.3.1 -> 2.1.0
  • Loading branch information
jmjuanes authored Mar 21, 2024
2 parents 4e9dd48 + 4a231e3 commit 7439a36
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/webcomponents/variant/variant-browser-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit 7439a36

Please sign in to comment.