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-7205 - Variant Browser infinite loop when using Cellbase v4 #1005

Merged
merged 2 commits into from
Dec 17, 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
56 changes: 1 addition & 55 deletions src/webcomponents/variant/variant-browser-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,61 +238,7 @@ export default class VariantBrowserGrid extends LitElement {

this.opencgaSession.opencgaClient.variants()
.query(this.filters)
.then(res => {
// FIXME A quick temporary fix -> TASK-947
if (this.opencgaSession?.project?.cellbase?.version === "v4" || this.opencgaSession?.project?.internal?.cellbase?.version === "v4") {
let found = false;
const variants = res.responses[0].results;
for (const variant of variants) {
for (const ct of variant.annotation.consequenceTypes) {
if (ct.transcriptFlags || ct.transcriptAnnotationFlags) {
found = true;
break;
}
}
}

if (!found) {
this.cellbaseClient = new CellBaseClient({
host: this.opencgaSession?.project?.cellbase?.url || this.opencgaSession?.project?.internal?.cellbase?.url,
// host: "https://ws.opencb.org/cellbase-4.8.2",
version: "v4",
species: "hsapiens",
});
const variantIds = variants.map(v => v.id);
this.cellbaseClient.get("genomic", "variant", variantIds.join(","), "annotation", {
assembly: this.opencgaSession.project.organism.assembly,
exclude: "populationFrequencies,conservation,expression,geneDisease,drugInteraction"
}).then(response => {
const annotatedVariants = response.responses;
for (let i = 0; i < variants.length; i++) {
// Store annotatedVariant in a Map, so we can search later and we do not need them to have the same order
const annotatedVariantsMap = new Map();
for (const av of annotatedVariants[i].results[0].consequenceTypes) {
// We can ignore the CTs without ensemblTranscriptId since they do not have flags.
if (av.ensemblTranscriptId) {
annotatedVariantsMap.set(av.ensemblTranscriptId, av);
}
}

for (let j = 0; j < variants[i].annotation.consequenceTypes.length; j++) {
if (variants[i].annotation.consequenceTypes[j].ensemblTranscriptId) {
// We can ignore the CTs without ensemblTranscriptId since they do not have flags.
const annotatedVariant = annotatedVariantsMap.get(variants[i].annotation.consequenceTypes[j].ensemblTranscriptId).transcriptAnnotationFlags;
if (annotatedVariant) {
variants[i].annotation.consequenceTypes[j].transcriptFlags = annotatedVariant;
variants[i].annotation.consequenceTypes[j].transcriptAnnotationFlags = annotatedVariant;
}
}
}
}
}).catch(error => {
console.log(error);
});
}
}
params.success(res);
})
.then(response => params.success(response))
.catch(error => {
console.error(error);
params.error(error);
Expand Down