Commit 8d3f4472 authored by Carine Rey's avatar Carine Rey Committed by Philippe Veber
Browse files

fix error during tree pruning

parent 987009b7
...@@ -185,14 +185,24 @@ else: ...@@ -185,14 +185,24 @@ else:
trim_t = t.copy(method="deepcopy") trim_t = t.copy(method="deepcopy")
if sp_present: if sp_present:
trim_t.prune(sp_present) trim_t.prune(sp_present,preserve_branch_length=True)
# Check father node transition if Condition == 1
for n in trim_t.traverse("postorder"):
if (hasattr(n, "Condition") and n.Condition == "1"):
if not (hasattr(n, "Transition") and n.Transition == "1"):
parent_n = n.up
if not parent_n.Condition == "1":
if not (hasattr(parent_n, "Transition") and parent_n.Transition == "1"):
n.Transition = "1"
sister_T = True sister_T = True
while sister_T: while sister_T:
sister_T=False sister_T=False
for n in trim_t.traverse("postorder"): for n in trim_t.traverse("postorder"):
# Check for 2 sister Transitions
children = n.get_children() children = n.get_children()
if len(children) == 2: if len(children) == 2:
if hasattr(children[0], "Transition" ) and hasattr(children[1], "Transition" ): if hasattr(children[0], "Transition") and hasattr(children[1], "Transition"):
if children[0].Transition == "1" and children[1].Transition == "1": if children[0].Transition == "1" and children[1].Transition == "1":
n.Transition = "1" n.Transition = "1"
n.Condition = "1" n.Condition = "1"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment