Skip to content

Commit

Permalink
Update alignment code (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
jarbesfeld authored Oct 17, 2024
1 parent b9cb1d8 commit 7ff07a2
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/dcd_mapping/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ def _get_best_hsp(
"""Retrieve preferred HSP from BLAT Hit object.
We select the hsp object with the lowest distance from the start of the
corresponding gene and the highest BLAT score
corresponding gene and the highest BLAT score. We omit the first sorting step
when a gene symbol is not associated with a score set
:param hit: hit object from BLAT result
:param urn: scoreset identifier for use in error messages
Expand All @@ -245,7 +246,11 @@ def _get_best_hsp(
:raise AlignmentError: if hit object appears to be empty (should be impossible)
"""
best_hsp = None
hsp_list = sorted(hit, key=lambda hsp: abs(hsp.hit_start - gene_location.start))
hsp_list = (
sorted(hit, key=lambda hsp: abs(hsp.hit_start - gene_location.start))
if gene_location
else hit
)
hsp_list = sorted(
hsp_list,
key=lambda hsp: (hsp.query_end - hsp.query_start) / output.seq_len,
Expand Down

0 comments on commit 7ff07a2

Please sign in to comment.