Skip to content

Commit

Permalink
Merge branch 'release-2.12.x' into TASK-5864
Browse files Browse the repository at this point in the history
  • Loading branch information
jmjuanes authored Apr 17, 2024
2 parents a4f70f0 + 8ce5d35 commit 88025cd
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 70 deletions.
2 changes: 1 addition & 1 deletion src/genome-browser/tracks/opencga-alignment-track.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class OpenCGAAlignmentTrack extends FeatureTrack {
const coverageRequest = this.config.opencgaClient.alignments().queryCoverage(this.alignmentInfo.id, {
study: this.config.opencgaStudy,
region: options.region.toString(),
windowSize: 1,
windowSize: Math.max(1, Math.round(10 / this.pixelBase)),
offset: 0,
});

Expand Down
6 changes: 3 additions & 3 deletions src/webcomponents/commons/json-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,16 @@ export default class JsonEditor extends LitElement {

return html`
${this._config.showDownloadButton ? html`
<div class="text-right">
<div class="text-right" style="margin-bottom:8px;">
<download-button
.json="${this.data}"
class="btn-sm">
.class="${"btn-sm"}">
</download-button>
</div>
` : null
}
<div style="padding-top: 10px" id="${this.jsonEditorId}"></div>
<div id="${this.jsonEditorId}"></div>
`;
}

Expand Down
72 changes: 45 additions & 27 deletions src/webcomponents/commons/json-viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

import {LitElement, html} from "lit";
import {JSONEditor} from "vanilla-jsoneditor";
import UtilsNew from "../../core/utils-new.js";
import "../download-button.js";

Expand All @@ -34,43 +35,54 @@ export default class JsonViewer extends LitElement {
data: {
type: Object
},
// title: {
// type: String
// },
showDownloadButton: {
type: Boolean
},
active: {
type: Boolean
}
},
config: {
type: Object,
},
};
}

_init() {
this._prefix = UtilsNew.randomString(8);

this.showDownloadButton = true;
this.active = true;
this.jsonView = null;
this._config = this.getDefaultConfig();
}

connectedCallback() {
super.connectedCallback();

// this._config = {...this.getDefaultConfig(), ...this.config};
update(changedProperties) {
if (changedProperties.has("config")) {
this._config = {
...this.getDefaultConfig(),
...this.config,
};
}
super.update(changedProperties);
}

updated(changedProperties) {
if ((changedProperties.has("data") || changedProperties.has("active")) && this.active) {
if (this.data) {
// $(".json-renderer", this).jsonViewer(this.data);
$(`#${this._prefix}JsonView`, this).jsonViewer(this.data);
if ((changedProperties.has("data") || changedProperties.has("active") || changedProperties.has("config")) && this.active) {
if (!this.jsonView) {
this.initJsonView();
} else {
this.jsonView.update({json: this.data});
}
}
// super.update(changedProperties);
}

getDefaultConfig() {
return {};
initJsonView() {
this.jsonView = new JSONEditor({
target: this.querySelector(`#${this._prefix}JsonView`),
props: {
content: {
json: this.data || {},
},
mode: this._config?.mode || "tree",
indentation: this._config?.indentation || 4,
readOnly: true,
}
});
}

render() {
Expand All @@ -79,20 +91,26 @@ export default class JsonViewer extends LitElement {
}

return html`
${this.showDownloadButton ? html`
<div class="text-right">
${this._config?.showDownloadButton ? html`
<div class="text-right" style="margin-bottom:8px;">
<download-button
.json="${this.data}"
class="btn-sm">
.class="${"btn-sm"}">
</download-button>
</div>
` : null
}
<div id="${this._prefix}JsonView" class="json-renderer"></div>
` : null}
<div id="${this._prefix}JsonView"></div>
`;
}

getDefaultConfig() {
return {
showDownloadButton: true,
indentation: 4,
mode: "tree",
};
}

}

customElements.define("json-viewer", JsonViewer);
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 @@ -562,7 +562,8 @@ export default class VariantInterpreterGrid extends LitElement {
colspan: 1,
formatter: this.vcfDataFormatter,
halign: this.displayConfigDefault.header.horizontalAlign,
visible: this.gridCommons.isColumnVisible(columnId, "VCF_Data"),
excludeFromSettings: true,
visible: !this._config.hideVcfFileData,
});
}
}
Expand Down Expand Up @@ -1069,20 +1070,18 @@ 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,
visible: this.gridCommons.isColumnVisible(samples[i].id, "sampleGenotypes"),
excludeFromSettings: true,
visible: !this._config.hideSampleGenotypes,
});
}
}
Expand Down Expand Up @@ -1120,18 +1119,18 @@ 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,
visible: this.gridCommons.isColumnVisible(samples[i].id, "sampleGenotypes"),
excludeFromSettings: true,
visible: !this._config.hideSampleGenotypes,
});
}
}
Expand Down Expand Up @@ -1549,6 +1548,8 @@ export default class VariantInterpreterGrid extends LitElement {
hidePopulationFrequencies: false,
hideClinicalInfo: false,
hideDeleteriousness: false,
hideSampleGenotypes: false,
hideVcfFileData: false,

quality: {
qual: 30,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,8 @@ export default class VariantInterpreterRearrangementGrid extends LitElement {
colspan: 1,
formatter: (value, row) => this.vcfDataFormatter(value, row[index], field),
halign: "center",
visible: this.gridCommons.isColumnVisible(id),
excludeFromSettings: true,
visible: !this._config.hideVcfFileData,
});
});
});
Expand Down Expand Up @@ -1104,6 +1105,7 @@ export default class VariantInterpreterRearrangementGrid extends LitElement {
showActions: false,
multiSelection: false,
nucleotideGenotype: true,
hideVcfFileData: false,

alleleStringLengthMax: 50,

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 88025cd

Please sign in to comment.