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

Python pybedtools.create_interval_from_list函数代码示例

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

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



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

示例1: test_pickleable

def test_pickleable():
    interval = pybedtools.create_interval_from_list(
        ['chr1', '1', '100', 'asdf'])
    fn = pybedtools.BedTool._tmp()
    import pickle
    out = open(fn, 'w')
    pickle.dump(interval, out)
    out.close()
    new_interval = pickle.load(open(fn))
    assert str(interval) == str(new_interval)

    interval = pybedtools.create_interval_from_list(
        ['chr1', '1', '100'])
    fn = pybedtools.BedTool._tmp()
    import pickle
    out = open(fn, 'w')
    pickle.dump(interval, out)
    out.close()
    new_interval = pickle.load(open(fn))
    assert str(interval) == str(new_interval)

    interval = pybedtools.create_interval_from_list(
        "chr2L	.	UTR	41	70	0	+	.	ID=mRNA:xs2:UTR:41-70;Parent=mRNA:xs2;".split('\t'))
    fn = pybedtools.BedTool._tmp()
    import pickle
    out = open(fn, 'w')
    pickle.dump(interval, out)
    out.close()
    new_interval = pickle.load(open(fn))
    assert str(interval) == str(new_interval)
开发者ID:ml4wc,项目名称:pybedtools,代码行数:30,代码来源:test1.py


示例2: test_RNA_position_placement

 def test_RNA_position_placement(self):
     
     """
     
     Makes sure that the placement within a region or list of regions is correct
     
     """
     
 
     tool = pybedtools.create_interval_from_list("chr1    50    60    ENSMUSG1_1_83;ENSMUSG1_6_83    0    +    60    60".split())
     location_dict = {"ENSMUSG1" : {"strand" : "+", "regions" : [(0,100),
                                                                 ] 
                                    }
                      }
     
     self.assertEqual(RNA_position(tool, location_dict), (.60, .60))
     
     tool = pybedtools.create_interval_from_list("chr1    50    60    ENSMUSG1_1_83;ENSMUSG1_6_83    0    -    60    60".split())
     location_dict = {"ENSMUSG1" : {"strand" : "-", "regions" : [(0,100),
                                                                 ] 
                                    }
                      }
     
     #individual_fraction, total_fraction
     self.assertEqual(RNA_position(tool, location_dict), (.4, .4))
开发者ID:LeiLiSysBio,项目名称:clipper,代码行数:25,代码来源:test_CLIP_analysis.py


示例3: string_to_interval

def string_to_interval(s):
    """
    Convert string of the form "chrom:start-stop" or "chrom:start-stop[strand]" to an interval.

    Assumes zero-based coords.

    If it's already an interval, then return it as-is.
    """
    if isinstance(s, basestring):
        m = coord_re.search(s)
        if m.group('strand'):
            return pybedtools.create_interval_from_list([
                m.group('chrom'),
                m.group('start'),
                m.group('stop'),
                '.',
                '0',
                m.group('strand')])
        else:
            return pybedtools.create_interval_from_list([
                m.group('chrom'),
                m.group('start'),
                m.group('stop'),
            ])
    return s
开发者ID:jdiez,项目名称:pybedtools,代码行数:25,代码来源:helpers.py


