Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for mutations and clades before removing #264

Merged
merged 1 commit into from
Jan 21, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions phylogenetic/scripts/fix_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,14 @@
print(f"Below {clade}: {mut_child} in {child.name} reverted in {grandchild.name}")

for reversion in reversions:
# Remove reversion from grandchild
reversion["grandchild"].relevant_mutations.remove(reversion["mut_grandchild"])
# Remove grandchild from child
reversion["child"].clades.remove(reversion["grandchild"])
if reversion["mut_grandchild"] in reversion["grandchild"].relevant_mutations:
# Remove reversion from grandchild
reversion["grandchild"].relevant_mutations.remove(reversion["mut_grandchild"])

if reversion["grandchild"] in reversion["child"].clades:
# Remove grandchild from child
reversion["child"].clades.remove(reversion["grandchild"])

# If there are mutations, add grandchild as child of parent
if reversion["grandchild"].relevant_mutations != reversion["parent"].relevant_mutations:
reversion["parent"].clades.append(reversion["grandchild"])
Expand Down