def testClusterNamingWithBootstraps(self): tree = TreeNode.read( StringIO( "((F:20, ((A:11, B:12):10, (H:8, D:9):3):20)'0.7:G':30)root;")) clusters = Tree2Tax().named_clusters(tree, 40) self.assertSameClusters([['F'], _('A B D H')], clusters) assert_equals(_('G.2 G.1'), [c.name() for c in clusters])
def testSimpleTwice(self): tree = TreeNode.read(StringIO('((A:0.11, B:0.12)C:0.1, D:0.2)root;')) clusters = Tree2Tax().named_clusters_for_several_thresholds( tree, [0.25, 0.25]) self.assertSameClusterSets( [[0.25, [['A', 'B'], ['D']]], [0.25, [['A', 'B'], ['D']]]], clusters)
def testClusterNamingConventionsWithSomeUnnamed(self): tree = TreeNode.read( StringIO('((((A:11, B:12):10, D:9):20, F:20)G:30)root;')) clusters = Tree2Tax().named_clusters( tree, 0.05) #i.e. everything is a separate cluster self.assertSameClusters([['A'], ['B'], ['D'], ['F']], clusters) assert_equals(['G.1', 'G.2', 'G.3', 'G.4'], [c.name() for c in clusters])
def testOppositeSorting(self): tree = TreeNode.read(StringIO('((A:0.11, B:0.12)C:0.1, D:0.2)root;')) clusters = Tree2Tax().named_clusters_for_several_thresholds( tree, [0.05, 0.25]) self.assertSameClusterSets( [[0.05, [['A'], ['B'], ['D']]], [0.25, [['A', 'B'], ['D']]]], clusters) assert_equals(_('C.1 C.2 Root'), [c.name() for c in clusters[0].clusters])
def testNaming(self): tree = TreeNode.read( StringIO('((F:20, ((A:11, B:12):10, (H:8, D:9):3):20)G:30)root;')) clusters = Tree2Tax().named_clusters_for_several_thresholds( tree, [40, 25]) self.assertSameClusterSets( [[25, [['F'], _('A B'), _('D H')]], [40, [['F'], _('A B D H')]]], clusters) assert_equals(_('G.3 G.1 G.2'), [c.name() for c in clusters[0].clusters]) assert_equals(_('G.2 G.1'), [c.name() for c in clusters[1].clusters])
def testNamingWithBootstraps(self): tree = TreeNode.read( StringIO('((A:0.11, B:0.12)0.091:0.1, D:0.2)root;')) clusters = Tree2Tax().named_clusters(tree, 0.05) self.assertSameClusters([['A'], ['B'], ['D']], clusters) assert_equals(_('Root.1 Root.2 Root.3'), [c.name() for c in clusters])
def testClusterNamingOnTwoInternalNodesReverseOrder(self): tree = TreeNode.read( StringIO('((F:20, ((A:11, B:12):10, (H:8, D:9):3):20)G:30)root;')) clusters = Tree2Tax().named_clusters(tree, 40) self.assertSameClusters([['F'], _('A B D H')], clusters) assert_equals(_('G.2 G.1'), [c.name() for c in clusters])
def testClusterIntoThree(self): tree = TreeNode.read( StringIO( '((((A:11, B:12)C:10, (H:8, D:9)I:3)E:20, F:20)G:30)root;')) clusters = Tree2Tax().named_clusters(tree, 25) self.assertSameClusters([_('A B'), _('D H'), ['F']], clusters)
def testClusterOnTwoInternalNodes(self): tree = TreeNode.read( StringIO( '((((A:11, B:12)C:10, (H:8, D:9)I:3)E:20, F:20)G:30)root;')) clusters = Tree2Tax().named_clusters(tree, 40) self.assertSameClusters([_('A B D H'), ['F']], clusters)
def testClusterEverything(self): tree = TreeNode.read(StringIO('((A:0.11, B:0.12)C:0.1, D:0.2)root;')) clusters = Tree2Tax().named_clusters(tree, 0.5) self.assertSameClusters([['A', 'B', 'D']], clusters) assert_equals('Root', clusters[0].name())
def testNoClusering(self): tree = TreeNode.read(StringIO('((A:0.11, B:0.12)C:0.1, D:0.2)root;')) clusters = Tree2Tax().named_clusters(tree, 0.05) self.assertSameClusters([['A'], ['B'], ['D']], clusters) assert_equals(_('C.1 C.2 Root'), [c.name() for c in clusters])
def testSimple(self): tree = TreeNode.read(StringIO('((A:0.11, B:0.12)C:0.1, D:0.2)root;')) clusters = Tree2Tax().named_clusters(tree, 0.25) self.assertSameClusters([['A', 'B'], ['D']], clusters)