本文整理汇总了Python中skbio.metadata.IntervalMetadata.query方法的典型用法代码示例。如果您正苦于以下问题:Python IntervalMetadata.query方法的具体用法?Python IntervalMetadata.query怎么用?Python IntervalMetadata.query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skbio.metadata.IntervalMetadata
的用法示例。
在下文中一共展示了IntervalMetadata.query方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestIntervalMetadata
# 需要导入模块: from skbio.metadata import IntervalMetadata [as 别名]
# 或者: from skbio.metadata.IntervalMetadata import query [as 别名]
#.........这里部分代码省略.........
self.assertEqual(obs, exp)
# test it is shallow copy
self.assertIsNot(obs._intervals, self.im_empty._intervals)
self.assertIsNot(obs._interval_tree, self.im_empty._interval_tree)
def test_init_copy_from_shallow_copy(self):
obs = IntervalMetadata(self.upper_bound, self.im_2)
self.assertEqual(self.im_2, obs)
# test it is shallow copy
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_init_copy_from_error(self):
i = self.upper_bound - 1
with self.assertRaisesRegex(
ValueError, r'larger than upper bound \(%r\)' % i):
IntervalMetadata(i, self.im_2)
def test_num_interval_features(self):
self.assertEqual(self.im_empty.num_interval_features, 0)
self.assertEqual(self.im_1.num_interval_features, 1)
self.assertEqual(self.im_2.num_interval_features, 2)
def test_duplicate(self):
'''Test query and drop methods on duplicate Intervals.'''
intvl_1 = self.im_empty.add([(1, 2)])
intvl_2 = self.im_empty.add([(1, 2)])
self.assertEqual(len(list(self.im_empty.query([(1, 2)]))), 2)
self.im_empty.drop([intvl_1])
self.assertEqual(len(self.im_empty._intervals), 1)
self.assertTrue(self.im_empty._intervals[0] is intvl_2)
def test_duplicate_bounds(self):
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])