コード例 #1
0
    def test_get_fracs(self):
        """"get_fracs should Return fractions for matplotlib piechart"""

        fracs_labels_other,fracs_labels,all_counts, other_cat, red,other_frac \
                                        = get_fracs(self.counts1,5,10)
        
        self.assertEqual(fracs_labels_other,[("a;b;c",1.0/10),("a;g;h",4.0/10),
                                            ("d;e;f",3.0/10),("d;e;i",2.0/10)])
        self.assertEqual(fracs_labels,[])
        self.assertEqual(all_counts,
                [DATA_HTML % ("4",(4.0/10)*100,'a<br>g','h', 'h',"a;g;h"),
                DATA_HTML % ('3',(3.0/10)*100,'d<br>e','f', 'f',"d;e;f"),
                DATA_HTML % ('2',(2.0/10)*100,'d<br>e','i', 'i',"d;e;i"),
                DATA_HTML % ('1',(1.0/10)*100,'a<br>b','c', 'c',"a;b;c")])
        self.assertEqual(other_cat,0)
        self.assertEqual(red,10)
        self.assertEqual(other_frac,0)

        fracs_labels_other,fracs_labels,all_counts, other_cat, red,other_frac \
                                        = get_fracs(self.counts1,3,10)
        self.assertEqual(fracs_labels_other,[("a;g;h",4.0/10),("d;e;f",3.0/10)])
        self.assertEqual(fracs_labels,[("a;g;h",4.0/7),("d;e;f",3.0/7)])

        self.assertEqual(all_counts,
                [DATA_HTML % ("4",(4.0/10)*100,'a<br>g','h', 'h',"a;g;h"),
                DATA_HTML % ('3',(3.0/10)*100,'d<br>e','f', 'f',"d;e;f"),
                DATA_HTML % ('2',(2.0/10)*100,'d<br>e','i', 'i',"d;e;i"),
                DATA_HTML % ('1',(1.0/10)*100,'a<br>b','c', 'c',"a;b;c")])
        self.assertEqual(other_cat,2)
        self.assertEqual(red,7)
        self.assertEqual(other_frac,3.0/10)
コード例 #2
0
    def test_make_HTML_table(self):
        """make_HTML_table should Make HTML tables for one set of pie charts """
        try:
            mkdir("/tmp/qiimewebfiles/")
        except OSError:
            pass
        dir_path = "/tmp/qiimewebfiles/"
        
        try:
            mkdir("/tmp/qiimewebfiles/pie_charts")
        except OSError:
            pass

        fracs_labels_other,fracs_labels,all_counts, other_cat, red,other_frac \
                                        = get_fracs(self.counts1,5,10)

        img_data = make_HTML_table("Phylum",
                            other_frac,10,red,other_cat,fracs_labels_other,
                            fracs_labels,dir_path,all_counts,1,\
                            self.lines_parsed_2,self.color_prefs,'black','white')
        self.assertEqual(len(img_data),1)
        
        self._paths_to_clean_up = ["/tmp/qiimewebfiles/pie_charts/"+f \
                                   for f in listdir("/tmp/qiimewebfiles/pie_charts")]
        self._dirs_to_clean_up = ["/tmp/qiimewebfiles/pie_charts"]
コード例 #3
0
    def test_make_HTML_table(self):
        """make_HTML_table should Make HTML tables for one set of pie charts """
        try:
            mkdir("/tmp/qiimewebfiles/")
        except OSError:
            pass
        dir_path = "/tmp/qiimewebfiles/"

        try:
            mkdir("/tmp/qiimewebfiles/pie_charts")
        except OSError:
            pass

        fracs_labels_other,fracs_labels,all_counts, other_cat, red,other_frac \
                                        = get_fracs(self.counts1,5,10)

        img_data = make_HTML_table("Phylum",
                            other_frac,10,red,other_cat,fracs_labels_other,
                            fracs_labels,dir_path,all_counts,1,\
                            self.lines_parsed_2,self.color_prefs,'black','white')
        self.assertEqual(len(img_data), 1)

        self._paths_to_clean_up = ["/tmp/qiimewebfiles/pie_charts/"+f \
                                   for f in listdir("/tmp/qiimewebfiles/pie_charts")]
        self._dirs_to_clean_up = ["/tmp/qiimewebfiles/pie_charts"]
コード例 #4
0
    def test_get_fracs(self):
        """"get_fracs should Return fractions for matplotlib piechart"""

        fracs_labels_other,fracs_labels,all_counts, other_cat, red,other_frac \
                                        = get_fracs(self.counts1,5,10)

        self.assertEqual(fracs_labels_other, [("a;b;c", 1.0 / 10),
                                              ("a;g;h", 4.0 / 10),
                                              ("d;e;f", 3.0 / 10),
                                              ("d;e;i", 2.0 / 10)])
        self.assertEqual(fracs_labels, [])
        self.assertEqual(all_counts, [
            DATA_HTML %
            ("4", (4.0 / 10) * 100, 'a<br>g', 'h', 'h', "a;g;h"), DATA_HTML %
            ('3', (3.0 / 10) * 100, 'd<br>e', 'f', 'f', "d;e;f"), DATA_HTML %
            ('2', (2.0 / 10) * 100, 'd<br>e', 'i', 'i', "d;e;i"), DATA_HTML %
            ('1', (1.0 / 10) * 100, 'a<br>b', 'c', 'c', "a;b;c")
        ])
        self.assertEqual(other_cat, 0)
        self.assertEqual(red, 10)
        self.assertEqual(other_frac, 0)

        fracs_labels_other,fracs_labels,all_counts, other_cat, red,other_frac \
                                        = get_fracs(self.counts1,3,10)
        self.assertEqual(fracs_labels_other, [("a;g;h", 4.0 / 10),
                                              ("d;e;f", 3.0 / 10)])
        self.assertEqual(fracs_labels, [("a;g;h", 4.0 / 7),
                                        ("d;e;f", 3.0 / 7)])

        self.assertEqual(all_counts, [
            DATA_HTML %
            ("4", (4.0 / 10) * 100, 'a<br>g', 'h', 'h', "a;g;h"), DATA_HTML %
            ('3', (3.0 / 10) * 100, 'd<br>e', 'f', 'f', "d;e;f"), DATA_HTML %
            ('2', (2.0 / 10) * 100, 'd<br>e', 'i', 'i', "d;e;i"), DATA_HTML %
            ('1', (1.0 / 10) * 100, 'a<br>b', 'c', 'c', "a;b;c")
        ])
        self.assertEqual(other_cat, 2)
        self.assertEqual(red, 7)
        self.assertEqual(other_frac, 3.0 / 10)