poli.core.util.proteins.mutations.edits_between_strings

poli.core.util.proteins.mutations.edits_between_strings#

poli.core.util.proteins.mutations.edits_between_strings(string_1: str, string_2: str, strict: bool = True) List[Tuple[str, int, int]]#

Compute the edit operations between two strings.

Parameters
  • string_1 (str) – The first string.

  • string_2 (str) – The second string.

  • strict (bool, optional) – If True, check if the lengths of string_1 and string_2 are equal. Defaults to True.

Returns

A list of tuples representing the edit operations between the two strings. Each tuple contains the operation type (“replace”), the position in string_1, and the position in string_2.

Return type

List[Tuple[str, int, int]]

Raises

AssertionError – If strict is True and the lengths of string_1 and string_2 are different.

Examples

>>> edits_between_strings("abc", "abd")
[('replace', 2, 2)]
>>> edits_between_strings("abc", "def")
[('replace', 0, 0), ('replace', 1, 1), ('replace', 2, 2)]