-
-
Save oshikrororo/6aae586ebd3ae025a4502abfb8402bf8 to your computer and use it in GitHub Desktop.
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
def count_indels(alignment): | |
total = 0 | |
sequences = [''.join(sequence.split('\n')[1:]) for sequence in alignment.split('>')][1:] | |
names = [sequence.split('\n')[0] for sequence in alignment.split('>')][1:] | |
for seq_id, sequence in enumerate(sequences): | |
indels = 0 | |
closed = True | |
for index, symbol in enumerate(sequence[:-1]): | |
if symbol == '-' and closed: | |
closed = False | |
elif symbol != '-' and not closed: | |
indels += 1 | |
closed = True | |
if not closed: | |
indels += 1 | |
print(names[seq_id], indels) | |
total += indels | |
print(f'Total {total}') | |
return | |
PATH = input() | |
with open(PATH) as file: | |
alignment = file.read() | |
count_indels(alignment) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment