Skip to content

Commit 0aea8c1

Browse files
Merge pull request #1027 from opencb/TASK-7531
TASK-7531 - Port Patch 2.12.8 -> 3.5.0 XB 1.10.9 - 2.5.0
2 parents 497c9c4 + aec3471 commit 0aea8c1

File tree

3 files changed

+78
-61
lines changed

3 files changed

+78
-61
lines changed

src/core/clients/opencga/opencga-client.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,14 @@ export class OpenCGAClient {
444444
// Fetch all the cohort
445445
console.log("Fetching cohorts");
446446
const cohortsResponse = await _this.cohorts()
447-
.search({study: study.fqn, exclude: "samples", limit: 100});
447+
.search({
448+
study: study.fqn,
449+
internalStatus: "READY,CALCULATING,INVALID",
450+
exclude: "samples",
451+
limit: 100,
452+
});
448453
study.cohorts = cohortsResponse.responses[0].results
449454
.filter(cohort => !cohort.attributes?.IVA?.ignore);
450-
// FIXME line above should check cohort.internal instead
451-
// .filter(cohort => cohort.internal.index?.status === "READY");
452455

453456
// Keep track of the studies to fetch Disease Panels
454457
studies.push(study.fqn);

src/webcomponents/commons/filters/variant-file-format-filter.js

Lines changed: 71 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export default class VariantFileFormatFilter extends LitElement {
2222
constructor() {
2323
super();
2424

25-
this._init();
25+
this.#init();
2626
}
2727

2828
createRenderRoot() {
@@ -40,10 +40,23 @@ export default class VariantFileFormatFilter extends LitElement {
4040
};
4141
}
4242

43-
_init() {
43+
#init() {
4444
this.sampleData = "";
4545
this._sampleData = {};
4646

47+
this.fields = [
48+
{
49+
id: "DP", name: "Depth"
50+
},
51+
{
52+
id: "AF", name: "AF"
53+
},
54+
{
55+
id: "EXT_VAF", name: "VAF"
56+
}
57+
];
58+
this.indexedFields = {};
59+
4760
this._config = this.getDefaultConfig();
4861
}
4962

@@ -58,33 +71,36 @@ export default class VariantFileFormatFilter extends LitElement {
5871
}
5972

6073
opencgaSessionObserver() {
61-
this.depthIndex = this.opencgaSession.study.internal.configuration.variantEngine.sampleIndex.fileIndexConfiguration.customFields
62-
.find(field => field.key === "DP" && field.source === "SAMPLE");
63-
this.afIndex = this.opencgaSession.study.internal.configuration.variantEngine.sampleIndex.fileIndexConfiguration.customFields
64-
.find(field => field.key === "AF" && field.source === "SAMPLE");
65-
this.extVafIndex = this.opencgaSession.study.internal.configuration.variantEngine.sampleIndex.fileIndexConfiguration.customFields
66-
.find(field => field.key === "EXT_VAF" && field.source === "SAMPLE");
74+
// Parse custom fields and add them to the fields array
75+
for (const dataFilter of this.opencgaSession?.study?.internal?.configuration?.clinical?.interpretation?.variantCallers[0]?.dataFilters) {
76+
if (dataFilter.source === "SAMPLE") {
77+
const indexPosition = this.fields.findIndex(f => f.id === dataFilter.id);
78+
if (indexPosition >= 0) {
79+
this.fields[indexPosition] = {id: dataFilter.id, name: dataFilter.name};
80+
} else {
81+
this.fields.push({id: dataFilter.id, name: dataFilter.name});
82+
}
83+
}
84+
}
85+
86+
// Search for the indexed fields
87+
for (const field of this.fields) {
88+
this.indexedFields[field.id] = this.opencgaSession.study.internal.configuration.variantEngine.sampleIndex.fileIndexConfiguration.customFields
89+
.find(f => f.key === field.id && f.source === "SAMPLE");
90+
}
6791
this._config = this.getDefaultConfig();
6892
}
6993

7094
sampleDataObserver() {
7195
if (this.sampleData) {
7296
const sampleDataFilters = this.sampleData.split(";");
7397

74-
const depth = sampleDataFilters.find(filter => filter.startsWith("DP"))?.replace("DP", "");
75-
depth ? this._sampleData.DP = depth : delete this._sampleData.DP;
76-
this.depthIndex = this.opencgaSession.study.internal.configuration.variantEngine.sampleIndex.fileIndexConfiguration.customFields
77-
.find(field => field.key === "DP" && field.source === "SAMPLE");
78-
79-
const af = sampleDataFilters.find(filter => filter.startsWith("AF"))?.replace("AF", "");
80-
af ? this._sampleData.AF = af : delete this._sampleData.AF;
81-
this.afIndex = this.opencgaSession.study.internal.configuration.variantEngine.sampleIndex.fileIndexConfiguration.customFields
82-
.find(field => field.key === "AF" && field.source === "SAMPLE");
83-
84-
const extVaf = sampleDataFilters.find(filter => filter.startsWith("EXT_VAF"))?.replace("EXT_VAF", "");
85-
extVaf ? this._sampleData.EXT_VAF = extVaf : delete this._sampleData.EXT_VAF;
86-
this.extVafIndex = this.opencgaSession.study.internal.configuration.variantEngine.sampleIndex.fileIndexConfiguration.customFields
87-
.find(field => field.key === "EXT_VAF" && field.source === "SAMPLE");
98+
for (const field of this.fields) {
99+
const filter = sampleDataFilters.find(filter => filter.startsWith(field.id))?.replace(field.id, "");
100+
filter ? this._sampleData[field.id] = filter : delete this._sampleData[field.id];
101+
this.indexedFields[field.id] = this.opencgaSession.study.internal.configuration.variantEngine.sampleIndex.fileIndexConfiguration.customFields
102+
.find(f => f.key === field.id && f.source === "SAMPLE");
103+
}
88104

89105
this._config = this.getDefaultConfig();
90106
} else {
@@ -116,6 +132,38 @@ export default class VariantFileFormatFilter extends LitElement {
116132
}
117133

118134
getDefaultConfig() {
135+
const elements = [];
136+
for (const field of this.fields) {
137+
// Check if the field is actually indexed, only indexed fields can be used for filtering
138+
if (this.indexedFields[field.id]) {
139+
if (this.indexedFields[field.id]?.type?.startsWith("RANGE_")) {
140+
elements.push({
141+
name: field.name,
142+
field: field.id,
143+
type: "input-number",
144+
comparators: this.indexedFields[field.id]?.type === "RANGE_LT" ? "<,>=" : "<=,>",
145+
allowedValues: this.indexedFields[field.id]?.thresholds,
146+
display: {
147+
defaultValue: "",
148+
visible: () => this.indexedFields[field.id]?.thresholds?.length > 0,
149+
}
150+
});
151+
} else {
152+
// Categorical
153+
elements.push({
154+
name: field.name,
155+
field: field.id,
156+
type: "select",
157+
allowedValues: this.indexedFields[field.id]?.values,
158+
multiple: this.indexedFields[field.id]?.type === "CATEGORICAL_MULTI_VALUE",
159+
display: {
160+
defaultValue: "",
161+
},
162+
});
163+
}
164+
}
165+
}
166+
119167
return {
120168
title: "",
121169
icon: "",
@@ -134,41 +182,7 @@ export default class VariantFileFormatFilter extends LitElement {
134182
titleHeader: "h4",
135183
titleStyle: "margin: 5px 0"
136184
},
137-
elements: [
138-
{
139-
name: "Depth",
140-
field: "DP",
141-
type: "input-number",
142-
comparators: this.depthIndex?.type === "RANGE_LT" ? "<,>=" : "<=,>",
143-
allowedValues: this.depthIndex?.thresholds,
144-
display: {
145-
defaultValue: "",
146-
visible: () => this.depthIndex?.thresholds?.length > 0,
147-
}
148-
},
149-
{
150-
name: "AF",
151-
field: "AF",
152-
type: "input-number",
153-
comparators: this.afIndex?.type === "RANGE_LT" ? "<,>=" : "<=,>",
154-
allowedValues: this.afIndex?.thresholds,
155-
display: {
156-
defaultValue: "",
157-
visible: () => this.afIndex?.thresholds?.length > 0,
158-
}
159-
},
160-
{
161-
name: "VAF",
162-
field: "EXT_VAF",
163-
type: "input-number",
164-
comparators: this.extVafIndex?.type === "RANGE_LT" ? "<,>=" : "<=,>",
165-
allowedValues: this.extVafIndex?.thresholds,
166-
display: {
167-
defaultValue: "",
168-
visible: () => this.extVafIndex?.thresholds?.length > 0,
169-
}
170-
}
171-
]
185+
elements: elements
172186
}
173187
],
174188
};

src/webcomponents/variant/interpretation/variant-interpreter-browser-rd.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ class VariantInterpreterBrowserRd extends LitElement {
255255
});
256256

257257
// Add 'file' filter if 'fileData' exists
258-
if (this.files) {
258+
if (this.files?.length > 1) {
259259
const fileNames = this.files.map(f => f.name).join(",");
260260
for (const filter of _activeFilterFilters) {
261261
if (filter.query?.fileData && !filter.query?.file) {

0 commit comments

Comments
 (0)