def main(): option_parser, opts, args = parse_command_line_parameters(**script_info) if not os.path.exists(opts.output_path): os.makedirs(opts.output_path) maker = RarefactionMaker(opts.input_path, opts.depth, opts.depth, 1, opts.num_reps) maker.rarefy_to_files( opts.output_path, False, include_lineages=opts.lineages_included, empty_otus_removed=(not opts.keep_empty_otus) )
def main(): option_parser, opts, args = parse_command_line_parameters(**script_info) if not os.path.exists(opts.output_path): os.makedirs(opts.output_path) maker = RarefactionMaker(opts.input_path, opts.depth, opts.depth, 1, opts.num_reps) maker.rarefy_to_files(opts.output_path, False, include_lineages=opts.lineages_included, empty_otus_removed=(not opts.keep_empty_otus))
def main(): option_parser, opts, args = parse_command_line_parameters(**script_info) if opts.step <= 0: option_parser.error("nonpositive step not allowed (%s was supplied)" % \ (opts.step,)) create_dir(opts.output_path, fail_on_exist=False) maker = RarefactionMaker(opts.input_path, opts.min, opts.max, opts.step, opts.num_reps) maker.rarefy_to_files(opts.output_path, False, include_lineages=opts.lineages_included, empty_otus_removed=(not opts.keep_empty_otus))
def test_rarefy_to_files(self): """rarefy_to_files should write valid files """ maker = RarefactionMaker(self.otu_table_fp, 1, 2, 1, 1) maker.rarefy_to_files(self.rare_dir, include_full=True, include_lineages=False) fname = os.path.join(self.rare_dir, "rarefaction_1_0.biom") otu_table = load_table(fname) self.assertItemsEqual(otu_table.ids(), self.otu_table.ids()[:2])
def test_rarefy_to_files(self): """rarefy_to_files should write valid files """ maker = RarefactionMaker(self.otu_table_fp, 0, 1, 1, 1) maker.rarefy_to_files(self.rare_dir,include_full=True,include_lineages=False) fname = os.path.join(self.rare_dir,"rarefaction_1_0.biom") otu_table = parse_biom_table(open(fname,'U')) self.assertFloatEqual(otu_table.SampleIds, self.otu_table.SampleIds[:2]) # third sample had 0 seqs, so it's gone self.assertFloatEqual(otu_table.ObservationIds, self.otu_table.ObservationIds)
def test_rarefy_to_files2(self): """rarefy_to_files should write valid files with some metadata on otus """ maker = RarefactionMaker(self.otu_table_meta_fp, 0, 1, 1, 1) maker.rarefy_to_files(self.rare_dir, include_full=True, include_lineages=False) fname = os.path.join(self.rare_dir, "rarefaction_1_0.biom") with biom_open(fname, 'U') as biom_file: otu_table = Table.from_hdf5(biom_file) self.assertItemsEqual(otu_table.ids(), self.otu_table.ids()[:2])
def test_rarefy_to_files(self): """rarefy_to_files should write valid files """ maker = RarefactionMaker(self.otu_table_fp, 1, 2, 1, 1) maker.rarefy_to_files( self.rare_dir, include_full=True, include_lineages=False) fname = os.path.join(self.rare_dir, "rarefaction_1_0.biom") otu_table = load_table(fname) self.assertItemsEqual( otu_table.ids(), self.otu_table.ids()[:2])
def test_rarefy_to_files2(self): """rarefy_to_files should write valid files with some metadata on otus """ maker = RarefactionMaker(self.otu_table_meta_fp, 0, 1, 1, 1) maker.rarefy_to_files(self.rare_dir, include_full=True, include_lineages=False) fname = os.path.join(self.rare_dir, "rarefaction_1_0.biom") otu_table = parse_biom_table(open(fname, 'U')) self.assertItemsEqual(otu_table.SampleIds, self.otu_table.SampleIds[:2]) # third sample had 0 seqs, so it's gone self.assertItemsEqual(otu_table.ObservationIds, self.otu_table.ObservationIds)
def test_rarefy_to_files(self): """rarefy_to_files should write valid files """ maker = RarefactionMaker(self.otu_table_fp, 0, 1, 1, 1) maker.rarefy_to_files( self.rare_dir, include_full=True, include_lineages=False) fname = os.path.join(self.rare_dir, "rarefaction_1_0.biom") with biom_open(fname, 'U') as biom_file: otu_table = Table.from_hdf5(biom_file) self.assertItemsEqual( otu_table.sample_ids, self.otu_table.sample_ids[:2])
def main(): option_parser, opts, args = parse_command_line_parameters(**script_info) if opts.step <= 0: option_parser.error("step must be greater than 0") create_dir(opts.output_path, fail_on_exist=False) maker = RarefactionMaker(opts.input_path, opts.min, opts.max, opts.step, opts.num_reps) if opts.subsample_multinomial: subsample_f = partial(subsample, replace=True) else: subsample_f = subsample maker.rarefy_to_files(opts.output_path, False, include_lineages=opts.lineages_included, empty_otus_removed=(not opts.keep_empty_otus), subsample_f=subsample_f)
def main(): option_parser, opts, args = parse_command_line_parameters(**script_info) if opts.step <= 0: option_parser.error("nonpositive step not allowed (%s was supplied)" % (opts.step, )) create_dir(opts.output_path, fail_on_exist=False) maker = RarefactionMaker(opts.input_path, opts.min, opts.max, opts.step, opts.num_reps) if opts.subsample_multinomial: subsample_f = partial(subsample, replace=True) else: subsample_f = subsample maker.rarefy_to_files(opts.output_path, False, include_lineages=opts.lineages_included, empty_otus_removed=(not opts.keep_empty_otus), subsample_f=subsample_f)