Skip to content

Commit

Permalink
windows fix
Browse files Browse the repository at this point in the history
  • Loading branch information
TahiriNadia committed Jul 16, 2024
1 parent b6c1cd5 commit 751e206
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions aphylogeo/alignement.py
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,8 @@ def slidingWindow(self, heuristicMSA, optimized=True):
i = The starting position of the window, relative to the original sequence
j = The ending position of the window, relative to the original sequence
"""
step = Params.window_size
step = Params.step_size
window = Params.window_size

windowed_alignment = dict()
seq_len = max([len(h) for h in heuristicMSA.values()])
Expand All @@ -760,11 +761,11 @@ def slidingWindow(self, heuristicMSA, optimized=True):
if optimized:
for i in range(0, seq_len, step):
if i + step < seq_len:
windowed_alignment[f"{i}_{i + step - 1}"] = {key: val[i : i + step - 1] for key, val in paddedMSA.items()}
combinations = itertools.combinations(windowed_alignment[f"{i}_{i + step - 1}"].values(), 2)
windowed_alignment[f"{i}_{i + window - 1}"] = {key: val[i : i + window - 1] for key, val in paddedMSA.items()}
combinations = itertools.combinations(windowed_alignment[f"{i}_{i + window - 1}"].values(), 2)
df = pd.DataFrame(list(combinations))
if Params.rate_similarity > self.similarity(df):
windowed_alignment.pop(f"{i}_{i + step - 1}")
windowed_alignment.pop(f"{i}_{i + window - 1}")
else:
windowed_alignment[f"{i}_{seq_len-1}"] = {key: val[i : i + seq_len - 1] for key, val in paddedMSA.items()}
combinations = itertools.combinations(windowed_alignment[f"{i}_{seq_len-1}"].values(), 2)
Expand All @@ -774,7 +775,7 @@ def slidingWindow(self, heuristicMSA, optimized=True):
else:
for i in range(0, seq_len, step):
if i + step < seq_len:
windowed_alignment[f"{i}_{i + step - 1}"] = {key: val[i : i + step - 1] for key, val in paddedMSA.items()}
windowed_alignment[f"{i}_{i + window - 1}"] = {key: val[i : i + window - 1] for key, val in paddedMSA.items()}
else:
windowed_alignment[f"{i}_{seq_len-1}"] = {key: val[i : i + seq_len - 1] for key, val in paddedMSA.items()}

Expand Down

0 comments on commit 751e206

Please sign in to comment.