本文整理汇总了Python中skbio.TabularMSA.sort方法的典型用法代码示例。如果您正苦于以下问题:Python TabularMSA.sort方法的具体用法?Python TabularMSA.sort怎么用?Python TabularMSA.sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skbio.TabularMSA
的用法示例。
在下文中一共展示了TabularMSA.sort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_sort_on_invalid_key
# 需要导入模块: from skbio import TabularMSA [as 别名]
# 或者: from skbio.TabularMSA import sort [as 别名]
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]))
示例2: test_sort_empty_with_msa_keys_on_metadata_key
# 需要导入模块: from skbio import TabularMSA [as 别名]
# 或者: from skbio.TabularMSA import sort [as 别名]
def test_sort_empty_with_msa_keys_on_metadata_key(self):
msa = TabularMSA([], keys=[])
msa.sort(key='id')
self.assertEqual(msa, TabularMSA([], keys=[]))
msa = TabularMSA([], keys=[])
msa.sort(key='id', reverse=True)
self.assertEqual(msa, TabularMSA([], keys=[]))
示例3: test_sort_single_sequence_no_msa_keys_on_metadata_key
# 需要导入模块: from skbio import TabularMSA [as 别名]
# 或者: from skbio.TabularMSA import sort [as 别名]
def test_sort_single_sequence_no_msa_keys_on_metadata_key(self):
msa = TabularMSA([RNA('UCA', metadata={'id': 42})])
msa.sort(key='id')
self.assertEqual(msa, TabularMSA([RNA('UCA', metadata={'id': 42})]))
msa = TabularMSA([RNA('UCA', metadata={'id': 42})])
msa.sort(key='id', reverse=True)
self.assertEqual(msa, TabularMSA([RNA('UCA', metadata={'id': 42})]))
示例4: test_sort_single_sequence_on_msa_keys
# 需要导入模块: from skbio import TabularMSA [as 别名]
# 或者: from skbio.TabularMSA import sort [as 别名]
def test_sort_single_sequence_on_msa_keys(self):
msa = TabularMSA([DNA('ACGT')], keys=[42])
msa.sort()
self.assertEqual(msa, TabularMSA([DNA('ACGT')], keys=[42]))
msa = TabularMSA([DNA('ACGT')], keys=[42])
msa.sort(reverse=True)
self.assertEqual(msa, TabularMSA([DNA('ACGT')], keys=[42]))
示例5: test_sort_empty_on_msa_keys
# 需要导入模块: from skbio import TabularMSA [as 别名]
# 或者: from skbio.TabularMSA import sort [as 别名]
def test_sort_empty_on_msa_keys(self):
msa = TabularMSA([], keys=[])
msa.sort()
self.assertEqual(msa, TabularMSA([], keys=[]))
msa = TabularMSA([], keys=[])
msa.sort(reverse=True)
self.assertEqual(msa, TabularMSA([], keys=[]))
示例6: test_sort_on_unorderable_msa_keys
# 需要导入模块: from skbio import TabularMSA [as 别名]
# 或者: from skbio.TabularMSA import sort [as 别名]
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]))
示例7: test_sort_empty_with_msa_keys_on_callable_key
# 需要导入模块: from skbio import TabularMSA [as 别名]
# 或者: from skbio.TabularMSA import sort [as 别名]
def test_sort_empty_with_msa_keys_on_callable_key(self):
msa = TabularMSA([], keys=[])
msa.sort(key=str)
self.assertEqual(msa, TabularMSA([], keys=[]))
msa = TabularMSA([], keys=[])
msa.sort(key=str, reverse=True)
self.assertEqual(msa, TabularMSA([], keys=[]))
示例8: test_sort_single_sequence_with_msa_keys_on_callable_key
# 需要导入模块: from skbio import TabularMSA [as 别名]
# 或者: from skbio.TabularMSA import sort [as 别名]
def test_sort_single_sequence_with_msa_keys_on_callable_key(self):
msa = TabularMSA([RNA('UCA')], keys=['foo'])
msa.sort(key=str)
self.assertEqual(msa, TabularMSA([RNA('UCA')], keys=['foo']))
msa = TabularMSA([RNA('UCA')], keys=['foo'])
msa.sort(key=str, reverse=True)
self.assertEqual(msa, TabularMSA([RNA('UCA')], keys=['foo']))
示例9: test_sort_no_msa_keys_and_key_not_specified
# 需要导入模块: from skbio import TabularMSA [as 别名]
# 或者: from skbio.TabularMSA import sort [as 别名]
def test_sort_no_msa_keys_and_key_not_specified(self):
msa = TabularMSA([])
with self.assertRaises(OperationError):
msa.sort()
# original state is maintained
self.assertEqual(msa, TabularMSA([]))
msa = TabularMSA([DNA('TC'), DNA('AA')])
with self.assertRaises(OperationError):
msa.sort()
self.assertEqual(msa, TabularMSA([DNA('TC'), DNA('AA')]))
示例10: test_sort_reverse_sorted
# 需要导入模块: from skbio import TabularMSA [as 别名]
# 或者: from skbio.TabularMSA import sort [as 别名]
def test_sort_reverse_sorted(self):
msa = TabularMSA([DNA('T'), DNA('G'), DNA('A')], keys=[3, 2, 1])
msa.sort()
self.assertEqual(
msa,
TabularMSA([DNA('A'), DNA('G'), DNA('T')], keys=[1, 2, 3]))
msa = TabularMSA([DNA('T'), DNA('G'), DNA('A')], keys=[1, 2, 3])
msa.sort(reverse=True)
self.assertEqual(
msa,
TabularMSA([DNA('A'), DNA('G'), DNA('T')], keys=[3, 2, 1]))
示例11: test_sort_on_key_with_all_repeats
# 需要导入模块: from skbio import TabularMSA [as 别名]
# 或者: from skbio.TabularMSA import sort [as 别名]
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)))
示例12: test_sort_multiple_sequences_no_msa_keys_on_callable_key
# 需要导入模块: from skbio import TabularMSA [as 别名]
# 或者: from skbio.TabularMSA import sort [as 别名]
def test_sort_multiple_sequences_no_msa_keys_on_callable_key(self):
msa = TabularMSA([RNA('UCC'),
RNA('UCG'),
RNA('UCA')])
msa.sort(key=str)
self.assertEqual(msa, TabularMSA([RNA('UCA'), RNA('UCC'), RNA('UCG')]))
msa = TabularMSA([RNA('UCC'),
RNA('UCG'),
RNA('UCA')])
msa.sort(key=str, reverse=True)
self.assertEqual(msa, TabularMSA([RNA('UCG'), RNA('UCC'), RNA('UCA')]))
示例13: test_sort_on_unorderable_key
# 需要导入模块: from skbio import TabularMSA [as 别名]
# 或者: from skbio.TabularMSA import sort [as 别名]
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]))
示例14: test_sort_multiple_sequences_with_msa_keys_on_callable_key
# 需要导入模块: from skbio import TabularMSA [as 别名]
# 或者: from skbio.TabularMSA import sort [as 别名]
def test_sort_multiple_sequences_with_msa_keys_on_callable_key(self):
msa = TabularMSA([RNA('UCC'),
RNA('UCG'),
RNA('UCA')], keys=[1, 'abc', None])
msa.sort(key=str)
self.assertEqual(msa, TabularMSA([RNA('UCA'), RNA('UCC'), RNA('UCG')],
keys=[None, 1, 'abc']))
msa = TabularMSA([RNA('UCC'),
RNA('UCG'),
RNA('UCA')], keys=[1, 'abc', None])
msa.sort(key=str, reverse=True)
self.assertEqual(msa, TabularMSA([RNA('UCG'), RNA('UCC'), RNA('UCA')],
keys=['abc', 1, None]))
示例15: test_sort_on_key_with_some_repeats
# 需要导入模块: from skbio import TabularMSA [as 别名]
# 或者: from skbio.TabularMSA import sort [as 别名]
def test_sort_on_key_with_some_repeats(self):
msa = TabularMSA([
DNA('TCCG', metadata={'id': 10}),
DNA('TAGG', metadata={'id': 10}),
DNA('GGGG', metadata={'id': 8}),
DNA('ACGT', metadata={'id': 0}),
DNA('TAGG', metadata={'id': 10})], keys=range(5))
msa.sort(key='id')
self.assertEqual(
msa,
TabularMSA([
DNA('ACGT', metadata={'id': 0}),
DNA('GGGG', metadata={'id': 8}),
DNA('TCCG', metadata={'id': 10}),
DNA('TAGG', metadata={'id': 10}),
DNA('TAGG', metadata={'id': 10})], keys=[3, 2, 0, 1, 4]))