pybedtools.bedtool.BedTool.random

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

Wraps bedtools random.

Since this method does not operate on an existing file, create a BedTool with no arguments and then call this method, e.g.,

>>> x = BedTool()
>>> y = x.random(l=100, n=10, genome='hg19')

There are two alternatives for supplying a genome. Use g="genome.filename" if you have a genome’s chrom sizes saved as a file. This is the what BEDTools expects when using it from the command line. Alternatively, use the genome="assembly.name" (for example, genome="hg19") to use chrom sizes for that assembly without having to manage a separate file. The genome argument triggers a call pybedtools.chromsizes, so see that method for more details.

Original BEDTools help::

Tool:    bedtools random (aka randomBed)
Version: v2.30.0
Summary: Generate random intervals among a genome.

Usage:   bedtools random [OPTIONS] -g <genome>

Options: 
        -l      The length of the intervals to generate.
                - Default = 100.
                - (INTEGER)

        -n      The number of intervals to generate.
                - Default = 1,000,000.
                - (INTEGER)

        -seed   Supply an integer seed for the shuffling.
                - By default, the seed is chosen automatically.
                - (INTEGER)

Notes: 
        (1)  The genome file should tab delimited and structured as follows:
             <chromName><TAB><chromSize>

        For example, Human (hg19):
        chr1    249250621
        chr2    243199373
        ...
        chr18**gl000207**random 4262

Tips: 
        One can use the UCSC Genome Browser's MySQL database to extract
        chromosome sizes. For example, H. sapiens:

        mysql --user=genome --host=genome-mysql.cse.ucsc.edu -A -e \
        "select chrom, size from hg19.chromInfo"  > hg19.genome