2020-07-06 18:39:31 +03:00
|
|
|
from typing import List
|
|
|
|
from dataclasses import dataclass
|
|
|
|
|
2020-11-03 18:24:38 +03:00
|
|
|
from .align import get_alignments
|
2022-04-01 10:02:06 +03:00
|
|
|
from .alignment_array import AlignmentArray
|
2020-08-04 17:29:18 +03:00
|
|
|
|
2020-07-06 18:39:31 +03:00
|
|
|
|
|
|
|
@dataclass
|
|
|
|
class Alignment:
|
2022-04-01 10:02:06 +03:00
|
|
|
x2y: AlignmentArray
|
|
|
|
y2x: AlignmentArray
|
2020-07-06 18:39:31 +03:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def from_indices(cls, x2y: List[List[int]], y2x: List[List[int]]) -> "Alignment":
|
2022-04-01 10:02:06 +03:00
|
|
|
x2y = AlignmentArray(x2y)
|
|
|
|
y2x = AlignmentArray(y2x)
|
2020-07-06 18:39:31 +03:00
|
|
|
return Alignment(x2y=x2y, y2x=y2x)
|
2020-07-25 16:01:15 +03:00
|
|
|
|
2020-07-06 18:39:31 +03:00
|
|
|
@classmethod
|
|
|
|
def from_strings(cls, A: List[str], B: List[str]) -> "Alignment":
|
2020-11-03 18:24:38 +03:00
|
|
|
x2y, y2x = get_alignments(A, B)
|
2020-07-06 18:39:31 +03:00
|
|
|
return Alignment.from_indices(x2y=x2y, y2x=y2x)
|