def testAllStrainHetero(self):
        """Verify computation of strain heterogeneity score on highly similar sequences."""
        aai = AminoAcidIdentity()

        aaiScores = defaultdict(dict)
        aaiScores['b1'] = {'g1': [0.95], 'g2': [0.95], 'g3': [0.95]}

        aaiHetero, aaiMeanBinHetero = aai.strainHetero(aaiScores, 0.9)

        self.assertAlmostEqual(aaiHetero['b1']['g1'], 1.0)
        self.assertAlmostEqual(aaiHetero['b1']['g2'], 1.0)
        self.assertAlmostEqual(aaiHetero['b1']['g3'], 1.0)

        self.assertAlmostEqual(aaiMeanBinHetero['b1'], 100.0)
    def testMixedStrainHetero(self):
        """Verify computation of strain heterogeneity score on sequences with variable similarity."""
        aai = AminoAcidIdentity()

        aaiScores = defaultdict(dict)
        aaiScores['b1'] = {'g1': [0.95], 'g2': [0.1], 'g3': [0.1]}

        aaiHetero, aaiMeanBinHetero = aai.strainHetero(aaiScores, 0.9)

        self.assertAlmostEqual(aaiHetero['b1']['g1'], 1.0)
        self.assertAlmostEqual(aaiHetero['b1']['g2'], 0.0)
        self.assertAlmostEqual(aaiHetero['b1']['g3'], 0.0)

        self.assertAlmostEqual(aaiMeanBinHetero['b1'], 1.0 * 100 / 3.0)
    def testAllStrainHetero(self):
        """Verify computation of strain heterogeneity score on highly similar sequences."""
        aai = AminoAcidIdentity()

        aaiScores = defaultdict(dict)
        aaiScores['b1'] = {'g1': [0.95], 'g2': [0.95], 'g3': [0.95]}

        aaiHetero, aaiMeanBinHetero = aai.strainHetero(aaiScores, 0.9)

        self.assertAlmostEqual(aaiHetero['b1']['g1'], 1.0)
        self.assertAlmostEqual(aaiHetero['b1']['g2'], 1.0)
        self.assertAlmostEqual(aaiHetero['b1']['g3'], 1.0)

        self.assertAlmostEqual(aaiMeanBinHetero['b1'], 100.0)
    def testMultiCopyStrainHetero(self):
        """Verify computation of strain heterogeneity score when there are multiple copies of a sequence."""
        aai = AminoAcidIdentity()

        aaiScores = defaultdict(dict)
        aaiScores['b1'] = {'g1': [0.95, 0.95, 0.95], 'g2': [0.1, 0.1, 0.1], 'g3': [0.95, 0.1, 0.1]}

        aaiHetero, aaiMeanBinHetero = aai.strainHetero(aaiScores, 0.9)

        self.assertAlmostEqual(aaiHetero['b1']['g1'], 1.0)
        self.assertAlmostEqual(aaiHetero['b1']['g2'], 0.0)
        self.assertAlmostEqual(aaiHetero['b1']['g3'], 1.0 / 3.0)

        self.assertAlmostEqual(aaiMeanBinHetero['b1'], 4.0 * 100 / 9.0)
    def testMixedStrainHetero(self):
        """Verify computation of strain heterogeneity score on sequences with variable similarity."""
        aai = AminoAcidIdentity()

        aaiScores = defaultdict(dict)
        aaiScores['b1'] = {'g1': [0.95], 'g2': [0.1], 'g3': [0.1]}

        aaiHetero, aaiMeanBinHetero = aai.strainHetero(aaiScores, 0.9)

        self.assertAlmostEqual(aaiHetero['b1']['g1'], 1.0)
        self.assertAlmostEqual(aaiHetero['b1']['g2'], 0.0)
        self.assertAlmostEqual(aaiHetero['b1']['g3'], 0.0)

        self.assertAlmostEqual(aaiMeanBinHetero['b1'], 1.0 * 100 / 3.0)
    def testMultiCopyStrainHetero(self):
        """Verify computation of strain heterogeneity score when there are multiple copies of a sequence."""
        aai = AminoAcidIdentity()

        aaiScores = defaultdict(dict)
        aaiScores['b1'] = {
            'g1': [0.95, 0.95, 0.95],
            'g2': [0.1, 0.1, 0.1],
            'g3': [0.95, 0.1, 0.1]
        }

        aaiHetero, aaiMeanBinHetero = aai.strainHetero(aaiScores, 0.9)

        self.assertAlmostEqual(aaiHetero['b1']['g1'], 1.0)
        self.assertAlmostEqual(aaiHetero['b1']['g2'], 0.0)
        self.assertAlmostEqual(aaiHetero['b1']['g3'], 1.0 / 3.0)

        self.assertAlmostEqual(aaiMeanBinHetero['b1'], 4.0 * 100 / 9.0)