本文整理汇总了Python中pybedtools.IntervalFile.all_hits方法的典型用法代码示例。如果您正苦于以下问题:Python IntervalFile.all_hits方法的具体用法?Python IntervalFile.all_hits怎么用?Python IntervalFile.all_hits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybedtools.IntervalFile
的用法示例。
在下文中一共展示了IntervalFile.all_hits方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IntervalFileTest
# 需要导入模块: from pybedtools import IntervalFile [as 别名]
# 或者: from pybedtools.IntervalFile import all_hits [as 别名]
class IntervalFileTest(unittest.TestCase):
file = "data/rmsk.hg18.chr21.small.bed"
def setUp(self):
self.file = os.path.join(PATH, self.file)
self.bed = IntervalFile(self.file)
def testFileType(self):
self.assert_(self.bed.file_type == "bed", (self.bed.file_type, self.file))
gff = os.path.join(PATH, "data/c.gff")
i = IntervalFile(gff)
self.assert_(i.file_type == "gff", (i.file_type, gff))
def testOverlaps(self):
i = Interval("chr21", 9719768, 9739768)
hits = self.bed.all_hits(i)
self.assertEqual(len(hits), 8)
for hit in hits:
self.assert_(hit.start <= 9739768 and hit.end >= 9719768)
def testStrands(self):
i = Interval("chr21", 9719768, 9739768, "+")
hits = self.bed.all_hits(i, same_strand=True)
for hit in hits:
self.assert_(hit.strand == '+')
i = Interval("chr21", 9719768, 9739768, "-")
hits = self.bed.all_hits(i, same_strand=True)
for hit in hits:
self.assert_(hit.strand == '-')
def testRichCmp(self):
a = Interval("chr21", 9719768, 9739768)
b = Interval("chr21", 9719767, 9739768)
self.assert_(a < b)
self.assert_(b < a)
c = Interval("chr21", 9719767, 9739768)
self.assert_(c == b)
d = Interval("chr22", 9719767, 9739768)
self.assert_(c != d)
示例2: IntervalFileTest
# 需要导入模块: from pybedtools import IntervalFile [as 别名]
# 或者: from pybedtools.IntervalFile import all_hits [as 别名]
class IntervalFileTest(unittest.TestCase):
file = "data/rmsk.hg18.chr21.small.bed"
def setUp(self):
self.file = os.path.join(PATH, self.file)
self.bed = IntervalFile(self.file)
def testFileType(self):
self.assert_(self.bed.file_type == "bed", (self.bed.file_type, self.file))
gff = os.path.join(PATH, "data/c.gff")
i = IntervalFile(gff)
self.assert_(i.file_type == "gff", (i.file_type, gff))
def testOverlaps(self):
i = Interval("chr21", 9719768, 9739768)
hits = self.bed.all_hits(i)
self.assertEqual(len(hits), 8)
for hit in hits:
self.assert_(hit.start <= 9739768 and hit.end >= 9719768)
def testStrands(self):
i = Interval("chr21", 9719768, 9739768, "+")
hits = self.bed.all_hits(i, same_strand=True)
for hit in hits:
self.assert_(hit.strand == '+')
i = Interval("chr21", 9719768, 9739768, "-")
hits = self.bed.all_hits(i, same_strand=True)
for hit in hits:
self.assert_(hit.strand == '-')
def testRichCmp(self):
# be obsessive . . .
#
# ==
a = Interval("chr21", 100, 200)
b = Interval("chr21", 100, 200)
self.assert_(a == b)
self.assertFalse(a != b)
self.assert_(a <= b)
self.assert_(a >= b)
self.assertFalse(a < b)
self.assertFalse(a > b)
a = Interval("chr21", 100, 100)
b = Interval("chr21", 100, 100)
self.assert_(a == b)
self.assertFalse(a != b)
self.assert_(a <= b)
self.assert_(a >= b)
self.assertFalse(a < b)
self.assertFalse(a > b)
# != because of strand
a = Interval("chr21", 100, 200, strand='+')
b = Interval("chr21", 100, 200, strand='-')
self.assertFalse(a == b)
self.assert_(a != b)
self.assertFalse(a <= b)
self.assertFalse(a >= b)
self.assertFalse(a < b)
self.assertFalse(a > b)
# a >= b
a = Interval("chr21", 100, 300)
b = Interval("chr21", 100, 200)
self.assertFalse(a == b)
self.assert_(a != b)
self.assertFalse(a <= b)
self.assert_(a >= b)
self.assertFalse(a < b)
self.assertFalse(a > b)
# a <= b
a = Interval("chr21", 100, 300)
b = Interval("chr21", 300, 300)
self.assertFalse(a == b)
self.assert_(a != b)
self.assert_(a <= b)
self.assertFalse(a >= b)
self.assertFalse(a < b)
self.assertFalse(a > b)
# a <= b
a = Interval("chr21", 100, 300)
b = Interval("chr21", 250, 300)
self.assertFalse(a == b)
self.assert_(a != b)
self.assert_(a <= b)
self.assertFalse(a >= b)
self.assertFalse(a < b)
self.assertFalse(a > b)
# a < b
a = Interval("chr21", 100, 200)
b = Interval("chr21", 201, 300)
self.assertFalse(a == b)
#.........这里部分代码省略.........