def test_coverage_report(self): bayes = pkg_resources.resource_filename('shogun.tests', os.path.join('data', 'sheared_bayes.32.txt')) df_bayes = parse_bayes(bayes) taxatable = pkg_resources.resource_filename('shogun.tests', os.path.join('data', 'results', 'burst_taxatable.txt')) infile = pkg_resources.resource_filename('shogun.tests', os.path.join('data', 'results', 'burst_results.b6')) self.assertTrue(get_coverage_of_microbes(infile, df_bayes, 6) is not None) self.assertTrue(get_coverage_of_microbes(infile, df_bayes, 7) is not None) self.assertTrue(get_coverage_of_microbes(infile, df_bayes, 8) is not None)
def _coverage(input, database, output, level, taxonomy): data_files = _load_metadata(database) shear = os.path.join(database, data_files['general']['shear']) if taxonomy == 'mapping': taxatree = Taxonomy(os.path.join(database, data_files['general']['taxonomy'])) parse_taxonomy_from_row = lambda row: taxatree(row[1]) else: parse_taxonomy_from_row = lambda row: row[-1] shear_df = parse_bayes(shear) outdf = get_coverage_of_microbes(input, shear_df, level, parse_taxonomy_from_row=parse_taxonomy_from_row) outdf.to_csv(output, sep='\t', float_format="%.5f", na_rep=0)