def test_ace_for_picrust_ml(self): """ test_ace_for_picrust with method 'ML' functions as expected with valid input """ actual, actual_ci = ace_for_picrust(self.in_tree1_fp, self.in_trait1_fp, method="ML") expected = Table( ["nodes", "trait1", "trait2"], [ ["14", "2.9737", "2.5436"], ["12", "2.3701", "2.7056"], ["11", "0.8370", "2.9706"], ["10", "4.4826", "2.1388"], ], ) self.assertEqual(actual.tostring(), expected.tostring()) expected_ci = Table( ["nodes", "trait1", "trait2"], [ ["14", "1.4467|4.5007", "2.1979|2.8894"], ["12", "0.9729|3.7674", "2.3892|3.0219"], ["11", "0.147|1.527", "2.8143|3.1268"], ["10", "3.4227|5.5426", "1.8988|2.3788"], ["sigma", "1.9742|0.6981", "0.1012|0.0359"], ["loglik", "-6.7207", "5.1623"], ], ) self.assertEqual(actual_ci.tostring(), expected_ci.tostring())
def test_ace_for_picrust_pic(self): """ test_ace_for_picrust with method 'pic' functions as expected with valid input """ actual,actual_ci= ace_for_picrust(self.in_tree1_fp,self.in_trait1_fp, method="pic") expected=Table(['nodes','trait1','trait2'],[['14','2.9737','2.5436'],['12','1.2727','3'],['11','0.6667','3'],['10','5','2']]) self.assertEqual(actual.tostring(),expected.tostring()) expected_ci=Table(['nodes','trait1','trait2'],\ [['14','0.7955|5.1519','0.3655|4.7218'],\ ['12','-1.1009|3.6464','0.6264|5.3736'],\ ['11','-0.4068|1.7402','1.9265|4.0735'],\ ['10','3.3602|6.6398','0.3602|3.6398'],\ ]) self.assertEqual(actual_ci.tostring(),expected_ci.tostring())
def test_ace_for_picrust_ml(self): """ test_ace_for_picrust with method 'ML' functions as expected with valid input """ actual,actual_ci= ace_for_picrust(self.in_tree1_fp, self.in_trait1_fp, method="ML") expected=Table(['nodes','trait1','trait2'],[['14','2.9737','2.5436'],['12','2.3701','2.7056'],['11','0.8370','2.9706'],['10','4.4826','2.1388']]) self.assertEqual(actual.tostring(),expected.tostring()) expected_ci=Table(['nodes','trait1','trait2'],\ [['14','1.4467|4.5007','2.1979|2.8894'],\ ['12','0.9729|3.7674','2.3892|3.0219'],\ ['11','0.147|1.527','2.8143|3.1268'],\ ['10','3.4227|5.5426','1.8988|2.3788'],\ ['sigma','1.9742|0.6981','0.1012|0.0359'],\ ['loglik','-6.7207','5.1623'],\ ]) self.assertEqual(actual_ci.tostring(),expected_ci.tostring())
def test_wagner_for_picrust_with_funky_tip_labels(self): """ test_wagner_for_picrust for a tree with quoted tip labels """ actual = wagner_for_picrust(self.in_tree2_fp, self.in_trait3_fp) expected = Table( ["nodes", "trait1", "trait2"], [["11", "1", "3"], ["12", "2", "3"], ["10", "5", "2"], ["14", "5", "3"]] ) self.assertEqual(actual.tostring(), expected.tostring())
def test_wagner_for_picrust_with_funky_tip_labels(self): """ test_wagner_for_picrust for a tree with quoted tip labels """ actual = wagner_for_picrust(self.in_tree2_fp, self.in_trait3_fp) expected = Table(['nodes', 'trait1', 'trait2'], [['11', '1', '3'], ['12', '2', '3'], ['10', '5', '2'], ['14', '5', '3']]) self.assertEqual(actual.tostring(), expected.tostring())
def test_ace_for_picrust_pic_with_funky_tip_labels(self): """ test_ace_for_picrust for a tree with underscores in tip labels """ actual, ci = ace_for_picrust(self.in_tree2_fp, self.in_trait3_fp, method="pic") expected = Table( ["nodes", "trait1", "trait2"], [["14", "2.9737", "2.5436"], ["12", "1.2727", "3"], ["11", "0.6667", "3"], ["10", "5", "2"]], ) self.assertEqual(actual.tostring(), expected.tostring())
def test_ace_for_picrust_pic_single_trait(self): """ test_ace_for_picrust with method 'pic' functions as expected with single column trait table """ actual, ci = ace_for_picrust(self.in_tree1_fp, self.in_trait2_fp, method="pic") expected = Table(['nodes', 'trait1'], [['14', '2.9737'], ['12', '1.2727'], ['11', '0.6667'], ['10', '5']]) self.assertEqual(actual.tostring(), expected.tostring())
def test_ace_for_picrust_pic(self): """ test_ace_for_picrust with method 'pic' functions as expected with valid input """ actual, actual_ci = ace_for_picrust(self.in_tree1_fp, self.in_trait1_fp, method="pic") expected = Table( ["nodes", "trait1", "trait2"], [["14", "2.9737", "2.5436"], ["12", "1.2727", "3"], ["11", "0.6667", "3"], ["10", "5", "2"]], ) self.assertEqual(actual.tostring(), expected.tostring()) expected_ci = Table( ["nodes", "trait1", "trait2"], [ ["14", "0.7955|5.1519", "0.3655|4.7218"], ["12", "-1.1009|3.6464", "0.6264|5.3736"], ["11", "-0.4068|1.7402", "1.9265|4.0735"], ["10", "3.3602|6.6398", "0.3602|3.6398"], ], ) self.assertEqual(actual_ci.tostring(), expected_ci.tostring())
def test_ace_for_picrust_pic_with_funky_tip_labels(self): """ test_ace_for_picrust for a tree with underscores in tip labels """ actual, ci = ace_for_picrust(self.in_tree2_fp, self.in_trait3_fp, method="pic") expected = Table(['nodes', 'trait1', 'trait2'], [['14', '2.9737', '2.5436'], ['12', '1.2727', '3'], ['11', '0.6667', '3'], ['10', '5', '2']]) self.assertEqual(actual.tostring(), expected.tostring())
def test_only_required_columns(self): """generate bedgraph from minimal data""" table = Table(header=['chrom', 'start', 'end', 'value'], rows=[['1', 100, i, 0] for i in range(101,111)] + \ [['1', 150, i, 10] for i in range(151,161)]) bgraph = table.tostring(format='bedgraph', name='test track', description='test of bedgraph', color=(255,0,0)) self.assertTrue(bgraph, '\n'.join(['track type=bedGraph name="test track" '\ +'description="test of bedgraph" color=255,0,0', '1\t100\t110\t0', '1\t150\t160\t10']))
def test_merged_overlapping_spans(self): """bedgraph merged overlapping spans, one chrom""" rows = [['1', i, i+1, 0] for i in range(100, 121)] +\ [['1', i, i+1, 10] for i in range(150, 161)] table = Table(header=['chrom', 'start', 'end', 'value'], rows=rows) bgraph = table.tostring(format='bedgraph', name='test track', description='test of bedgraph', color=(255,0,0)) self.assertTrue(bgraph, '\n'.join(['track type=bedGraph name="test track" '\ +'description="test of bedgraph" color=255,0,0', '1\t100\t120\t0', '1\t150\t160\t10']))
def test_int_correctly_formatted(self): """int should be correctly formatted""" rows = [['1', i, i+1, 0] for i in range(100, 121)] +\ [['1', i, i+1, 10] for i in range(150, 161)] table = Table(header=['chrom', 'start', 'end', 'value'], rows=rows) bgraph = table.tostring(format='bedgraph', name='test track', description='test of bedgraph', color=(255,0,0), smoothingWindow=10) self.assertTrue(bgraph, '\n'.join(['track type=bedGraph name="test track" '\ +'description="test of bedgraph" color=255,0,0 smoothingWindow=10', '1\t100\t110\t1', '1\t150\t160\t10']))
def test_boolean_correctly_formatted(self): """boolean setting correctly formatted""" rows = [['1', i, i+1, 0] for i in range(100, 121)] +\ [['1', i, i+1, 10] for i in range(150, 161)] table = Table(header=['chrom', 'start', 'end', 'value'], rows=rows) bgraph = table.tostring(format='bedgraph', name='test track', description='test of bedgraph', color=(255,0,0), autoScale=True) self.assertTrue(bgraph, '\n'.join(['track type=bedGraph name="test track" '\ +'description="test of bedgraph" color=255,0,0 autoScale=on', '1\t100\t110\t1', '1\t150\t160\t10']))
def test_wagner_for_picrust_with_funky_tip_labels(self): """ test_wagner_for_picrust for a tree with quoted tip labels """ actual= wagner_for_picrust(self.in_tree2_fp,self.in_trait3_fp) expected=Table(['nodes','trait1','trait2'],[['11','1','3'],['12','2','3'],['10','5','2'],['14','5','3']]) self.assertEqual(actual.tostring(),expected.tostring())
def test_ace_for_picrust_pic_single_trait(self): """ test_ace_for_picrust with method 'pic' functions as expected with single column trait table """ actual, ci = ace_for_picrust(self.in_tree1_fp, self.in_trait2_fp, method="pic") expected = Table(["nodes", "trait1"], [["14", "2.9737"], ["12", "1.2727"], ["11", "0.6667"], ["10", "5"]]) self.assertEqual(actual.tostring(), expected.tostring())
def test_ace_for_picrust_pic_single_trait(self): """ test_ace_for_picrust with method 'pic' functions as expected with single column trait table """ actual,ci= ace_for_picrust(self.in_tree1_fp,self.in_trait2_fp, method="pic") expected=Table(['nodes','trait1'],[['14','2.9737'],['12','1.2727'],['11','0.6667'],['10','5']]) self.assertEqual(actual.tostring(),expected.tostring())
def test_ace_for_picrust_pic_with_funky_tip_labels(self): """ test_ace_for_picrust for a tree with underscores in tip labels """ actual,ci= ace_for_picrust(self.in_tree2_fp,self.in_trait3_fp, method="pic") expected=Table(['nodes','trait1','trait2'],[['14','2.9737','2.5436'],['12','1.2727','3'],['11','0.6667','3'],['10','5','2']]) self.assertEqual(actual.tostring(),expected.tostring())