Skip to content

Commit

Permalink
Merge pull request #830 from opencb/TASK-5279
Browse files Browse the repository at this point in the history
TASK-5279 - Port Patch 1.6.6 -> 1.10.1
  • Loading branch information
juanfeSanahuja authored Nov 22, 2023
2 parents d60ef12 + 8d29e3d commit fdbe2f1
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 18 deletions.
32 changes: 15 additions & 17 deletions src/webcomponents/clinical/analysis/rd-tiering-analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
*/

import {LitElement, html} from "lit";
import FormUtils from "../../commons/forms/form-utils";
import AnalysisUtils from "../../commons/analysis/analysis-utils";
import AnalysisUtils from "../../commons/analysis/analysis-utils.js";
import UtilsNew from "../../../core/utils-new.js";
import "../../commons/forms/data-form.js";
import "../../commons/filters/catalog-search-autocomplete.js";
Expand Down Expand Up @@ -87,15 +86,15 @@ export default class RdTieringAnalysis extends LitElement {
return null;
}

onFieldChange(e, field) {
onFieldChange() {
this.toolParams = {...this.toolParams};
this.requestUpdate();
}

onSubmit() {
const toolParams = {
clinicalAnalysis: this.toolParams.clinicalAnalysis || "",
panels: this.toolParams.panels.split(",") || [],
panels: (this.toolParams.panels || "").split(","),
};
const params = {
study: this.opencgaSession.study.fqn,
Expand Down Expand Up @@ -138,12 +137,12 @@ export default class RdTieringAnalysis extends LitElement {
elements: [
{
title: "Clinical Analysis ID",
field: "clinicalAnalysisId",
field: "clinicalAnalysis",
type: "custom",
display: {
render: (clinicalAnalysisId, dataFormFilterChange, updateParams, clinicalAnalysis) => html`
render: (clinicalAnalysis, dataFormFilterChange) => html`
<catalog-search-autocomplete
.value="${clinicalAnalysisId}"
.value="${clinicalAnalysis}"
.resource="${"CLINICAL_ANALYSIS"}"
.opencgaSession="${this.opencgaSession}"
.config="${{multiple: false, disabled: !!clinicalAnalysis}}"
Expand All @@ -157,13 +156,12 @@ export default class RdTieringAnalysis extends LitElement {
// - Once the clinical analysis id is selected, query its panels?
// - All the studies have panels?
title: "Disease Panels",
field: "panels.id",
field: "panels",
type: "custom",
display: {
render: (panels, dataFormFilterChange) => {
// Todo: check if its working
// Get whether disease panels can be modified or are fixed
const casePanelLock = !!this.clinicalAnalysisId;
const casePanelLock = !!this.clinicalAnalysis;
// Get the list of disease panels for the dropdown
let diseasePanels = [];
if (casePanelLock) {
Expand All @@ -177,15 +175,15 @@ export default class RdTieringAnalysis extends LitElement {
diseasePanels = this.opencgaSession.study?.panels;
}
return html`
<disease-panel-filter
.opencgaSession="${this.opencgaSession}"
.diseasePanels="${diseasePanels}"
.panel="${this.diseasePanelIds}"
.showExtendedFilters="${false}"
.showSelectedPanels="${false}"
<select-field-filter
.data="${diseasePanels}"
.value=${panels}
.liveSearch=${diseasePanels?.length > 5}
.multiple="${true}"
.disabled="${casePanelLock}"
separator="\n"
@filterChange="${e => dataFormFilterChange(e.detail.value)}">
</disease-panel-filter>
</select-field-filter>
`;
},
}
Expand Down
89 changes: 88 additions & 1 deletion src/webcomponents/variant/variant-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/

import UtilsNew from "../../core/utils-new.js";
import BioinfoUtils from "../../core/bioinfo/bioinfo-utils.js";
import VariantGridFormatter from "./variant-grid-formatter.js";


export default class VariantUtils {
Expand Down Expand Up @@ -73,6 +75,7 @@ export default class VariantUtils {
"deleteriousness.polyphen",
"deleteriousness.revel",
"deleteriousness.cadd",
"deleteriousness.spliceai",
"conservation.phylop",
"conservation.phastCons",
"conservation.gerp",
Expand Down Expand Up @@ -155,7 +158,7 @@ export default class VariantUtils {
for (let j = 0; j < v.annotation.consequenceTypes.length; j++) {
const cT = v.annotation.consequenceTypes[j];
// gene
if (cT?.geneName !== "") {
if (typeof cT?.geneName === "string" && ct?.geneName !== "") {
genes.add(cT.geneName);
}

Expand Down Expand Up @@ -361,6 +364,13 @@ export default class VariantUtils {
if (flatFieldList.includes("conservation.gerp")) {
dataToTsv["conservation.gerp"] = gerp;
}
if (flatFieldList.includes("deleteriousness.spliceai")) {
dataToTsv["deleteriousness.spliceai"] = this.getSpliceAI(v);
}

if (flatFieldList.includes("hgvs")) {
dataToTsv["hgvs"] = this.gethgvsValues(v);
}

// Allele stats (VB)
// frequencies.cohort (SVB)
Expand Down Expand Up @@ -528,6 +538,83 @@ export default class VariantUtils {
return res;
}

static gethgvsValues(variant) {

BioinfoUtils.sort(variant.annotation?.consequenceTypes, v => v.geneName);
const gridConfig = {
geneSet: {
ensembl: true,
refseq: true,
},
consequenceType: {
// all: false,
maneTranscript: true,
gencodeBasicTranscript: false,
ensemblCanonicalTranscript: true,
refseqTranscript: true,
ccdsTranscript: false,
ensemblTslTranscript: false,
proteinCodingTranscript: false,
highImpactConsequenceTypeTranscript: false,
showNegativeConsequenceTypes: true
}
};
const showArrayIndexes = VariantGridFormatter._consequenceTypeDetailFormatterFilter(variant.annotation?.consequenceTypes, gridConfig).indexes;

if (showArrayIndexes?.length > 0 && variant.annotation.hgvs?.length > 0) {
const results = [];
for (const index of showArrayIndexes) {
const consequenceType = variant.annotation.consequenceTypes[index];
const hgvsTranscriptIndex = variant.annotation.hgvs.findIndex(hgvs => hgvs.startsWith(consequenceType.transcriptId));
const hgvsProteingIndex = variant.annotation.hgvs.findIndex(hgvs => hgvs.startsWith(consequenceType.proteinVariantAnnotation?.proteinId));
if (hgvsTranscriptIndex > -1 || hgvsProteingIndex > -1) {
results.push(`${this.getHgvs(consequenceType.transcriptId, variant.annotation.hgvs) || "-"} ${this.getHgvs(consequenceType.proteinVariantAnnotation?.proteinId, variant.annotation.hgvs) || "-"}`);
}
}
return results.join();
}
}

static getHgvs(id, hgvsArray) {
if (!id) {
return;
}

let hgvs = hgvsArray?.find(hgvs => hgvs.startsWith(id));
if (hgvs) {
if (hgvs.includes("(")) {
const split = hgvs.split(new RegExp("[()]"));
hgvs = split[0] + split[2];
}
const split = hgvs.split(":");
return `${split[0]}:${split[1]}`;

}
return id;
}

static getSpliceAI(variant) {
if (variant.annotation.consequenceTypes?.length > 0) {
// We need to find the max Delta Score:
// Delta score of a variant, defined as the maximum of (DS_AG, DS_AL, DS_DG, DS_DL),
// ranges from 0 to 1 and can be interpreted as the probability of the variant being splice-altering.
let dscore = 0;
for (const ct of variant.annotation.consequenceTypes) {
if (ct.spliceScores?.length > 0) {
const spliceAi = ct.spliceScores.find(ss => ss.source.toUpperCase() === "SPLICEAI");
if (spliceAi) {
const max = Math.max(spliceAi.scores["DS_AG"], spliceAi.scores["DS_AL"], spliceAi.scores["DS_DG"], spliceAi.scores["DS_DL"]);
if (max > dscore) {
dscore = max;
}
}
}
}
return dscore;
}
return "-";
}

static removeUnlockQuery(lockedFields, preparedQuery, executedQuery) {
// Get all keys
const queryKeys = new Set([...Object.keys(preparedQuery), ...Object.keys(executedQuery)]);
Expand Down

0 comments on commit fdbe2f1

Please sign in to comment.