Skip to content

Commit

Permalink
Merge pull request #901 from opencb/TASK-6003
Browse files Browse the repository at this point in the history
TASK-6003 - New selected variants or new changes to primary findings cannot be saved with a specific sample variant browser configuration
  • Loading branch information
jmjuanes authored Apr 16, 2024
2 parents d51f579 + 7c969fb commit 8ce5d35
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,11 @@ export default class VariantInterpreterGridFormatter {
/*
* SAMPLE GENOTYPE RENDERER
*/
static sampleGenotypeFormatter(value, row, index) {
static sampleGenotypeFormatter(value, row, index, params) {
let resultHtml = "";

if (row && row.studies?.length > 0 && row.studies[0].samples?.length > 0) {
const sampleId = this.field.sampleId;
const sampleId = params?.sampleId;
let sampleEntries = [row.studies[0].samples.find(s => s.sampleId === sampleId)];

// If not sampleId is found and there is only one sample we take that one
Expand All @@ -474,15 +474,15 @@ export default class VariantInterpreterGridFormatter {

// Render genotypes
let content = "";
switch (this.field.config?.genotype?.type?.toUpperCase() || "VCF_CALL") {
switch (params?.config?.genotype?.type?.toUpperCase() || "VCF_CALL") {
case "ALLELES":
content = VariantInterpreterGridFormatter.alleleGenotypeRenderer(row, sampleEntry, "alleles");
break;
case "VCF_CALL":
content = VariantInterpreterGridFormatter.alleleGenotypeRenderer(row, sampleEntry, "call");
break;
case "ZYGOSITY":
content = VariantInterpreterGridFormatter.zygosityGenotypeRenderer(row, sampleEntry, this.field.clinicalAnalysis);
content = VariantInterpreterGridFormatter.zygosityGenotypeRenderer(row, sampleEntry, params?.clinicalAnalysis);
break;
case "VAF":
const vaf = VariantInterpreterGridFormatter._getVariantAlleleFraction(row, sampleEntry, file);
Expand All @@ -508,15 +508,17 @@ export default class VariantInterpreterGridFormatter {
content = VariantInterpreterGridFormatter.circleGenotypeRenderer(sampleEntry, file, 10);
break;
default:
console.error("No valid genotype render option:", this.field.config.genotype.type.toUpperCase());
console.error("No valid genotype render option:", params?.config?.genotype?.type?.toUpperCase());
break;
}

// Get tooltip text
const tooltipText = VariantInterpreterGridFormatter._getSampleGenotypeTooltipText(row, sampleEntry, file);
resultHtml += `<a class="zygositySampleTooltip" tooltip-title="Variant Call Information" tooltip-text='${tooltipText}'>
${content}
</a><br>`;
resultHtml += `
<a class="zygositySampleTooltip" tooltip-title="Variant Call Information" tooltip-text='${tooltipText}'>
${content}
</a><br>
`;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1070,19 +1070,16 @@ export default class VariantInterpreterGrid extends LitElement {
title: `<span style="color: ${color}">${samples[i].id}</span>
<br>
<span style="font-style: italic">${sampleInfo[samples[i].id].role}, ${affected}</span>`,
field: {
memberIdx: i,
memberName: samples[i].id,
sampleId: samples[i].id,
quality: this._config.quality,
clinicalAnalysis: this.clinicalAnalysis,
config: this._config
},
rowspan: 1,
colspan: 1,
formatter: VariantInterpreterGridFormatter.sampleGenotypeFormatter,
formatter: (value, row, index) => {
return VariantInterpreterGridFormatter.sampleGenotypeFormatter(value, row, index, {
sampleId: samples[i].id,
clinicalAnalysis: this.clinicalAnalysis,
config: this._config
});
},
align: "center",
nucleotideGenotype: true,
excludeFromSettings: true,
visible: !this._config.hideSampleGenotypes,
});
Expand Down Expand Up @@ -1122,17 +1119,16 @@ export default class VariantInterpreterGrid extends LitElement {
<div style="word-break:break-all;max-width:192px;white-space:break-spaces;">${sample.id}</div>
<div style="color:${color};font-style:italic;">${sample?.somatic ? "somatic" : "germline"}</div>
`,
field: {
sampleId: sample.id,
quality: this._config.quality,
config: this._config,
clinicalAnalysis: this.clinicalAnalysis
},
rowspan: 1,
colspan: 1,
formatter: VariantInterpreterGridFormatter.sampleGenotypeFormatter,
formatter: (value, row, index) => {
return VariantInterpreterGridFormatter.sampleGenotypeFormatter(value, row, index, {
sampleId: sample.id,
config: this._config,
clinicalAnalysis: this.clinicalAnalysis
});
},
align: "center",
nucleotideGenotype: true,
excludeFromSettings: true,
visible: !this._config.hideSampleGenotypes,
});
Expand Down
15 changes: 6 additions & 9 deletions src/webcomponents/variant/variant-browser-grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,18 +562,15 @@ export default class VariantBrowserGrid extends LitElement {
sampleColumns.push({
id: this.samples[i].id,
title: this.samples[i].id,
// field: "samples",
field: {
memberIdx: i,
memberName: this.samples[i].id,
sampleId: this.samples[i].id,
config: this._config
},
rowspan: 1,
colspan: 1,
formatter: VariantInterpreterGridFormatter.sampleGenotypeFormatter,
formatter: (value, row, index) => {
return VariantInterpreterGridFormatter.sampleGenotypeFormatter(value, row, index, {
sampleId: this.samples[i].id,
config: this._config
});
},
align: "center",
// nucleotideGenotype: true,
visible: this.gridCommons.isColumnVisible(this.samples[i].id, "samples"),
});
}
Expand Down

0 comments on commit 8ce5d35

Please sign in to comment.