本文整理汇总了Python中skbio.metadata.IntervalMetadata._query_attribute方法的典型用法代码示例。如果您正苦于以下问题:Python IntervalMetadata._query_attribute方法的具体用法?Python IntervalMetadata._query_attribute怎么用?Python IntervalMetadata._query_attribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skbio.metadata.IntervalMetadata
的用法示例。
在下文中一共展示了IntervalMetadata._query_attribute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestIntervalMetadata
# 需要导入模块: from skbio.metadata import IntervalMetadata [as 别名]
# 或者: from skbio.metadata.IntervalMetadata import _query_attribute [as 别名]
#.........这里部分代码省略.........
# check sorting does not have other side effects
self.assertEqual(im, self.im_2)
self.assertEqual(self.im_2._intervals,
[self.im_2_2, self.im_2_1, interval])
self.im_2.sort()
self.assertEqual(im, self.im_2)
self.assertEqual(self.im_2._intervals,
[interval, self.im_2_1, self.im_2_2])
self.im_empty.sort()
self.assertEqual(self.im_empty, IntervalMetadata(self.upper_bound))
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):