From 4b90f367b15e710a567331a3913d43e8c3a2c33b Mon Sep 17 00:00:00 2001 From: "Abeshouse, Adam A./Sloan Kettering Institute" Date: Wed, 11 Dec 2019 17:23:18 -0500 Subject: [PATCH] oncoprint - fix bugs with removing tracks arising from putting more oncoprint state in URL Signed-off-by: Abeshouse, Adam A./Sloan Kettering Institute --- .../specs/core/oncoprint.screenshot.spec.js | 41 ++++++++++++------- package.json | 7 +++- src/shared/components/oncoprint/DeltaUtils.ts | 16 ++++++-- src/shared/components/oncoprint/Oncoprint.tsx | 3 +- .../components/oncoprint/OncoprintUtils.ts | 5 +-- yarn.lock | 8 ++-- 6 files changed, 52 insertions(+), 28 deletions(-) diff --git a/end-to-end-test/remote/specs/core/oncoprint.screenshot.spec.js b/end-to-end-test/remote/specs/core/oncoprint.screenshot.spec.js index 1244a017a54..a945d3ee69e 100644 --- a/end-to-end-test/remote/specs/core/oncoprint.screenshot.spec.js +++ b/end-to-end-test/remote/specs/core/oncoprint.screenshot.spec.js @@ -11,6 +11,20 @@ const CBIOPORTAL_URL = process.env.CBIOPORTAL_URL.replace(/\/$/, ""); const ONCOPRINT_TIMEOUT = 60000; +function getNthTrackOptionsElements(n) { + // n is one-indexed + + const button_selector = "#oncoprintDiv .oncoprintjs__track_options__toggle_btn_img.nth-"+n; + const dropdown_selector = "#oncoprintDiv .oncoprintjs__track_options__dropdown.nth-"+n; + + return { + button: $(button_selector), + button_selector, + dropdown: $(dropdown_selector), + dropdown_selector + }; +} + describe("oncoprint screenshot tests", function() { it("coadread_tcga_pub with clinical and heatmap tracks", function(){ var url = `${CBIOPORTAL_URL}/index.do?cancer_study_id=coadread_tcga_pub&Z_SCORE_THRESHOLD=1&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=coadread_tcga_pub_nonhypermut&gene_list=KRAS%20NRAS%20BRAF&geneset_list=%20&tab_index=tab_visualize&Action=Submit&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=coadread_tcga_pub_mutations&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=coadread_tcga_pub_gistic&genetic_profile_ids_PROFILE_MRNA_EXPRESSION=coadread_tcga_pub_rna_seq_mrna_median_Zscores&show_samples=false&clinicallist=0%2C2%2CMETHYLATION_SUBTYPE&heatmap_track_groups=coadread_tcga_pub_rna_seq_mrna_median_Zscores%2CKRAS%2CNRAS%2CBRAF&`; @@ -93,6 +107,18 @@ describe("oncoprint screenshot tests", function() { var res = checkOncoprintElement('.oncoprintContainer'); assertScreenShotMatch(res); }); + it("removes top treatment track successfully", function() { + goToUrlAndSetLocalStorage(`${CBIOPORTAL_URL}/results/oncoprint?Action=Submit&RPPA_SCORE_THRESHOLD=2.0&Z_SCORE_THRESHOLD=2.0&cancer_study_list=ccle_broad_2019&case_set_id=ccle_broad_2019_cnaseq&data_priority=0&gene_list=TP53&geneset_list=%20&genetic_profile_ids_PROFILE_COPY_NUMBER_ALTERATION=ccle_broad_2019_cna&genetic_profile_ids_PROFILE_MUTATION_EXTENDED=ccle_broad_2019_mutations&profileFilter=0&tab_index=tab_visualize&heatmap_track_groups=ccle_broad_2019_CCLE_drug_treatment_IC50%2CAfatinib-2%2CAKTinhibitorVIII-1&treatment_list=Afatinib-2%3BAKTinhibitorVIII-1`); + waitForOncoprint(ONCOPRINT_TIMEOUT); + + const elements = getNthTrackOptionsElements(2); + setDropdownOpen(true, elements.button_selector, elements.dropdown_selector, "Couldnt open top treatment track options"); + browser.click(elements.dropdown_selector + ' li:nth-child(3)'); // Click Remove + waitForOncoprint(ONCOPRINT_TIMEOUT); + + var res = checkOncoprintElement('.oncoprintContainer'); + assertScreenShotMatch(res); + }); }); describe("track group headers", function() { @@ -153,21 +179,6 @@ describe("track group headers", function() { }); describe("sorting", function(){ - - function getNthTrackOptionsElements(n) { - // n is one-indexed - - const button_selector = "#oncoprintDiv .oncoprintjs__track_options__toggle_btn_img.nth-"+n; - const dropdown_selector = "#oncoprintDiv .oncoprintjs__track_options__dropdown.nth-"+n; - - return { - button: $(button_selector), - button_selector, - dropdown: $(dropdown_selector), - dropdown_selector - }; - } - it("oncoprint should sort patients correctly in coadread_tcga_pub", function(){ goToUrlAndSetLocalStorage(CBIOPORTAL_URL); diff --git a/package.json b/package.json index 27619dd2e96..82fa85db6d9 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,10 @@ "private": true, "version": "0.0.0", "workspaces": { - "packages": [".", "packages/*"] + "packages": [ + ".", + "packages/*" + ] }, "description": "", "scripts": { @@ -172,7 +175,7 @@ "node-sass": "^4.9.3", "numeral": "^2.0.6", "object-sizeof": "^1.2.0", - "oncoprintjs": "4.0.8", + "oncoprintjs": "4.1.3", "parameter-validator": "^1.0.2", "pdfobject": "^2.0.201604172", "pegjs": "^0.10.0", diff --git a/src/shared/components/oncoprint/DeltaUtils.ts b/src/shared/components/oncoprint/DeltaUtils.ts index 0d61c645bcc..01716b05b9a 100644 --- a/src/shared/components/oncoprint/DeltaUtils.ts +++ b/src/shared/components/oncoprint/DeltaUtils.ts @@ -581,7 +581,9 @@ function tryRemoveTrack( // removeCallback to forget its track ID const trackId = trackSpecKeyToTrackId[prevSpec.key]; if (typeof trackId !== "undefined") { - oncoprint.removeTrack(trackId); + if (oncoprint.getTracks().includes(trackId)) { + oncoprint.removeTrack(trackId); + } delete trackSpecKeyToTrackId[prevSpec.key]; } return true; @@ -792,8 +794,10 @@ function transitionClinicalTrack( label: nextSpec.label, description: ((nextSpec.label || "").trim() === (nextSpec.description || "").trim()) ? undefined : nextSpec.description, removable: true, - removeCallback: ()=>{ + removeCallback: () => { delete getTrackSpecKeyToTrackId()[nextSpec.key]; + }, + onClickRemoveInTrackMenu: ()=>{ nextProps.onDeleteClinicalTrack && nextProps.onDeleteClinicalTrack(nextSpec.key); }, sort_direction_changeable: true, @@ -938,7 +942,10 @@ export function transitionHeatmapTrack( removable: true, removeCallback: ()=>{ delete getTrackSpecKeyToTrackId()[nextSpec.key]; - nextSpec.onRemove(); + nextSpec.onRemove && nextSpec.onRemove(); + }, + onClickRemoveInTrackMenu:()=>{ + nextSpec.onClickRemoveInTrackMenu && nextSpec.onClickRemoveInTrackMenu(); }, sort_direction_changeable: true, sortCmpFn: heatmapTrackSortComparator, @@ -971,6 +978,9 @@ export function transitionHeatmapTrack( } else { // if the track is a treatment profile, add to trackIdForRuleSetSharing under its `molecularProfileId` // this makes the trackId available for existing tracks of the same mol.profile for ruleset sharing + if (trackIdForRuleSetSharing.treatment![nextSpec.molecularProfileId] !== undefined) { + oncoprint.shareRuleSet(trackIdForRuleSetSharing.treatment![nextSpec.molecularProfileId]!, newTrackId); + } trackIdForRuleSetSharing.treatment![nextSpec.molecularProfileId] = newTrackId; } diff --git a/src/shared/components/oncoprint/Oncoprint.tsx b/src/shared/components/oncoprint/Oncoprint.tsx index 0d856b01ac8..3223c80b531 100644 --- a/src/shared/components/oncoprint/Oncoprint.tsx +++ b/src/shared/components/oncoprint/Oncoprint.tsx @@ -120,7 +120,8 @@ export interface IHeatmapTrackSpec extends IBaseHeatmapTrackSpec { info?: string; labelColor?: string; trackLinkUrl?: string | undefined; - onRemove: () => void; + onRemove?:()=>void; + onClickRemoveInTrackMenu?: ()=>void; molecularProfileName?: string; pivotThreshold?: number; sortOrder?: string; diff --git a/src/shared/components/oncoprint/OncoprintUtils.ts b/src/shared/components/oncoprint/OncoprintUtils.ts index 3afc83c9631..1d585317ae6 100644 --- a/src/shared/components/oncoprint/OncoprintUtils.ts +++ b/src/shared/components/oncoprint/OncoprintUtils.ts @@ -702,7 +702,7 @@ export function makeHeatmapTracksMobxPromise(oncoprint:ResultsViewOncoprint, sam data ), trackGroupIndex: molecularProfileIdToHeatmapTracks[molecularProfileId].trackGroupIndex, - onRemove:action(()=>{ + onClickRemoveInTrackMenu:action(()=>{ const trackGroup = oncoprint.molecularProfileIdToHeatmapTracks[molecularProfileId]; if (trackGroup) { const newEntities = _.keys(trackGroup.entities).filter((entity)=>entity!==gene); @@ -787,8 +787,7 @@ export function makeTreatmentProfileHeatmapTracksMobxPromise(oncoprint:ResultsVi sortOrder: sortOrder, trackLinkUrl: treatmentLinkMap[treatmentId], trackGroupIndex: molecularProfileIdToHeatmapTracks[molecularProfileId]!.trackGroupIndex, - onRemove:action(()=>{ - + onClickRemoveInTrackMenu:action(()=>{ const trackGroup = oncoprint.molecularProfileIdToHeatmapTracks[molecularProfileId]!; if (trackGroup){ const newEntities = _.keys(trackGroup.entities).filter((entity)=>entity!==treatmentId); diff --git a/yarn.lock b/yarn.lock index 207a2614ab9..9a59abc2b93 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15699,10 +15699,10 @@ oncokb-styles@~0.1.2: resolved "https://registry.yarnpkg.com/oncokb-styles/-/oncokb-styles-0.1.2.tgz#8b26c0a0829787cdc1b595d3a021b3266607102b" integrity sha512-tuy5s3qFxgf1ogMATQSRPNgLlAMrvOOTCAN1dm/wJ+VZoStbJ7g36/qHwc99UPfh3vrB05broLodF+k58p5tUw== -oncoprintjs@4.0.8: - version "4.0.8" - resolved "https://registry.yarnpkg.com/oncoprintjs/-/oncoprintjs-4.0.8.tgz#03d586ea45c415805d952ddeb6fc5399a9e4737b" - integrity sha512-wSl9je+fEgitLRydOKae1gftKCB0XRv5oqbNYE9+Y1inLYj7RUVqDKTBS+HaYaAFD+vmEVoTPTtboRpiE5obQw== +oncoprintjs@4.1.3: + version "4.1.3" + resolved "https://registry.yarnpkg.com/oncoprintjs/-/oncoprintjs-4.1.3.tgz#aca0528fc18d04e5c505333d603f871b1f40dec9" + integrity sha512-iP3mXiokJT5j1M3vsRaU9lxQUyt9zY57RSATlFa1rpegbZGyVwMwdZawZRd+Gov9P49JHNPvKeM/qagYo1Gglg== dependencies: gl-matrix "2.3.2" jquery "^3.0.0"