skbio.tree.TreeNode.unpack_by_func¶
- TreeNode.unpack_by_func(func)[源代码]¶
解压满足特定条件的树的内部节点。
状态:从0.5.3开始实验。
- 参数:
func (function) -- 接受TreeNode并返回 True 或 False 在哪里 True 指示要解包的节点
示例
>>> from skbio import TreeNode >>> tree = TreeNode.read(['((c:2,d:3)a:1,(e:1,f:2)b:2);']) >>> tree.unpack_by_func(lambda x: x.length <= 1) >>> print(tree) ((e:1.0,f:2.0)b:2.0,c:3.0,d:4.0); >>> tree = TreeNode.read(['(((a,b)85,(c,d)78)75,(e,(f,g)64)80);']) >>> tree.assign_supports() >>> tree.unpack_by_func(lambda x: x.support < 75) >>> print(tree) (((a,b)85,(c,d)78)75,(e,f,g)80);