Skip to content

Commit

Permalink
Get index of tx_ac column
Browse files Browse the repository at this point in the history
  • Loading branch information
jarbesfeld committed Nov 14, 2024
1 parent 805a1e2 commit bb14ea7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/cool_seq_tool/mappers/exon_genomic_coords.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,9 +966,11 @@ async def _select_optimal_transcript(
AND alt_ac = '{genomic_ac}'
""" # noqa: S608
results = await self.uta_db.execute_query(query)
schema = ["tx_ac", "alt_ac", "hgnc"]
transcripts = [(r["tx_ac"], r["alt_ac"], r["hgnc"]) for r in results]
transcripts = pl.DataFrame(data=transcripts, schema=schema, orient="row")
schema = ["tx_ac"]
transcripts = [(r["tx_ac"]) for r in results]
transcripts = pl.DataFrame(
data=transcripts, schema=schema, orient="row"
).unique()
result = self.mane_transcript.get_prioritized_transcripts_from_gene(
transcripts
)
Expand Down
8 changes: 6 additions & 2 deletions src/cool_seq_tool/mappers/mane_transcript.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,8 @@ def get_prioritized_transcripts_from_gene(self, df: pl.DataFrame) -> list:
most recent version of a transcript associated with an assembly will be kept
"""
copy_df = df.clone()
copy_df = copy_df.drop("alt_ac").unique()
if "alt_ac" in copy_df.columns:
copy_df = copy_df.drop("alt_ac").unique()
copy_df = copy_df.with_columns(
[
pl.col("tx_ac")
Expand All @@ -670,9 +671,12 @@ def get_prioritized_transcripts_from_gene(self, df: pl.DataFrame) -> list:
)
copy_df = copy_df.unique(["ac_no_version_as_int"], keep="first")

tx_ac_index = copy_df.columns.index("tx_ac")
copy_df = copy_df.with_columns(
copy_df.map_rows(
lambda x: len(self.seqrepo_access.get_reference_sequence(x[1])[0])
lambda x: len(
self.seqrepo_access.get_reference_sequence(x[tx_ac_index])[0]
)
)
.to_series()
.alias("len_of_tx")
Expand Down

0 comments on commit bb14ea7

Please sign in to comment.