PoonLab / covizu

Rapid analysis and visualization of coronavirus genome variation
https://filogeneti.ca/CoVizu/
MIT License
46 stars 20 forks source link

Update HUNePi models #539

Open ArtPoon opened 2 months ago

ArtPoon commented 2 months ago
ArtPoon commented 6 days 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')
ArtPoon commented 6 days ago

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
[]
ArtPoon commented 5 days ago

I've updated the Bioplus repo, @GopiGugan can you please re-run with the new prunetree code?