本文整理匯總了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)
#.........這裏部分代碼省略.........