Skip to content

Commit

Permalink
add transcript
Browse files Browse the repository at this point in the history
  • Loading branch information
katiestahl committed Jul 10, 2024
1 parent b5a2b7b commit 3bdd399
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 70 deletions.
23 changes: 2 additions & 21 deletions client/src/services/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,36 +145,17 @@ export const getTxSegmentElementECT = async (
return responseJson;
};

export const getTxSegmentElementGCT = async (
transcript: string,
chromosome: string,
start: string,
end: string,
strand: string
): Promise<TxSegmentElementResponse> => {
const params: Array<string> = [
`transcript=${transcript}`,
`chromosome=${chromosome}`,
`strand=${strand === "+" ? "%2B" : "-"}`,
];
if (start !== "") params.push(`start=${start}`);
if (end !== "") params.push(`end=${end}`);
const url =
"api/construct/structural_element/tx_segment_gct?" + params.join("&");
const response = await fetch(url);
const responseJson = await response.json();
return responseJson;
};

export const getTxSegmentElementGCG = async (
gene: string,
transcript: string,
chromosome: string,
start: string,
end: string,
strand: string
): Promise<TxSegmentElementResponse> => {
const params: Array<string> = [
`gene=${gene}`,
`transcript=${transcript}`,
`chromosome=${chromosome}`,
`strand=${strand === "+" ? "%2B" : "-"}`,
];
Expand Down
52 changes: 3 additions & 49 deletions server/curfu/routers/constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,55 +82,6 @@ async def build_tx_segment_ect(
)
return TxSegmentElementResponse(element=tx_segment, warnings=warnings)


@router.get(
"/api/construct/structural_element/tx_segment_gct",
operation_id="buildTranscriptSegmentElementGCT",
response_model=TxSegmentElementResponse,
response_model_exclude_none=True,
tags=[RouteTag.CONSTRUCTORS],
)
async def build_tx_segment_gct(
request: Request,
transcript: str,
chromosome: str,
start: Optional[int] = Query(None),
end: Optional[int] = Query(None),
strand: Optional[str] = Query(None),
) -> TxSegmentElementResponse:
"""Construct Transcript Segment element by providing transcript and genomic
coordinates (chromosome, start, end positions).
\f
:param request: the HTTP request context, supplied by FastAPI. Use to access
FUSOR and UTA-associated tools.
:param transcript: transcript accession identifier
:param chromosome: chromosome (TODO how to identify?)
:param start: starting position (TODO assume residue-based?)
:param end: ending position
:return: Pydantic class with TranscriptSegment element if successful, and
warnings otherwise.
"""
if strand is not None:
try:
strand_validated = get_strand(strand)
except InvalidInputError:
warning = f"Received invalid strand value: {strand}"
logger.warning(warning)
return TxSegmentElementResponse(warnings=[warning], element=None)
else:
strand_validated = strand
tx_segment, warnings = await request.app.state.fusor.transcript_segment_element(
tx_to_genomic_coords=False,
transcript=parse_identifier(transcript),
chromosome=parse_identifier(chromosome),
start=start,
end=end,
strand=strand_validated,
residue_mode="inter-residue",
)
return TxSegmentElementResponse(element=tx_segment, warnings=warnings)


@router.get(
"/api/construct/structural_element/tx_segment_gcg",
operation_id="buildTranscriptSegmentElementGCG",
Expand All @@ -141,6 +92,7 @@ async def build_tx_segment_gct(
async def build_tx_segment_gcg(
request: Request,
gene: str,
transcript: str,
chromosome: str,
start: Optional[int] = Query(None),
end: Optional[int] = Query(None),
Expand All @@ -152,6 +104,7 @@ async def build_tx_segment_gcg(
:param request: the HTTP request context, supplied by FastAPI. Use to access
FUSOR and UTA-associated tools.
:param gene: gene (TODO how to identify?)
:param transcript: transcript accession identifier
:param chromosome: chromosome (TODO how to identify?)
:param start: starting position (TODO assume residue-based?)
:param end: ending position
Expand All @@ -170,6 +123,7 @@ async def build_tx_segment_gcg(
tx_segment, warnings = await request.app.state.fusor.transcript_segment_element(
tx_to_genomic_coords=False,
gene=gene,
transcript=parse_identifier(transcript),
chromosome=parse_identifier(chromosome),
strand=strand_validated,
start=start,
Expand Down

0 comments on commit 3bdd399

Please sign in to comment.