예제 #1
0
    def test_generate_heatmap_plots(self):
        """generate_heatmap_plots: create default output files"""

        # create directories and move js files to verify everything works
        # in the script file
        dir_path = join(self.output_dir, 'test')
        create_dir(dir_path)

        js_dir_path = join(dir_path, 'js')
        create_dir(js_dir_path)

        self._folders_to_cleanup.append(dir_path)

        qiime_dir = get_qiime_project_dir()

        js_path = join(qiime_dir, 'qiime/support_files/js')
        shutil.copyfile(join(js_path, 'overlib.js'),
                        join(js_dir_path, 'overlib.js'))
        shutil.copyfile(join(js_path, 'otu_count_display.js'),
                        join(js_dir_path, 'otu_count_display.js'))
        shutil.copyfile(join(js_path, 'jquery.js'),
                        join(js_dir_path, 'jquery.js'))
        shutil.copyfile(join(js_path, 'jquery.tablednd_0_5.js'),
                        join(js_dir_path, 'jquery.tablednd_0_5.js'))

        # generate otu_table object
        orig_data = array([[0, 1, 2], [1000, 0, 0]])

        orig_otu_table = table_factory(orig_data,
                                       ['Sample1', 'Sample2', 'Sample3'],
                                       ['OTU1', 'OTU2'], [None, None, None], [{
                                           "taxonomy": ["Bacteria"]
                                       }, {
                                           "taxonomy": ["Archaea"]
                                       }])

        # put in an OTU sort order and sample order
        otu_sort = ['OTU2', 'OTU1']
        sample_sort = ['Sample2', 'Sample1', 'Sample3']
        num_otu_hits = 3

        # generate test files
        generate_heatmap_plots(num_otu_hits,
                               orig_otu_table,
                               otu_sort,
                               sample_sort,
                               dir_path,
                               js_dir_path,
                               'test',
                               fractional_values=False)

        self.assertEqual(
            open(join(js_dir_path, 'test.js'), 'U').read(), exp_js_output_file)
예제 #2
0
    def test_generate_heatmap_plots(self):
        """generate_heatmap_plots: create default output files"""

        # create directories and move js files to verify everything works
        # in the script file
        dir_path = join(self.output_dir, 'test')
        create_dir(dir_path)

        js_dir_path = join(dir_path, 'js')
        create_dir(js_dir_path)

        self._folders_to_cleanup.append(dir_path)

        qiime_dir = get_qiime_project_dir()

        js_path = join(qiime_dir, 'qiime/support_files/js')
        shutil.copyfile(join(js_path, 'overlib.js'),
                        join(js_dir_path, 'overlib.js'))
        shutil.copyfile(join(js_path, 'otu_count_display.js'),
                        join(js_dir_path, 'otu_count_display.js'))
        shutil.copyfile(join(js_path, 'jquery.js'),
                        join(js_dir_path, 'jquery.js'))
        shutil.copyfile(join(js_path, 'jquery.tablednd_0_5.js'),
                        join(js_dir_path, 'jquery.tablednd_0_5.js'))

        # generate otu_table object
        orig_data = array([[0, 1, 2], [1000, 0, 0]])

        orig_otu_table = table_factory(orig_data,
                                       ['Sample1', 'Sample2', 'Sample3'],
                                       ['OTU1', 'OTU2'],
                                       [None, None, None],
                                       [{"taxonomy": ["Bacteria"]},
                                        {"taxonomy": ["Archaea"]}])

        # put in an OTU sort order and sample order
        otu_sort = ['OTU2', 'OTU1']
        sample_sort = ['Sample2', 'Sample1', 'Sample3']
        num_otu_hits = 3

        # generate test files
        generate_heatmap_plots(num_otu_hits, orig_otu_table, otu_sort,
                               sample_sort, dir_path, js_dir_path,
                               'test', fractional_values=False)

        self.assertEqual(open(join(js_dir_path, 'test.js'), 'U').read(),
                         exp_js_output_file)