@@ -13,6 +13,9 @@ import { onValue, ref, get } from 'firebase/database';
1313import { Button , Col , Row } from 'reactstrap' ;
1414import { GroupBase } from 'react-select' ;
1515import Select from 'react-select/dist/declarations/src/Select' ;
16+ import { alterationControllerClient } from '../api/clients' ;
17+ import { AnnotateAlterationBody , Alteration as ApiAlteration , Gene as ApiGene } from 'app/shared/api/generated/curation' ;
18+ import { REFERENCE_GENOME } from 'app/config/constants/constants' ;
1619
1720export interface IAddVusModalProps extends StoreProps {
1821 hugoSymbol : string | undefined ;
@@ -86,14 +89,14 @@ const AddVusModal = (props: IAddVusModalProps) => {
8689 } , [ ] ) ;
8790
8891 function handleInitialVariantsAdd ( ) {
89- props . convertOptions ?. initialAlterations . forEach ( initAlt => {
90- const filteredAlts = filterAlterationsAndNotify ( initAlt ) ;
92+ props . convertOptions ?. initialAlterations . forEach ( async initAlt => {
93+ const filteredAlts = await filterAlterationsAndNotify ( initAlt ) ;
9194 setVariants ( state => [ ...state , ...filteredAlts . map ( alt => createOption ( alt ) ) ] ) ;
9295 } ) ;
9396 }
9497
95- function handleVariantAdded ( ) {
96- const filteredAlterations = filterAlterationsAndNotify ( inputValue ) ;
98+ async function handleVariantAdded ( ) {
99+ const filteredAlterations = await filterAlterationsAndNotify ( inputValue ) ;
97100 setVariants ( state => [ ...state , ...filteredAlterations . map ( alt => createOption ( alt ) ) ] ) ;
98101 setInputValue ( '' ) ;
99102 }
@@ -106,7 +109,7 @@ const AddVusModal = (props: IAddVusModalProps) => {
106109 }
107110 } ;
108111
109- const filterAlterationsAndNotify = ( variant : string ) => {
112+ const filterAlterationsAndNotify = async ( variant : string ) => {
110113 const result : string [ ] = [ ] ;
111114 const alterations = parseAlterationName ( variant ) ;
112115 // should only have a single alteration
@@ -123,12 +126,31 @@ const AddVusModal = (props: IAddVusModalProps) => {
123126 return name . toLowerCase ( ) === alteration . toLowerCase ( ) ;
124127 } ) ;
125128
129+ let isHotspot = false ;
130+ try {
131+ const request : AnnotateAlterationBody [ ] = [
132+ {
133+ referenceGenome : REFERENCE_GENOME . GRCH37 ,
134+ alteration : { alteration, genes : [ { hugoSymbol : props . hugoSymbol } as ApiGene ] } as ApiAlteration ,
135+ } ,
136+ ] ;
137+ const response = await alterationControllerClient . annotateAlterations ( request ) ;
138+ if ( response . data [ 0 ] . annotation ?. hotspot ) {
139+ isHotspot = true ;
140+ }
141+ } catch ( error ) {
142+ notifyError ( `Error annotating alteration: ${ error } ` ) ;
143+ continue ;
144+ }
145+
126146 if ( dropdownAlreadyHasVariant ) {
127147 notifyError ( new Error ( `${ alteration } is already selected. The duplicate alteration(s) was not added.` ) ) ;
128148 } else if ( vusTableAlreadyHasVariant ) {
129149 notifyError ( new Error ( `${ alteration } is already in the VUS table. The duplicate alteration(s) was not added.` ) ) ;
130150 } else if ( alreadyHasVariantInMutationList ) {
131151 notifyError ( new Error ( `${ alteration } is already in the Mutation List. The duplicate alteration(s) was not added.` ) ) ;
152+ } else if ( isHotspot ) {
153+ notifyError ( new Error ( `${ alteration } is a hotspot. The alteration(s) was not added.` ) ) ;
132154 } else {
133155 result . push ( alteration ) ;
134156 }
0 commit comments