def test_get_rarefaction_data(self):
        """get_rarefaction_data: This tests the functionality of taking a 
           rarefaction file and returns three values"""

        obs1, obs2, obs3 = get_rarefaction_data(self.rarefaction_file_data, self.col_headers2)

        exp1 = [[1.0, 3.0]]
        exp2 = [10.0, 10.0]
        exp3 = ["Sample1", "Sample2"]

        self.assertEqual(obs1, exp1)
        self.assertEqual(obs2, exp2)
        self.assertEqual(obs3, exp3)
    def test_get_rarefaction_data(self):
        '''get_rarefaction_data: This tests the functionality of taking a 
           rarefaction file and returns three values'''

        obs1,obs2,obs3 = get_rarefaction_data(self.rarefaction_file_data, \
                                                self.col_headers2)

        exp1 = [[1.0, 3.0]]
        exp2 = [10.0, 10.0]
        exp3 = ['Sample1', 'Sample2']

        self.assertEqual(obs1, exp1)
        self.assertEqual(obs2, exp2)
        self.assertEqual(obs3, exp3)
    def setUp(self):
        """define some top-level data"""

        self.data = {}
        self.data['xaxis'] = [10.0]
        self.sample_dict = {'Sample1': {10.00: [1.3276140000000001]}}
        self.data['yvals'] = {'Sample1': [1.3276140000000001]}
        self.data['err'] = {'Sample1': [.1]}
        self.xmax = 140
        self.ymax = 20
        self.std_type = 'stddev'
        self.ops = ['Sample1']
        self.mapping_category = 'SampleID'
        self.imagetype = 'png'
        self.resolution = 70
        self.mapping_lookup = {'SampleID-Sample1': 'col_0_row_0'}
        self.data['map'] = [['SampleID', 'Day'], ['Sample1', 'Day1']]
        self.color_prefs={'SampleID': {'column': 'SampleID', 'color': \
                          {'Sample1': '#ff0000'}}}
        self.groups = {'Sample1': ['Sample1']}
        self.background_color = 'black'
        self.label_color = 'white'
        self.labelname = 'SampleID'
        self.rare_data={'color': {'Sample1': '#ff0000'}, \
            'series': {'Sample1': [2.0515300000000001],}, \
             'headers': ['test.txt','SampleID'], 'xaxis': [10.0], \
             'error': {'Sample1': [0.0]}, 'options': ['Sample1']}
        self.fpath = '/tmp/'
        self.output_dir = '/tmp/'
        self.metric_name = 'test'
        self._paths_to_clean_up = []
        self._folders_to_cleanup = []
        self.rarefaction_file_data = [[10.0, 0.0, 1.0], [10.0, 1.0, 3.0]]
        d = {'redtowhite3_0': '#7fff00', 'redtowhite3_1': '#7fff00'}
        self.data_colors = color_dict_to_objects(d)
        self.colors = {'Sample1': 'redtowhite3_0', 'Sample2': 'redtowhite3_1'}
        self.colors2 = {'Sample1': 'redtowhite3_0'}
        self.mappingfile = [
            '#SampleID\tSex\tAge', '123\tF\t32', '234\tM\t30', '345\tM\t32'
        ]
        #self.p_mappingfile = parse_mapping_file(self.mappingfile,\
        #                                            strip_quotes=True)
        self.rarefactionfile=[\
                    '\tsequences per sample\titeration\t123\t234\t345',
                    'rare10.txt\t10\t0\t1.99181\t0.42877\t2.13996',
                    'rare10.txt\t10\t1\t2.07163\t0.42877\t2.37055',
                    'rare310.txt\t310\t0\t8.83115\t0.42877\t11.00725',
                    'rare310.txt\t310\t1\t10.05242\t0.42877\t8.24474',
                    'rare610.txt\t610\t0\t12.03067\t0.42877\t11.58928',
                    'rare610.txt\t610\t1\t12.9862\t0.42877\t11.58642']

        self.rares = {'test.txt': (['', 'sequences per sample', 'iteration', \
                      'Sample1'], [], ['rare1.txt', 'rare2.txt'], \
                      [[10.0, 2.0, 7.0, 7.0, 9.0], [10.0, 2.0, 7.0, 7.0, 9.0]])}
        self.col_headers, self.comments, self.rarefaction_fns, \
        self.rarefaction_data = parse_rarefaction(self.rarefactionfile)
        self.matrix, self.seqs_per_samp, self.sampleIDs = \
        get_rarefaction_data(self.rarefaction_data, self.col_headers)
        self.ave_seqs_per_sample1 = {'Sample1':[2.03172,9.4417849999999994,\
        12.508435]}
        self.ave_seqs_per_sample = {'123':[2.03172,9.4417849999999994,\
        12.508435],'234':[0.42876999999999998,0.42876999999999998,\
        0.42876999999999998],'345':[2.255255,9.625995,11.58785]}
        self.collapsed_ser_sex = {'M':[1.3420125000000001,5.0273824999999999,\
        6.0083099999999998], 'F':[2.03172,9.4417849999999994,12.508435]}
        self.err_ser_sex = {'M':[0.91324250000000007,4.5986124999999998,\
        5.5795399999999997],'F':[0.0,0.0,0.0]}
        self.rarefaction_legend_mat_init = {'test': {'SampleID': {}}}
        self.col_headers2=['', 'sequences per sample', 'iteration', 'Sample1', \
                           'Sample2']

        self.rarefaction_data_mat = {
            'SampleID': {
                'Sample1': {
                    'test': {
                        'ave': ['     7.000'],
                        'err': ['       nan']
                    }
                }
            }
        }

        self.rarefaction_legend_mat = {
            'test': {
                'samples': {
                    'Sample1': {
                        'color': '#ff0000',
                        'link': 'html_plots/testcol_0_row_0.png'
                    }
                },
                'groups': {
                    'SampleID': {
                        'Sample1': {
                            'groupcolor': '#ff0000',
                            'groupsamples': ['Sample1']
                        }
                    }
                }
            }
        }
        self.exp_err_series_ave = {
            'M': [1.571915, 6.49885, 8.1750183333333339]
        }
    def setUp(self):
        """define some top-level data"""

        self.data={}
        self.data['xaxis']=[10.0]
        self.sample_dict={'Sample1':{10.00: [1.3276140000000001]}}
        self.data['yvals']={'Sample1': [1.3276140000000001]}
        self.data['err']={'Sample1': [.1]}
        self.xmax=140
        self.ymax=20
        self.std_type='stddev'
        self.ops=['Sample1']
        self.mapping_category='SampleID'
        self.imagetype='png'
        self.resolution=70
        self.mapping_lookup={'SampleID-Sample1':'col_0_row_0'}
        self.data['map']=[['SampleID','Day'],['Sample1','Day1']]
        self.color_prefs={'SampleID': {'column': 'SampleID', 'color': \
                          {'Sample1': '#ff0000'}}}
        self.groups={'Sample1':['Sample1']}
        self.background_color='black'
        self.label_color='white'
        self.labelname='SampleID'
        self.rare_data={'color': {'Sample1': '#ff0000'}, \
            'series': {'Sample1': [2.0515300000000001],}, \
             'headers': ['test.txt','SampleID'], 'xaxis': [10.0], \
             'error': {'Sample1': [0.0]}, 'options': ['Sample1']}
        self.fpath='/tmp/'
        self.output_dir='/tmp/'
        self.metric_name='test'
        self._paths_to_clean_up = []
        self._folders_to_cleanup = []
        self.rarefaction_file_data=[[10.0, 0.0, 1.0], [10.0, 1.0, 3.0]]
        d = {'redtowhite3_0':'#7fff00','redtowhite3_1':'#7fff00'}
        self.data_colors = color_dict_to_objects(d)
        self.colors={'Sample1':'redtowhite3_0','Sample2':'redtowhite3_1'}
        self.colors2={'Sample1':'redtowhite3_0'}
        self.mappingfile = ['#SampleID\tSex\tAge',
                            '123\tF\t32',
                            '234\tM\t30',
                            '345\tM\t32']
        #self.p_mappingfile = parse_mapping_file(self.mappingfile,\
        #                                            strip_quotes=True)
        self.rarefactionfile=[\
                    '\tsequences per sample\titeration\t123\t234\t345',
                    'rare10.txt\t10\t0\t1.99181\t0.42877\t2.13996',
                    'rare10.txt\t10\t1\t2.07163\t0.42877\t2.37055',
                    'rare310.txt\t310\t0\t8.83115\t0.42877\t11.00725',
                    'rare310.txt\t310\t1\t10.05242\t0.42877\t8.24474',
                    'rare610.txt\t610\t0\t12.03067\t0.42877\t11.58928',
                    'rare610.txt\t610\t1\t12.9862\t0.42877\t11.58642']
                    
        self.rares = {'test.txt': (['', 'sequences per sample', 'iteration', \
                      'Sample1'], [], ['rare1.txt', 'rare2.txt'], \
                      [[10.0, 2.0, 7.0, 7.0, 9.0], [10.0, 2.0, 7.0, 7.0, 9.0]])}
        self.col_headers, self.comments, self.rarefaction_fns, \
        self.rarefaction_data = parse_rarefaction(self.rarefactionfile)
        self.matrix, self.seqs_per_samp, self.sampleIDs = \
        get_rarefaction_data(self.rarefaction_data, self.col_headers)
        self.ave_seqs_per_sample1 = {'Sample1':[2.03172,9.4417849999999994,\
        12.508435]}
        self.ave_seqs_per_sample = {'123':[2.03172,9.4417849999999994,\
        12.508435],'234':[0.42876999999999998,0.42876999999999998,\
        0.42876999999999998],'345':[2.255255,9.625995,11.58785]}
        self.collapsed_ser_sex = {'M':[1.3420125000000001,5.0273824999999999,\
        6.0083099999999998], 'F':[2.03172,9.4417849999999994,12.508435]}
        self.err_ser_sex = {'M':[0.91324250000000007,4.5986124999999998,\
        5.5795399999999997],'F':[0.0,0.0,0.0]}
        self.rarefaction_legend_mat_init={'test': {'SampleID': {}}}
        self.col_headers2=['', 'sequences per sample', 'iteration', 'Sample1', \
                           'Sample2']
                           
        self.rarefaction_data_mat={'SampleID': {'Sample1': {'test': {'ave': ['     7.000'], 'err': ['       nan']}}}}
       
        self.rarefaction_legend_mat={'test': {'samples': {'Sample1': {'color': '#ff0000', 'link': 'html_plots/testcol_0_row_0.png'}}, 'groups': {'SampleID': {'Sample1': {'groupcolor': '#ff0000', 'groupsamples': ['Sample1']}}}}}
        self.exp_err_series_ave={'M': [1.571915, 6.49885, 8.1750183333333339]}
    def setUp(self):
        """define some top-level data"""

        self.data = {}
        self.data["xaxis"] = [10.0]
        self.sample_dict = {"Sample1": {10.00: [1.3276140000000001]}}
        self.data["yvals"] = {"Sample1": [1.3276140000000001]}
        self.data["err"] = {"Sample1": [0.1]}
        self.xmax = 140
        self.ymax = 20
        self.std_type = "stddev"
        self.ops = ["Sample1"]
        self.mapping_category = "SampleID"
        self.imagetype = "png"
        self.resolution = 70
        self.mapping_lookup = {"SampleID-Sample1": "col_0_row_0"}
        self.data["map"] = [["SampleID", "Day"], ["Sample1", "Day1"]]
        self.color_prefs = {"SampleID": {"column": "SampleID", "color": {"Sample1": "#ff0000"}}}
        self.groups = {"Sample1": ["Sample1"]}
        self.background_color = "black"
        self.label_color = "white"
        self.labelname = "SampleID"
        self.rare_data = {
            "color": {"Sample1": "#ff0000"},
            "series": {"Sample1": [2.0515300000000001]},
            "headers": ["test.txt", "SampleID"],
            "xaxis": [10.0],
            "error": {"Sample1": [0.0]},
            "options": ["Sample1"],
        }
        self.fpath = "/tmp/"
        self.output_dir = "/tmp/"
        self.metric_name = "test"
        self._paths_to_clean_up = []
        self._folders_to_cleanup = []
        self.rarefaction_file_data = [[10.0, 0.0, 1.0], [10.0, 1.0, 3.0]]
        d = {"redtowhite3_0": "#7fff00", "redtowhite3_1": "#7fff00"}
        self.data_colors = color_dict_to_objects(d)
        self.colors = {"Sample1": "redtowhite3_0", "Sample2": "redtowhite3_1"}
        self.colors2 = {"Sample1": "redtowhite3_0"}
        self.mappingfile = ["#SampleID\tSex\tAge", "123\tF\t32", "234\tM\t30", "345\tM\t32"]
        # self.p_mappingfile = parse_mapping_file(self.mappingfile,\
        #                                            strip_quotes=True)
        self.rarefactionfile = [
            "\tsequences per sample\titeration\t123\t234\t345",
            "rare10.txt\t10\t0\t1.99181\t0.42877\t2.13996",
            "rare10.txt\t10\t1\t2.07163\t0.42877\t2.37055",
            "rare310.txt\t310\t0\t8.83115\t0.42877\t11.00725",
            "rare310.txt\t310\t1\t10.05242\t0.42877\t8.24474",
            "rare610.txt\t610\t0\t12.03067\t0.42877\t11.58928",
            "rare610.txt\t610\t1\t12.9862\t0.42877\t11.58642",
        ]

        self.rares = {
            "test.txt": (
                ["", "sequences per sample", "iteration", "Sample1"],
                [],
                ["rare1.txt", "rare2.txt"],
                [[10.0, 2.0, 7.0, 7.0, 9.0], [10.0, 2.0, 7.0, 7.0, 9.0]],
            )
        }
        self.col_headers, self.comments, self.rarefaction_fns, self.rarefaction_data = parse_rarefaction(
            self.rarefactionfile
        )
        self.matrix, self.seqs_per_samp, self.sampleIDs = get_rarefaction_data(self.rarefaction_data, self.col_headers)
        self.ave_seqs_per_sample1 = {"Sample1": [2.03172, 9.4417849999999994, 12.508435]}
        self.ave_seqs_per_sample = {
            "123": [2.03172, 9.4417849999999994, 12.508435],
            "234": [0.42876999999999998, 0.42876999999999998, 0.42876999999999998],
            "345": [2.255255, 9.625995, 11.58785],
        }
        self.collapsed_ser_sex = {
            "M": [1.3420125000000001, 5.0273824999999999, 6.0083099999999998],
            "F": [2.03172, 9.4417849999999994, 12.508435],
        }
        self.err_ser_sex = {"M": [0.91324250000000007, 4.5986124999999998, 5.5795399999999997], "F": [0.0, 0.0, 0.0]}
        self.rarefaction_legend_mat_init = {"test": {"SampleID": {}}}
        self.col_headers2 = ["", "sequences per sample", "iteration", "Sample1", "Sample2"]

        self.rarefaction_data_mat = {"SampleID": {"Sample1": {"test": {"ave": ["     7.000"], "err": ["       nan"]}}}}

        self.rarefaction_legend_mat = {
            "test": {
                "samples": {"Sample1": {"color": "#ff0000", "link": "html_plots/testcol_0_row_0.png"}},
                "groups": {"SampleID": {"Sample1": {"groupcolor": "#ff0000", "groupsamples": ["Sample1"]}}},
            }
        }
        self.exp_err_series_ave = {"M": [1.571915, 6.49885, 8.1750183333333339]}