Skip to content

Commit bb14ea7

Browse files
committed
Get index of tx_ac column
1 parent 805a1e2 commit bb14ea7

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/cool_seq_tool/mappers/exon_genomic_coords.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -966,9 +966,11 @@ async def _select_optimal_transcript(
966966
AND alt_ac = '{genomic_ac}'
967967
""" # noqa: S608
968968
results = await self.uta_db.execute_query(query)
969-
schema = ["tx_ac", "alt_ac", "hgnc"]
970-
transcripts = [(r["tx_ac"], r["alt_ac"], r["hgnc"]) for r in results]
971-
transcripts = pl.DataFrame(data=transcripts, schema=schema, orient="row")
969+
schema = ["tx_ac"]
970+
transcripts = [(r["tx_ac"]) for r in results]
971+
transcripts = pl.DataFrame(
972+
data=transcripts, schema=schema, orient="row"
973+
).unique()
972974
result = self.mane_transcript.get_prioritized_transcripts_from_gene(
973975
transcripts
974976
)

src/cool_seq_tool/mappers/mane_transcript.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,8 @@ def get_prioritized_transcripts_from_gene(self, df: pl.DataFrame) -> list:
651651
most recent version of a transcript associated with an assembly will be kept
652652
"""
653653
copy_df = df.clone()
654-
copy_df = copy_df.drop("alt_ac").unique()
654+
if "alt_ac" in copy_df.columns:
655+
copy_df = copy_df.drop("alt_ac").unique()
655656
copy_df = copy_df.with_columns(
656657
[
657658
pl.col("tx_ac")
@@ -670,9 +671,12 @@ def get_prioritized_transcripts_from_gene(self, df: pl.DataFrame) -> list:
670671
)
671672
copy_df = copy_df.unique(["ac_no_version_as_int"], keep="first")
672673

674+
tx_ac_index = copy_df.columns.index("tx_ac")
673675
copy_df = copy_df.with_columns(
674676
copy_df.map_rows(
675-
lambda x: len(self.seqrepo_access.get_reference_sequence(x[1])[0])
677+
lambda x: len(
678+
self.seqrepo_access.get_reference_sequence(x[tx_ac_index])[0]
679+
)
676680
)
677681
.to_series()
678682
.alias("len_of_tx")

0 commit comments

Comments
 (0)