def test_add_node(self): exp = {'name':'foo','popcount':0,'children':[ {'name':'bar', 'popcount':0, 'children':[]} ] } foo = create_node('foo') bar = create_node('bar') add_node(foo,bar) self.assertEqual(foo, exp)
def test_update_per_sample_tree(self): taxons = (('k__a', 'p__x'), ('k__a', 'p__x'), ('k__a', 'p__y'), # indep of p__x; c__1 ('k__b', 'p__z')) counts = (5, 7, 9, 11) exp = {'name': 'root', 'count': 32, 'freq': None, 'children': [{'name': 'k__a', 'count': 21, 'freq': None, 'children': [{'name': 'p__x', 'count': 12, 'freq': None, 'children': []}, {'name': 'p__y', 'count': 9, 'freq': None, 'children': []}]}, {'name': 'k__b', 'count': 11, 'freq': None, 'children': [{'name': 'p__z', 'count': 11, 'freq': None, 'children': []}]}]} tree = create_node('root', count=0, freq=None) update_per_sample_tree(tree, taxons[0], counts[0]) update_per_sample_tree(tree, taxons[1], counts[1]) update_per_sample_tree(tree, taxons[2], counts[2]) update_per_sample_tree(tree, taxons[3], counts[3]) self.assertEqual(tree, exp)
def test_update_per_sample_tree(self): taxons = ( ('k__a', 'p__x'), ('k__a', 'p__x'), ('k__a', 'p__y'), # indep of p__x; c__1 ('k__b', 'p__z')) counts = (5, 7, 9, 11) exp = { 'name': 'root', 'count': 32, 'freq': None, 'children': [{ 'name': 'k__a', 'count': 21, 'freq': None, 'children': [{ 'name': 'p__x', 'count': 12, 'freq': None, 'children': [] }, { 'name': 'p__y', 'count': 9, 'freq': None, 'children': [] }] }, { 'name': 'k__b', 'count': 11, 'freq': None, 'children': [{ 'name': 'p__z', 'count': 11, 'freq': None, 'children': [] }] }] } tree = create_node('root', count=0, freq=None) update_per_sample_tree(tree, taxons[0], counts[0]) update_per_sample_tree(tree, taxons[1], counts[1]) update_per_sample_tree(tree, taxons[2], counts[2]) update_per_sample_tree(tree, taxons[3], counts[3]) self.assertEqual(tree, exp)
def test_create_node(self): exp = {'name':'foo','popcount':0,'children':[]} obs = create_node('foo') self.assertEqual(obs, exp)
def test_create_node(self): exp = {'name': 'foo', 'children': []} obs = create_node('foo') self.assertEqual(obs, exp)