本文整理匯總了Python中dark.proteins.ProteinGrouper.maxProteinFraction方法的典型用法代碼示例。如果您正苦於以下問題:Python ProteinGrouper.maxProteinFraction方法的具體用法?Python ProteinGrouper.maxProteinFraction怎麽用?Python ProteinGrouper.maxProteinFraction使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類dark.proteins.ProteinGrouper
的用法示例。
在下文中一共展示了ProteinGrouper.maxProteinFraction方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testMaxProteinFraction
# 需要導入模塊: from dark.proteins import ProteinGrouper [as 別名]
# 或者: from dark.proteins.ProteinGrouper import maxProteinFraction [as 別名]
def testMaxProteinFraction(self):
"""
The maxProteinFraction method must return the correct values.
"""
class SideEffect(object):
def __init__(self, test):
self.test = test
self.count = 0
def sideEffect(self, filename, **kwargs):
if self.count == 0:
self.test.assertEqual('proteins.fasta', filename)
self.count += 1
return File(['>protein 1 [pathogen 1]\n',
'ACTG\n',
'>protein 2 [pathogen 1]\n',
'AA\n',
'>protein 3 [pathogen 1]\n',
'AA\n',
'>protein 4 [pathogen 1]\n',
'AA\n',
'>no pathogen name here\n',
'AA\n',
'>protein 5 [pathogen 2]\n',
'AA\n'])
else:
self.test.fail('We are only supposed to be called once!')
sideEffect = SideEffect(self)
with patch.object(builtins, 'open') as mockMethod:
mockMethod.side_effect = sideEffect.sideEffect
pg = ProteinGrouper(proteinFastaFilenames=['proteins.fasta'])
self.assertEqual(1, sideEffect.count)
fp = StringIO(
'0.77 46.6 48.1 5 6 74 gi|32|X|I4 protein 1 [pathogen 1]\n'
'0.77 46.6 48.1 5 6 74 gi|32|X|I4 protein 5 [pathogen 2]\n'
)
pg.addFile('sample-1', fp)
fp = StringIO(
'0.77 46.6 48.1 5 6 74 gi|32|X|I4 protein 2 [pathogen 1]\n'
'0.77 46.6 48.1 5 6 74 gi|32|X|I4 protein 3 [pathogen 1]\n'
)
pg.addFile('sample-1', fp)
fp = StringIO(
'0.77 46.6 48.1 5 6 74 gi|32|X|I4 protein 1 [pathogen 1]\n'
'0.77 46.6 48.1 5 6 74 gi|32|X|I4 protein 2 [pathogen 1]\n'
)
pg.addFile('sample-2', fp)
self.assertEqual(0.75, pg.maxProteinFraction('pathogen 1'))
self.assertEqual(1.0, pg.maxProteinFraction('pathogen 2'))