當前位置: 首頁>>代碼示例>>Python>>正文


Python ProteinGrouper.maxProteinFraction方法代碼示例

本文整理匯總了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'))
開發者ID:bamueh,項目名稱:dark-matter,代碼行數:56,代碼來源:test_proteins.py


注:本文中的dark.proteins.ProteinGrouper.maxProteinFraction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。