def test_combine_mappings(self):
        """combine_mappings works as expected"""

        self.tmp_dir = mkdtemp(dir="./", suffix="/")

        combine_mappings(
            fasta,
            denoiser_mapping,
            denoised_seqs,
            otu_picker_map,
            self.tmp_dir)

        observed_otu_map = "".join(
            list(open(self.tmp_dir + "/denoised_otu_map.txt")))

        expected_otu_map = """1:\tS1_1\tS1_2\tS2_4\tS2_5
2:\tS2_3\tS1_6
"""
        self.assertEqual(observed_otu_map, expected_otu_map)

        observed_fasta = "".join(
            list(open(self.tmp_dir + "/denoised_all.fasta")))
        expected_fasta = """>S1_1 Read1
AAA
>S1_2 Read2
TTT
>S2_3 Read3
GGG
"""
        self.assertEqual(observed_fasta, expected_fasta)
Example #2
0
    def test_combine_mappings(self):
        """combine_mappings works as expected"""

        self.tmp_dir = mkdtemp(dir="./", suffix="/")

        combine_mappings(fasta, denoiser_mapping, denoised_seqs,
                         otu_picker_map, self.tmp_dir)

        observed_otu_map = "".join(
            list(open(self.tmp_dir + "/denoised_otu_map.txt")))

        expected_otu_map = """1:\tS1_1\tS1_2\tS2_4\tS2_5
2:\tS2_3\tS1_6
"""
        self.assertEqual(observed_otu_map, expected_otu_map)

        observed_fasta = "".join(
            list(open(self.tmp_dir + "/denoised_all.fasta")))
        expected_fasta = """>S1_1 Read1
AAA
>S1_2 Read2
TTT
>S2_3 Read3
GGG
"""
        self.assertEqual(observed_fasta, expected_fasta)
def main(commandline_args=None):
    option_parser, opts, args = parse_command_line_parameters(**script_info)
 
    #check for missing files
    required_files = [opts.denoiser_map_file, opts.otu_picker_map_file,
                      opts.fasta_fp, opts.denoised_fasta_fp]
    if (not all(required_files) or not all(map(exists, required_files))):
        option_parser.error('Missing input files.')

    create_dir(opts.output_dir, fail_on_exist=False)
           
    combine_mappings(open(opts.fasta_fp), open(opts.denoiser_map_file),
                     open(opts.denoised_fasta_fp),
                     open(opts.otu_picker_map_file), opts.output_dir)