本文整理汇总了Python中pybedtools.BedTool.each方法的典型用法代码示例。如果您正苦于以下问题:Python BedTool.each方法的具体用法?Python BedTool.each怎么用?Python BedTool.each使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pybedtools.BedTool
的用法示例。
在下文中一共展示了BedTool.each方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BedTool
# 需要导入模块: from pybedtools import BedTool [as 别名]
# 或者: from pybedtools.BedTool import each [as 别名]
logging.basicConfig(level=logging.DEBUG, format="%(asctime)s - %(filename)s - %(levelname)s - %(message)s")
elif args.verbose:
logging.basicConfig(level=logging.INFO, format="%(filename)s - %(levelname)s - %(message)s")
else:
logging.basicConfig(format="%(filename)s - %(levelname)s - %(message)s")
logging.info("Parsed arguments:")
if args.outfile:
logging.info(" outfile: enabled writing to file")
logging.info(" outfile: '{}'".format(args.outfile))
logging.info(" outfile: '{}'".format(args.outfile))
logging.info("")
# data processing
alns = BedTool(args.infile)
# select either from 5' or 3'-end
if args.threeprime:
clnts = alns.each(three_prime, upstream=0, downstream=1)
else:
clnts = alns.each(five_prime, upstream=1, downstream=0)
# write to file or to stdout
if args.outfile:
clnts.saveas(args.outfile)
else:
tmptool = clnts.saveas()
logging.debug("results written to temporary file :" + tmptool.fn)
tmp = open(tmptool.fn)
for line in tmp:
stdout.write(line)
tmp.close()
示例2: str
# 需要导入模块: from pybedtools import BedTool [as 别名]
# 或者: from pybedtools.BedTool import each [as 别名]
#!/usr/bin/env python
import os
import sys
import subprocess
sys.path.insert(0,'/mnt/lustre/home/cusanovich/Programs/lib/python2.6/site-packages/pybedtools-0.6.2-py2.6-linux-x86_64.egg/pybedtools')
from pybedtools import BedTool, featurefuncs
windowsize = 10000
windowname = str(windowsize/1000) + 'kb'
indir = '/mnt/lustre/home/cusanovich/Kd_Arrays/GenomeAnnotations/StartAnnots/'
outdir = '/mnt/lustre/home/cusanovich/Kd_Arrays/GenomeAnnotations/FinalAnnots/'
annots = ['GSE31388_eQtlTable_cleaned.bed','sorted_PritchardQTLs_merged.bed','gwascatalog_ucsc_merged.bed']
#annots = ['GSE31388_eQtlTable_cleaned.bed']
jacked = BedTool('/mnt/lustre/home/cusanovich/centipede/hg19_jack_centipede_sorted_pwms_clean.bed')
tss = BedTool('/mnt/lustre/home/cusanovich/Kd_Arrays/Centipede/Annotation/HT12ensemblTSScombinedsorted.bed')
for annot in annots:
print annot
currannot = BedTool(indir + annot)
currout = annot.split('.')[0]
print 'Intersecting...'
inter = jacked.intersect(currannot,wa=True,wb=True).moveto(outdir + windowname + '_' + currout + '_centipede_intersect.bed')
inter = BedTool(outdir + windowname + '_' + currout + '_centipede_intersect.bed')
print 'Calculating midpoints...'
intermid = inter.each(featurefuncs.midpoint).moveto(outdir + windowname + '_' + currout + '_centipede_intersect_midpoint.bed')
print 'Finding TSSs...'
inter = BedTool(outdir + windowname + '_' + currout + '_centipede_intersect_midpoint.bed')
outter = tss.window(intermid,w=windowsize).moveto(outdir + windowname + '_' + currout + '_insite.bed')
示例3: reader
# 需要导入模块: from pybedtools import BedTool [as 别名]
# 或者: from pybedtools.BedTool import each [as 别名]
core_reader = reader(core_tabseq, delimiter="\t")
fdown_reader = reader(fdown_tabseq, delimiter="\t")
for fup, core, fdown in izip(fup_reader, core_reader, fdown_reader):
assert fup[0] == core[0] == fdown[0], "Error: sequence ids of cores and flanks don't match."
# setup fasta headers and sequences
fa_header = ">" + core[0]
seq_viewpoint = fup[1].lower() + core[1].upper() + fdown[1].lower()
# seq_normal = fup[1].upper() + core[1].upper() + fdown[1].upper()
viewpointfa.write(fa_header + "\n")
viewpointfa.write(seq_viewpoint + "\n")
viewpointfa.close()
# prepare input coordinates
bsites = BedTool(args.bsites_fn).sort().saveas()
centers = bsites.each(midpoint).saveas()
# prepare positive instances
logging.info("preparing positive instances")
if (args.chromosome_limits):
logging.debug("using chromosome_limits " + args.chromosome_limits)
cores = centers.slop(s=True,
l=int(args.core_length / 2),
# -1 to account for the center nucleotide!
r=int(args.core_length / 2) +
(args.core_length % 2) - 1,
g=args.chromosome_limits).each(offset_zero_by_one).saveas(pos_core_bed_fn)
else:
cores = centers.slop(s=True,
l=int(args.core_length / 2),
# -1 to account for the center nucleotide!
示例4: newber
# 需要导入模块: from pybedtools import BedTool [as 别名]
# 或者: from pybedtools.BedTool import each [as 别名]
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)