def core_model_test(base_dir, mapping_table, taxa_level, output_dir): """ Tests the core model Inputs: base_dir: base common directory of all mapping files mapping_table: dictionary with the mapping table information output_dir: output directory """ profiles = get_profiles_list(base_dir, mapping_table, taxa_level) # Bootstrap profiles to get the results profile, mean, stdev, ci = bootstrap_profiles(normalize_profiles(profiles)) # Write the bootstrapped profile profile_fp = join(output_dir, 'core_model_profile.txt') write_profile(profile, profile_fp) # Write the test result output_fp = join(output_dir, 'core_model_result.txt') outf = open(output_fp, 'w') outf.write("Results for the core model test:\n") outf.write("Microbiome model: ") if profile['not_shared'] < 0.5: outf.write("Substantial core.\n") elif profile['not_shared'] < 1.0: outf.write("Minimal core.\n") else: outf.write('No core\n') outf.write("\nStatistical results (amount shared):\n") outf.write("Mean: %f %%\n" % (mean * 100)) outf.write("Standard deviation: %f %%\n" % (stdev * 100)) outf.write("Confidence interval for the mean: [%f %%, %f %%]\n" % ((ci[0] * 100), (ci[1] * 100)))
def test_bootstrap_profiles(self): randfunc = lambda : 1 obs_prof, obs_mean, obs_stdev, obs_ci = \ bootstrap_profiles(self.profiles_list, randfunc = randfunc) exp_prof = {'taxa1': (0.10),'taxa2': (0.22), 'taxa3': (0.15),'taxa4': (0.25)}
def test_bootstrap_profiles(self): randfunc = lambda: 1 obs_prof, obs_mean, obs_stdev, obs_ci = \ bootstrap_profiles(self.profiles_list, randfunc = randfunc) exp_prof = { 'taxa1': (0.10), 'taxa2': (0.22), 'taxa3': (0.15), 'taxa4': (0.25) }