def test_bases(self): """AminoAcidUsage bases should return most likely base freqs""" a = AminoAcidUsage('GGG') self.assertEqual(a.bases(), {'G':9.0/12,'U':1.0/12,'C':1.0/12,'A':1.0/12}) a = AminoAcidUsage('CAGTWERQWE') exp = a.codons().bases() exp.normalize() self.assertFloatEqual(a.bases(), exp)
def test_codons(self): """AminoAcidUsage codons should return most likely codon freqs""" a = AminoAcidUsage('GGG') c = CodonUsage('GGUGGCGGAGGG') c.normalize() self.assertEqual(a.codons(), c) a = AminoAcidUsage('D') c = CodonUsage('GAUGAC') c.normalize() self.assertEqual(a.codons(), c) a = AminoAcidUsage('GDDFMM') c = CodonUsage('GGUGGCGGAGGG'+'GAUGAC'*4+'UUUUUC'*2+'AUG'*8) c.normalize() self.assertEqual(a.codons(), c) a = AminoAcidUsage('II*') c = CodonUsage('AUUAUCAUA'*2+'UAAUAGUGA') c.normalize() self.assertEqual(a.codons(), c) #check that it works with a nonstandard code code = GeneticCode('A'*4+'C'*28+'G'*32) a = AminoAcidUsage('AAA') c = CodonUsage('UUUUUCUUAUUG') c.normalize() self.assertEqual(a.codons(code), c) #check that it works with unequal codon frequencies unequal = CodonUsage({'GGU':5,'GGC':2,'GGA':2,'GGG':1,'UUU':3,'UUC':1}) a = AminoAcidUsage('GFFF') exp = { 'GGU':0.5*0.25, 'GGC':0.2*0.25, 'GGA':0.2*0.25, 'GGG':0.1*0.25, 'UUU':0.75*0.75, 'UUC':0.25*0.75 } obs = a.codons(codon_usage=unequal) for codon, freq in obs.items(): self.assertFloatEqual(freq, exp.get(codon, 0))
def test_positionalBases(self): """AminoAcidUsage positionalBases should return best positional bases""" a = AminoAcidUsage('WQRSFADDQW') exp = a.codons().positionalBases() obs = a.positionalBases() self.assertFloatEqual(obs, exp)