Skip to content

Commit

Permalink
Merge pull request #1081 from zhx828/master
Browse files Browse the repository at this point in the history
Linkout to categorical alteration page if the alteration starts with the categorical alteration
  • Loading branch information
zhx828 authored Feb 7, 2024
2 parents e3691d9 + a7320d9 commit f67a10d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
8 changes: 8 additions & 0 deletions src/main/webapp/app/config/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,14 @@ export const GAIN_OF_FUNCTION_MUTATIONS = 'Gain-of-function Mutations';
export const LOSS_OF_FUNCTION_MUTATIONS = 'Loss-of-function Mutations';
export const SWITCH_OF_FUNCTION_MUTATIONS = 'Switch-of-function Mutations';

export const CATEGORICAL_ALTERATIONS = [
ONCOGENIC_MUTATIONS,
FUSIONS,
TRUNCATING_MUTATIONS,
GAIN_OF_FUNCTION_MUTATIONS,
LOSS_OF_FUNCTION_MUTATIONS,
SWITCH_OF_FUNCTION_MUTATIONS,
];
export enum SEARCH_QUERY_KEY {
REFERENCE_GENOME = 'refGenome',
}
Expand Down
9 changes: 6 additions & 3 deletions src/main/webapp/app/shared/utils/UrlUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
import {
encodeSlash,
getAlterationName,
getCategoricalAlteration,
getYouTubeLink,
IAlteration,
} from 'app/shared/utils/Utils';
Expand Down Expand Up @@ -73,17 +74,19 @@ export const getAlterationPageLink = (props: {
searchQueries?: AlterationPageSearchQueries;
hashQueries?: AlterationPageHashQueries;
}): string => {
let pageLink = `${PAGE_ROUTE.GENE_HEADER}/${props.hugoSymbol}/${
const linkoutAltName = getCategoricalAlteration(
typeof props.alteration === 'string'
? props.alteration
: props.alteration.name
}`;
);

let pageLink = `${PAGE_ROUTE.GENE_HEADER}/${props.hugoSymbol}/${linkoutAltName}`;
if (props.cancerType) {
pageLink = `${pageLink}/${encodeSlash(props.cancerType)}`;
}
const sq = props.searchQueries || {};

// Prop alterationRefGenomes is just a convinient way to process reference genomes when it's a list.
// Prop alterationRefGenomes is just a convenient way to process reference genomes when it's a list.
if (!sq.refGenome && props.alterationRefGenomes) {
if (!props.alterationRefGenomes.includes(DEFAULT_REFERENCE_GENOME)) {
sq.refGenome = props.alterationRefGenomes[0];
Expand Down
27 changes: 15 additions & 12 deletions src/main/webapp/app/shared/utils/Utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
APP_LOCAL_DATE_FORMAT,
APP_LOCAL_DATETIME_FORMAT_Z,
APP_TIMESTAMP_FORMAT,
CATEGORICAL_ALTERATIONS,
DELETION,
FUSIONS,
GAIN_OF_FUNCTION_MUTATIONS,
Expand Down Expand Up @@ -756,22 +757,24 @@ export interface IAlteration {
}

export const isCategoricalAlteration = (alteration: string) => {
const categoricalAlterations = [
ONCOGENIC_MUTATIONS,
FUSIONS,
TRUNCATING_MUTATIONS,
GAIN_OF_FUNCTION_MUTATIONS,
LOSS_OF_FUNCTION_MUTATIONS,
SWITCH_OF_FUNCTION_MUTATIONS,
];
return (
alteration &&
categoricalAlterations.filter(alt =>
CATEGORICAL_ALTERATIONS.filter(alt =>
alteration.toLowerCase().startsWith(alt.toLowerCase())
).length > 0
);
};

export const getCategoricalAlteration = (alteration: string) => {
if (isCategoricalAlteration(alteration)) {
const matched = CATEGORICAL_ALTERATIONS.filter(categoricalAlt => {
return alteration.toLowerCase().startsWith(categoricalAlt.toLowerCase());
});
return matched.pop();
}
return alteration;
};

/**
*
* @param alteration Alteration, either in string or in IAlteration
Expand Down Expand Up @@ -856,7 +859,7 @@ export const getCategoricalAlterationDescription = (
default:
break;
}
if (alteration.startsWith(ONCOGENIC_MUTATIONS)) {
if (ONCOGENIC_MUTATIONS.toLowerCase() === alteration.toLowerCase()) {
let prefix =
'Defined as point mutations, rearrangements/fusions or copy number alterations within';
if (oncogene && !tsg) {
Expand All @@ -869,8 +872,8 @@ export const getCategoricalAlterationDescription = (
<span>
{prefix} {geneLink} considered "oncogenic", "likely oncogenic" or
"resistance" as defined by{' '}
<SopPageLink version={2.2}>
{ONCOKB_TM} Curation Standard Operating Protocol v2.2, Chapter 2,
<SopPageLink>
{ONCOKB_TM} Curation Standard Operating Protocol, Chapter 1,
Sub-Protocol 2.5
</SopPageLink>
.
Expand Down

0 comments on commit f67a10d

Please sign in to comment.