示例4: test_convert_to_mRNA_position_placement

 def test_convert_to_mRNA_position_placement(self):
     
     """
     
     Makes sure that the placement within a region or list of regions is correct
     
     """
     
     return
     interval = pybedtools.create_interval_from_list("ENSMUSG1    50    60    ENSMUSG1_1_83;ENSMUSG1_6_83    0    +    60    60".split())
     location_dict = {"ENSMUSG1" : {"strand" : "+", "regions" : [(0,100),
                                                                 ] 
                                    }
                      }
     
     correct_tool = pybedtools.create_interval_from_list("ENSMUSG1    50    60    ENSMUSG1_1_83;ENSMUSG1_6_83    0    +    60    60".split())
     self.assertEqual(convert_to_mRNA_position(interval, location_dict), correct_tool)
     
     interval = pybedtools.create_interval_from_list("ENSMUSG1    50    60    ENSMUSG1_1_83;ENSMUSG1_6_83    0    -".split())
     location_dict = {"ENSMUSG1" : {"strand" : "-", "regions" : [(0,100),
                                                                 ] 
                                    }
                      }
     
     #individual_fraction, total_fraction
     correct_tool = pybedtools.create_interval_from_list("ENSMUSG1    40    50    ENSMUSG1_1_83;ENSMUSG1_6_83    0    -".split())
     x =  convert_to_mRNA_position(interval, location_dict)
     print x
     self.assertEqual(x, correct_tool)
开发者ID:gpratt,项目名称:gscripts,代码行数:29,代码来源:test_pybedtools_helpers.py


示例5: test_convert_to_mRNA_position_placement_split

 def test_convert_to_mRNA_position_placement_split(self):    
     
     """
     
     Makes sure that lists of regions works for both positive and negative strands
     
     """
     
     return
     tool = pybedtools.create_interval_from_list("ENSMUSG1    125    127    ENSMUSG1_1_83;ENSMUSG1_6_83    0    +    125    125".split())
     location_dict = {"ENSMUSG1" : {"strand" : "+", "regions" : [(0, 50),
                                                                 (100, 150),
                                                                 ] 
                                    }
                      }
     
     correct_tool = pybedtools.create_interval_from_list("ENSMUSG1    75    77    ENSMUSG1_1_83;ENSMUSG1_6_83    0    +    125    125".split())
     self.assertEqual(convert_to_mRNA_position(tool, location_dict), correct_tool )
     
     tool = pybedtools.create_interval_from_list("ENSMUSG1    25    27    ENSMUSG1_1_83;ENSMUSG1_6_83    0    -    25    25".split())
     location_dict = {"ENSMUSG1" : {"strand" : "-", "regions" : [(100, 150),
                                                                 (0, 50),
                                                                 ] 
                                    }
                      }
     
     correct_tool = pybedtools.create_interval_from_list("ENSMUSG1    73    75    ENSMUSG1_1_83;ENSMUSG1_6_83    0    -    25    25".split())
     self.assertEqual(convert_to_mRNA_position(tool, location_dict), correct_tool)
开发者ID:gpratt,项目名称:gscripts,代码行数:28,代码来源:test_pybedtools_helpers.py


示例6: finder

 def finder(self, region):
     s = ['.' for i in self.current_seq]
     for hit in self.regex_plus.finditer(self.current_seq):
         start, stop = hit.span()
         s[start:stop] = hit.group()
         strand = ' (+)'
         s[stop:len(strand)] = strand
         self.intervals.append(pybedtools.create_interval_from_list([
             region.chrom,
             str(region.start + start),
             str(region.start + stop),
             hit.group(),
             '0',
             '+']))
     for hit in self.regex_minus.finditer(self.current_seq):
         start, stop = hit.span()
         s[start:stop] = Seq(hit.group()).reverse_complement()
         strand = ' (-)'
         s[stop:len(strand)] = strand
         self.intervals.append(pybedtools.create_interval_from_list([
             region.chrom,
             str(region.start + start),
             str(region.start + stop),
             hit.group(),
             '0',
             '-']))
     yield ''.join(s)
开发者ID:daler,项目名称:seqprint,代码行数:27,代码来源:seqprinter.py


