Exemple #1
0
 def test_row_degeneracy(self):
     """row_degeneracy: should work with different cutoff values and arrays
     """
     a = array([[.1, .3, .4, .2],[.5, .3, 0, .2],[.8, 0, .1, .1]])
     self.assertEqual(row_degeneracy(a,cutoff=.75),[3,2,1])
     self.assertEqual(row_degeneracy(a,cutoff=.95),[4,3,3])
     #one-dimensional array
     self.assertRaises(ValueError, row_degeneracy,\
         array([.25,.25,.25,.25]))
     #if cutoff value is not found, results are clipped to the
     #number of columns in the array
     self.assertEqual(row_degeneracy(a,cutoff=2), [4,4,4])
     #same behavior on empty array
     self.assertEqual(row_degeneracy(array([[]])),[])
Exemple #2
0
    def rowDegeneracy(self, cutoff=0.5):
        """Returns how many chars are needed to cover the cutoff value.

        cutoff: value that should be covered in each row

        For example:
        pos 0: [.1,.2,.3,.4] char order=TCAG. 
        If cutoff=0.75 -> degeneracy = 3 (degenearate char for CAG)
        If cutoff=0.25 -> degeneracy = 1 (G alone covers this cutoff)
        If cutoff=0.5  -> degeneracy = 2 (degenerate char for AG)

        If the cutoff value is not reached in the row, the returned value
        will be clipped to the length of the character order (=the number
        of columns in the Profile).
        """
        try:
            return row_degeneracy(self.Data,cutoff)
        except ValueError:
            raise ProfileError,\
            "Profile has to be two dimensional to calculate rowDegeneracy"