Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK-5791 - Implement SNP search by rsID #879

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/webcomponents/variant/variant-browser-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,34 @@ 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(",");
}
}
}

this.opencgaSession.opencgaClient.variants().query(this.filters)
.then(res => {
// FIXME A quick temporary fix -> TASK-947
Expand Down
Loading