Skip to content

Commit

Permalink
Show variant name and variant group in the navigation panel in Entity…
Browse files Browse the repository at this point in the history
…Viewer
  • Loading branch information
azangru committed Jan 31, 2024
1 parent c7b956e commit b38efff
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

import React from 'react';

import { getReferenceAndAltAlleles } from 'src/shared/helpers/variantHelpers';
import {
getReferenceAndAltAlleles,
getMostSevereVariantConsequence,
getVariantGroupLabel
} from 'src/shared/helpers/variantHelpers';

import { useDefaultEntityViewerVariantQuery } from 'src/content/app/entity-viewer/state/api/entityViewerThoasSlice';

Expand Down Expand Up @@ -44,14 +48,17 @@ const VariantViewNavigationPanel = (props: Props) => {
return null;
}

const { alleleSequence, isReferenceAlleleActive } = currentData;
const { variant, alleleSequence, isReferenceAlleleActive } = currentData;

const mostSevereVariantConsequence = getMostSevereVariantConsequence(variant);
const variantGroupLabel = getVariantGroupLabel(mostSevereVariantConsequence);

return (
<div className={styles.grid}>
<VariantViewTab
viewId="default"
tabText="Variant name"
labelText="Protein altering variant"
tabText={variant.name}
labelText={variantGroupLabel}
pressed={true}
/>
<VariantViewTab
Expand Down Expand Up @@ -153,6 +160,7 @@ const useVariantViewNavigationData = (params: Props) => {

return {
currentData: {
variant: currentData.variant,
alleleSequence,
isReferenceAlleleActive
},
Expand Down
9 changes: 9 additions & 0 deletions src/shared/helpers/variantHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ export const getVariantGroupCSSColour = (variantType: string) => {
: undefined;
};

/**
* Given variant consequence (predicted by VEP),
* return the name of the group to which it belongs
*/
export const getVariantGroupLabel = (variantConsequence: string) => {
const variantGroupId = getVariantGroupIdByConsequence(variantConsequence);
return variantGroups.find((group) => group.id === variantGroupId)?.label;
};

const buildVariantConsequenceToGroupIdMap = () => {
const colourMap = new Map<string, number>();

Expand Down

0 comments on commit b38efff

Please sign in to comment.