Skip to content

Commit

Permalink
fix: utilities requests
Browse files Browse the repository at this point in the history
  • Loading branch information
katiestahl committed Jul 29, 2024
1 parent 77f3088 commit 17beba5
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const GeneElementInput: React.FC<GeneElementInputProps> = ({
) {
const clientGeneElement: ClientGeneElement = {
...geneElementResponse.element,
element_id: element.element_id,
elementId: element.elementId,
nomenclature: nomenclatureResponse.nomenclature,
};
handleSave(index, clientGeneElement);
Expand Down
44 changes: 22 additions & 22 deletions client/src/services/ResponseModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ export interface Assay {
* Response model for domain ID autocomplete suggestion endpoint.
*/
export interface AssociatedDomainResponse {
warnings: string[] | null;
warnings?: string[] | null;
geneId: string;
suggestions: DomainParams[] | null;
}
Expand Down Expand Up @@ -628,8 +628,8 @@ export interface ClientStructuralElement {
* Response model for genomic coordinates retrieval
*/
export interface CoordsUtilsResponse {
warnings: string[] | null;
coordinatesData: GenomicData | null;
warnings?: string[] | null;
coordinates_data: GenomicData | null;
}
/**
* Model containing genomic and transcript exon data.
Expand All @@ -650,7 +650,7 @@ export interface GenomicData {
* Response model for demo fusion object retrieval endpoints.
*/
export interface DemoResponse {
warnings: string[] | null;
warnings?: string[] | null;
fusion: ClientAssayedFusion | ClientCategoricalFusion;
}
/**
Expand All @@ -668,21 +668,21 @@ export interface ExonCoordsRequest {
* Response model for gene element construction endoint.
*/
export interface GeneElementResponse {
warnings: string[] | null;
warnings?: string[] | null;
element: GeneElement | null;
}
/**
* Response model for functional domain constructor endpoint.
*/
export interface GetDomainResponse {
warnings: string[] | null;
warnings?: string[] | null;
domain: FunctionalDomain | null;
}
/**
* Response model for MANE transcript retrieval endpoint.
*/
export interface GetTranscriptsResponse {
warnings: string[] | null;
warnings?: string[] | null;
transcripts: ManeGeneTranscript[] | null;
}
/**
Expand All @@ -700,22 +700,22 @@ export interface ManeGeneTranscript {
Ensembl_prot: string;
MANE_status: string;
GRCh38_chr: string;
chr_start: string;
chr_end: string;
chr_start: number;
chr_end: number;
chr_strand: string;
}
/**
* Response model for regulatory element nomenclature endpoint.
*/
export interface NomenclatureResponse {
warnings: string[] | null;
warnings?: string[] | null;
nomenclature: string | null;
}
/**
* Response model for gene normalization endpoint.
*/
export interface NormalizeGeneResponse {
warnings: string[] | null;
warnings?: string[] | null;
term: string;
conceptId: string | null;
symbol: string | null;
Expand All @@ -725,20 +725,20 @@ export interface NormalizeGeneResponse {
* Response model for regulatory element constructor.
*/
export interface RegulatoryElementResponse {
warnings: string[] | null;
warnings?: string[] | null;
regulatoryElement: RegulatoryElement;
}
/**
* Abstract Response class for defining API response structures.
*/
export interface Response {
warnings: string[] | null;
warnings?: string[] | null;
}
/**
* Response model for sequence ID retrieval endpoint.
*/
export interface SequenceIDResponse {
warnings: string[] | null;
warnings?: string[] | null;
sequence: string;
refseqId: string | null;
ga4ghId: string | null;
Expand All @@ -748,7 +748,7 @@ export interface SequenceIDResponse {
* Response model for service_info endpoint.
*/
export interface ServiceInfoResponse {
warnings: string[] | null;
warnings?: string[] | null;
curfu_version: string;
fusor_version: string;
cool_seq_tool_version: string;
Expand All @@ -757,32 +757,32 @@ export interface ServiceInfoResponse {
* Response model for gene autocomplete suggestions endpoint.
*/
export interface SuggestGeneResponse {
warnings: string[] | null;
warnings?: string[] | null;
term: string;
matchesCount: number;
conceptId: [unknown, unknown, unknown, unknown, unknown][] | null;
matches_count: number;
concept_id: [unknown, unknown, unknown, unknown, unknown][] | null;
symbol: [unknown, unknown, unknown, unknown, unknown][] | null;
prevSymbols: [unknown, unknown, unknown, unknown, unknown][] | null;
prev_symbols: [unknown, unknown, unknown, unknown, unknown][] | null;
aliases: [unknown, unknown, unknown, unknown, unknown][] | null;
}
/**
* Response model for transcript segment element construction endpoint.
*/
export interface TemplatedSequenceElementResponse {
warnings: string[] | null;
warnings?: string[] | null;
element: TemplatedSequenceElement | null;
}
/**
* Response model for transcript segment element construction endpoint.
*/
export interface TxSegmentElementResponse {
warnings: string[] | null;
warnings?: string[] | null;
element: TranscriptSegmentElement | null;
}
/**
* Response model for Fusion validation endpoint.
*/
export interface ValidateFusionResponse {
warnings: string[] | null;
warnings?: string[] | null;
fusion: CategoricalFusion | AssayedFusion | null;
}
9 changes: 5 additions & 4 deletions client/src/services/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,14 @@ export const getExonCoords = async (
gene?: string,
txAc?: string
): Promise<CoordsUtilsResponse> => {
console.log(txAc);
const argsArray = [
`chromosome=${chromosome}`,
`strand=${strand === "+" ? "%2B" : "-"}`,
gene !== "" ? `gene=${gene}` : "",
txAc !== "" ? `transcript=${txAc}` : "",
start !== "" ? `start=${start}` : "",
end !== "" ? `end=${end}` : "",
gene && gene !== "" ? `gene=${gene}` : "",
txAc && txAc !== "" ? `transcript=${txAc}` : "",
start && start !== "" ? `start=${start}` : "",
end && end !== "" ? `end=${end}` : "",
];
const args = argsArray.filter((a) => a !== "").join("&");
const response = await fetch(`/api/utilities/get_exon?${args}`);
Expand Down
18 changes: 9 additions & 9 deletions server/src/curfu/routers/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def get_mane_transcripts(request: Request, term: str) -> dict:
normalized = request.app.state.fusor.gene_normalizer.normalize(term)
if normalized.match_type == gene_schemas.MatchType.NO_MATCH:
return {"warnings": [f"Normalization error: {term}"]}
if not normalized.gene.id.lower().startswith("hgnc"):
if not normalized.gene.id.replace("normalize.gene.", "").lower().startswith("hgnc"):
return {"warnings": [f"No HGNC symbol: {term}"]}
symbol = normalized.gene.label
transcripts = request.app.state.fusor.cool_seq_tool.mane_transcript_mappings.get_gene_mane_data(
Expand Down Expand Up @@ -99,7 +99,7 @@ async def get_genome_coords(
if warnings:
for warning in warnings:
logger.warning(warning)
return CoordsUtilsResponse(warnings=warnings, coordinatesData=None)
return CoordsUtilsResponse(warnings=warnings, coordinates_data=None)

# TODO necessary for now
if exon_start is not None and exon_start_offset is None:
Expand All @@ -120,9 +120,9 @@ async def get_genome_coords(
)
warnings = response.warnings
if warnings:
return CoordsUtilsResponse(warnings=warnings, coordinatesData=None)
return CoordsUtilsResponse(warnings=warnings, coordinates_data=None)

return CoordsUtilsResponse(coordinatesData=response.genomic_data, warnings=None)
return CoordsUtilsResponse(coordinates_data=response.genomic_data, warnings=None)


@router.get(
Expand Down Expand Up @@ -168,10 +168,10 @@ async def get_exon_coords(
if warnings:
for warning in warnings:
logger.warning(warning)
return CoordsUtilsResponse(warnings=warnings, coordinatesData=None)
return CoordsUtilsResponse(warnings=warnings, coordinates_data=None)

response = await request.app.state.fusor.cool_seq_tool.genomic_to_transcript_exon_coordinates(
chromosome,
response = await request.app.state.fusor.cool_seq_tool.ex_g_coords_mapper.genomic_to_transcript_exon_coordinates(
alt_ac=chromosome,
start=start,
end=end,
strand=strand_validated,
Expand All @@ -180,9 +180,9 @@ async def get_exon_coords(
)
warnings = response.warnings
if warnings:
return CoordsUtilsResponse(warnings=warnings, coordinatesData=None)
return CoordsUtilsResponse(warnings=warnings, coordinates_data=None)

return CoordsUtilsResponse(coordinatesData=response.genomic_data, warnings=None)
return CoordsUtilsResponse(coordinates_data=response.genomic_data, warnings=None)


@router.get(
Expand Down
14 changes: 7 additions & 7 deletions server/src/curfu/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class ClientRegulatoryElement(RegulatoryElement):
class Response(BaseModel):
"""Abstract Response class for defining API response structures."""

warnings: ResponseWarnings
warnings: ResponseWarnings | None = None

class Config:
"""Configure class"""
Expand Down Expand Up @@ -142,11 +142,11 @@ class SuggestGeneResponse(Response):
"""Response model for gene autocomplete suggestions endpoint."""

term: StrictStr
matchesCount: int
matches_count: int
# complete term, normalized symbol, normalized concept ID, chromosome ID, strand
conceptId: list[tuple[str, str, str, str, str]] | None
concept_id: list[tuple[str, str, str, str, str]] | None
symbol: list[tuple[str, str, str, str, str]] | None
prevSymbols: list[tuple[str, str, str, str, str]] | None
prev_symbols: list[tuple[str, str, str, str, str]] | None
aliases: list[tuple[str, str, str, str, str]] | None


Expand Down Expand Up @@ -207,7 +207,7 @@ def validate_number(cls, v) -> int:
class CoordsUtilsResponse(Response):
"""Response model for genomic coordinates retrieval"""

coordinatesData: GenomicData | None
coordinates_data: GenomicData | None


class SequenceIDResponse(Response):
Expand All @@ -233,8 +233,8 @@ class ManeGeneTranscript(BaseModel):
Ensembl_prot: str
MANE_status: str
GRCh38_chr: str
chr_start: str
chr_end: str
chr_start: int
chr_end: int
chr_strand: str


Expand Down
6 changes: 4 additions & 2 deletions server/src/curfu/sequence_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import logging

from cool_seq_tool.schemas import Strand

logger = logging.getLogger("curfu")
logger.setLevel(logging.DEBUG)

Expand All @@ -18,7 +20,7 @@ def get_strand(strand_input: str) -> int:
:raises InvalidInputException: if strand arg is invalid
"""
if strand_input == "+":
return 1
return Strand.POSITIVE
if strand_input == "-":
return -1
return Strand.NEGATIVE
raise InvalidInputError

0 comments on commit 17beba5

Please sign in to comment.