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 (#336)

* fix: unable to construct tx segment when genomic coordinate between exons

* build: update cool-seq-tool and fusor versions

* test: add test case for get exon coordinates where genomic coord occurs between exons

* test: remove test case for now

* Update server/tests/integration/test_utilities.py

Co-authored-by: Kori Kuzma <[email protected]>

* styling

---------

Co-authored-by: Kori Kuzma <[email protected]>
  • Loading branch information
katiestahl and korikuzma authored Sep 27, 2024
1 parent 100bb39 commit bda641b
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,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 @@ -55,7 +55,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 @@ -89,9 +89,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 @@ -100,7 +97,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({

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

// programming horror
Expand All @@ -117,7 +114,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
inputComplete &&
hasRequiredEnds &&
txGeneText === "" &&
txAcText === "" &&
txAcHelperText === "" &&
txStartingGenomicText === "" &&
txEndingGenomicText === "" &&
startingExonText === "" &&
Expand Down Expand Up @@ -172,7 +169,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 @@ -227,7 +223,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
getTxSegmentElementGC(
txGene,
txChrom,
selectedTranscript,
txAc,
txStartingGenomic,
txEndingGenomic
).then((txSegmentResponse) => {
Expand All @@ -242,6 +238,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
inputType: txInputType,
inputStrand: txStrand,
inputGene: txGene,
inputTx: txAc,
inputChr: txChrom,
inputGenomicStart: txStartingGenomic,
inputGenomicEnd: txEndingGenomic,
Expand All @@ -266,7 +263,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 @@ -284,7 +281,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
setPendingResponse(false);
setErrors(txSegmentResponse.warnings);
} else {
setTxAcText("");
setTxAcHelperText("");
setStartingExonText("");
setEndingExonText("");
setErrors([]);
Expand Down Expand Up @@ -394,7 +391,7 @@ const TxSegmentCompInput: React.FC<TxSegmentElementInputProps> = ({
<TranscriptField
fieldValue={txAc}
valueSetter={setTxAc}
errorText={txAcText}
errorText={txAcHelperText}
keyHandler={handleEnterKey}
/>
</Box>
Expand Down Expand Up @@ -436,7 +433,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 @@ -445,7 +442,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
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ charset-normalizer==3.3.2
click==8.1.7
coloredlogs==15.0.1
configparser==7.1.0
cool_seq_tool==0.7.0
cool_seq_tool==0.7.1
coverage==7.6.1
decorator==5.1.1
distlib==0.3.8
executing==2.0.1
fastapi==0.112.1
filelock==3.15.4
fusor==0.4.3
fusor==0.4.4
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.4.3",
"cool-seq-tool ~= 0.7.0",
"fusor ~= 0.4.4",
"cool-seq-tool ~= 0.7.1",
"pydantic == 2.4.2", # validation errors with more recent versions, so don't remove this specific pin
"gene-normalizer ~= 0.4.0",
]
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
24 changes: 22 additions & 2 deletions server/tests/integration/test_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,29 @@ def check_coords_response(response: dict, expected_response: dict):
check_coords_response,
)

# check correct response for genomic coordinate that occurs between exons (should get nearest junction)
await check_response(
"/api/utilities/get_exon?chromosome=NC_000001.11&start=154192131&gene=TPM3",
{"warnings": ["Must find exactly one row for genomic data, but found: 0"]},
"/api/utilities/get_exon?chromosome=NC_000001.11&end=154191900&transcript=NM_152263.3",
{
"coordinates_data": {
"gene": "TPM3",
"genomic_ac": "NC_000001.11",
"tx_ac": "NM_152263.3",
"seg_end": {
"exon_ord": 0,
"offset": 1,
"genomic_location": {
"type": "SequenceLocation",
"sequenceReference": {
"type": "SequenceReference",
"refgetAccession": "SQ.Ya6Rs7DHhDeg7YaOSg1EoNi3U_nQ9SvO",
},
"start": 154191900,
},
},
"errors": [],
}
},
check_coords_response,
)

Expand Down

0 comments on commit bda641b

Please sign in to comment.