本文整理汇总了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'))