Skip to content

Commit

Permalink
Independent display logic for sample treatments chart
Browse files Browse the repository at this point in the history
- Sample treatments sometimes should not be shown when patient treatments
are shown
- This PR uses a new API endpoint to determine when sample treatments should be shown
- Also, unknown treatments are no longer shows on the frontend
- Switched from passing a filter object to passing a list a study ids to the display
treatment endpoints
  • Loading branch information
Luke-Sikina committed Oct 19, 2020
1 parent 23e5754 commit 584810d
Show file tree
Hide file tree
Showing 6 changed files with 161 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5113,7 +5113,7 @@
"tags": [
"Treatments"
],
"summary": "Should sample level treatments be displayed",
"summary": "Should patient level treatments be displayed",
"operationId": "getContainsTreatmentDataUsingPOST",
"consumes": [
"application/json"
Expand All @@ -5124,11 +5124,52 @@
"parameters": [
{
"in": "body",
"name": "studyViewFilter",
"description": "Study view filter",
"name": "studyIds",
"description": "List of Study IDs",
"required": true,
"schema": {
"$ref": "#/definitions/StudyViewFilter"
"type": "array",
"items": {
"type": "string"
}
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "boolean"
}
}
},
"deprecated": false
}
},
"/treatments/display-sample": {
"post": {
"tags": [
"Treatments"
],
"summary": "Should sample level treatments be displayed",
"operationId": "getContainsSampleTreatmentDataUsingPOST",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"parameters": [
{
"in": "body",
"name": "studyIds",
"description": "List of Study IDs",
"required": true,
"schema": {
"type": "array",
"items": {
"type": "string"
}
}
}
],
Expand Down Expand Up @@ -6854,8 +6895,7 @@
"type": "string",
"enum": [
"Pre",
"Post",
"Unknown"
"Post"
]
},
"treatment": {
Expand All @@ -6881,8 +6921,7 @@
"type": "string",
"enum": [
"Pre",
"Post",
"Unknown"
"Post"
]
},
"treatment": {
Expand Down
102 changes: 89 additions & 13 deletions packages/cbioportal-ts-api-client/src/generated/CBioPortalAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ export type SampleMolecularIdentifier = {

};
export type SampleTreatmentFilter = {
'time': "Pre" | "Post" | "Unknown"
'time': "Pre" | "Post"

'treatment': string

Expand All @@ -725,7 +725,7 @@ export type SampleTreatmentRow = {

'samples': Array < ClinicalEventSample >

'time': "Pre" | "Post" | "Unknown"
'time': "Pre" | "Post"

'treatment': string

Expand Down Expand Up @@ -8803,7 +8803,7 @@ export default class CBioPortalAPI {
});
};
getContainsTreatmentDataUsingPOSTURL(parameters: {
'studyViewFilter': StudyViewFilter,
'studyIds': Array < string > ,
$queryParameters ? : any
}): string {
let queryParameters: any = {};
Expand All @@ -8820,13 +8820,13 @@ export default class CBioPortalAPI {
};

/**
* Should sample level treatments be displayed
* Should patient level treatments be displayed
* @method
* @name CBioPortalAPI#getContainsTreatmentDataUsingPOST
* @param {} studyViewFilter - Study view filter
* @param {} studyIds - List of Study IDs
*/
getContainsTreatmentDataUsingPOSTWithHttpInfo(parameters: {
'studyViewFilter': StudyViewFilter,
'studyIds': Array < string > ,
$queryParameters ? : any,
$domain ? : string
}): Promise < request.Response > {
Expand All @@ -8842,12 +8842,12 @@ export default class CBioPortalAPI {
headers['Accept'] = 'application/json';
headers['Content-Type'] = 'application/json';

if (parameters['studyViewFilter'] !== undefined) {
body = parameters['studyViewFilter'];
if (parameters['studyIds'] !== undefined) {
body = parameters['studyIds'];
}

if (parameters['studyViewFilter'] === undefined) {
reject(new Error('Missing required parameter: studyViewFilter'));
if (parameters['studyIds'] === undefined) {
reject(new Error('Missing required parameter: studyIds'));
return;
}

Expand All @@ -8864,20 +8864,96 @@ export default class CBioPortalAPI {
};

/**
* Should sample level treatments be displayed
* Should patient level treatments be displayed
* @method
* @name CBioPortalAPI#getContainsTreatmentDataUsingPOST
* @param {} studyViewFilter - Study view filter
* @param {} studyIds - List of Study IDs
*/
getContainsTreatmentDataUsingPOST(parameters: {
'studyViewFilter': StudyViewFilter,
'studyIds': Array < string > ,
$queryParameters ? : any,
$domain ? : string
}): Promise < boolean > {
return this.getContainsTreatmentDataUsingPOSTWithHttpInfo(parameters).then(function(response: request.Response) {
return response.body;
});
};
getContainsSampleTreatmentDataUsingPOSTURL(parameters: {
'studyIds': Array < string > ,
$queryParameters ? : any
}): string {
let queryParameters: any = {};
let path = '/treatments/display-sample';

if (parameters.$queryParameters) {
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
var parameter = parameters.$queryParameters[parameterName];
queryParameters[parameterName] = parameter;
});
}
let keys = Object.keys(queryParameters);
return this.domain + path + (keys.length > 0 ? '?' + (keys.map(key => key + '=' + encodeURIComponent(queryParameters[key])).join('&')) : '');
};

/**
* Should sample level treatments be displayed
* @method
* @name CBioPortalAPI#getContainsSampleTreatmentDataUsingPOST
* @param {} studyIds - List of Study IDs
*/
getContainsSampleTreatmentDataUsingPOSTWithHttpInfo(parameters: {
'studyIds': Array < string > ,
$queryParameters ? : any,
$domain ? : string
}): Promise < request.Response > {
const domain = parameters.$domain ? parameters.$domain : this.domain;
const errorHandlers = this.errorHandlers;
const request = this.request;
let path = '/treatments/display-sample';
let body: any;
let queryParameters: any = {};
let headers: any = {};
let form: any = {};
return new Promise(function(resolve, reject) {
headers['Accept'] = 'application/json';
headers['Content-Type'] = 'application/json';

if (parameters['studyIds'] !== undefined) {
body = parameters['studyIds'];
}

if (parameters['studyIds'] === undefined) {
reject(new Error('Missing required parameter: studyIds'));
return;
}

if (parameters.$queryParameters) {
Object.keys(parameters.$queryParameters).forEach(function(parameterName) {
var parameter = parameters.$queryParameters[parameterName];
queryParameters[parameterName] = parameter;
});
}

request('POST', domain + path, body, headers, queryParameters, form, reject, resolve, errorHandlers);

});
};

/**
* Should sample level treatments be displayed
* @method
* @name CBioPortalAPI#getContainsSampleTreatmentDataUsingPOST
* @param {} studyIds - List of Study IDs
*/
getContainsSampleTreatmentDataUsingPOST(parameters: {
'studyIds': Array < string > ,
$queryParameters ? : any,
$domain ? : string
}): Promise < boolean > {
return this.getContainsSampleTreatmentDataUsingPOSTWithHttpInfo(parameters).then(function(response: request.Response) {
return response.body;
});
};
getAllPatientTreatmentsUsingPOSTURL(parameters: {
'studyViewFilter': StudyViewFilter,
$queryParameters ? : any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3741,8 +3741,7 @@
"type": "string",
"enum": [
"Pre",
"Post",
"Unknown"
"Post"
]
},
"treatment": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ export type SampleIdentifier = {

};
export type SampleTreatmentFilter = {
'time': "Pre" | "Post" | "Unknown"
'time': "Pre" | "Post"

'treatment': string

Expand Down
27 changes: 22 additions & 5 deletions src/pages/studyView/StudyViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3832,7 +3832,7 @@ export class StudyViewPageStore {
_chartMetaSet
);

if (this.displayTreatments.result) {
if (this.displaySampleTreatments.result) {
_chartMetaSet['SAMPLE_TREATMENTS'] = {
uniqueKey: 'SAMPLE_TREATMENTS',
dataType: ChartMetaDataTypeEnum.CLINICAL,
Expand All @@ -3845,7 +3845,9 @@ export class StudyViewPageStore {
description:
'List of treatments and the corresponding number of samples acquired before treatment or after/on treatment',
};
}

if (this.displayPatientTreatments.result) {
_chartMetaSet['PATIENT_TREATMENTS'] = {
uniqueKey: 'PATIENT_TREATMENTS',
dataType: ChartMetaDataTypeEnum.CLINICAL,
Expand Down Expand Up @@ -4039,7 +4041,7 @@ export class StudyViewPageStore {
this.cnaProfiles.isPending ||
this.structuralVariantProfiles.isPending ||
this.survivalClinicalAttributesPrefix.isPending ||
this.displayTreatments.isPending;
this.displayPatientTreatments.isPending;

if (
this.clinicalAttributes.isComplete &&
Expand Down Expand Up @@ -4326,7 +4328,7 @@ export class StudyViewPageStore {
}
}

if (this.displayTreatments.result) {
if (this.displayPatientTreatments.result) {
this.changeChartVisibility(
SpecialChartsUniqueKeyEnum.SAMPLE_TREATMENTS,
true
Expand Down Expand Up @@ -6914,11 +6916,26 @@ export class StudyViewPageStore {
});

@computed
public get displayTreatments() {
public get displayPatientTreatments() {
const studyIds = toJS(this.studyIds);

return remoteData({
invoke: () => {
return defaultClient.getContainsTreatmentDataUsingPOST({
studyViewFilter: this.initialFilters,
studyIds,
});
},
});
}

@computed
public get displaySampleTreatments() {
const studyIds = toJS(this.studyIds);

return remoteData({
invoke: () => {
return defaultClient.getContainsSampleTreatmentDataUsingPOST({
studyIds,
});
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function toSampleTreatmentFilter(
const split = uniqueKey.split('::');
return {
treatment: split[0],
time: split[1] as 'Pre' | 'Post' | 'Unknown',
time: split[1] as 'Pre' | 'Post',
};
}

Expand Down

0 comments on commit 584810d

Please sign in to comment.