本文整理汇总了Python中skbio.metadata.IntervalMetadata._query_interval方法的典型用法代码示例。如果您正苦于以下问题:Python IntervalMetadata._query_interval方法的具体用法?Python IntervalMetadata._query_interval怎么用?Python IntervalMetadata._query_interval使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skbio.metadata.IntervalMetadata
的用法示例。
在下文中一共展示了IntervalMetadata._query_interval方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestIntervalMetadata
# 需要导入模块: from skbio.metadata import IntervalMetadata [as 别名]
# 或者: from skbio.metadata.IntervalMetadata import _query_interval [as 别名]
#.........这里部分代码省略.........
def test_add_eq_upper_bound(self):
self.im_empty.add(bounds=[(1, 2), (4, self.upper_bound)],
metadata={'gene': 'sagA', 'bound': 0})
self.assertTrue(self.im_empty._is_stale_tree)
interval = self.im_empty._intervals[0]
self.assertEqual(interval.bounds, [(1, 2), (4, self.upper_bound)])
self.assertEqual(interval.metadata, {'gene': 'sagA', 'bound': 0})
self.assertTrue(isinstance(self.im_empty._interval_tree, IntervalTree))
def test_add_gt_upper_bound(self):
with self.assertRaises(ValueError):
self.im_empty.add(bounds=[(1, 2), (4, self.upper_bound+1)],
metadata={'gene': 'sagA', 'bound': 0})
def test_add_eq_start_end_bound(self):
for i in 0, 1, self.upper_bound:
# test that no exception is raised
self.im_empty.add(bounds=[(i, i)],
metadata={'gene': 'sagA', 'bound': 0})
def test_query_attribute(self):
intervals = self.im_2._query_attribute({})
for i, j in zip(intervals, self.im_2._intervals):
self.assertEqual(i, j)
intervals = list(self.im_2._query_attribute(None))
self.assertEqual(len(intervals), 0)
for i in self.im_2._intervals:
intervals = list(self.im_2._query_attribute(i.metadata))
self.assertEqual(len(intervals), 1)
self.assertEqual(intervals[0], i)
def test_query_interval(self):
intervals = list(self.im_2._query_interval((1, 2)))
self.assertEqual(len(intervals), 1)
self.assertEqual(intervals[0], self.im_2_1)
intervals = list(self.im_2._query_interval((3, 4)))
self.assertEqual(len(intervals), 1)
self.assertEqual(intervals[0], self.im_2_2)
intervals = {repr(i) for i in self.im_2._query_interval((1, 7))}
self.assertEqual(len(intervals), 2)
self.assertSetEqual(intervals,
{repr(i) for i in self.im_2._intervals})
def test_query_interval_upper_bound(self):
intervals = list(self.im_2._query_interval((self.upper_bound-1,
self.upper_bound)))
self.assertEqual(intervals, [self.im_2_1])
def test_query(self):
intervals = list(self.im_2.query(bounds=[(1, 5)],
metadata={'gene': 'sagA'}))
self.assertEqual(len(intervals), 1)
self.assertEqual(intervals[0], self.im_2_1)
def test_query_empty(self):
intervals = list(self.im_1.query())
self.assertEqual(len(intervals), 0)
def test_query_no_hits(self):
intervals = list(self.im_2.query(bounds=[(self.upper_bound, 200)]))
self.assertEqual(len(intervals), 0)