本文整理汇总了Python中pybedtools.BedTool.cat方法的典型用法代码示例。如果您正苦于以下问题:Python BedTool.cat方法的具体用法?Python BedTool.cat怎么用?Python BedTool.cat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybedtools.BedTool
的用法示例。
在下文中一共展示了BedTool.cat方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_remainder
# 需要导入模块: from pybedtools import BedTool [as 别名]
# 或者: from pybedtools.BedTool import cat [as 别名]
def generate_remainder(whole_bed, bed_prefix, bed_list):
"""
Calculate the remaining regions that are not included in the truth set
:param whole_bed: path to the truth regions for the whole panel
:param bed_prefix: prefix used for all the bed files
:param bed_list: list of all the bed files for that panel
:return: BEDTool containing any regions that are completely missing from the truth regions
"""
whole_truth = BedTool(whole_bed)
whole_truth.saveas()
whole = BedTool()
for bed in bed_list:
print bed
tool = BedTool(bed)
tool.saveas()
if bed == bed_list[0]:
whole = tool
else:
whole = whole.cat(tool)
whole.saveas()
whole_sorted = whole.sort()
whole_merged = whole_sorted.merge()
whole_merged.saveas()
remainder = whole_merged.subtract(whole_truth)
remainder.moveto('/results/Analysis/MiSeq/MasterBED/GIAB/' + bed_prefix + '.remainder.bed')
missing_regions = whole_merged.subtract(whole_truth, A=True)
return missing_regions
示例2: GenomicSubset
# 需要导入模块: from pybedtools import BedTool [as 别名]
# 或者: from pybedtools.BedTool import cat [as 别名]
class GenomicSubset(object):
def __init__(self, name, path=paths.genome_subsets, assembly='hg19'):
self.assembly = assembly
self.name = name
self.bedtool = BedTool(path + name + '.bed').sort()
# Intersect the pathway with the appropriate genome build
# TODO: this step should be unnecessary if the pathways are correct
if name != self.assembly:
self.bedtool = GenomicSubset.reference_genome(
self.assembly).bedtool.intersect(self.bedtool).sort().saveas()
def expand_by(self, expansion_in_each_direction_Mb):
window_size_str = str(expansion_in_each_direction_Mb) + 'Mb'
print('total size before window addition:', self.bedtool.total_coverage(), 'bp')
# compute the flanks
# TODO: use 1cM instead of 1Mb
print('computing flanks')
flanks = self.bedtool.flank(
genome=self.assembly,
b=expansion_in_each_direction_Mb*1000000).sort().merge().saveas()
# compute the union of the flanks and the pathway
print('computing union')
union = self.bedtool.cat(flanks, postmerge=False).sort()
merged = union.merge().saveas()
print('total size after window addition:', merged.total_coverage(), 'bp')
self.bedtool = merged
def restricted_to_chrom_bedtool(self, chrnum):
return self.bedtool.filter(
lambda x : x[0] == 'chr' + str(int(chrnum))).saveas()
@classmethod
def reference_genome(cls, assembly='hg19'):
return GenomicSubset(assembly, path=paths.reference, assembly=assembly)
@classmethod
def reference_chrom_bedtool(cls, chrnum, assembly='hg19'):
return cls.reference_genome(assembly=assembly).restricted_to_chrom_bedtool(chrnum)
@classmethod
def whole_genome(cls, assembly='hg19'):
return cls(assembly, path=paths.reference)
示例3: generate_remainder
# 需要导入模块: from pybedtools import BedTool [as 别名]
# 或者: from pybedtools.BedTool import cat [as 别名]
def generate_remainder(whole_bed, out_dir, bed_list):
"""
Calculate the remaining regions that are not included in the truth set
:param whole_bed: Path to the truth regions for the whole panel
:type whole_bed: String
:param out_dir: Prefix used for all the bed files
:type out_dir: String
:param bed_list: List of all the bed files for that panel
:type bed_list: List of String
:return: BEDTool containing any regions that are completely missing from the truth regions
:rtype: BedTool
"""
try:
whole_truth = BedTool(whole_bed)
whole_truth.saveas()
whole = BedTool()
for bed in bed_list:
print(bed)
tool = BedTool(bed)
tool.saveas()
if bed == bed_list[0]:
whole = tool
else:
whole = whole.cat(tool)
whole.saveas()
whole_sorted = whole.sort()
whole_merged = whole_sorted.merge()
whole_merged.saveas()
remainder = whole_merged.subtract(whole_truth)
remainder.moveto(out_dir + '/remainder.bed')
missing_regions = whole_merged.subtract(whole_truth, A=True)
except UnicodeDecodeError:
missing_regions = None
return missing_regions
示例4: merge
# 需要导入模块: from pybedtools import BedTool [as 别名]
# 或者: from pybedtools.BedTool import cat [as 别名]
def merge(regulators):
"""Merge a list of regulators using BedTool.cat"""
if len(regulators) > 1:
return BedTool.cat(*regulators, postmerge=False)
else:
return regulators[0]
示例5: return
# 需要导入模块: from pybedtools import BedTool [as 别名]
# 或者: from pybedtools.BedTool import cat [as 别名]
sorting.wait()
return(0)
def newber(binner,factor):
"""Returns bed record with all binding for a factor merged and renamed."""
newbie = BedTool(binner).sort().merge(nms=True).each(featurefuncs.midpoint)
newbie = newbie.each(featurefuncs.rename,factor)
return(newbie)
print "Loading bed files..."
tssbed = BedTool(tsss)
jacker = BedTool(jacked)
chiper = BedTool(chiped)
print "Combining binding files..."
comber = chiper.cat(jacker,force_truncate=False,postmerge=False).moveto('./combtemp.bed')
#print "Generating oldstyle bed file..."
#oldstyle = comber.each(featurefuncs.midpoint)
#oldstyle2 = bedmaker(oldstyle,tssbed,oldout)
print "Generating newstyle bed files..."
for factor in sorted(pwmlist.keys()):
print factor
for model in pwmlist[factor]:
print model
grepper = 'grep ' + model + ' ./combtemp.bed >> ./temp1.bed'
grepping = subprocess.Popen(grepper,shell=True)
grepping.wait()
newbie = newber('./temp1.bed',factor)
newbie2 = bedmaker(newbie,tssbed,outdir + factor + '_midpoint_sorted.bed',unmatched=False)