pybedtools.bedtool.BedTool.cat

BedTool.cat(*args, **kwargs)[source]

Concatenate interval files together.

Concatenates two BedTool objects (or an object and a file) and does an optional post-merge of the features.

postmerge=True by default; use postmerge=False if you want to keep features separate.

force_truncate=False by default; force_truncate=True to truncate all files to chrom, start, stop.

When force_truncate=False and postmerge=False, the output will contain the smallest number of fields observed across all inputs. This maintains compatibility with BEDTools programs, which assume constant number of fields in all lines of a file.

Other kwargs are sent to BedTool.merge() (and assuming that postmerge=True).

Example usage:

>>> a = pybedtools.example_bedtool('a.bed')
>>> b = pybedtools.example_bedtool('b.bed')
>>> print(a.cat(b)) 
chr1    1       500
chr1    800     950

>>> print(a.cat(*[b,b],
...   postmerge=False)) 
chr1    1       100     feature1        0       +
chr1    100     200     feature2        0       +
chr1    150     500     feature3        0       -
chr1    900     950     feature4        0       +
chr1    155     200     feature5        0       -
chr1    800     901     feature6        0       +
chr1    155     200     feature5        0       -
chr1    800     901     feature6        0       +