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


Python TabularMSA.keys方法代碼示例

本文整理匯總了Python中skbio.TabularMSA.keys方法的典型用法代碼示例。如果您正苦於以下問題:Python TabularMSA.keys方法的具體用法?Python TabularMSA.keys怎麽用?Python TabularMSA.keys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在skbio.TabularMSA的用法示例。


在下文中一共展示了TabularMSA.keys方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_keys_setter_non_empty

# 需要導入模塊: from skbio import TabularMSA [as 別名]
# 或者: from skbio.TabularMSA import keys [as 別名]
 def test_keys_setter_non_empty(self):
     msa = TabularMSA([DNA('AC'), DNA('AG'), DNA('AT')])
     self.assertFalse(msa.has_keys())
     msa.keys = range(3)
     npt.assert_array_equal(msa.keys, np.array([0, 1, 2]))
     msa.keys = range(3, 6)
     npt.assert_array_equal(msa.keys, np.array([3, 4, 5]))
開發者ID:hainm,項目名稱:scikit-bio,代碼行數:9,代碼來源:test_tabular_msa.py

示例2: test_keys_setter_non_hashable_keys

# 需要導入模塊: from skbio import TabularMSA [as 別名]
# 或者: from skbio.TabularMSA import keys [as 別名]
    def test_keys_setter_non_hashable_keys(self):
        msa = TabularMSA([DNA('ACGT'), DNA('TGCA')], key=str)
        keys = np.array(['ACGT', 'TGCA'])
        npt.assert_array_equal(msa.keys, keys)

        with self.assertRaises(TypeError):
            msa.keys = [[42], [42]]

        # original state is maintained
        npt.assert_array_equal(msa.keys, keys)
開發者ID:hainm,項目名稱:scikit-bio,代碼行數:12,代碼來源:test_tabular_msa.py

示例3: test_keys_setter_non_unique_keys

# 需要導入模塊: from skbio import TabularMSA [as 別名]
# 或者: from skbio.TabularMSA import keys [as 別名]
    def test_keys_setter_non_unique_keys(self):
        msa = TabularMSA([DNA('ACGT'), DNA('TGCA')], key=str)
        keys = np.array(['ACGT', 'TGCA'])
        npt.assert_array_equal(msa.keys, keys)

        with six.assertRaisesRegex(self, UniqueError, 'Duplicate keys:.*42'):
            msa.keys = [42, 42]

        # original state is maintained
        npt.assert_array_equal(msa.keys, keys)
開發者ID:hainm,項目名稱:scikit-bio,代碼行數:12,代碼來源:test_tabular_msa.py

示例4: test_keys_setter_length_mismatch

# 需要導入模塊: from skbio import TabularMSA [as 別名]
# 或者: from skbio.TabularMSA import keys [as 別名]
    def test_keys_setter_length_mismatch(self):
        msa = TabularMSA([DNA('ACGT'), DNA('TGCA')], key=str)
        keys = np.array(['ACGT', 'TGCA'])
        npt.assert_array_equal(msa.keys, keys)

        with six.assertRaisesRegex(self, ValueError,
                                   'Number.*keys.*number.*sequences: 3 != 2'):
            msa.keys = iter(['ab', 'cd', 'ef'])

        # original state is maintained
        npt.assert_array_equal(msa.keys, keys)
開發者ID:hainm,項目名稱:scikit-bio,代碼行數:13,代碼來源:test_tabular_msa.py

示例5: test_keys_update_subset_of_keys

# 需要導入模塊: from skbio import TabularMSA [as 別名]
# 或者: from skbio.TabularMSA import keys [as 別名]
    def test_keys_update_subset_of_keys(self):
        # keys can be copied, modified, then re-set
        msa = TabularMSA([DNA('AC'), DNA('AG'), DNA('AT')], key=str)
        npt.assert_array_equal(msa.keys, np.array(['AC', 'AG', 'AT']))

        new_keys = msa.keys.copy()
        new_keys[1] = 42
        msa.keys = new_keys
        npt.assert_array_equal(msa.keys,
                               np.array(['AC', 42, 'AT'], dtype=object))

        self.assertFalse(msa.keys.flags.writeable)
        self.assertTrue(new_keys.flags.writeable)
        new_keys[1] = 'GG'
        npt.assert_array_equal(msa.keys,
                               np.array(['AC', 42, 'AT'], dtype=object))
開發者ID:hainm,項目名稱:scikit-bio,代碼行數:18,代碼來源:test_tabular_msa.py

示例6: test_keys_setter_empty

# 需要導入模塊: from skbio import TabularMSA [as 別名]
# 或者: from skbio.TabularMSA import keys [as 別名]
 def test_keys_setter_empty(self):
     msa = TabularMSA([])
     self.assertFalse(msa.has_keys())
     msa.keys = iter([])
     npt.assert_array_equal(msa.keys, np.array([]))
開發者ID:hainm,項目名稱:scikit-bio,代碼行數:7,代碼來源:test_tabular_msa.py


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