Skip to content

Commit

Permalink
updating models and fixing validation
Browse files Browse the repository at this point in the history
  • Loading branch information
katiestahl committed Jul 30, 2024
1 parent 1a1b61d commit c8dd15b
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
9 changes: 6 additions & 3 deletions client/src/components/Pages/Summary/Main/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ export const Summary: React.FC<Props> = ({ setVisibleTab }) => {
const [validatedFusion, setValidatedFusion] = useState<
AssayedFusion | CategoricalFusion | null
>(null);
const [formattedFusion, setFormattedFusion] = useState<
FormattedAssayedFusion | FormattedCategoricalFusion | null
>(null);
const [validationErrors, setValidationErrors] = useState<string[]>([]);
const { fusion } = useContext(FusionContext);

Expand Down Expand Up @@ -154,15 +157,15 @@ export const Summary: React.FC<Props> = ({ setVisibleTab }) => {
};
}
requestValidatedFusion(formattedFusion);
setFormattedFusion(formattedFusion);
}, [fusion]);

console.log(validatedFusion);

return (
<>
{(!validationErrors || validationErrors.length === 0) &&
formattedFusion &&
validatedFusion ? (
<Success fusion={validatedFusion} />
<Success fusion={formattedFusion} />
) : (
<>
{validationErrors && validationErrors.length > 0 ? (
Expand Down
17 changes: 11 additions & 6 deletions client/src/components/Pages/Summary/Readable/Readable.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import "./Readable.scss";
import { ClientStructuralElement } from "../../../../services/ResponseModels";
import {
ClientStructuralElement,
FormattedAssayedFusion,
FormattedCategoricalFusion,
} from "../../../../services/ResponseModels";
import React, { useContext, useEffect, useState } from "react";
import Chip from "@material-ui/core/Chip";
import { FusionContext } from "../../../../global/contexts/FusionContext";
Expand All @@ -12,24 +16,25 @@ import {
Typography,
} from "@material-ui/core";
import { eventDisplayMap } from "../../CausativeEvent/CausativeEvent";
import { FusionType } from "../Main/Summary";
import { getFusionNomenclature } from "../../../../services/main";

type Props = {
validatedFusion: FusionType;
formattedFusion: FormattedAssayedFusion | FormattedCategoricalFusion;
};

export const Readable: React.FC<Props> = ({ validatedFusion }) => {
export const Readable: React.FC<Props> = ({
formattedFusion: formattedFusion,
}) => {
// the validated fusion object is available as a parameter, but we'll use the
// client-ified version to grab things like nomenclature and display values
const { fusion } = useContext(FusionContext);
const [nomenclature, setNomenclature] = useState<string>("");

useEffect(() => {
getFusionNomenclature(validatedFusion).then((nmResponse) =>
getFusionNomenclature(formattedFusion).then((nmResponse) =>
setNomenclature(nmResponse.nomenclature as string)
);
}, [validatedFusion]);
}, [formattedFusion]);

const assayName = fusion.assay?.assayName ? fusion.assay.assayName : "";
const assayId = fusion.assay?.assayId ? `(${fusion.assay.assayId})` : "";
Expand Down
9 changes: 6 additions & 3 deletions client/src/components/Pages/Summary/Success/Success.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { useColorTheme } from "../../../../global/contexts/Theme/ColorThemeConte
import { Readable } from "../Readable/Readable";
import { Tabs, Tab } from "@material-ui/core/";
import { SummaryJSON } from "../JSON/SummaryJSON";
import { FusionType } from "../Main/Summary";
import {
FormattedAssayedFusion,
FormattedCategoricalFusion,
} from "../../../../services/ResponseModels";

const TabPanel = (props) => {
const { children, value, index, ...other } = props;
Expand All @@ -22,7 +25,7 @@ const TabPanel = (props) => {
};

interface Props {
fusion: FusionType;
fusion: FormattedAssayedFusion | FormattedCategoricalFusion;
}

export const Success: React.FC<Props> = ({ fusion }) => {
Expand Down Expand Up @@ -52,7 +55,7 @@ export const Success: React.FC<Props> = ({ fusion }) => {
</div>
<TabPanel value={currentTab} index={0}>
<div className="summary-sub-tab">
{fusion && <Readable validatedFusion={fusion} />}
{fusion && <Readable formattedFusion={fusion} />}
</div>
</TabPanel>
<TabPanel value={currentTab} index={1}>
Expand Down
1 change: 0 additions & 1 deletion client/src/services/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ export const getExonCoords = async (
gene?: string,
txAc?: string
): Promise<CoordsUtilsResponse> => {
console.log(txAc);
const argsArray = [
`chromosome=${chromosome}`,
`strand=${strand === "+" ? "%2B" : "-"}`,
Expand Down
5 changes: 3 additions & 2 deletions server/src/curfu/routers/nomenclature.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ def generate_fusion_nomenclature(
:return: response with fusion nomenclature
"""
try:
nomenclature = request.app.state.fusor.generate_nomenclature(fusion)
return {"nomenclature": nomenclature}
valid_fusion = request.app.state.fusor.fusion(**fusion)
except FUSORParametersException as e:
return {"warnings": [str(e)]}
nomenclature = request.app.state.fusor.generate_nomenclature(valid_fusion)
return {"nomenclature": nomenclature}

0 comments on commit c8dd15b

Please sign in to comment.