Skip to content

Commit

Permalink
Improve readability
Browse files Browse the repository at this point in the history
  • Loading branch information
jarbesfeld committed Feb 29, 2024
1 parent fc802d3 commit 3873535
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/cool_seq_tool/mappers/exon_genomic_coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,14 +520,17 @@ async def _genomic_to_transcript_exon_coordinate(
"Gene or strand must be provided to select the adjacent transcript junction",
)
alt_acs, w = self.seqrepo_access.chromosome_to_acs(chromosome)

if not alt_acs:
return self._return_warnings(resp, w)
alt_ac = alt_acs[0]

if not transcript:
# Select a transcript if not provided
mane_transcripts = self.mane_transcript_mappings.get_gene_mane_data(
gene
)

if mane_transcripts:
transcript = mane_transcripts[0]["RefSeq_nuc"]
else:
Expand All @@ -536,6 +539,7 @@ async def _genomic_to_transcript_exon_coordinate(
results = await self.uta_db.get_transcripts(
gene=gene, alt_ac=alt_ac
)

if not results.is_empty():
transcript = results[0]["tx_ac"][0]
else:
Expand All @@ -547,18 +551,21 @@ async def _genomic_to_transcript_exon_coordinate(
AND alt_ac = '{alt_ac}'
""" # noqa: S608
result = await self.uta_db.execute_query(query)

if result:
transcript = result[0]["tx_ac"]
else:
return self._return_warnings(
resp,
f"Could not find a transcript for {gene} on {alt_ac}",
)

tx_genomic_coords, w = await self.uta_db.get_tx_exons_genomic_coords(
tx_ac=transcript, alt_ac=alt_ac
)
if not tx_genomic_coords:
return self._return_warnings(resp, w)

# Check if breakpoint occurs on an exon.
# If not, determine the adjacent exon given the selected transcript
if not self._is_exonic_breakpoint(pos, tx_genomic_coords):
Expand All @@ -568,11 +575,13 @@ async def _genomic_to_transcript_exon_coordinate(
start=pos if is_start else None,
end=pos if not is_start else None,
)

params["exon"] = exon
params["transcript"] = transcript
params["gene"] = gene
params["pos"] = pos
params["chr"] = alt_ac

self._set_exon_offset(
params=params,
start=tx_genomic_coords[exon - 1][3], # Start exon coordinate
Expand Down Expand Up @@ -921,6 +930,7 @@ def _get_adjacent_exon(
and the exon following the breakpoint for the 3' end. For the negative strand,
adjacent is defined as the exon following the breakpoint for the 5' end and the
exon preceding the breakpoint for the 3' end.
:param: tx_exons_genomic_coords: List of tuples describing exons and genomic
coordinates for a transcript. Each tuple contains the transcript number
(0-indexed), the transcript coordinates for the exon, and the genomic
Expand Down

0 comments on commit 3873535

Please sign in to comment.