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


Python BedTool.count方法代码示例

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


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

示例1: comp_score

# 需要导入模块: from pybedtools import BedTool [as 别名]
# 或者: from pybedtools.BedTool import count [as 别名]
 def comp_score(self, gap_penalty):
     '''compute_score_given_gap_penalty'''
     if gap_penalty in self.__cache:
         return self.__cache[gap_penalty]['score']
     
     gb = self.orig_bins.scale_neg_scores(gap_penalty)
     observed_result = gb.max_segments()
     mc_res = MonteCarlo.run_simulation(gb.chrom_scores, 
                                        niter=self.mc_trials, nprocs=self.nprocs)
     tester = IntervalTest(observed_result, mc_res)
     segments = [segment for (segment, pval) in tester.pvalues()
                 if pval < self.pval_lim]
     if len(segments) == 0:
         # no potential peaks found
         log.notice('''Gap penalty of %.2f gives a score of 0.0 \
         (0 potential peaks with 0.00MB coverage)''' % gap_penalty)
         self.__cache[gap_penalty] = {'score': 0.00}
         return 0.0
     # TODO use bx.python instead of pybedtools
     peaks_sb = StringIO.StringIO()
     tester.segments_to_bedstream(segments, peaks_sb)
     peaks = BedTool(peaks_sb.getvalue(), from_string=True)
     d = self.count_stats(self.bins_bedtool.intersect(peaks))
     d['gap-penalty'] = gap_penalty
     try:
         d['peak_EIB_ratio'] = d['EIB'] / float(d['EIB'] + d['DIB'])
     except ZeroDivisionError:
         # no peaks found
         d['peak_EIB_ratio'] = 0.0
     d['global_EIB_coverage'] = d['EIB'] / float(self.genome_wide_stats['EIB'])
     d['score'] = d['peak_EIB_ratio']**5 * d['global_EIB_coverage']
     peak_cov = sum(x.end - x.start for x in peaks) / 1e6
     log.notice('''Gap penalty of %.2f gives a score of %.3f \
     (%d potential peaks with %.2fMB coverage)''' % (gap_penalty, d['score'], peaks.count(), peak_cov))
     self.__cache[gap_penalty] = d
     return d['score']
开发者ID:CollasLab,项目名称:edd,代码行数:38,代码来源:estimate.py

示例2: main

# 需要导入模块: from pybedtools import BedTool [as 别名]
# 或者: from pybedtools.BedTool import count [as 别名]
def main():
	
	error_site = BedTool('/home/kwoklab-user/Error_exome_all.bed')
#	protein_coding_site = BedTool('/home/kwoklab-user/Shared_resources/gemini/data/gencode15.protein_coding.20130131.hg19.bed')
	gemini_data_dir = "/home/kwoklab-user/Shared_resources/gemini/data"

	dbsnp_137_site = BedTool('/home/kwoklab-user/Shared_resources/gemini/data/dbsnp.137.vcf.gz')
	#https://code.google.com/p/discovering-cse/
	cse_site = BedTool('/home/kwoklab-user/Shared_resources/gemini/data/cse-hiseq-8_4-2013-02-20.bed.gz')
#	gms_site = BedTools( path.join(gemini_data_dir, 'GRCh37-gms-mappability.vcf.gz'))
	rmsk_site = BedTool(path.join(gemini_data_dir, 'hg19.rmsk.bed.gz'))
	segdup_site = BedTool(path.join(gemini_data_dir, 'hg19.segdup.bed.gz'))
	clinvar_site = BedTool(path.join(gemini_data_dir,'clinvar_20130118.vcf.gz'))
	dgv_site = BedTool(path.join(gemini_data_dir,'hg19.dgv.bed.gz'))
	CpG_site = BedTool(path.join(gemini_data_dir,'hg19.CpG.bed.gz'))
	
	print "total error sites %d" % error_site.count()
	print "error in cse site %d" % (error_site+cse_site).count()
	print "error in dbsnp137 site %d" %(error_site+dbsnp_137_site).count()
	print "errors in repeat mask region %d" % (error_site+rmsk_site).count()
	print "errors in segdup %d" % (error_site+segdup_site).count()
	print "errors in Clinvar %d" % (error_site+clinvar_site).count()
	print "errors in dgv %d" % (error_site+dgv_site).count()
	print "errors in CpG %d" % (error_site+CpG_site).count()
开发者ID:tanglingfung,项目名称:projects,代码行数:26,代码来源:compare-bed.py

示例3: BedTool

# 需要导入模块: from pybedtools import BedTool [as 别名]
# 或者: from pybedtools.BedTool import count [as 别名]
split_num = 100

split_region_list = [[]*5]
print split_region_list
bed = BedTool('/Users/huangzhibo/workitems/10.testData/testPlatformTJ/bed/test.bed')


bed = BedTool(bed.sort().merge().window_maker(b=bed.fn, w=100))

bed.all_hits()

# x = BedTool().window_maker(genome='hg38', w=1000000)
bed.saveas('/Users/huangzhibo/workitems/10.testData/testPlatformTJ/bed/test_w100.bed')

split_num = bed.count() if bed.count() < split_num else split_num

print bed.count()/split_num

# print bed.split(10, 'out')

# print x

n = 0
for region in bed:
    # print region.length
    print str(region).strip()
    n += 1

print n
开发者ID:huangzhibo,项目名称:HelloWorld,代码行数:31,代码来源:bed_split.py


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