Пример #1
0
 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])
Пример #2
0
 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)
Пример #3
0
 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])
Пример #4
0
 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])
Пример #5
0
 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])
Пример #6
0
 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])
Пример #7
0
 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])
Пример #8
0
 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)
Пример #9
0
 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)
Пример #10
0
 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())
Пример #11
0
 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])
Пример #12
0
 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)