示例7: test_RNA_position_placement_split

 def test_RNA_position_placement_split(self):    
     
     """
     
     Makes sure that lists of regions works for both positive and negative strands
     
     """
     
     tool = pybedtools.create_interval_from_list("chr1    50    60    ENSMUSG1_1_83;ENSMUSG1_6_83    0    +    125    125".split())
     location_dict = {"ENSMUSG1" : {"strand" : "+", "regions" : [(0, 50),
                                                                 (100, 150),
                                                                 ] 
                                    }
                      }
     
     self.assertEqual(RNA_position(tool, location_dict), (.50, .75) )
     
     tool = pybedtools.create_interval_from_list("chr1    50    60    ENSMUSG1_1_83;ENSMUSG1_6_83    0    -    25    25".split())
     location_dict = {"ENSMUSG1" : {"strand" : "-", "regions" : [(100, 150),
                                                                 (0, 50),
                                                                 ] 
                                    }
                      }
     
     self.assertEqual(RNA_position(tool, location_dict), (.50, .75))
开发者ID:LeiLiSysBio,项目名称:clipper,代码行数:25,代码来源:test_CLIP_analysis.py


示例8: test_minus_feature_is_reversed_profile

 def test_minus_feature_is_reversed_profile(self):
     feature1 = pybedtools.create_interval_from_list(['chr2L', '0', '20', '.', '.', '+'])
     feature2 = pybedtools.create_interval_from_list(['chr2L', '0', '20', '.', '.', '-'])
     x, y = self.m.local_coverage(feature1, fragment_size=5)
     xm, ym = self.m.local_coverage(feature2, fragment_size=5)
     pp(list(enumerate(zip(ym, y))))
     assert list(ym) == list(y[::-1])
     assert list(xm) == list(x)
开发者ID:tanglingfung,项目名称:metaseq,代码行数:8,代码来源:test.py


示例9: test_all_hits

def test_all_hits():
    a = pybedtools.example_bedtool('a.bed')

    assert [a[2], a[3]] == a.all_hits(pybedtools.create_interval_from_list(
                      ['chr1', '450', '905', '.', '.', '-']))

    assert [a[2]] == a.all_hits(pybedtools.create_interval_from_list(
                      ['chr1', '450', '905', '.', '.', '-']), same_strand=True)
开发者ID:ml4wc,项目名称:pybedtools,代码行数:8,代码来源:test1.py


示例10: test_count_hits

def test_count_hits():
    a = pybedtools.example_bedtool('a.bed')

    assert len(a.all_hits(pybedtools.create_interval_from_list(
                      ['chr1', '450', '905', '.', '.', '-']))) == 2

    assert len(a.all_hits(pybedtools.create_interval_from_list(
                      ['chr1', '450', '905', '.', '.', '-']), same_strand=True)) == 1
开发者ID:ml4wc,项目名称:pybedtools,代码行数:8,代码来源:test1.py


示例11: test_any_hits

def test_any_hits():
    a = pybedtools.example_bedtool('a.bed')

    assert 1 == a.any_hits(pybedtools.create_interval_from_list(
                      ['chr1', '900', '905', '.', '.', '-']))

    assert 0 == a.any_hits(pybedtools.create_interval_from_list(
                      ['chr1', '900', '905', '.', '.', '-']), same_strand=True)

    assert 0 == a.any_hits(pybedtools.create_interval_from_list(
                      ['chr1', '8000', '9000', '.', '.', '-']))
开发者ID:ml4wc,项目名称:pybedtools,代码行数:11,代码来源:test1.py


示例12: test_gtf_gff_attrs

def test_gtf_gff_attrs():
    # smoke test.
    #
    # this has always worked:
    gff = ["chr1","fake","mRNA","51", "300",".", "+",".","ID=mRNA1;Parent=gene1;"]
    gff = pybedtools.create_interval_from_list(gff)
    gff.attrs

    # this previously failed because of the "=" in the attr string.
    gff = ['scaffold_52', 'Cufflinks', 'exon', '5478', '5568', '.', '+', '.', 'gene_id "XLOC_017766"; transcript_id "TCONS_00033979"; exon_number "6"; gene_name "g18412"; oId "PAC:26897502"; nearest_ref "PAC:26897502"; class_code "="; tss_id "TSS21210"; p_id "P18851";']
    gff = pybedtools.create_interval_from_list(gff)
    gff.attrs
