Skip to content

Commit

Permalink
Only use OQL filtering in mutations tab if theres mutation oql
Browse files Browse the repository at this point in the history
Signed-off-by: Abeshouse, Adam A./Sloan Kettering Institute <abeshoua@mskcc.org>
  • Loading branch information
Abeshouse, Adam A./Sloan Kettering Institute committed Aug 15, 2018
1 parent da24bc6 commit e1ca660
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 8 deletions.
7 changes: 5 additions & 2 deletions end-to-end-tests/specs/results.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ describe('Results Page', function() {
describe.only('oql status banner', function() {
const yesBannerSelector = 'div[data-test="OqlStatusBannerYes"]';
const noBannerSelector = 'div[data-test="OqlStatusBannerNo"]';
const unaffectedBannerSelector = 'div[data-test="OqlStatusBannerUnaffected"]';
const simpleQueryUrl = `${CBIOPORTAL_URL}/index.do?cancer_study_id=coadread_tcga_pub&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=coadread_tcga_pub_nonhypermut&gene_list=KRAS%2520NRAS%2520BRAF&geneset_list=+&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`;
const explicitOqlQueryUrl = `${CBIOPORTAL_URL}/index.do?cancer_study_id=coadread_tcga_pub&Z_SCORE_THRESHOLD=2&RPPA_SCORE_THRESHOLD=2&data_priority=0&case_set_id=coadread_tcga_pub_nonhypermut&gene_list=KRAS%2520NRAS%2520%250ABRAF%253AMUT&geneset_list=+&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`;

Expand Down Expand Up @@ -190,6 +191,7 @@ describe('Results Page', function() {
browser.pause(500);
assert(!browser.isVisible(`${yesBannerSelector}.mutations-oql-status-banner`));
assert(!browser.isVisible(`${noBannerSelector}.mutations-oql-status-banner`));
assert(!browser.isVisible(`${unaffectedBannerSelector}.mutations-oql-status-banner`));
});
it("should not be present in coexpression tab with simple query", function(){
browser.click("#coexp-result-tab");
Expand Down Expand Up @@ -249,9 +251,10 @@ describe('Results Page', function() {
});
it("should be present in mutations tab with explicit query", function(){
browser.click("#mutation-result-tab");
browser.waitForVisible(`${noBannerSelector}.mutations-oql-status-banner`, 10000);
assert(browser.isVisible(`${yesBannerSelector}.mutations-oql-status-banner`));
browser.waitForVisible(`${unaffectedBannerSelector}.mutations-oql-status-banner`, 10000);
assert(!browser.isVisible(`${yesBannerSelector}.mutations-oql-status-banner`));
assert(!browser.isVisible(`${noBannerSelector}.mutations-oql-status-banner`));
assert(browser.isVisible(`${unaffectedBannerSelector}.mutations-oql-status-banner`));
});
it("should be present in coexpression tab with explicit query", function(){
browser.click("#coexp-result-tab");
Expand Down
10 changes: 8 additions & 2 deletions src/pages/resultsView/ResultsViewPageStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
import {writeTest} from "../../shared/lib/writeTest";
import {PatientSurvival} from "../../shared/model/PatientSurvival";
import {
doesQueryContainMutationOQL,
doesQueryContainOQL,
filterCBioPortalWebServiceData,
filterCBioPortalWebServiceDataByOQLLine,
Expand Down Expand Up @@ -342,6 +343,10 @@ export class ResultsViewPageStore {
return doesQueryContainOQL(this.oqlQuery);
}

@computed get queryContainsMutationOql() {
return doesQueryContainMutationOQL(this.oqlQuery);
}

private getURL() {
const shareURL = window.location.href;

Expand Down Expand Up @@ -1177,11 +1182,12 @@ export class ResultsViewPageStore {

});

@observable public mutationsTabUsingOql = true;
@observable public mutationsTabShouldUseOql = true;

@computed get mutationsByGene():{ [hugeGeneSymbol:string]:Mutation[]}{
let mutations:Mutation[];
if (this.mutationsTabUsingOql) {
if (this.mutationsTabShouldUseOql && this.queryContainsMutationOql) {
// use oql filtering in mutations tab only if query contains mutation oql
mutations = (this.filteredAlterations.result || []).filter(a=>isMutation(a));
} else {
mutations = this.mutations.result || [];
Expand Down
5 changes: 3 additions & 2 deletions src/pages/resultsView/mutation/Mutations.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default class Mutations extends React.Component<IMutationsPageProps, {}>

@autobind
private onToggleOql() {
this.props.store.mutationsTabUsingOql = !this.props.store.mutationsTabUsingOql;
this.props.store.mutationsTabShouldUseOql = !this.props.store.mutationsTabShouldUseOql;
}

public render() {
Expand All @@ -43,7 +43,8 @@ export default class Mutations extends React.Component<IMutationsPageProps, {}>
<OqlStatusBanner
className="mutations-oql-status-banner"
store={this.props.store}
tabReflectsOql={this.props.store.mutationsTabUsingOql}
tabReflectsOql={this.props.store.mutationsTabShouldUseOql}
isUnaffected={!this.props.store.queryContainsMutationOql}
style={{marginTop:-2}}
onToggle={this.onToggleOql}
/>
Expand Down
10 changes: 8 additions & 2 deletions src/shared/components/oqlStatusBanner/OqlStatusBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "./styles.scss";
interface IOqlStatusBannerProps {
store:ResultsViewPageStore;
tabReflectsOql:boolean;
isUnaffected?:boolean;
onToggle?:()=>void;
className?:string;
style?:any;
Expand All @@ -16,7 +17,7 @@ interface IOqlStatusBannerProps {
@observer
export default class OqlStatusBanner extends React.Component<IOqlStatusBannerProps, {}> {
@computed get toggleButton() {
if (this.props.onToggle) {
if (this.props.onToggle && !this.props.isUnaffected) {
return (
<span>
<button
Expand Down Expand Up @@ -47,7 +48,12 @@ export default class OqlStatusBanner extends React.Component<IOqlStatusBannerPro
let iconClassName:string;
let dataTest:string;

if (this.props.tabReflectsOql) {
if (this.props.isUnaffected) {
className="alert alert-unaffected";
message = "The results below are not affected by the OQL specification from your query.";
iconClassName = "fa fa-md fa-info-circle";
dataTest="OqlStatusBannerUnaffected";
} else if (this.props.tabReflectsOql) {
className="alert alert-success";
message = "The results below reflect the OQL specification from your query.";
iconClassName = "fa fa-md fa-check";
Expand Down
6 changes: 6 additions & 0 deletions src/shared/components/oqlStatusBanner/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,10 @@
.banner-icon {
vertical-align:middle !important;
}

&.alert-unaffected {
background-color: #f3f3f3;
border-color: #bce8f1;
color: #31708f;
}
}
4 changes: 4 additions & 0 deletions src/shared/lib/oql/oqlfilter.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export declare function doesQueryContainOQL(
oql_query:string
):boolean;

export declare function doesQueryContainMutationOQL(
oql_query:string
):boolean;

export declare function filterCBioPortalWebServiceData(oql_query:string, data:(Mutation | NumericGeneMolecularData)[], accessors:any, default_oql:string): ExtendedAlteration[];

export declare function filterCBioPortalWebServiceDataByOQLLine(oql_query:string, data:(AnnotatedMutation | NumericGeneMolecularData)[], accessors:any, default_oql:string): OQLLineFilterOutput<ExtendedAlteration&AnnotatedMutation>[];
Expand Down
25 changes: 25 additions & 0 deletions src/shared/lib/oql/oqlfilter.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,31 @@ export function doesQueryContainOQL(oql_query) {
return ret;
}

export function doesQueryContainMutationOQL(oql_query) {
/* In: oql_query, a string, an OQL query (which could just be genes with no specified alterations)
Out: boolean, true iff the query has explicit mutation OQL (e.g. `BRCA1: MISSENSE` as opposed to just `BRCA1` or `BRCA1: MUT`)
*/

const parsedQuery = parseOQLQuery(oql_query);
let ret = false;
for (const singleGeneQuery of parsedQuery) {
if (singleGeneQuery.alterations !== false) {
for (const alteration of singleGeneQuery.alterations) {
if (alteration.alteration_type === "mut" &&
alteration.constr_rel !== undefined) {
// nontrivial mutation specification
ret = true;
break;
}
}
if (ret) {
break;
}
}
}
return ret;
}

var parsedOQLAlterationToSourceOQL = function(alteration) {
if (alteration.alteration_type === "cna") {
if (alteration.constr_rel === "=") {
Expand Down

0 comments on commit e1ca660

Please sign in to comment.