Beispiel #1
0
 def test_pr2bias(self):
     """CodonUsage pr2bias should give correct ratios."""
     c = EqualBases.codons()
     b = c.pr2bias('UU')
     self.assertEqual(len(b), 6)
     self.assertEqual(b, tuple([.5]*6))
     c = CodonUsage()
     c['ACU'] = 10
     c['ACC'] = 5
     c['ACA'] = 15
     c['ACG'] = 20
     self.assertEqual(c.pr2bias('AC'), (20/25,15/25,20/35,5/15,20/30,5/20))
Beispiel #2
0
 def test_pr2bias(self):
     """CodonUsage pr2bias should give correct ratios."""
     c = EqualBases.codons()
     b = c.pr2bias('UU')
     self.assertEqual(len(b), 6)
     self.assertEqual(b, tuple([.5] * 6))
     c = CodonUsage()
     c['ACU'] = 10
     c['ACC'] = 5
     c['ACA'] = 15
     c['ACG'] = 20
     self.assertEqual(c.pr2bias('AC'),
                      (20 / 25, 15 / 25, 20 / 35, 5 / 15, 20 / 30, 5 / 20))
Beispiel #3
0
 def test_fingerprint(self):
     """CodonUsage fingerprint should give correct ratios."""
     c = EqualBases.codons()
     f = c.fingerprint()
     self.assertEqual(len(f), 9)
     self.assertEqual(f, \
         [[.5,.5,.125] for i in range(8)] + [[.5,.5,1]])
     #should be able to omit mean...
     f = c.fingerprint(include_mean=False)
     self.assertEqual(f, [[.5,.5,.125] for i in range(8)])
     #...or use all doublets
     f = c.fingerprint(include_mean=False, which_blocks='all')
     self.assertEqual(len(f), 16)
     #...or do just the non-quartet ones
     f = c.fingerprint(include_mean=False, which_blocks='split')
     self.assertEqual(len(f), 6)
     #check that it doesn't fail on an empty codon usage
     c = CodonUsage('')
     f = c.fingerprint()
     self.assertEqual(f[0], [0.5, 0.5, 0])
Beispiel #4
0
 def test_fingerprint(self):
     """CodonUsage fingerprint should give correct ratios."""
     c = EqualBases.codons()
     f = c.fingerprint()
     self.assertEqual(len(f), 9)
     self.assertEqual(f, \
         [[.5,.5,.125] for i in range(8)] + [[.5,.5,1]])
     #should be able to omit mean...
     f = c.fingerprint(include_mean=False)
     self.assertEqual(f, [[.5, .5, .125] for i in range(8)])
     #...or use all doublets
     f = c.fingerprint(include_mean=False, which_blocks='all')
     self.assertEqual(len(f), 16)
     #...or do just the non-quartet ones
     f = c.fingerprint(include_mean=False, which_blocks='split')
     self.assertEqual(len(f), 6)
     #check that it doesn't fail on an empty codon usage
     c = CodonUsage('')
     f = c.fingerprint()
     self.assertEqual(f[0], [0.5, 0.5, 0])
Beispiel #5
0
 def test_positionalGC(self):
     """CodonUsage positionalGC should give correct GC contents."""
     c = EqualBases.codons()
     self.assertEqual(c.positionalGC(False), [0.5,0.5,0.5,0.5])
     c = EqualBases.codons()
     self.assertNotEqual(c.positionalGC(True), [0.5,0.5,0.5,0.5])
Beispiel #6
0
 def test_positionalGC(self):
     """CodonUsage positionalGC should give correct GC contents."""
     c = EqualBases.codons()
     self.assertEqual(c.positionalGC(False), [0.5, 0.5, 0.5, 0.5])
     c = EqualBases.codons()
     self.assertNotEqual(c.positionalGC(True), [0.5, 0.5, 0.5, 0.5])