Skip to content

Commit

Permalink
Improve type of connect_cigar_hits
Browse files Browse the repository at this point in the history
  • Loading branch information
Donaim committed Oct 22, 2024
1 parent 46ee051 commit 02e53b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/aligntools/cigar_hit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from math import ceil, floor
from typing import Tuple, Iterable, Optional, List
from typing import Tuple, Iterable, Optional, List, Sequence, Iterator
from dataclasses import dataclass
from functools import cached_property, reduce
from fractions import Fraction
Expand Down Expand Up @@ -396,7 +396,7 @@ def __str__(self):
% (str(self.cigar), self.q_st, self.q_ei, self.r_st, self.r_ei)


def connect_cigar_hits(cigar_hits: List[CigarHit]) -> List[CigarHit]:
def connect_cigar_hits(cigar_hits: Sequence[CigarHit]) -> Iterator[CigarHit]:
"""
This function exists to deal with the fact that mappy does not
always connect big gaps, and returns surrounding parts as two
Expand Down Expand Up @@ -442,5 +442,5 @@ def find_group(phit: CigarHit) -> None:

# Collect all intervals back together,
# connecting them with CigarActions.DELETE.
return [reduce(CigarHit.connect, group)
for group in sorted_groups]
for group in sorted_groups:
yield reduce(CigarHit.connect, group)
4 changes: 2 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,10 +813,10 @@ def test_connect_cigar_hits(hits, expected_result):

if isinstance(expected_result, Exception):
with pytest.raises(type(expected_result)):
connect_cigar_hits(hits)
list(connect_cigar_hits(hits))
else:
expected_result = list(map(parsed_hit, expected_result))
result = connect_cigar_hits(hits)
result = list(connect_cigar_hits(hits))
assert expected_result == result


Expand Down

0 comments on commit 02e53b1

Please sign in to comment.