• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python core.Cluster类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyicoteolib.core.Cluster的典型用法代码示例。如果您正苦于以下问题:Python Cluster类的具体用法?Python Cluster怎么用?Python Cluster使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Cluster类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:28,代码来源:bam.py


示例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))
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:9,代码来源:testCore.py


示例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])
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:10,代码来源:testCore.py


示例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)
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:11,代码来源:testCore.py


示例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())
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:11,代码来源:testCore.py


示例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')
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:8,代码来源:testCore.py


示例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')
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:12,代码来源:testCore.py


示例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)
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:9,代码来源:testCore.py


示例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')
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:7,代码来源:testCore.py


示例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
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:14,代码来源:testCore.py


示例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')
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:15,代码来源:testCore.py


示例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))
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:9,代码来源:testCore.py


示例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)
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:13,代码来源:testCore.py


示例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))
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:7,代码来源:testCore.py


示例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')
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:7,代码来源:testCore.py


示例16: test_is_contiguous_wig

 def test_is_contiguous_wig(self):
     cluster = Cluster(read=WIG,  read_half_open=True)
     cluster.read_line('chr1    1599888 1599949 1.77')
     cluster2 = Cluster(read=WIG, write=WIG,  read_half_open=True)
     cluster2.read_line('chr1    1599949 1600001 2.65')
     #print cluster2.write_line()
     self.assertTrue(cluster.is_contiguous(cluster2))
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:7,代码来源:testCore.py


示例17: test_normalized_counts

    def test_normalized_counts(self):
        total_number_reads = 1e7
        region = Region("chr1", 1, 300)
        region_bed12 = Region("chr1", 1, 300, exome_size = 200)
        c = Cluster(read=BED)
        for i in range(0, 5):
            c.read_line("chr1 1 100")
            region.add_tags(c, True)
            region_bed12.add_tags(c, True)
            c.clear()

        self.assertEqual(region.normalized_counts(), 5.) #simple-counts
        self.assertEqual(region.normalized_counts(region_norm=True, total_n_norm=True, total_reads = total_number_reads), 1.666666666666667) #rpkm
        self.assertEqual(region_bed12.normalized_counts(region_norm=True, total_n_norm=True, total_reads = total_number_reads), 2.5) #rpkm with exon_size


        self.assertEqual(region.normalized_counts(pseudocount=True), 6.) #with pseudocounts
        self.assertEqual(region.normalized_counts(region_norm=True, total_n_norm=True, total_reads = total_number_reads, regions_analyzed=10000, pseudocount=True), 1.998001998001998)
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:18,代码来源:testCore.py


示例18: test_sub_fast

 def test_sub_fast(self):
    #random/experiment.pk 
    experiment = Cluster(rounding=True)       
    experiment.read_line("chr1   1     1107     101:2|7:1  2.0     .       263     238.0")   
    control = Cluster() 
    control.read_line(  "chr1   46    1222      47:1|54:2|47:1 2.0     .       71331   202.0")
    experiment -= control
    self.assertEqual(experiment.write_line(), 'chr1\t1\t92\t45:2|47:1\t2.0\t.\t23\t137.0\n')#chr1    1       92      45:2|47:1       2.0     .       23      137.0
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:8,代码来源:testCore.py


示例19: test_intersects

 def test_intersects(self):
     self.assertTrue(Cluster('chr1', 1, 10).intersects(Cluster('chr1', 10, 14)))
     self.assertFalse(Cluster('chr2', 1, 10).intersects(Cluster('chr1', 4, 14)))
     self.assertTrue(Cluster('chr1', 1, 10).intersects(Cluster('chr1', 4, 14)))
     cluster = Cluster(read=PK, rounding=True)
     cluster.read_line('chr1  1 100 100:1')
     cluster2 = Cluster(read=PK,rounding=True)
     cluster2.read_line('chr1 100 199 100:1')
     result = cluster + cluster2
     self.assertTrue(cluster.intersects(cluster2))
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:10,代码来源:testCore.py


示例20: test_add_pk

 def test_add_pk(self):
     cluster1 = Cluster(read=PK)
     cluster2 = Cluster(read=PK)
     cluster1.read_line('chr1\t1\t145\t9:2.00|41:3.00|50:2.00|45:1.00\n')
     cluster2.read_line('chr1\t1\t125\t9:4.00|41:3.00|30:2.00|45:1.00\n')
     result = cluster1 + cluster2
     self.assertEqual(result.write_line(), 'chr1\t1\t145\t50:6.00|30:4.00|20:3.00|25:2.00|20:1.00\t6.0\t.\t25\t550.0\n')
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:7,代码来源:testCore.py



注:本文中的pyicoteolib.core.Cluster类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python idf.IDF类代码示例发布时间:2022-05-25
下一篇:
Python text.progprint_xrange函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap