Skip to content

Commit

Permalink
fix: adding validation to disallow same-gene fusions (#251) (#263)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
katiestahl authored Sep 6, 2023
1 parent 95b95a7 commit ce74f4b
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions client/src/components/Pages/Summary/Invalid/Invalid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,26 @@ export const Invalid: React.FC<Props> = ({
}));
const classes = useStyles();

const duplicateGeneError = (duplicateGenes: string[]) => {
return (
<ListItemText>
Duplicate gene element(s) detected: <b>{duplicateGenes.join(", ")}</b>. Per the{" "}
<Link
href="https://fusions.cancervariants.org/en/latest/information_model.html#structural-elements"
target="_blank"
rel="noopener noreferrer"
>
Gene Fusion Specification
</Link>
, Internal Tandem Duplications are not considered gene fusions, as they do not involve an interaction
between <b>two or more genes</b>.{" "}
<Link href="#" onClick={() => setVisibleTab(0)}>
Edit elements to resolve.
</Link>
</ListItemText>
)
};

const elementNumberError = (
<ListItemText>
Insufficient number of structural and regulatory elements. Per the{" "}
Expand Down Expand Up @@ -146,6 +166,10 @@ export const Invalid: React.FC<Props> = ({

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 (
Expand All @@ -166,6 +190,9 @@ export const Invalid: React.FC<Props> = ({
errorElements.push(noGeneElementsError);
}
}
if (duplicateGenes.length > 0) {
errorElements.push(duplicateGeneError(duplicateGenes))
}
if (fusion.type == "AssayedFusion") {
if (
!(
Expand Down Expand Up @@ -210,10 +237,10 @@ export const Invalid: React.FC<Props> = ({
</Box>
<List component={Paper} className={classes.list}>
{checkErrors().map((error, index: number) => (
<>
<Box key={index}>
{index > 0 ? <Divider /> : <></>}
<ListItem key={index}>{error}</ListItem>
</>
</Box>
))}
</List>
</Box>
Expand Down

0 comments on commit ce74f4b

Please sign in to comment.