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


Python skbio.TabularMSA類代碼示例

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


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

示例1: test_sort_on_invalid_key

 def test_sort_on_invalid_key(self):
     msa = TabularMSA([DNA('AAA'), DNA('ACG')], keys=[42, 43])
     with self.assertRaises(KeyError):
         msa.sort(key='id')
     self.assertEqual(
         msa,
         TabularMSA([DNA('AAA'), DNA('ACG')], keys=[42, 43]))
開發者ID:hainm,項目名稱:scikit-bio,代碼行數:7,代碼來源:test_tabular_msa.py

示例2: test_keys_setter_non_empty

 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,代碼行數:7,代碼來源:test_tabular_msa.py

示例3: test_sort_on_unorderable_msa_keys

 def test_sort_on_unorderable_msa_keys(self):
     unorderable = Unorderable()
     msa = TabularMSA([DNA('AAA'), DNA('ACG')], keys=[42, unorderable])
     with self.assertRaises(TypeError):
         msa.sort()
     self.assertEqual(
         msa,
         TabularMSA([DNA('AAA'), DNA('ACG')], keys=[42, unorderable]))
開發者ID:hainm,項目名稱:scikit-bio,代碼行數:8,代碼來源:test_tabular_msa.py

示例4: test_metadata_setter_invalid_type

    def test_metadata_setter_invalid_type(self):
        msa = TabularMSA([Protein('PAW')], metadata={123: 456})

        for md in (None, 0, 'a', ('f', 'o', 'o'), np.array([]),
                   pd.DataFrame()):
            with six.assertRaisesRegex(self, TypeError,
                                       'metadata must be a dict'):
                msa.metadata = md
            self.assertEqual(msa.metadata, {123: 456})
開發者ID:hainm,項目名稱:scikit-bio,代碼行數:9,代碼來源:test_tabular_msa.py

示例5: test_keys_setter_non_hashable_keys

    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,代碼行數:10,代碼來源:test_tabular_msa.py

示例6: test_keys_setter_non_unique_keys

    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,代碼行數:10,代碼來源:test_tabular_msa.py

示例7: test_from_dict_to_dict_roundtrip

    def test_from_dict_to_dict_roundtrip(self):
        d = {}
        self.assertEqual(TabularMSA.from_dict(d).to_dict(), d)

        # can roundtrip even with mixed key types
        d1 = {'a': DNA('CAT'), 42: DNA('TAG')}
        d2 = TabularMSA.from_dict(d1).to_dict()
        self.assertEqual(d2, d1)
        self.assertIs(d1['a'], d2['a'])
        self.assertIs(d1[42], d2[42])
開發者ID:hainm,項目名稱:scikit-bio,代碼行數:10,代碼來源:test_tabular_msa.py

示例8: test_reindex_makes_copy_of_keys

    def test_reindex_makes_copy_of_keys(self):
        msa = TabularMSA([DNA('AC'), DNA('AG'), DNA('AT')])
        keys = np.asarray([1, 2, 3])
        msa.reindex(keys=keys)
        npt.assert_array_equal(msa.keys, np.array([1, 2, 3]))

        self.assertFalse(msa.keys.flags.writeable)
        self.assertTrue(keys.flags.writeable)
        keys[1] = 42
        npt.assert_array_equal(msa.keys, np.array([1, 2, 3]))
開發者ID:hainm,項目名稱:scikit-bio,代碼行數:10,代碼來源:test_tabular_msa.py

示例9: test_reindex_key_and_keys_both_provided

    def test_reindex_key_and_keys_both_provided(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, 'both.*key.*keys'):
            msa.reindex(key=str, keys=['a', 'b'])

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

示例10: test_has_metadata

    def test_has_metadata(self):
        msa = TabularMSA([])
        self.assertFalse(msa.has_metadata())
        # Handles metadata efficiently.
        self.assertIsNone(msa._metadata)

        self.assertFalse(TabularMSA([], metadata={}).has_metadata())

        self.assertTrue(TabularMSA([], metadata={'': ''}).has_metadata())
        self.assertTrue(TabularMSA([], metadata={'foo': 42}).has_metadata())
開發者ID:hainm,項目名稱:scikit-bio,代碼行數:10,代碼來源:test_tabular_msa.py

示例11: test_reindex_keys_length_mismatch

    def test_reindex_keys_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: 0 != 2'):
            msa.reindex(keys=iter([]))

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

示例12: test_sort_on_unorderable_key

 def test_sort_on_unorderable_key(self):
     unorderable = Unorderable()
     msa = TabularMSA([
         DNA('AAA', metadata={'id': 42}),
         DNA('ACG', metadata={'id': unorderable})], keys=[42, 43])
     with self.assertRaises(TypeError):
         msa.sort(key='id')
     self.assertEqual(
         msa,
         TabularMSA([
             DNA('AAA', metadata={'id': 42}),
             DNA('ACG', metadata={'id': unorderable})], keys=[42, 43]))
開發者ID:hainm,項目名稱:scikit-bio,代碼行數:12,代碼來源:test_tabular_msa.py

示例13: test_sort_on_key_with_all_repeats

 def test_sort_on_key_with_all_repeats(self):
     msa = TabularMSA([
         DNA('TTT', metadata={'id': 'a'}),
         DNA('TTT', metadata={'id': 'b'}),
         DNA('TTT', metadata={'id': 'c'})], keys=range(3))
     msa.sort(key=str)
     self.assertEqual(
         msa,
         TabularMSA([
             DNA('TTT', metadata={'id': 'a'}),
             DNA('TTT', metadata={'id': 'b'}),
             DNA('TTT', metadata={'id': 'c'})], keys=range(3)))
開發者ID:hainm,項目名稱:scikit-bio,代碼行數:12,代碼來源:test_tabular_msa.py

示例14: filter_positions

def filter_positions(alignment_fh, maximum_gap_frequency,
                     maximum_position_entropy):
    """Filter gaps and high entropy positions from an alignment."""

    with alignment_fh:
        try:
            aln = TabularMSA.read(alignment_fh, constructor=DNA)
        except ValueError:
            alignment_fh.seek(0)
            aln = TabularMSA.read(alignment_fh, constructor=RNA)
    aln = _filter_gap_positions(aln, maximum_gap_frequency)
    aln = _filter_high_entropy_positions(aln, maximum_position_entropy)
    return aln
開發者ID:JTFouquier,項目名稱:ghost-tree,代碼行數:13,代碼來源:filter.py

示例15: test_metadata_getter

    def test_metadata_getter(self):
        msa = TabularMSA([])
        self.assertIsNone(msa._metadata)
        self.assertEqual(msa.metadata, {})
        self.assertIsNotNone(msa._metadata)
        self.assertIsInstance(msa.metadata, dict)

        msa = TabularMSA([], metadata={42: 'foo', ('hello', 'world'): 43})
        self.assertEqual(msa.metadata, {42: 'foo', ('hello', 'world'): 43})
        self.assertIsInstance(msa.metadata, dict)

        msa.metadata[42] = 'bar'
        self.assertEqual(msa.metadata, {42: 'bar', ('hello', 'world'): 43})
開發者ID:hainm,項目名稱:scikit-bio,代碼行數:13,代碼來源:test_tabular_msa.py


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