Skip to content

Commit

Permalink
fix: make OfftargetDetector.filter generic
Browse files Browse the repository at this point in the history
  • Loading branch information
msto committed Sep 18, 2024
1 parent 5333eeb commit c9d2733
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions prymer/offtarget/offtarget_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
from types import TracebackType
from typing import Optional
from typing import Self
from typing import TypeVar

from ordered_set import OrderedSet

Expand All @@ -93,6 +94,8 @@
from prymer.offtarget.bwa import BwaResult
from prymer.offtarget.bwa import Query

PrimerType = TypeVar("PrimerType", bound=Primer)


@dataclass(init=True, frozen=True)
class OffTargetResult:
Expand Down Expand Up @@ -188,7 +191,7 @@ def __init__(
self._keep_spans: bool = keep_spans
self._keep_primer_spans: bool = keep_primer_spans

def filter(self, primers: list[Primer]) -> list[Primer]:
def filter(self, primers: list[PrimerType]) -> list[PrimerType]:
"""Filters an iterable of Primers to return only those that have less than
`max_primer_hits` mappings to the genome."""
results: dict[str, BwaResult] = self.mappings_of(primers)
Expand Down Expand Up @@ -282,13 +285,13 @@ def _build_off_target_result(

return result

def mappings_of(self, primers: list[Primer]) -> dict[str, BwaResult]:
def mappings_of(self, primers: list[PrimerType]) -> dict[str, BwaResult]:
"""Function to take a set of primers and map any that are not cached, and return mappings
for all of them. Note: the genomics sequence of the returned mappings are on the opposite
strand of that of the strand of the primer. I.e. we map the complementary bases (reversed)
to that of the primer."""

primers_to_map: list[Primer]
primers_to_map: list[PrimerType]
if not self._cache_results:
primers_to_map = primers
else:
Expand Down

0 comments on commit c9d2733

Please sign in to comment.