def test_format_method_comparison_table(self): """Test formatting a methods summary table.""" obs = format_method_comparison_table(self.per_method_results1) self.assertEqual(obs, exp_method_comparison_table1) self.assertRaises(ValueError, format_method_comparison_table, self.per_method_results2) self.assertRaises(ValueError, format_method_comparison_table, self.per_method_results3)
def create_real_data_summary_tables(in_dir, workflow): """Summarizes the results of the various method runs on real data. Effect sizes and p-values are collected for each of the tests that were run and summary tables are created, one for each sampling depth / metric combination. These tables will be in TSV format so that they can be easily imported into Excel for viewing and cleanup for publication. """ results = _collate_real_data_results(in_dir, workflow) for depth_desc, depth_res in results.items(): for metric, metric_res in depth_res.items(): table_rows = format_method_comparison_table(metric_res) table_name = 'summary_table_%s_%s.txt' % (depth_desc, metric) with open(join(in_dir, table_name), 'wb') as out_f: # We use \r so that we can force linebreaks within cells # when imported into Excel. Not sure if this will work with # other spreadsheet programs such as Open Office. tsv_writer = writer(out_f, delimiter='\t', lineterminator='\r') tsv_writer.writerows(table_rows)