pybedtools.bedtool.BedTool.window

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

Wraps bedtools window.

Example usage:

>>> a = pybedtools.example_bedtool('a.bed')
>>> b = pybedtools.example_bedtool('b.bed')
>>> print(a.window(b, w=1000)) 
chr1        1       100     feature1        0       +       chr1    155     200     feature5        0       -
chr1        1       100     feature1        0       +       chr1    800     901     feature6        0       +
chr1        100     200     feature2        0       +       chr1    155     200     feature5        0       -
chr1        100     200     feature2        0       +       chr1    800     901     feature6        0       +
chr1        150     500     feature3        0       -       chr1    155     200     feature5        0       -
chr1        150     500     feature3        0       -       chr1    800     901     feature6        0       +
chr1        900     950     feature4        0       +       chr1    155     200     feature5        0       -
chr1        900     950     feature4        0       +       chr1    800     901     feature6        0       +

For convenience, the file or stream this BedTool points to is implicitly passed as the -a argument to windowBed

Original BEDTools help::

Tool:    bedtools window (aka windowBed)
Version: v2.30.0
Summary: Examines a "window" around each feature in A and
         reports all features in B that overlap the window. For each
         overlap the entire entry in A and B are reported.

Usage:   bedtools window [OPTIONS] -a <bed/gff/vcf> -b <bed/gff/vcf>

Options: 
        -abam   The A input file is in BAM format.  Output will be BAM as well. Replaces -a.

        -ubam   Write uncompressed BAM output. Default writes compressed BAM.

        -bed    When using BAM input (-abam), write output as BED. The default
                is to write output in BAM when using -abam.

        -w      Base pairs added upstream and downstream of each entry
                in A when searching for overlaps in B.
                - Creates symmetrical "windows" around A.
                - Default is 1000 bp.
                - (INTEGER)

        -l      Base pairs added upstream (left of) of each entry
                in A when searching for overlaps in B.
                - Allows one to define asymmetrical "windows".
                - Default is 1000 bp.
                - (INTEGER)

        -r      Base pairs added downstream (right of) of each entry
                in A when searching for overlaps in B.
                - Allows one to define asymmetrical "windows".
                - Default is 1000 bp.
                - (INTEGER)

        -sw     Define -l and -r based on strand.  For example if used, -l 500
                for a negative-stranded feature will add 500 bp downstream.
                - Default = disabled.

        -sm     Only report hits in B that overlap A on the **same** strand.
                - By default, overlaps are reported without respect to strand.

        -Sm     Only report hits in B that overlap A on the **opposite** strand.
                - By default, overlaps are reported without respect to strand.

        -u      Write the original A entry **once** if **any** overlaps found in B.
                - In other words, just report the fact >=1 hit was found.

        -c      For each entry in A, report the number of overlaps with B.
                - Reports 0 for A entries that have no overlap with B.
                - Overlaps restricted by -w, -l, and -r.

        -v      Only report those entries in A that have **no overlaps** with B.
                - Similar to "grep -v."

        -header Print the header from the A file prior to results.