Open ArtPoon opened 2 months ago
Something strange happened here:
>>> phy = Phylo.read("consensus.nwk", 'newick')
>>> tips = phy.get_terminals()
>>> target = 500
>>> while len(tips) > target:
... tips = sorted(tips, key=lambda x: x.branch_length)
... tip = tips[0]
... parent = phy.prune(tip)
... tips = tips[1:]
... bad = [tip for tip in tips if tip.name is None]
... if bad:
... break
...
>>> bad
[]
>>> len(tips)
500
>>> tips = phy.get_terminals()
>>> len(tips)
501
>>> bad = [tip for tip in tips if tip.name is None]
>>> bad
[Clade(branch_length=7.27065, confidence=0.5)]
>>> parent
Clade(branch_length=0.0, confidence=1.0)
>>> tip
Clade(branch_length=6.09403, name='1483')
This seems to work:
>>> phy = Phylo.read("consensus.nwk", 'newick')
>>> tips = phy.get_terminals()
>>> while len(tips) > target:
... tips = sorted(tips, key=lambda x: x.branch_length)
... tip = tips[0]
... parent = phy.prune(tip)
... tips = phy.get_terminals()
...
>>> tip
Clade(branch_length=6.09498, name='3592')
>>> parent
Clade(branch_length=0.0, confidence=1.0)
>>> len(tips)
500
>>> bad = [tip for tip in tips if tip.name is None]
>>> bad
[]
>>> bad = [tip for tip in phy.get_terminals() if tip.name is None]
>>> bad
[]
I've updated the Bioplus repo, @GopiGugan can you please re-run with the new prunetree
code?