def test_compute_sample_novelty(self): """Test computing the novelty of a sample using various metrics.""" exp = [('B', 4, 57.692307692307686), ('C', 3, 57.142857142857139), ('A', 0, 0.0)] obs = compute_sample_novelty([self.table1_f, self.table2_f], self.ref_seqs_f) self.assertFloatEqual(obs, exp) # Test that table order doesn't matter. obs = compute_sample_novelty([self.table2_f, self.table1_f], self.ref_seqs_f) self.assertFloatEqual(obs, exp) # Test duplicate table (should still work). exp = [('B', 2, 44.444444444444443), ('A', 0, 0.0)] obs = compute_sample_novelty([self.table1_f, self.table1_f], self.ref_seqs_f) self.assertFloatEqual(obs, exp)
def main(): option_parser, opts, args = parse_command_line_parameters(**script_info) sample_novelty_data = compute_sample_novelty( [qiime_open(otu_table_fp) for otu_table_fp in opts.otu_table_fps], qiime_open(opts.rep_set_fp), opts.verbose) with open(opts.output_fp, 'w') as out_f: header = ['SampleID', 'Number of novel OTUs', 'Percent novel sequences'] table_writer = writer(out_f, delimiter='\t', lineterminator='\n') table_writer.writerow(header) table_writer.writerows(sample_novelty_data)
def main(): option_parser, opts, args = parse_command_line_parameters(**script_info) sample_novelty_data = compute_sample_novelty( [qiime_open(otu_table_fp) for otu_table_fp in opts.otu_table_fps], qiime_open(opts.rep_set_fp), opts.verbose) with open(opts.output_fp, 'w') as out_f: header = [ 'SampleID', 'Number of novel OTUs', 'Percent novel sequences' ] table_writer = writer(out_f, delimiter='\t', lineterminator='\n') table_writer.writerow(header) table_writer.writerows(sample_novelty_data)