def test_mean_otu_pct_abundance(self):
        """
        Testing mean_otu_pct_abundance() function of biom_calc.py.

        :return: Returns OK, if testing goal was achieved, otherwise raises
                error.
        """
        self.rel_a = bc.relative_abundance(self.biom)

        self.result = bc.mean_otu_pct_abundance(
            self.rel_a, ['GG_OTU_1','GG_OTU_2']
            )

        # Obtaining lists of function calculations and manual hand calculations
        func_calc = self.result.values()
        result1 = self.rel_a.values()       # result1 is a list

        # list containing hand calculated relative abundance values
        hand_calc = [0.25/6, (1.0+0.3333333333333333+0.25+0.7142857142857143+0.3333333333333333)/6]

        # Testing the validity of the calculations of mean_otu_pct_abundance().
        for hand, res in zip(hand_calc, func_calc):
            self.assertAlmostEqual(
                hand*100, res,
                msg='Mean OTU not calculated accurately.'
                )
    def test_MRA(self):
        """
        Testing mean relative abundance calculation, MRA() function
        of biom_calc.py.

        :return: Returns OK, if testing goal was achieved, otherwise
            raises error.
        """
        self.result = bc.MRA(self.biom)
        self.mean_otu = bc.mean_otu_pct_abundance(
            bc.relative_abundance(self.biom),
            ['GG_OTU_1', 'GG_OTU_2', 'GG_OTU_3', 'GG_OTU_4', 'GG_OTU_5']
            )

        # Obtaining lists of function calculations and
        # manual hand calculations
        func_calc = self.result.values()
        hand_calc = self.mean_otu.values()

        # Testing the validity of the calculations of mean_otu_pct_abundance().
        for hand, res in zip(hand_calc, func_calc):
            self.assertAlmostEqual(
                hand, res,
                msg='Mean OTU not calculated accurately.'
                )
Example #3
0
    def test_mean_otu_pct_abundance(self):
        """
        Testing mean_otu_pct_abundance() function of biom_calc.py.

        :return: Returns OK, if testing goal was achieved, otherwise raises
                error.
        """
        self.rel_a = bc.relative_abundance(self.biomf)

        self.result = bc.mean_otu_pct_abundance(
            self.rel_a, ["GG_OTU_1", "GG_OTU_2"]
            )

        # Obtaining lists of function calculations and manual hand calculations
        func_calc = self.result.values()

        # list containing hand calculated relative abundance values
        hand_calc = [(0 + 0.0153846153846 + 0.0285714285714 + 0.04 + 0.05 +
                      0.0588235294118)/6,
                     (0.1 + 0.107692307692 + 0.114285714286 + 0.12 + 0.125 +
                      0.129411764706)/6]

        # Testing the validity of the calculations of mean_otu_pct_abundance().
        for hand, res in zip(hand_calc, func_calc):
            self.assertAlmostEqual(
                hand*100, res,
                msg="Mean OTU not calculated accurately."
                )
Example #4
0
    def test_mean_otu_pct_abundance(self):
        """
        Testing mean_otu_pct_abundance() function of biom_calc.py.

        :return: Returns OK, if testing goal was achieved, otherwise raises error.
        """
        self.rel_a = bc.relative_abundance(self.biomf)
        self.result = bc.mean_otu_pct_abundance(self.rel_a, ["GG_OTU_1", "GG_OTU_2"])

        # list containing hand calculated relative abundance values
        hand_calc = {"GG_OTU_1": 14.52348298, "GG_OTU_2": 15.73217761,
                     "GG_OTU_3": 26.58131438, "GG_OTU_4": 22.91732137,
                     "GG_OTU_5": 20.24570366}

        # Testing the validity of the calculations of mean_otu_pct_abundance().
        for oid in ["GG_OTU_1", "GG_OTU_2"]:
            self.assertAlmostEqual(
                hand_calc[oid], self.result[oid],
                msg="Mean OTU percent abundance not calculated accurately."
            )