本文整理匯總了Python中skbio.metadata.IntervalMetadata.drop方法的典型用法代碼示例。如果您正苦於以下問題:Python IntervalMetadata.drop方法的具體用法?Python IntervalMetadata.drop怎麽用?Python IntervalMetadata.drop使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類skbio.metadata.IntervalMetadata
的用法示例。
在下文中一共展示了IntervalMetadata.drop方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestIntervalMetadata
# 需要導入模塊: from skbio.metadata import IntervalMetadata [as 別名]
# 或者: from skbio.metadata.IntervalMetadata import drop [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])