Skip to content

Commit

Permalink
fix: unable to construct tx segment when genomic coordinate between e…
Browse files Browse the repository at this point in the history
…xons
  • Loading branch information
katiestahl committed Sep 25, 2024
1 parent d15a82c commit 0a22cb1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ interface TxSegmentElementInputProps extends StructuralElementInputProps {

const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
element,
index,
handleSave,
handleDelete,
icon,
Expand All @@ -44,7 +43,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({

const [genomicInputType, setGenomicInputType] =
useState<GenomicInputType | null>(
element.inputGene
element.inputGene || element.gene
? GenomicInputType.GENE
: element.inputTx
? GenomicInputType.TRANSCRIPT
Expand All @@ -54,7 +53,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
// "Text" variables refer to helper or warning text to set under input fields
// TODO: this needs refactored so badly
const [txAc, setTxAc] = useState(element.inputTx || "");
const [txAcText, setTxAcText] = useState("");
const [txAcHelperText, setTxAcHelperText] = useState("");

const [txGene, setTxGene] = useState(element.inputGene || "");
const [txGeneText, setTxGeneText] = useState("");
Expand Down Expand Up @@ -88,9 +87,6 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
const [endingExonOffsetText, setEndingExonOffsetText] = useState("");

const [geneTranscripts, setGeneTranscripts] = useState([]);
const [selectedTranscript, setSelectedTranscript] = useState(
element.inputTx || ""
);

const [pendingResponse, setPendingResponse] = useState(false);

Expand All @@ -99,7 +95,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({

const genomicInputComplete =
genomicInputType === GenomicInputType.GENE
? txGene !== "" && selectedTranscript !== ""
? txGene !== "" && txAc !== ""
: txAc !== "";

// programming horror
Expand All @@ -116,7 +112,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
inputComplete &&
hasRequiredEnds &&
txGeneText === "" &&
txAcText === "" &&
txAcHelperText === "" &&
txStartingGenomicText === "" &&
txEndingGenomicText === "" &&
startingExonText === "" &&
Expand Down Expand Up @@ -171,7 +167,6 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
};

const handleTranscriptSelect = (event: any) => {
setSelectedTranscript(event.target.value as string);
setTxAc(event.target.value as string);
};

Expand Down Expand Up @@ -226,7 +221,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
getTxSegmentElementGC(
txGene,
txChrom,
selectedTranscript,
txAc,
txStartingGenomic,
txEndingGenomic
).then((txSegmentResponse) => {
Expand All @@ -240,6 +235,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
inputType: txInputType,
inputStrand: txStrand,
inputGene: txGene,
inputTx: txAc,
inputChr: txChrom,
inputGenomicStart: txStartingGenomic,
inputGenomicEnd: txEndingGenomic,
Expand All @@ -263,7 +259,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
// transcript invalid
const txWarning = `Unable to get exons for ${txAc}`;
if (txSegmentResponse.warnings.includes(txWarning)) {
setTxAcText("Unrecognized value");
setTxAcHelperText("Unrecognized value");
}
// exon(s) invalid
if (startingExon !== undefined) {
Expand All @@ -279,7 +275,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
}
}
} else {
setTxAcText("");
setTxAcHelperText("");
setStartingExonText("");
setEndingExonText("");
const inputParams = {
Expand Down Expand Up @@ -388,7 +384,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
<TranscriptField
fieldValue={txAc}
valueSetter={setTxAc}
errorText={txAcText}
errorText={txAcHelperText}
keyHandler={handleEnterKey}
/>
</Box>
Expand Down Expand Up @@ -430,7 +426,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
setChromosome={setTxChrom}
setStrand={setTxStrand}
setTranscripts={setGeneTranscripts}
setDefaultTranscript={setSelectedTranscript}
setDefaultTranscript={setTxAc}
/>
<FormControl variant="standard">
<InputLabel id="transcript-select-label">
Expand All @@ -439,7 +435,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
<Select
labelId="transcript-select-label"
id="transcript-select"
value={selectedTranscript}
value={txAc}
label="Transcript"
onChange={handleTranscriptSelect}
placeholder="Transcript"
Expand Down
1 change: 1 addition & 0 deletions server/src/curfu/routers/constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ async def build_tx_segment_gc(
seg_start_genomic=start,
seg_end_genomic=end,
transcript=transcript,
get_nearest_transcript_junction=True,
)
return TxSegmentElementResponse(element=tx_segment, warnings=warnings)

Expand Down
1 change: 1 addition & 0 deletions server/src/curfu/routers/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ async def get_exon_coords(
seg_end_genomic=end,
transcript=transcript,
gene=gene,
get_nearest_transcript_junction=True,
)
warnings = response.errors
if warnings:
Expand Down

0 comments on commit 0a22cb1

Please sign in to comment.