本文整理匯總了Python中cogent.core.profile.Profile.columnDegeneracy方法的典型用法代碼示例。如果您正苦於以下問題:Python Profile.columnDegeneracy方法的具體用法?Python Profile.columnDegeneracy怎麽用?Python Profile.columnDegeneracy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cogent.core.profile.Profile
的用法示例。
在下文中一共展示了Profile.columnDegeneracy方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: ProfileTests
# 需要導入模塊: from cogent.core.profile import Profile [as 別名]
# 或者: from cogent.core.profile.Profile import columnDegeneracy [as 別名]
#.........這裏部分代碼省略.........
def test_columnUncertainty(self):
"""columnUncertainty: should handle full and empty profiles
"""
p = Profile(array([[0.25, 0.5], [0.25, 0.5], [0.25, 0], [0.25, 0]]), "AB")
self.assertEqual(p.columnUncertainty(), [2, 1])
# for empty cols nothing is returned as the uncertainty
self.assertEqual(self.empty.columnUncertainty().tolist(), [])
p = Profile(array([[], [], []]), "")
self.assertEqual(p.columnUncertainty().tolist(), [])
# doesn't work on 1D array
self.assertRaises(ProfileError, self.oned.columnUncertainty)
def test_rowDegeneracy(self):
"""rowDegneracy: should work as expected"""
p1 = self.consensus
p2 = self.not_same_value
self.assertEqual(p1.rowDegeneracy(), [1, 1, 1, 2, 1])
self.assertEqual(p1.rowDegeneracy(cutoff=0.5), [1, 1, 1, 2, 1])
self.assertEqual(p1.rowDegeneracy(cutoff=0.75), [1, 2, 1, 3, 2])
# when a row seems to add up to the cutoff value, it's not
# always found because of floating point error. E.g. second row
# in this example
self.assertEqual(p1.rowDegeneracy(cutoff=1), [2, 4, 1, 4, 2])
# when the cutoff can't be found, the number of columns in the
# profile is returned (for each row)
self.assertEqual(p1.rowDegeneracy(cutoff=1.5), [4, 4, 4, 4, 4])
self.assertEqual(p2.rowDegeneracy(cutoff=0.95), [4, 2, 4, 1])
self.assertEqual(p2.rowDegeneracy(cutoff=1.4), [4, 3, 4, 1])
self.assertEqual(self.empty.rowDegeneracy(), [])
def test_columnDegeneracy(self):
"""columnDegeneracy: shoudl work as expected"""
p1 = self.consensus
p1.Data = transpose(p1.Data)
p2 = self.not_same_value
p2.Data = transpose(p2.Data)
p1d = p1.columnDegeneracy()
self.assertEqual(p1d, [1, 1, 1, 2, 1])
self.assertEqual(p1.columnDegeneracy(cutoff=0.5), [1, 1, 1, 2, 1])
self.assertEqual(p1.columnDegeneracy(cutoff=0.75), [1, 2, 1, 3, 2])
# when a row seems to add up to the cutoff value, it's not
# always found because of floating point error. E.g. second row
# in this example
self.assertEqual(p1.columnDegeneracy(cutoff=1), [2, 4, 1, 4, 2])
# when the cutoff can't be found, the number of rows in the
# profile is returned (for each column)
self.assertEqual(p1.columnDegeneracy(cutoff=1.5), [4, 4, 4, 4, 4])
self.assertEqual(p2.columnDegeneracy(cutoff=0.95), [4, 2, 4, 1])
self.assertEqual(p2.columnDegeneracy(cutoff=1.4), [4, 3, 4, 1])
self.assertEqual(self.empty.columnDegeneracy(), [])
def test_rowMax(self):
"""rowMax should return max value in each row"""
p1 = self.consensus
obs = p1.rowMax()
self.assertEqual(obs, array([0.8, 0.7, 1, 0.4, 0.5]))
def test_toConsensus(self):
"""toConsensus: should work with all the different options
"""
p = self.consensus