Example #1
0
def main():
    option_parser, opts, args =\
        parse_command_line_parameters(**script_info)

    otu_files = map(open, opts.otu_map_fps)
    failures_fp = opts.failures_fp
    output_fp = opts.output_fp
    if failures_fp:
        failures_f = open(failures_fp, 'U')
    else:
        failures_f = None

    try:
        result = map_otu_map_files(otu_files, failures_file=failures_f)
    except KeyError as e:
        print(
            'Some keys do not map (' + str(e) + ') -- is the order of'
            ' your OTU maps equivalent to the order in which the OTU pickers'
            ' were run? If expanding a failures file, did you remember to leave'
            ' out the otu map from the run which generated the failures file?')
        exit(1)

    if failures_fp is not None:
        of = open(output_fp, 'w')
        of.write('\n'.join(result))
        of.close()
    else:
        write_otu_map(result.items(), output_fp)
Example #2
0
def main():
    option_parser, opts, args =\
        parse_command_line_parameters(**script_info)

    otu_files = map(open, opts.otu_map_fps)
    failures_fp = opts.failures_fp
    output_fp = opts.output_fp
    if failures_fp:
        failures_f = open(failures_fp, 'U')
    else:
        failures_f = None

    try:
        result = map_otu_map_files(otu_files, failures_file=failures_f)
    except KeyError as e:
        print ('Some keys do not map (' + str(e) + ') -- is the order of'
               ' your OTU maps equivalent to the order in which the OTU pickers'
               ' were run? If expanding a failures file, did you remember to leave'
               ' out the otu map from the run which generated the failures file?')
        exit(1)

    if failures_fp is not None:
        of = open(output_fp, 'w')
        of.write('\n'.join(result))
        of.close()
    else:
        write_otu_map(result.items(), output_fp)
Example #3
0
    def test_write_otu_map_prefix(self):
        """write_otu_map functions as expected w otu prefix """
        write_otu_map(self.otu_map1, self.tmp_fp1, "my.otu.")
        actual = fields_to_dict(open(self.tmp_fp1))
        self.files_to_remove.append(self.tmp_fp1)

        exp = {"my.otu.0": ["seq1", "seq2", "seq5"], "my.otu.1": ["seq3", "seq4"], "my.otu.2": ["seq6", "seq7", "seq8"]}
        self.assertEqual(actual, exp)
Example #4
0
 def test_write_otu_map_prefix(self):
     """write_otu_map functions as expected w otu prefix """
     write_otu_map(self.otu_map1,self.tmp_fp1,'my.otu.')
     actual = fields_to_dict(open(self.tmp_fp1))
     self.files_to_remove.append(self.tmp_fp1)
     
     exp = {'my.otu.0':['seq1','seq2','seq5'],
            'my.otu.1':['seq3','seq4'],
            'my.otu.2':['seq6','seq7','seq8']}
     self.assertEqual(actual,exp)
Example #5
0
    def test_write_otu_map_prefix(self):
        """write_otu_map functions as expected w otu prefix """
        write_otu_map(self.otu_map1, self.tmp_fp1, 'my.otu.')
        actual = fields_to_dict(open(self.tmp_fp1))
        self.files_to_remove.append(self.tmp_fp1)

        exp = {'my.otu.0': ['seq1', 'seq2', 'seq5'],
               'my.otu.1': ['seq3', 'seq4'],
               'my.otu.2': ['seq6', 'seq7', 'seq8']}
        self.assertEqual(actual, exp)
Example #6
0
 def test_write_otu_map(self):
     """write_otu_map functions as expected """
     write_otu_map(self.otu_map1, self.tmp_fp1)
     actual = fields_to_dict(open(self.tmp_fp1))
     self.files_to_remove.append(self.tmp_fp1)
     self.assertEqual(actual, dict(self.otu_map1))
Example #7
0
 def test_write_otu_map(self):
     """write_otu_map functions as expected """
     write_otu_map(self.otu_map1,self.tmp_fp1)
     actual = fields_to_dict(open(self.tmp_fp1))
     self.files_to_remove.append(self.tmp_fp1)
     self.assertEqual(actual,dict(self.otu_map1))
Example #8
0
    option_parser, opts, args =\
       parse_command_line_parameters(**script_info)
    
    otu_files = map(open,opts.otu_map_fps)
    failures_fp = opts.failures_fp
    output_fp = opts.output_fp
    if failures_fp:
        failures_f = open(failures_fp,'U')
    else:
        failures_f = None
    
    try:
        result = map_otu_map_files(otu_files,failures_file=failures_f)
    except KeyError,e:
        print ('Some keys do not map ('+ str(e) +') -- is the order of'
        ' your OTU maps equivalent to the order in which the OTU pickers'
        ' were run? If expanding a failures file, did you remember to leave'
        ' out the otu map from the run which generated the failures file?')
        exit(1)
    
    if failures_fp != None:
        of = open(output_fp,'w')
        of.write('\n'.join(result))
        of.close()
    else:
        write_otu_map(result.items(),output_fp)

    
if __name__ == "__main__":
    main()
Example #9
0
    option_parser, opts, args =\
       parse_command_line_parameters(**script_info)
    
    otu_files = map(open,opts.otu_map_fps)
    failures_fp = opts.failures_fp
    output_fp = opts.output_fp
    if failures_fp:
        failures_f = open(failures_fp,'U')
    else:
        failures_f = None
    
    try:
        result = map_otu_map_files(otu_files,failures_file=failures_f)
    except KeyError,e:
        print ('Some keys do not map ('+ str(e) +') -- is the order of'
        ' your OTU maps equivalent to the order in which the OTU pickers'
        ' were run? If expanding a failures file, did you remember to leave'
        ' out the otu map from the run which generated the failures file?')
        exit(1)
    
    if failures_fp != None:
        of = open(output_fp,'w')
        of.write('\n'.join(result))
        of.close()
    else:
        write_otu_map(result.items(),output_fp)

    
if __name__ == "__main__":
    main()