01API

1.创建BedTool对象

##读取bed文件
>>> import pybedtools

>>> # use a BED file that ships with pybedtools...
>>> a = pybedtools.example_bedtool('a.bed')

>>> # ...or use your own by passing a filename
>>> a = pybedtools.BedTool('peaks.bed')

2.两个bed文件取交集intersection

查看intersection函数的参数?pybedtools.BedTool.intersect和环境变量中bedtools的版本是一样的

>>> a = pybedtools.example_bedtool('a.bed')
>>> b = pybedtools.example_bedtool('b.bed')
>>> a_and_b = a.intersect(b)
##使用loj参数
a_b=a.intersect(b,loj=True)
## 遍历结果文件
a_b.head()

3.保存结果文件saveas

4.过滤初始的输入bed文件

$\color{red}{ filter生成的迭代器只能被使用一次}$

You’ll need to be careful when using BedTool objects as generators, since any operation that reads all the features of a BedTool will consume the iterable.

5.根据bed文件提取序列

6.改变bed文件

7.删除临时文件

8.批量取交集

Last updated

Was this helpful?