本文整理匯總了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,