Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: update tx segment element with updated cool-seq-tool structure changes #314

Merged
merged 19 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
fa8c93c
feat!: update tx segment element with updated cool-seq-tool structure…
katiestahl Aug 12, 2024
9a6281d
fix: tx segment element bugs
katiestahl Aug 12, 2024
fbe0a83
update response models
katiestahl Aug 12, 2024
b2c6787
feat: update variable names with cool-seq-tool updates
katiestahl Aug 20, 2024
053843e
feat: update calls to fusor and cool-seq-tool with updated params
katiestahl Aug 21, 2024
f314306
Merge branch 'staging' into cool-seq-tool-tx-updates
katiestahl Aug 21, 2024
b58a5b7
update fusor version
katiestahl Aug 21, 2024
726d7e6
updating fusor version
katiestahl Aug 22, 2024
6c672bd
wip: fixing tests from cool-seq-tool and fusor updates
katiestahl Aug 22, 2024
d56bff0
tests: updating tests with fusor changes
katiestahl Aug 22, 2024
7191723
fixing test examples and adding checks for correct start/end on seque…
katiestahl Aug 22, 2024
09e10bd
update reqs
korikuzma Aug 23, 2024
7f56752
fix: bug where chromosome field was not editable
katiestahl Aug 23, 2024
f26dd9f
Merge branch 'cool-seq-tool-tx-updates' of https://github.com/cancerv…
katiestahl Aug 23, 2024
a8833e4
removing editable field for now since it's not working as designed, w…
katiestahl Aug 23, 2024
c3d093c
changing validation for tx segment elemetn since they only require ei…
katiestahl Aug 23, 2024
b611f84
refactor: remove ability to change strand, since it's auto populated
katiestahl Aug 26, 2024
e5545eb
removing strand switch
katiestahl Aug 27, 2024
09183e1
fix: ability to change strand for templated sequence
katiestahl Aug 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
txAc,
txChrom,
txStartingGenomic,
txEndingGenomic,
txStrand
txEndingGenomic
).then((txSegmentResponse) => {
if (
txSegmentResponse.warnings &&
Expand Down
2 changes: 0 additions & 2 deletions client/src/components/Pages/Summary/Main/Summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ export const Summary: React.FC<Props> = ({ setVisibleTab }) => {
setFormattedFusion(formattedFusion);
}, [fusion]);

console.log(formattedFusion);

return (
<>
{(!validationErrors || validationErrors.length === 0) &&
Expand Down
48 changes: 29 additions & 19 deletions client/src/components/Utilities/GetCoordinates/GetCoordinates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,12 @@ const GetCoordinates: React.FC = () => {
exonEndOffset
).then((coordsResponse) => handleResponse(coordsResponse));
} else if (inputType == "genomic_coords_gene") {
getExonCoords(chromosome, start, end, strand, gene).then(
(coordsResponse) => handleResponse(coordsResponse)
getExonCoords(chromosome, start, end, gene).then((coordsResponse) =>
handleResponse(coordsResponse)
);
} else if (inputType == "genomic_coords_tx") {
getExonCoords(chromosome, start, end, strand, "", txAc).then(
(coordsResponse) => handleResponse(coordsResponse)
getExonCoords(chromosome, start, end, "", txAc).then((coordsResponse) =>
handleResponse(coordsResponse)
);
}
};
Expand All @@ -215,25 +215,38 @@ const GetCoordinates: React.FC = () => {
const renderResults = (): React.ReactFragment => {
if (inputValid) {
if (results) {
const txSegStart = results.seg_start;
const txSegEnd = results.seg_end;

const genomicStart =
txSegStart?.genomic_location.start ||
txSegStart?.genomic_location.end;
const genomicEnd =
txSegEnd?.genomic_location.start || txSegEnd?.genomic_location.end;

return (
<Table>
{renderRow("Gene", results.gene)}
{renderRow("Chromosome", results.chr)}
{results.start ? renderRow("Genomic start", results.start) : null}
{results.end ? renderRow("Genomic end", results.end) : null}
{renderRow("Chromosome", results.genomic_ac)}
{genomicStart != null
? renderRow("Genomic start", genomicStart)
: null}
{genomicEnd != null ? renderRow("Genomic end", genomicEnd) : null}
{results.strand
? renderRow("Strand", results.strand === 1 ? "+" : "-")
: null}
{renderRow("Transcript", results.transcript)}
{results.exon_start
? renderRow("Exon start", results.exon_start)
{renderRow("Transcript", results.tx_ac)}
{txSegStart?.exon_ord != null
? renderRow("Exon start", txSegStart.exon_ord)
: null}
{txSegStart?.offset != null
? renderRow("Exon start offset", txSegStart.offset)
: null}
{results.exon_start_offset
? renderRow("Exon start offset", results.exon_start_offset)
{txSegEnd?.exon_ord != null
? renderRow("Exon end", txSegEnd.exon_ord)
: null}
{results.exon_end ? renderRow("Exon end", results.exon_end) : null}
{results.exon_end_offset
? renderRow("Exon end offset", results.exon_end_offset)
{txSegEnd?.offset != null
? renderRow("Exon end offset", txSegEnd.offset)
: null}
</Table>
);
Expand All @@ -250,10 +263,7 @@ const GetCoordinates: React.FC = () => {
const genomicCoordinateInfo = (
<>
<Box display="flex" justifyContent="space-between" width="100%">
<ChromosomeField
fieldValue={chromosome}
errorText={chromosomeText}
/>
<ChromosomeField fieldValue={chromosome} errorText={chromosomeText} />
<Box mt="18px">
<Box className={classes.strand} width="125px">
<StrandSwitch
Expand Down
70 changes: 57 additions & 13 deletions client/src/services/ResponseModels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,22 +638,66 @@ export interface ClientStructuralElement {
*/
export interface CoordsUtilsResponse {
warnings?: string[] | null;
coordinates_data: GenomicData | null;
coordinates_data: GenomicTxSegService | null;
}
/**
* Model containing genomic and transcript exon data.
* Service model for genomic and transcript data.
*/
export interface GenomicData {
gene: string;
chr: string;
start?: number | null;
end?: number | null;
exon_start?: number | null;
exon_start_offset?: number | null;
exon_end?: number | null;
exon_end_offset?: number | null;
transcript: string;
strand: Strand;
export interface GenomicTxSegService {
/**
* HGNC gene symbol.
*/
gene?: string | null;
/**
* RefSeq genomic accession.
*/
genomic_ac?: string | null;
/**
* RefSeq transcript accession.
*/
tx_ac?: string | null;
/**
* Start transcript segment.
*/
seg_start?: TxSegment | null;
/**
* End transcript segment.
*/
seg_end?: TxSegment | null;
/**
* Error messages.
*/
errors?: string[];
/**
* Service metadata.
*/
service_meta: ServiceMeta;
}
/**
* Model for representing transcript segment data.
*/
export interface TxSegment {
/**
* Exon number. 0-based.
*/
exon_ord: number;
/**
* The value added to or subtracted from the `genomic_location` to find the start or end of an exon.
*/
offset?: number;
/**
* The genomic position of a transcript segment.
*/
genomic_location: SequenceLocation;
}
/**
* Metadata for cool_seq_tool service
*/
export interface ServiceMeta {
name?: "cool_seq_tool";
version: string;
response_datetime: string;
url?: "https://github.com/GenomicMedLab/cool-seq-tool";
}
/**
* Response model for demo fusion object retrieval endpoints.
Expand Down
6 changes: 1 addition & 5 deletions client/src/services/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,11 @@ export const getTxSegmentElementGCT = async (
transcript: string,
chromosome: string,
start: string,
end: string,
strand: string
end: 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}`);
Expand Down Expand Up @@ -251,13 +249,11 @@ export const getExonCoords = async (
chromosome: string,
start: string,
end: string,
strand: string,
gene?: string,
txAc?: string
): Promise<CoordsUtilsResponse> => {
const argsArray = [
`chromosome=${chromosome}`,
`strand=${strand === "+" ? "%2B" : "-"}`,
gene && gene !== "" ? `gene=${gene}` : "",
txAc && txAc !== "" ? `transcript=${txAc}` : "",
start && start !== "" ? `start=${start}` : "",
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ decorator==5.1.1
executing==1.2.0
fake-useragent==1.1.3
fastapi==0.100.0
fusor==0.2.0
fusor==0.4.1
ga4gh.vrs==2.0.0a10
gene-normalizer==0.4.0
h11==0.14.0
Expand Down
4 changes: 2 additions & 2 deletions server/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ dependencies = [
"click",
"boto3",
"botocore",
"fusor ~= 0.3.0",
"cool-seq-tool ~= 0.5.1",
"fusor ~= 0.4.1",
"cool-seq-tool ~= 0.7.0",
"pydantic == 2.4.2",
"gene-normalizer ~= 0.4.0",
]
Expand Down
38 changes: 7 additions & 31 deletions server/src/curfu/routers/constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
TemplatedSequenceElementResponse,
TxSegmentElementResponse,
)
from curfu.sequence_services import InvalidInputError, get_strand
from curfu.sequence_services import get_strand

router = APIRouter()

Expand Down Expand Up @@ -93,7 +93,6 @@ async def build_tx_segment_gct(
chromosome: str,
start: int | None = Query(None),
end: int | None = Query(None),
strand: str | None = Query(None),
) -> TxSegmentElementResponse:
"""Construct Transcript Segment element by providing transcript and genomic
coordinates (chromosome, start, end positions).
Expand All @@ -107,23 +106,12 @@ async def build_tx_segment_gct(
: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",
genomic_ac=parse_identifier(chromosome),
seg_start_genomic=start,
seg_end_genomic=end,
)
return TxSegmentElementResponse(element=tx_segment, warnings=warnings)

Expand All @@ -141,7 +129,6 @@ async def build_tx_segment_gcg(
chromosome: str,
start: int | None = Query(None),
end: int | None = Query(None),
strand: str | None = Query(None),
) -> TxSegmentElementResponse:
"""Construct Transcript Segment element by providing gene and genomic
coordinates (chromosome, start, end positions).
Expand All @@ -155,23 +142,12 @@ async def build_tx_segment_gcg(
: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,
gene=gene,
chromosome=parse_identifier(chromosome),
strand=strand_validated,
start=start,
end=end,
residue_mode="inter-residue",
genomic_ac=parse_identifier(chromosome),
seg_start_genomic=start,
seg_end_genomic=end,
)
return TxSegmentElementResponse(element=tx_segment, warnings=warnings)

Expand Down
6 changes: 3 additions & 3 deletions server/src/curfu/routers/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def clientify_structural_element(
context
:return: client-ready structural element
"""
element_args = element.dict()
element_args = element.model_dump()
element_args["elementId"] = str(uuid4())

if element.type == StructuralElementType.UNKNOWN_GENE_ELEMENT:
Expand Down Expand Up @@ -119,7 +119,7 @@ def clientify_fusion(fusion: Fusion, fusor_instance: FUSOR) -> ClientFusion:
:param fusor_instance: FUSOR object instance provided by FastAPI request context
:return: completed client-ready fusion
"""
fusion_args = fusion.dict()
fusion_args = fusion.model_dump()
client_elements = [
clientify_structural_element(element, fusor_instance)
for element in fusion.structure
Expand All @@ -145,7 +145,7 @@ def clientify_fusion(fusion: Fusion, fusor_instance: FUSOR) -> ClientFusion:
if fusion.criticalFunctionalDomains:
client_domains = []
for domain in fusion.criticalFunctionalDomains:
client_domain = domain.dict()
client_domain = domain.model_dump()
client_domain["domainId"] = str(uuid4())
client_domains.append(client_domain)
fusion_args["criticalFunctionalDomains"] = client_domains
Expand Down
Loading