本文整理汇总了Python中skbio.metadata.IntervalMetadata._reverse方法的典型用法代码示例。如果您正苦于以下问题:Python IntervalMetadata._reverse方法的具体用法?Python IntervalMetadata._reverse怎么用?Python IntervalMetadata._reverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skbio.metadata.IntervalMetadata
的用法示例。
在下文中一共展示了IntervalMetadata._reverse方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_upper_bound_is_none
# 需要导入模块: from skbio.metadata import IntervalMetadata [as 别名]
# 或者: from skbio.metadata.IntervalMetadata import _reverse [as 别名]
def test_upper_bound_is_none(self):
im = IntervalMetadata(None)
# should not raise error
im.add([(0, 1000000000)])
self.assertIsNone(im.upper_bound)
with self.assertRaisesRegex(
TypeError, r'upper bound is `None`'):
im._reverse()
with self.assertRaisesRegex(
TypeError, r'upper bound is `None`'):
IntervalMetadata.concat([self.im_1, im])
示例2: TestIntervalMetadata
# 需要导入模块: from skbio.metadata import IntervalMetadata [as 别名]
# 或者: from skbio.metadata.IntervalMetadata import _reverse [as 别名]
class TestIntervalMetadata(unittest.TestCase, ReallyEqualMixin):
def setUp(self):
self.upper_bound = 10
self.im_empty = IntervalMetadata(self.upper_bound)
self.im_1 = IntervalMetadata(self.upper_bound)
self.im_1_1 = Interval(
interval_metadata=self.im_1,
bounds=[(1, 2), (4, self.upper_bound)],
metadata={'gene': 'sagA', 'bound': 0})
self.im_2 = IntervalMetadata(self.upper_bound)
self.im_2_1 = Interval(
interval_metadata=self.im_2,
bounds=[(1, 2), (4, self.upper_bound)],
metadata={'gene': 'sagA', 'bound': 0})
self.im_2_2 = Interval(
interval_metadata=self.im_2,
bounds=[(3, 5)],
metadata={'gene': 'sagB', 'bound': 0, 'spam': [0]})
def test_copy_empty(self):
obs = copy(self.im_empty)
self.assertEqual(obs, self.im_empty)
self.assertIsNot(obs._intervals, self.im_empty._intervals)
self.assertIsNot(obs._interval_tree, self.im_empty._interval_tree)
def test_copy(self):
obs = copy(self.im_2)
self.assertEqual(obs, self.im_2)
self.assertIsNot(obs._intervals, self.im_2._intervals)
self.assertIsNot(obs._interval_tree, self.im_2._interval_tree)
for i in range(self.im_2.num_interval_features):
i1, i2 = obs._intervals[i], self.im_2._intervals[i]
self.assertIsNot(i1, i2)
self.assertIsNot(i1.bounds, i2.bounds)
self.assertIsNot(i1.fuzzy, i2.fuzzy)
self.assertIsNot(i1._interval_metadata, i2._interval_metadata)
self.assertIsNot(i1.metadata, i2.metadata)
for k in i1.metadata:
self.assertIs(i1.metadata[k], i2.metadata[k])
def test_deepcopy(self):
obs = deepcopy(self.im_2)
self.assertEqual(obs, self.im_2)
self.assertIsNot(obs._intervals, self.im_2._intervals)
self.assertIsNot(obs._interval_tree, self.im_2._interval_tree)
for i in range(self.im_2.num_interval_features):
i1, i2 = obs._intervals[i], self.im_2._intervals[i]
self.assertIsNot(i1, i2)
self.assertIsNot(i1.bounds, i2.bounds)
self.assertIsNot(i1.fuzzy, i2.fuzzy)
self.assertIsNot(i1.metadata, i2.metadata)
i2.metadata['spam'].append(1)
self.assertEqual(i2.metadata,
{'gene': 'sagB', 'bound': 0, 'spam': [0, 1]})
self.assertEqual(i1.metadata,
{'gene': 'sagB', 'bound': 0, 'spam': [0]})
def test_deepcopy_memo_is_respected(self):
memo = {}
deepcopy(self.im_1, memo)
self.assertGreater(len(memo), 2)
def test_init(self):
self.assertFalse(self.im_empty._is_stale_tree)
self.assertEqual(self.im_empty._intervals, [])
def test_init_upper_bound_lt_lower_bound(self):
# test that no exception is raised
IntervalMetadata(0)
with self.assertRaises(ValueError):
IntervalMetadata(-1)
def test_upper_bound_is_none(self):
im = IntervalMetadata(None)
# should not raise error
im.add([(0, 1000000000)])
self.assertIsNone(im.upper_bound)
with self.assertRaisesRegex(
TypeError, r'upper bound is `None`'):
im._reverse()
with self.assertRaisesRegex(
TypeError, r'upper bound is `None`'):
IntervalMetadata.concat([self.im_1, im])
def test_init_copy_from(self):
for i in [None, 99, 999]:
obs = IntervalMetadata(i, self.im_1)
exp = IntervalMetadata(i)
exp.add(bounds=[(1, 2), (4, self.upper_bound)],
metadata={'gene': 'sagA', 'bound': 0})
self.assertEqual(obs, exp)
def test_init_copy_from_empty(self):
for i in [None, 0, 9, 99, 999]:
obs = IntervalMetadata(i, self.im_empty)
exp = IntervalMetadata(i)
#.........这里部分代码省略.........