-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move type annotations of
pyopal.align
to a type stub for backwards …
…compatibility
- Loading branch information
Showing
2 changed files
with
92 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import contextlib | ||
import functools | ||
import multiprocessing.pool | ||
import os | ||
import typing | ||
|
||
try: | ||
from typing import Literal | ||
except ImportError: | ||
from typing_extensions import Literal # type: ignore | ||
|
||
from .lib import ( | ||
Aligner, | ||
BaseDatabase, | ||
Database, | ||
ScoreMatrix, | ||
ScoreResult, | ||
FullResult, | ||
EndResult, | ||
) | ||
|
||
ALIGN_MODE = Literal["score", "end", "full"] | ||
ALIGN_OVERFLOW = Literal["simple", "buckets"] | ||
ALIGN_ALGORITHM = Literal["nw", "hw", "ov", "sw"] | ||
|
||
T = typing.TypeVar("T") | ||
|
||
@contextlib.contextmanager | ||
def nullcontext(enter_result: T) -> typing.Iterator[T]: ... | ||
|
||
|
||
@typing.overload | ||
def align( | ||
query: typing.Union[str, bytes, bytearray], | ||
database: typing.Union[BaseDatabase, typing.Iterable[typing.Union[str, bytes, bytearray]]], | ||
score_matrix: typing.Optional[ScoreMatrix] = None, | ||
*, | ||
gap_open: int = 3, | ||
gap_extend: int = 1, | ||
mode: Literal["end"], | ||
overflow: Literal["simple", "buckets"] = "buckets", | ||
algorithm: Literal["nw", "hw", "ov", "sw"] = "sw", | ||
threads: int = 0, | ||
) -> typing.Iterator[EndResult]: | ||
... | ||
|
||
@typing.overload | ||
def align( | ||
query: typing.Union[str, bytes, bytearray], | ||
database: typing.Union[BaseDatabase, typing.Iterable[typing.Union[str, bytes, bytearray]]], | ||
score_matrix: typing.Optional[ScoreMatrix] = None, | ||
*, | ||
gap_open: int = 3, | ||
gap_extend: int = 1, | ||
mode: Literal["full"], | ||
overflow: Literal["simple", "buckets"] = "buckets", | ||
algorithm: Literal["nw", "hw", "ov", "sw"] = "sw", | ||
threads: int = 0, | ||
) -> typing.Iterator[FullResult]: | ||
... | ||
|
||
@typing.overload | ||
def align( | ||
query: typing.Union[str, bytes, bytearray], | ||
database: typing.Union[BaseDatabase, typing.Iterable[typing.Union[str, bytes, bytearray]]], | ||
score_matrix: typing.Optional[ScoreMatrix] = None, | ||
*, | ||
gap_open: int = 3, | ||
gap_extend: int = 1, | ||
mode: Literal["score", "end", "full"] = "score", | ||
overflow: Literal["simple", "buckets"] = "buckets", | ||
algorithm: Literal["nw", "hw", "ov", "sw"] = "sw", | ||
threads: int = 0, | ||
pool: typing.Optional[multiprocessing.pool.ThreadPool] = None | ||
) -> typing.Iterator[ScoreResult]: | ||
... |