本文整理汇总了Python中pyicoteolib.core.Cluster类的典型用法代码示例。如果您正苦于以下问题:Python Cluster类的具体用法?Python Cluster怎么用?Python Cluster使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Cluster类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_overlaping_clusters
def get_overlaping_clusters(self, region, overlap=1):
clusters = []
bam_tell, read_start = self.get_bam_tell(region)
print "TELL", bam_tell, read_start
if bam_tell or region.start < LINEAR_SIZE*4:
r = BamReader(self.bam_path, self.logger, bam_tell, read_start, self.chr_dict_inv)
for line in r:
c = Cluster(read=SAM, cached=False, read_half_open=self.read_half_open, rounding=self.rounding)
try:
c.read_line(line)
except InvalidLine:
print "Invalid line, .bam or .bai corrupt"
break
if c.overlap(region) >= overlap:
clusters.append(c)
elif c.start > region.end or c.name != region.name:
break
if len(clusters) > 0:
print "Num clusters", len(clusters)
print "first:", clusters[0].start, clusters[0].end
if len(clusters) > 1: print "end:", clusters[-1].start, clusters[-1].end
else:
print "No clusters found!"
print
return clusters
示例2: test_extend_bug
def test_extend_bug(self):
cluster = Cluster(read=BED, write=PK)
cluster.read_line('chr3 1 35 666 noname +')
cluster2 = Cluster(read=BED, write=PK)
cluster2.read_line('chr3 156 200 666 noname -')
cluster.extend(100)
cluster2.extend(100)
result = cluster + cluster2
self.assertEqual(200, len(result))
示例3: test_split_subtract_result
def test_split_subtract_result(self):
sub_result = Cluster(write_half_open=True, cached=True)
sub_result.read_line('chr4 1 300 20:1|40:0|20:3|20:0.3|10:-6|80:1|10:0')
clusters = sub_result.absolute_split(threshold=0)
result = []
result.append('chr4\t0\t20\t20:1.00\t1.0\t.\t10\t20.0\n')
result.append('chr4\t60\t100\t20:3.00|20:0.30\t3.0\t.\t70\t66.0\n')
result.append('chr4\t110\t190\t80:1.00\t1.0\t.\t150\t80.0\n')
for i in range(0, len(clusters)):
self.assertEqual(clusters[i].write_line(), result[i])
示例4: setUp
def setUp(self):
self.tag_list_short = [Cluster('chr1', 1, 10, read=PK), Cluster('chr1', 5, 14, read=PK)]
self.cluster_short = Cluster(rounding=True, read=PK)
self.cluster_short.read_line('chr1 1 14 4:1|6:2|4:1')
self.pk_cluster = Cluster(rounding=True, read=PK, write=PK)
self.pk_cluster.read_line('chr1 1 15 4:1|1:2|2:1|3:4|2:5|2:2|1:1')
self.bed_tag = Cluster(read=BED, write=BED, rounding=True)
self.bed_tag.read_line('chr1 1 100 hola 666 +')
self.cluster1 = Cluster(rounding=True, read=PK)
self.cluster2 = Cluster(rounding=True, read=PK)
示例5: test_split
def test_split(self):
double_cluster = Cluster(rounding=True)
double_cluster.read_line('chr1 100 215 5:1|10:5|5:7|5:80|5:1|5:40|15:1|10:2|5:3|5:8|10:6|10:5|10:4|10:3|6:2')
results = double_cluster.split(0.01)
correct_clusters = [Cluster(rounding=True), Cluster(rounding=True), Cluster(rounding=True)]
correct_clusters[0].read_line('chr1 100 125 5:1|10:5|5:7|5:80|2:1')
correct_clusters[1].read_line('chr1 128 141 2:1|5:40|7:1')
correct_clusters[2].read_line('chr1 143 215 7:1|10:2|5:3|5:8|10:6|10:5|10:4|10:3|6:2')
for i in range (0,len(correct_clusters)):
self.assertEqual(results[i].write_line(), correct_clusters[i].write_line())
示例6: test_wig_read_write
def test_wig_read_write(self):
cluster = Cluster(read=WIG, write=WIG, read_half_open=True, write_half_open=True, rounding=True)
cluster.read_line('chr2 1 10 1')
cluster.read_line('chr2 10 16 2')
cluster.read_line('chr2 16 26 1')
self.assertEqual(cluster.write_line(), 'chr2\t1\t10\t1\nchr2\t10\t16\t2\nchr2\t16\t26\t1\n')
cluster.write_as(WIG, False)
self.assertEqual(cluster.write_line(), 'chr2\t2\t10\t1\nchr2\t11\t16\t2\nchr2\t17\t26\t1\n')
示例7: test_simple_ucsc_representation
def test_simple_ucsc_representation(self):
"""Confirmed visually at the UCSC browser
track name=simple_read visibility=full
chr3 101 200 noname 555 +
track type=wiggle_0 name=the_test visibility=full
chr3 101 200 1
"""
cluster = Cluster(read=BED, write=WIG, read_half_open=True, write_half_open=True, rounding = True, cached=True)
cluster.read_line('chr3 101 200 noname 555 +')
self.assertEqual(cluster.write_line(), 'chr3\t101\t200\t1\n')
示例8: test_eq
def test_eq(self):
cluster = Cluster(read=PK)
cluster2 = Cluster(read=PK)
cluster3 = Cluster(read=PK)
cluster.read_line('chr1 1 15 4:1|1:2|2:1|3:4|2:5|2:2|1:1')
cluster2.read_line('chr1 1 15 4:1|1:2|2:1|3:4|2:5|2:2|1:1')
cluster3.read_line('chr1 1 15 4:1|1:2|2:1|3:4|2:5|2:2')
self.assertEqual(cluster, cluster2)
self.assertNotEqual(cluster, cluster3)
示例9: test_add2
def test_add2(self):
cluster = Cluster(read=BED)
cluster.read_line('chr1 1 20000 666 hola +')
cluster.read_line('chr1 1 20000 666 hola +')
cluster.read_line('chr1 1 20000 666 hola +')
cluster.read_line('chr1 1001 20000 666 hola +')
self.assertEqual(cluster.write_line(), 'chr1\t1\t20000\t1000:3.00|19000:4.00\t4.0\t+\t10500\t79000.0\n')
示例10: read_and_extend
def read_and_extend(self, cluster, line, extension):
cluster_aux = Cluster(read=BED, write=BED, read_half_open=True, write_half_open=True, rounding = True)
if cluster.is_empty():
cluster.read_line(line)
cluster.extend(extension)
#print cluster.write_line(), cluster._profile
else:
cluster_aux.read_line(line)
cluster_aux.extend(extension)
#print cluster_aux.write_line(), cluster_aux._profile
cluster += cluster_aux
#print cluster.write_line()
return cluster
示例11: test_bed_to_half_open_wig
def test_bed_to_half_open_wig(self):
"""Confirmed visually at the UCSC browser
track name=simple_cluster visibility=full
chr1 1 100 hola 666 +
chr1 10 130 hola 666 +
track type=wiggle_0 name=the_test visibility=full
chr1 1 10 1
chr1 10 100 2
chr1 100 130 1
"""
cluster = Cluster(read=BED, write=WIG, read_half_open=True, write_half_open=True, rounding = True, cached=True)
cluster.read_line('chr1 1 100 hola 666 +')
cluster.read_line('chr1 10 130 hola 666 +')
self.assertEqual(cluster.write_line(), 'chr1\t1\t10\t1\nchr1\t10\t100\t2\nchr1\t100\t130\t1\n')
示例12: test_is_significant
def test_is_significant(self):
cluster = Cluster(rounding=True)
cluster.read_line('chr1 1 15 4:1|1:2|2:1|3:4|2:5|2:2|1:1') #area 35
self.assertTrue(cluster.is_significant(5, "numreads"))
self.assertTrue(cluster.is_significant(34, "numreads"))
self.assertFalse(cluster.is_significant(36, "numreads"))
self.assertFalse(cluster.is_significant(20))
self.assertTrue(cluster.is_significant(1))
self.assertTrue(cluster.is_significant(5))
示例13: test_comparison
def test_comparison(self):
cluster = Region("chr1", 1, 100)
clusterdup = Cluster(read=BED)
clusterdup.read_line("chr1 1 100")
cluster2 = Cluster(read=BED)
cluster2.read_line("chr4 1000 1010")
cluster3 = Cluster(read=BED)
cluster3.read_line("chr5 3 103")
self.assertTrue(cluster < cluster2)
self.assertTrue(cluster2 < cluster3)
self.assertFalse(cluster > cluster3)
self.assertFalse(cluster < clusterdup)
self.assertTrue(cluster <= clusterdup)
示例14: test_bug_contiguous_peaks
def test_bug_contiguous_peaks(self):
cluster = Cluster(rounding=True, read=PK, write=PK)
cluster2 = Cluster(rounding=True, read=PK, write=PK)
cluster.read_line('chr1 849917 850408 8:2|10:4|80:5|23:6|29:7|8:5|10:3|39:2|12:3|29:4|5:3|18:4|41:3|30:4|15:5|12:4|34:3|59:2|30:1')
cluster2.read_line('chr1 850408 850648 66:2|25:3|59:4|66:2|25:1 +')
result = cluster + cluster2
self.assertTrue(cluster.intersects(cluster2))
示例15: test_sub_and_print
def test_sub_and_print(self):
cluster = Cluster()
cluster2 = Cluster(write_half_open=False)
cluster.read_line('chr1 1 1000 10:2|10:4|80:5|500:7|100:7|100:5')
cluster2.read_line('chr1 11 1000 10:4|80:5|500:6|100:7|99:5|1:4.99')
cluster2 = cluster - cluster2
self.assertEqual(cluster2.write_line(), 'chr1\t1\t10\t10:2.00\t2.0\t.\t5\t20.0\nchr1\t101\t600\t500:1.00\t1.0\t.\t350\t500.0\nchr1\t800\t800\t1:0.01\t0.01\t.\t800\t0.01\n')