From f1c00cd95427ffc06606ee723ea276486d13fa0b Mon Sep 17 00:00:00 2001 From: "Nadia Tahiri, PhD" Date: Tue, 7 Nov 2023 23:59:27 -0500 Subject: [PATCH] slidingWindow optimization --- aphylogeo/alignement.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/aphylogeo/alignement.py b/aphylogeo/alignement.py index 525e7597..ec80e816 100644 --- a/aphylogeo/alignement.py +++ b/aphylogeo/alignement.py @@ -757,15 +757,16 @@ def slidingWindow(self): 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) + combinations = itertools.combinations(windowed_alignment[f"{i}_{i + step - 1}"].values(),2) + df = pd.DataFrame(list(combinations)) + if self.rate_similarity[0] < self.similarity(df): + windowed_alignment.pop(f"{i}_{i + step - 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) - df = pd.DataFrame(list(combinations)) - - #if self.rate_similarity[0] < self.similarity(df): - # windowed_alignment.pop(f"{i}_{seq_len-1}") - # print(self.rate_similarity) + df = pd.DataFrame(list(combinations)) + if self.rate_similarity[0] < self.similarity(df): + windowed_alignment.pop(f"{i}_{seq_len-1}") # JUST TO MAKE THE DEBUG FILES if self.makeDebugFiles: