From ce74f4bfa44ee8e53a5e8b6efb44c6a1c1e08004 Mon Sep 17 00:00:00 2001 From: katie stahl Date: Wed, 6 Sep 2023 13:58:56 -0400 Subject: [PATCH] fix: adding validation to disallow same-gene fusions (#251) (#263) * fix: adding validation to disallow same-gene fusions * remove console log * fix: adding validation to disallow same-gene fusions * fix: fixing console error for unique keys --- .../Pages/Summary/Invalid/Invalid.tsx | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/client/src/components/Pages/Summary/Invalid/Invalid.tsx b/client/src/components/Pages/Summary/Invalid/Invalid.tsx index 793dc850..97bca2dd 100644 --- a/client/src/components/Pages/Summary/Invalid/Invalid.tsx +++ b/client/src/components/Pages/Summary/Invalid/Invalid.tsx @@ -49,6 +49,26 @@ export const Invalid: React.FC = ({ })); const classes = useStyles(); + const duplicateGeneError = (duplicateGenes: string[]) => { + return ( + + Duplicate gene element(s) detected: {duplicateGenes.join(", ")}. Per the{" "} + + Gene Fusion Specification + + , Internal Tandem Duplications are not considered gene fusions, as they do not involve an interaction + between two or more genes.{" "} + setVisibleTab(0)}> + Edit elements to resolve. + + + ) + }; + const elementNumberError = ( Insufficient number of structural and regulatory elements. Per the{" "} @@ -146,6 +166,10 @@ export const Invalid: React.FC = ({ const CURIE_PATTERN = /^\w[^:]*:.+$/; + const geneElements = fusion.structural_elements.filter(el => el.type === "GeneElement").map(el => { return el.nomenclature }) + const findDuplicates = arr => arr.filter((item, index) => arr.indexOf(item) !== index) + const duplicateGenes = findDuplicates(geneElements) + const checkErrors = () => { const errorElements: React.ReactFragment[] = []; if ( @@ -166,6 +190,9 @@ export const Invalid: React.FC = ({ errorElements.push(noGeneElementsError); } } + if (duplicateGenes.length > 0) { + errorElements.push(duplicateGeneError(duplicateGenes)) + } if (fusion.type == "AssayedFusion") { if ( !( @@ -210,10 +237,10 @@ export const Invalid: React.FC = ({ {checkErrors().map((error, index: number) => ( - <> + {index > 0 ? : <>} {error} - + ))}