开发者ID:ml4wc,项目名称:pybedtools,代码行数:12,代码来源:test1.py


示例13: _create_window

    def _create_window(self):
        istart = self.start  # interval start
        istop = self.start + self.size  # interval stop
        while istop < self.stop and istart < self.stop:
            window = map(str, [self.chrom, istart, istop])
            window = pybedtools.create_interval_from_list(window)
            yield window
            istart += self.slide
            istop += self.slide

        window = map(str, [self.chrom, istart, self.stop])
        window = pybedtools.create_interval_from_list(window)
        yield window
开发者ID:likit,项目名称:snpscan,代码行数:13,代码来源:snpscan.py


示例14: test_interval_index

def test_interval_index():
    """
    supplement to the more general test in test_cbedtools.IntervalTest.testGetItemNegative
    """
    iv = pybedtools.create_interval_from_list('chr21   9719768 9721892 ALR/Alpha       1004    +'.split())
    assert iv[-1] == '+'
    assert iv[2:-1] == ['9721892', 'ALR/Alpha', '1004']

    iv = pybedtools.create_interval_from_list(
            ['chr1', 'ucb', 'gene', '465', '805', '.', '+', '.',
                'ID=thaliana_1_465_805;match=scaffold_801404.1;rname=thaliana_1_465_805'])
    print iv[4:-3]
    assert iv[4:-3] == ['805', '.']
开发者ID:ml4wc,项目名称:pybedtools,代码行数:13,代码来源:test1.py


示例15: get_bedtool_iter

 def get_bedtool_iter():
     for gene_num, gene_entry in table.iterrows():
         chrom = gene_entry["chrom"]
         start = int(gene_entry["txStart"]) + 1
         end = int(gene_entry["txEnd"])
         strand = gene_entry["strand"]
         # Annotation fields
         name2 = gene_entry["name2"]
         if pandas.isnull(name2):
             name2 = "NA"
         refseq_id = gene_entry["refseq"]
         if pandas.isnull(refseq_id):
             refseq_id = "NA"
         gene_symbol = gene_entry[gene_symbol_col]
         if pandas.isnull(gene_symbol):
             gene_symbol = "NA"
         attributes = \
             "ID=%s;ensg_id=%s;refseq_id=%s;gsymbol=%s;" \
             %(name2,
               name2,
               refseq_id,
               gene_symbol)
         # Convert table to BedTool
         gff_entry = [chrom,
                      "genes_table",
                      "gene",
                      str(start),
                      str(end),
                      ".",
                      strand,
                      ".",
                      attributes]
         gff_interval = \
             pybedtools.create_interval_from_list(gff_entry)
         yield gff_interval
开发者ID:1eesh,项目名称:rnaseqlib,代码行数:35,代码来源:gff_annotate_events.py


示例16: test_shift_of_0

 def test_shift_of_0(self):
     feature = pybedtools.create_interval_from_list(['chr2L', '60', '80', '.', '.', '+'])
     x, y = self.m.local_coverage(feature, fragment_size=5, shift_width=0)
     pp(zip(x,y))
     assert zip(x, y) == \
         [(60, 0),
          (61, 0),
          (62, 0),
          (63, 0),
          (64, 0),
          (65, 0),
          (66, 0),
          (67, 0),
          (68, 0),
          (69, 0),
          (70, 2),
          (71, 2),
          (72, 2),
          (73, 2),
          (74, 2),
          (75, 0),
          (76, 0),
          (77, 0),
          (78, 0),
          (79, 0)]
开发者ID:tanglingfung,项目名称:metaseq,代码行数:25,代码来源:test.py


