本文整理汇总了Python中skbio.metadata.IntervalMetadata.merge方法的典型用法代码示例。如果您正苦于以下问题:Python IntervalMetadata.merge方法的具体用法?Python IntervalMetadata.merge怎么用?Python IntervalMetadata.merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skbio.metadata.IntervalMetadata
的用法示例。
在下文中一共展示了IntervalMetadata.merge方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_merge_to_unbounded
# 需要导入模块: from skbio.metadata import IntervalMetadata [as 别名]
# 或者: from skbio.metadata.IntervalMetadata import merge [as 别名]
def test_merge_to_unbounded(self):
for im in [self.im_empty, self.im_1, IntervalMetadata(None)]:
obs = IntervalMetadata(None)
obs.merge(im)
self.assertIsNone(obs.upper_bound)
self.assertEqual(obs._intervals, im._intervals)
示例2: TestIntervalMetadata
# 需要导入模块: from skbio.metadata import IntervalMetadata [as 别名]
# 或者: from skbio.metadata.IntervalMetadata import merge [as 别名]
#.........这里部分代码省略.........
intvl = self.im_empty.add([(1, 2), (1, 2)])
intvls = list(self.im_empty.query([(1, 2)]))
self.assertEqual(len(intvls), 1)
self.assertTrue(intvl is intvls[0])
def test_concat_empty(self):
for i in 0, 1, 2:
obs = IntervalMetadata.concat([self.im_empty] * i)
exp = IntervalMetadata(self.upper_bound * i)
self.assertEqual(obs, exp)
obs = IntervalMetadata.concat([])
self.assertEqual(obs, IntervalMetadata(0))
def test_concat(self):
im1 = IntervalMetadata(3)
im2 = IntervalMetadata(4)
im3 = IntervalMetadata(5)
im1.add([(0, 2)], [(True, True)])
im2.add([(0, 3)], [(True, False)], {'gene': 'sagA'})
im2.add([(2, 4)], metadata={'gene': 'sagB'})
im3.add([(1, 5)], [(False, True)], {'gene': 'sagC'})
obs = IntervalMetadata.concat([im1, im2, im3])
exp = IntervalMetadata(12)
exp.add(bounds=[(0, 2)], fuzzy=[(True, True)])
exp.add(bounds=[(3, 6)], fuzzy=[(True, False)],
metadata={'gene': 'sagA'})
exp.add(bounds=[(5, 7)], metadata={'gene': 'sagB'})
exp.add(bounds=[(8, 12)], fuzzy=[(False, True)],
metadata={'gene': 'sagC'})
self.assertEqual(obs, exp)
def test_merge(self):
# empty + empty
im = IntervalMetadata(self.upper_bound)
self.im_empty.merge(im)
self.assertEqual(self.im_empty, im)
# empty + non-empty
self.im_empty.merge(self.im_1)
self.assertEqual(self.im_empty, self.im_1)
# non-empty + non-empty
self.im_empty.merge(self.im_2)
self.im_2.merge(self.im_1)
self.assertEqual(self.im_empty, self.im_2)
def test_merge_unequal_upper_bounds(self):
n = 3
im1 = IntervalMetadata(n)
for im in [self.im_empty, self.im_1]:
with self.assertRaisesRegex(
ValueError,
r'not equal \(%d != %d\)' % (self.upper_bound, n)):
im.merge(im1)
def test_merge_to_unbounded(self):
for im in [self.im_empty, self.im_1, IntervalMetadata(None)]:
obs = IntervalMetadata(None)
obs.merge(im)
self.assertIsNone(obs.upper_bound)
self.assertEqual(obs._intervals, im._intervals)
def test_merge_unbounded_to_bounded(self):
im = IntervalMetadata(None)
with self.assertRaisesRegex(
ValueError,