Skip to content

Commit

Permalink
SlidingWin fix and new version
Browse files Browse the repository at this point in the history
  • Loading branch information
geomarceau committed Nov 13, 2023
1 parent 563a2c0 commit 51d88ce
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
10 changes: 5 additions & 5 deletions aphylogeo/alignement.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ def __init__(
self.alignment_method = alignment_method
self.reference_gene_file = reference_gene_file
self.fit_method = fit_method
self.rate_similarity = (rate_similarity,)
self.method_similarity = (method_similarity,)
self.rate_similarity = rate_similarity
self.method_similarity = method_similarity
"""
Method that align sequences
"""
Expand Down Expand Up @@ -726,7 +726,7 @@ def insertDash(self, dict, pos, keyList):
dict[k] = s
return dict

def slidingWindow(self, optimized=False):
def slidingWindow(self, optimized=True):
"""
Method that slices all the sequences in a dictionary to a specific window (substring)
Expand Down Expand Up @@ -763,13 +763,13 @@ def slidingWindow(self, optimized=False):
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)
df = pd.DataFrame(list(combinations))
if self.rate_similarity[0] < self.similarity(df):
if self.rate_similarity > 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):
if self.rate_similarity > self.similarity(df):
windowed_alignment.pop(f"{i}_{seq_len-1}")
else:
for i in range(0, seq_len, step):
Expand Down
5 changes: 4 additions & 1 deletion aphylogeo/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

from aphylogeo.params import Params
from aphylogeo import utils
from aphylogeo.genetic_trees import GeneticTrees

# from aphylogeo.utils import climaticPipeline, geneticPipeline, filterResults, loadSequenceFile

Expand All @@ -24,11 +25,13 @@
sequenceFile = utils.loadSequenceFile(Params().reference_gene_file)
seq_alignment = AlignSequences(sequenceFile).align()
# Phylo.write(tree1, "data/tree1.nwk", "newick")
# seq_alignment.save_to_json("./debug/sequences_aligned.json")
seq_alignment.save_to_json("./debug/sequences_aligned.json")

# loaded_seq_alignment = Alignment.load_from_json("./debug/sequences_aligned.json")

geneticTrees = utils.geneticPipeline(seq_alignment.msa)
trees = GeneticTrees(trees_dict=geneticTrees, format="newick")
trees.save_trees_to_json("./debug/geneticTreesTest.json")
with open("debug/res3.txt", "w") as f:
f.write(str(geneticTrees))
f.close()
Expand Down
2 changes: 1 addition & 1 deletion aphylogeo/params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ alignment_method: '1' #Please select one ~ 1:pairwiseAligner, 2:MUSCLE, 3:CLUSTA
distance_method: '1' #Please select one ~ 1: Least-Square distance, 2: Robinson-Foulds distance, 3: Euclidean distance (DendroPY)
fit_method: '1' #Please select one ~ 1:Wider Fit by elongating with Gap (starAlignment), 2:Narrow-fit prevent elongation with gap when possible
tree_type: '1' #Please select one ~ 1: BioPython consensus tree, 2: FastTree application
rate_similarity: 80
rate_similarity: 90
method_similarity: '1' #Please select one :
# 1: Hamming distance
# 2: Levenshtein distance
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "aphylogeo"
version = "0.3.2"
version = "0.4.2"
description = "A phylogenetic and geographic analysis tool"
authors = ["'Tahiri Lab'"]
license = "MIT"
Expand Down

0 comments on commit 51d88ce

Please sign in to comment.