Skip to content

Commit

Permalink
versionless ID comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
WalshKieran committed May 20, 2024
1 parent 84ff4a3 commit 7d318d3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pipeline/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ def _iter(dataset, matrix, rows, headers):
def parallel_transcript_iterator(dataset, transcript_to_gene):
'''Iterate over transcripts grouped by gene'''
def transcript_row_mutator(row):
if annot := transcript_to_gene.get(row[0], None):
versionless = row[0].split('.', 1)[0]
if annot := transcript_to_gene.get(versionless, None):
row[0] = versionless
row.insert(0, annot[0])
else:
raise AnnotationException(f'failed to annotate\ttranscript\t{row[0]}')
Expand All @@ -377,7 +379,8 @@ def transcript_row_mutator(row):
@contextlib.contextmanager
def parallel_dataset_context(datasets, gene_to_gene, transcript_to_gene, debug=False):
def gene_row_mutator(row):
if annot := gene_to_gene.get(row[0], None):
versionless = row[0].split('.', 1)[0]
if annot := gene_to_gene.get(versionless, None):
row[0] = annot[0]
else:
raise AnnotationException(f'failed to annotate\tgene\t{row[0]}')
Expand Down

0 comments on commit 7d318d3

Please sign in to comment.