Skip to content

Instantly share code, notes, and snippets.

@AlexanderFillbrunn
AlexanderFillbrunn / seq_repair.py
Last active December 6, 2018 08:32
Remove insertions and deletions in a String given a reference
"""
This script repairs insertions and deletions in a sequence by replacing them
with the correct value from a reference sequence, but keeps replacements.
The algorithm calculates a Levenshtein matrix first and then retraces the path
of least distances from the bottom right to the top left. Depending on the
movement along that path, it indentifies the different types of modifications
and fixes them if they are insertions or deletions.
Examples: