def main(): option_parser, opts, args = parse_command_line_parameters(**script_info) output_table_fp = opts.output_otu_table_fp metadata_field = opts.metadata_field positive_taxa = opts.positive_taxa negative_taxa = opts.negative_taxa input_table = load_table(opts.input_otu_table_fp) if positive_taxa is not None: positive_taxa = positive_taxa.split(',') else: positive_taxa = None if negative_taxa is not None: negative_taxa = negative_taxa.split(',') else: negative_taxa = None filter_fn = get_otu_ids_from_taxonomy_f(positive_taxa, negative_taxa, metadata_field) input_table.filter(filter_fn, axis='observation') try: write_biom_table(input_table, output_table_fp) except EmptyBIOMTableError: option_parser.error( "Filtering resulted in an empty BIOM table. " "This indicates that no OTUs remained after filtering.")
def main(): option_parser, opts, args =\ parse_command_line_parameters(**script_info) input_table = parse_biom_table(open(opts.input_otu_table_fp, 'U')) output_table_f = open(opts.output_otu_table_fp, 'w') metadata_field = opts.metadata_field positive_taxa = opts.positive_taxa negative_taxa = opts.negative_taxa if positive_taxa is not None: positive_taxa = positive_taxa.split(',') else: positive_taxa = None if negative_taxa is not None: negative_taxa = negative_taxa.split(',') else: negative_taxa = None filter_fn = get_otu_ids_from_taxonomy_f( positive_taxa, negative_taxa, metadata_field) output_table = input_table.filterObservations(filter_fn) output_table_f.write(format_biom_table(output_table)) output_table_f.close()
def main(): option_parser, opts, args = parse_command_line_parameters(**script_info) output_table_fp = opts.output_otu_table_fp metadata_field = opts.metadata_field positive_taxa = opts.positive_taxa negative_taxa = opts.negative_taxa input_table = load_table(opts.input_otu_table_fp) if positive_taxa is not None: positive_taxa = positive_taxa.split(',') else: positive_taxa = None if negative_taxa is not None: negative_taxa = negative_taxa.split(',') else: negative_taxa = None filter_fn = get_otu_ids_from_taxonomy_f(positive_taxa, negative_taxa, metadata_field) input_table.filter(filter_fn, axis='observation') write_biom_table(input_table, output_table_fp)