def main(): option_parser, opts, args = parse_command_line_parameters(**script_info) if not isfile(opts.input_path): raise IOError("Input path (%s) not valid. Does it exist?" % opts.input_path) samples, otus, data = parse_trflp(open(opts.input_path, 'U')) t = Table(data, otus, samples) write_biom_table(t, opts.output_path)
def main(): option_parser, opts, args = parse_command_line_parameters(**script_info) if not isfile(opts.input_path): raise IOError( "Input path (%s) not valid. Does it exist?" % opts.input_path) samples, otus, data = parse_trflp(open(opts.input_path, 'U')) t = Table(data, otus, samples) write_biom_table(t, opts.output_path)
def main(): option_parser, opts, args =\ parse_command_line_parameters(**script_info) if not isfile(opts.input_path): raise IOError, \ "Input path (%s) not valid. Does it exist?" % opts.input_path samples, otus, data = parse_trflp(open(opts.input_path,'U')) output_f = open(opts.output_path, 'w') t = table_factory(data,samples,otus) output_f.write(format_biom_table(t)) output_f.close()
def main(): option_parser, opts, args =\ parse_command_line_parameters(**script_info) if not isfile(opts.input_path): raise IOError, \ "Input path (%s) not valid. Does it exist?" % opts.input_path if isfile(opts.output_path): raise IOError, \ "Output path (%s) already exists. Please " % opts.output_path +\ "remove or specify a different path" samples, otus, data = parse_trflp(open(opts.input_path,'U')) output_f = open(opts.output_path, 'w') output_f.write(format_otu_table(samples,otus,data, comment='Created with %s' % __file__)) output_f.close()
def test_parse_trflp_headerless(self): """ should return a header and otu_table lists""" data = \ """Samp-le 1 1000 2000 3000 4000 Sample 2 2000 3000 4000 Sample 3 3000 4000 Sample 4 4000 Sample_5__ 25 """ samples, otus, data = parse_trflp(data.split('\n')) samples_exp = ['Samp.le.1', 'Sample.2', 'Sample.3', 'Sample.4', 'Sample.5..'] otus_exp = ['Bin__0', 'Bin__1', 'Bin__2', 'Bin__3'] data_exp = array([[1000, 0, 0, 0, 25],\ [2000, 2000, 0, 0, 0],\ [3000, 3000, 3000, 0, 0],\ [4000, 4000, 4000, 4000, 0]]) self.assertEqual(samples, samples_exp) self.assertEqual(otus, otus_exp) self.assertEqual(data, data_exp)
def test_parse_trflp(self): """ should return a header and otu_table lists""" data = \ """ Bin (10bp) Bin (20bp) Bin (30bp) Bin (40 bp) Samp-le 1 1000 2000 3000 4000 Sample 2 2000 3000 4000 Sample 3 3000 4000 Sample 4 4000 Sample 5 25 """ samples, otus, data = parse_trflp(data.split('\n')) samples_exp = ['Samp.le.1', 'Sample.2', 'Sample.3', 'Sample.4', 'Sample.5'] otus_exp = ['Bin__10bp_', 'Bin__20bp_', 'Bin__30bp_', 'Bin__40_bp_'] data_exp = array([[1000, 0, 0, 0, 25],\ [2000, 2000, 0, 0, 0],\ [3000, 3000, 3000, 0, 0],\ [4000, 4000, 4000, 4000, 0]]) self.assertEqual(samples, samples_exp) self.assertEqual(otus, otus_exp) self.assertEqual(data, data_exp)