当前位置: 首页>>代码示例>>Python>>正文


Python Cluster.set_tag_length方法代码示例

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


在下文中一共展示了Cluster.set_tag_length方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestCoreObjects

# 需要导入模块: from pyicoteolib.core import Cluster [as 别名]
# 或者: from pyicoteolib.core.Cluster import set_tag_length [as 别名]

#.........这里部分代码省略.........

    def test_pk_to_half_open_wig(self):
        cluster = Cluster(read=PK, write=WIG, write_half_open=True, rounding=True)
        cluster.read_line('chr1 1 15 4:1|1:2|2:1|3:4|2:5|2:2|1:1')
        self.assertEqual(cluster.write_line(),'chr1\t0\t4\t1\nchr1\t4\t5\t2\nchr1\t5\t7\t1\nchr1\t7\t10\t4\nchr1\t10\t12\t5\nchr1\t12\t14\t2\nchr1\t14\t15\t1\n')

    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')

    def test_pk_to_variable_wig(self):
        cluster = Cluster(read=PK, write=VARIABLE_WIG)
        cluster.read_line('chr1    1599889 1600275 61:1.77|52:2.65|7:1.77|4:2.65|6:3.54|9:2.65|19:3.54|6:4.42|14:5.31|1:6.19|11:7.08|1:7.96|20:7.08|9:7.96|1:8.85|13:9.73|1:10.62|8:11.50|5:12.39|6:13.27|2:12.39|1:13.27|1:14.16|11:15.04|19:14.16|6:13.27|14:12.39|1:11.50|11:10.62|21:9.73|9:8.85|1:7.96|13:7.08|1:6.19|8:5.31|5:4.42|2:3.54|6:2.65|1:1.77')
        self.assertEqual(cluster.write_line(), '1599889\t1.77\n1599909\t1.77\n1599929\t1.77\n1599949\t2.606\n1599969\t2.65\n1599989\t2.342\n1600009\t2.9615\n1600029\t3.628\n1600049\t5.2645\n1600069\t7.124\n1600089\t7.476\n1600109\t10.173\n1600129\t12.918\n1600149\t14.556\n1600169\t13.362\n1600189\t11.372\n1600209\t9.73\n1600229\t8.053\n1600249\t5.3085\n')

    def test_bed_reader(self):
        self.assertEqual(self.bed_tag.start, 1)
        self.assertEqual(self.bed_tag.end, 100)
        self.assertEqual(self.bed_tag.name2, 'hola')
        self.assertEqual(self.bed_tag.strand, '+')

    def test_bed_writer(self):
        self.assertEqual(self.bed_tag.write_line(), 'chr1\t1\t100\thola\t666\t+\n')

    def test_pk_reader_writer(self):
        self.assertEqual(self.pk_cluster.write_line(), 'chr1\t1\t15\t4:1|1:2|2:1|3:4|2:5|2:2|1:1\t5.0\t.\t11\t35.0\n')

    def test_pk_to_bed(self):
        self.cluster_short.set_tag_length(10)
        self.cluster_short.write_as(BED)
        self.assertEqual(self.cluster_short.write_line(), 'chr1\t1\t10\tnoname\t0\t.\nchr1\t5\t14\tnoname\t0\t.\n')

    def test_bed_half_open_to_wig_half_open(self):
        cluster = Cluster(read=BED, write=WIG, read_half_open=True, write_half_open=True, rounding=True)
        cluster.read_line('chr1\t0\t100\t666\thola\t+\n')
        cluster.read_line('chr1\t1\t101\t666\thola\t+\n')
        self.assertEqual(cluster.write_line(), 'chr1\t0\t1\t1\nchr1\t1\t100\t2\nchr1\t100\t101\t1\n')

    def test_bed_half_open_to_wig_half_open2(self):
        cluster = Cluster(read=BED, write=WIG, read_half_open=True, write_half_open=True, rounding=True, cached=True)
        cluster2 = Cluster(read=BED, write=WIG, read_half_open=True, write_half_open=True, rounding=True, cached=True)
        cluster3 = Cluster(read=BED, write=WIG, read_half_open=True, write_half_open=True, rounding=True, cached=True)
        result = Cluster(read=BED, write=WIG, read_half_open=True, write_half_open=True, rounding=True)
        extension = 130
        result.read_line('chr1    156     192     id:7043691      1000    +')
        result.extend(extension)
        cluster.read_line('chr1    241     277     id:916714       1000    +')
        cluster.extend(extension)
        result +=cluster
        cluster2.read_line('chr1    241     277     id:916714       1000    +')
        cluster2.extend(extension)
        result +=cluster2
        cluster3.read_line('chr1    241     277     id:6880101      1000    +')
        cluster3.extend(extension)
        result +=cluster3

        self.assertEqual(result.write_line(), 'chr1\t156\t241\t1\nchr1\t241\t286\t4\nchr1\t286\t371\t3\n')

    def test_openwig_to_pk(self):
        cluster = Cluster(read=WIG, write=PK, read_half_open=True, rounding = True)
        cluster.read_line('chr1    1599888 1599949 1.77')
开发者ID:23Skidoo,项目名称:genomizer-server,代码行数:70,代码来源:testCore.py


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