Hey Romain,
so, if I understand well, what you want is deleting lowly supported branches and making a polytomy instead. By deleting the corresponding node, the nodes below are by default transferred to the parental one, one "up". For instance :
from ete2 import Tree
t = Tree('(((a:1,b:1)1:1,c:1)1:1,((e:1,f:1)0.5:1,g:1)1:1);')
print t.get_ascii(attributes=['support', 'name'])
/-1.0, a
/1.0,
/1.0, \-1.0, b
| |
| \-1.0, c
-1.0,
| /-1.0, e
| /0.5,
\1.0, \-1.0, f
|
\-1.0, g
# Loop through the nodes below the basal one and delete based on their support attribute or any other condition.
for node in t.get_descendants():
if not node.is_leaf() and node.support <= 0.7:
node.delete()
print t.get_ascii(attributes=['support', 'name'])
/-1.0, a
/1.0,
/1.0, \-1.0, b
| |
| \-1.0, c
-1.0,
| /-1.0, g
| |
\1.0, -1.0, e
|
\-1.0, f
for more examples on various operations.