示例17: test_shiftwidth_and_fragmentsize

 def test_shiftwidth_and_fragmentsize(self):
     #
     # Reads on opposite strands shift oppositely...
     #
     #      |||||   original
     #
     #    +|||||    minus strand read, leftshift 1 and additional to left (3')
     #       |||||+ plus strand read, rightshift 1 and additional to right (3')
     #    111222111
     feature = pybedtools.create_interval_from_list(['chr2L', '60', '80', '.', '.', '+'])
     x, y = self.m.local_coverage(feature, fragment_size=6, shift_width=1)
     pp(zip(x, y))
     assert zip(x, y) == \
         [(60, 0),
          (61, 0),
          (62, 0),
          (63, 0),
          (64, 0),
          (65, 0),
          (66, 0),
          (67, 0),
          (68, 1),
          (69, 1),
          (70, 1),
          (71, 2),
          (72, 2),
          (73, 2),
          (74, 1),
          (75, 1),
          (76, 1),
          (77, 0),
          (78, 0),
          (79, 0)]
开发者ID:tanglingfung,项目名称:metaseq,代码行数:33,代码来源:test.py


示例18: test_shiftwidth_of_1_plus_only

 def test_shiftwidth_of_1_plus_only(self):
     # The plus-strand read should shift right by 1
     feature = pybedtools.create_interval_from_list(['chr2L', '0', '20', '.', '.', '+'])
     x, y = self.m.local_coverage(feature, fragment_size=5, shift_width=1)
     pp(zip(x, y))
     assert zip(x, y) == \
         [(0, 0),
          (1, 0),
          (2, 0),
          (3, 0),
          (4, 0),
          (5, 0),
          (6, 0),
          (7, 0),
          (8, 0),
          (9, 0),
          (10, 0),
          (11, 1),
          (12, 1),
          (13, 1),
          (14, 1),
          (15, 1),
          (16, 0),
          (17, 0),
          (18, 0),
          (19, 0)]
开发者ID:tanglingfung,项目名称:metaseq,代码行数:26,代码来源:test.py


示例19: __getitem__

    def __getitem__(self, key):
        chrom = key.chrom
        start = key.start
        stop = key.end
        try:
            bx_intervals = self.fileobj.get(chrom, start, stop)
        except StrandFormatError:
            raise NotImplementedError(dedent(
                """
                It appears you have a version of bx-python where bigBed files
                are temporarily unsupported due to recent changes in the
                bx-python dependency. In the meantime, please convert bigBed to
                BAM like this:

                    bigBedToBed {0} tmp.bed
                    bedtools bedtobam -i tmp.bed > {0}.bam

                and create a genomic signal object using this {0}.bam file.
                """.format(self.fn)))
        if bx_intervals is None:
            raise StopIteration
        for i in bx_intervals:
            interval = pybedtools.create_interval_from_list(i.fields)
            interval.file_type = 'bed'
            yield interval
开发者ID:bakerwm,项目名称:metaseq,代码行数:25,代码来源:filetype_adapters.py


示例20: test_plus_feature

    def test_plus_feature(self):
        # first make one where fragments are exactly as long as reads

        feature = pybedtools.create_interval_from_list(['chr2L', '0', '20', '.', '.', '+'])
        x, y = self.m.local_coverage(feature, fragment_size=5)
        pp(zip(x,y))
        assert zip(x, y) == \
                [(0, 0),
                 (1, 0),
                 (2, 0),
                 (3, 0),
                 (4, 0),
                 (5, 0),
                 (6, 0),
                 (7, 0),
                 (8, 0),
                 (9, 0),
                 (10, 1),
                 (11, 1),
                 (12, 1),
                 (13, 1),
                 (14, 1),
                 (15, 0),
                 (16, 0),
                 (17, 0),
                 (18, 0),
                 (19, 0)]
开发者ID:tanglingfung,项目名称:metaseq,代码行数:27,代码来源:test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python pybedtools.example_bedtool函数代码示例发布时间:2022-05-25
下一篇:
Python pybedtools.cleanup函数代码示例发布时间: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