Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
katiestahl committed Jul 30, 2024
1 parent c20a6f8 commit 1a1b61d
Show file tree
Hide file tree
Showing 5 changed files with 145 additions and 39 deletions.
7 changes: 2 additions & 5 deletions client/src/components/Pages/Summary/Main/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ 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 @@ -113,11 +110,9 @@ export const Summary: React.FC<Props> = ({ setVisibleTab }) => {
}
} else {
setValidationErrors([]);
console.log(response.fusion);
setValidatedFusion(
response.fusion as CategoricalFusion | AssayedFusion
);
setFormattedFusion(formattedFusion);
}
});
};
Expand Down Expand Up @@ -161,6 +156,8 @@ export const Summary: React.FC<Props> = ({ setVisibleTab }) => {
requestValidatedFusion(formattedFusion);
}, [fusion]);

console.log(validatedFusion);

return (
<>
{(!validationErrors || validationErrors.length === 0) &&
Expand Down
121 changes: 93 additions & 28 deletions client/src/services/ResponseModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

/**
* Form of evidence supporting identification of the fusion.
* Specify possible Fusion types.
*/
export type Evidence = "observed" | "inferred";
export type FusionType = "CategoricalFusion" | "AssayedFusion";
/**
* Define possible classes of Regulatory Elements. Options are the possible values
* for /regulatory_class value property in the INSDC controlled vocabulary:
Expand Down Expand Up @@ -66,6 +66,20 @@ export type Range = [number | null, number | null];
* A character string of Residues that represents a biological sequence using the conventional sequence order (5'-to-3' for nucleic acid sequences, and amino-to-carboxyl for amino acid sequences). IUPAC ambiguity codes are permitted in Sequence Strings.
*/
export type SequenceString = string;
/**
* Define possible structural element type values.
*/
export type StructuralElementType =
| "TranscriptSegmentElement"
| "TemplatedSequenceElement"
| "LinkerSequenceElement"
| "GeneElement"
| "UnknownGeneElement"
| "MultiplePossibleGenesElement";
/**
* Form of evidence supporting identification of the fusion.
*/
export type Evidence = "observed" | "inferred";
/**
* Create enum for positive and negative strand
*/
Expand All @@ -81,34 +95,13 @@ export type EventType = "rearrangement" | "read-through" | "trans-splicing";
export type DomainStatus = "lost" | "preserved";

/**
* Information pertaining to the assay used in identifying the fusion.
*/
export interface Assay {
type?: "Assay";
assayName?: string | null;
assayId?: string | null;
methodUri?: string | null;
fusionDetection?: Evidence | null;
}
/**
* Assayed gene fusions from biological specimens are directly detected using
* RNA-based gene fusion assays, or alternatively may be inferred from genomic
* rearrangements detected by whole genome sequencing or by coarser-scale cytogenomic
* assays. Example: an EWSR1 fusion inferred from a breakapart FISH assay.
* Define Fusion class
*/
export interface AssayedFusion {
type?: "AssayedFusion";
export interface AbstractFusion {
type: FusionType;
regulatoryElement?: RegulatoryElement | null;
structure: (
| TranscriptSegmentElement
| GeneElement
| TemplatedSequenceElement
| LinkerElement
| UnknownGeneElement
)[];
structure: BaseStructuralElement[];
readingFramePreserved?: boolean | null;
causativeEvent?: CausativeEvent | null;
assay?: Assay | null;
}
/**
* Define RegulatoryElement class.
Expand Down Expand Up @@ -325,6 +318,43 @@ export interface SequenceReference {
circular?: boolean | null;
[k: string]: unknown;
}
/**
* Define base structural element class.
*/
export interface BaseStructuralElement {
type: StructuralElementType;
[k: string]: unknown;
}
/**
* Information pertaining to the assay used in identifying the fusion.
*/
export interface Assay {
type?: "Assay";
assayName?: string | null;
assayId?: string | null;
methodUri?: string | null;
fusionDetection?: Evidence | null;
}
/**
* Assayed gene fusions from biological specimens are directly detected using
* RNA-based gene fusion assays, or alternatively may be inferred from genomic
* rearrangements detected by whole genome sequencing or by coarser-scale cytogenomic
* assays. Example: an EWSR1 fusion inferred from a breakapart FISH assay.
*/
export interface AssayedFusion {
type?: "AssayedFusion";
regulatoryElement?: RegulatoryElement | null;
structure: (
| TranscriptSegmentElement
| GeneElement
| TemplatedSequenceElement
| LinkerElement
| UnknownGeneElement
)[];
readingFramePreserved?: boolean | null;
causativeEvent?: CausativeEvent | null;
assay?: Assay | null;
}
/**
* Define TranscriptSegment class
*/
Expand Down Expand Up @@ -664,6 +694,41 @@ export interface ExonCoordsRequest {
exonEnd?: number | null;
exonEndOffset?: number | null;
}
/**
* Assayed fusion with parameters defined as expected in fusor assayed_fusion function
* validate attempts to validate a fusion by constructing it by sending kwargs. In the models and frontend, these are camelCase,
* but the assayed_fusion and categorical_fusion constructors expect snake_case
*/
export interface FormattedAssayedFusion {
structure: (
| TranscriptSegmentElement
| GeneElement
| TemplatedSequenceElement
| LinkerElement
| UnknownGeneElement
)[];
causative_event?: CausativeEvent | null;
assay?: Assay | null;
regulatory_element?: RegulatoryElement | null;
reading_frame_preserved?: boolean | null;
}
/**
* Categorical fusion with parameters defined as expected in fusor categorical_fusion function
* validate attempts to validate a fusion by constructing it by sending kwargs. In the models and frontend, these are camelCase,
* but the assayed_fusion and categorical_fusion constructors expect snake_case
*/
export interface FormattedCategoricalFusion {
structure: (
| TranscriptSegmentElement
| GeneElement
| TemplatedSequenceElement
| LinkerElement
| MultiplePossibleGenesElement
)[];
regulatory_element?: RegulatoryElement | null;
critical_functional_domains?: FunctionalDomain[] | null;
reading_frame_preserved?: boolean | null;
}
/**
* Response model for gene element construction endoint.
*/
Expand Down Expand Up @@ -784,5 +849,5 @@ export interface TxSegmentElementResponse {
*/
export interface ValidateFusionResponse {
warnings?: string[] | null;
fusion: CategoricalFusion | AssayedFusion | null;
fusion: AbstractFusion | null;
}
18 changes: 17 additions & 1 deletion client/src/services/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import {
RegulatoryClass,
RegulatoryElementResponse,
ClientRegulatoryElement,
FormattedAssayedFusion,
FormattedCategoricalFusion,
} from "./ResponseModels";

export enum ElementType {
Expand Down Expand Up @@ -67,6 +69,20 @@ export type ElementUnion =
| TemplatedSequenceElement
| TranscriptSegmentElement;

export type AssayedFusionElements =
| GeneElement
| LinkerElement
| UnknownGeneElement
| TemplatedSequenceElement
| TranscriptSegmentElement;

export type CategoricalFusionElements =
| MultiplePossibleGenesElement
| GeneElement
| LinkerElement
| TemplatedSequenceElement
| TranscriptSegmentElement;

export type ClientFusion = ClientCategoricalFusion | ClientAssayedFusion;

/**
Expand Down Expand Up @@ -387,7 +403,7 @@ export const getGeneNomenclature = async (
* @returns nomenclature if successful
*/
export const getFusionNomenclature = async (
fusion: AssayedFusion | CategoricalFusion
fusion: FormattedAssayedFusion | FormattedCategoricalFusion
): Promise<NomenclatureResponse> => {
const response = await fetch("/api/nomenclature/fusion", {
method: "POST",
Expand Down
5 changes: 2 additions & 3 deletions server/src/curfu/routers/nomenclature.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,7 @@ def generate_fusion_nomenclature(
:return: response with fusion nomenclature
"""
try:
valid_fusion = request.app.state.fusor.fusion(**fusion)
nomenclature = request.app.state.fusor.generate_nomenclature(fusion)
return {"nomenclature": nomenclature}
except FUSORParametersException as e:
return {"warnings": [str(e)]}
nomenclature = request.app.state.fusor.generate_nomenclature(valid_fusion)
return {"nomenclature": nomenclature}
33 changes: 31 additions & 2 deletions server/src/curfu/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@

from cool_seq_tool.schemas import GenomicData
from fusor.models import (
AbstractFusion,
Assay,
AssayedFusion,
AssayedFusionElements,
CategoricalFusion,
CategoricalFusionElements,
CausativeEvent,
FunctionalDomain,
Fusion,
GeneElement,
LinkerElement,
MultiplePossibleGenesElement,
Expand Down Expand Up @@ -176,7 +180,7 @@ class AssociatedDomainResponse(Response):
class ValidateFusionResponse(Response):
"""Response model for Fusion validation endpoint."""

fusion: Fusion | None
fusion: AbstractFusion | None


class ExonCoordsRequest(BaseModel):
Expand Down Expand Up @@ -288,6 +292,31 @@ class ClientAssayedFusion(AssayedFusion):
]


class FormattedAssayedFusion(BaseModel):
"""Assayed fusion with parameters defined as expected in fusor assayed_fusion function
validate attempts to validate a fusion by constructing it by sending kwargs. In the models and frontend, these are camelCase,
but the assayed_fusion and categorical_fusion constructors expect snake_case
"""

structure: AssayedFusionElements
causative_event: CausativeEvent | None = None
assay: Assay | None = None
regulatory_element: RegulatoryElement | None = None
reading_frame_preserved: bool | None = None


class FormattedCategoricalFusion(BaseModel):
"""Categorical fusion with parameters defined as expected in fusor categorical_fusion function
validate attempts to validate a fusion by constructing it by sending kwargs. In the models and frontend, these are camelCase,
but the assayed_fusion and categorical_fusion constructors expect snake_case
"""

structure: CategoricalFusionElements
regulatory_element: RegulatoryElement | None = None
critical_functional_domains: list[FunctionalDomain] | None = None
reading_frame_preserved: bool | None = None


class NomenclatureResponse(Response):
"""Response model for regulatory element nomenclature endpoint."""

Expand Down

0 comments on commit 1a1b61d

Please sign in to comment.