Genomic Interval Manipulation


bedExtendRanges database length files(s)


This tool is part of UCSC Genome Browser's utilities.

The bedExtendRanges command extends the length of entries in BED 6+ data to be at least the given length, taking strand directionality into account.

Required arguments

  • database: Name of the reference genome. The name should be in UCSC's naming nomenclature. For example, if you are working with human reference genome GRCh38/hg38, you should use hg38 for this argument. A full list of supported genomes can be found here.
  • length: The desired minimum length for the extended entries.
  • files(s): The input file(s) containing BED data to be extended. If you want the tool to take input regions from standard input, you can leave "stdin" here. These file should hava at least 6 columns (with their strand information defined). If the files miss the strand information, exceptions like 
    Expecting at least 6 words line 1 of stdin got 3
    will be raised.


  • -host mysql host: Specifies the MySQL host to connect to.
  • -user mysql user: Specifies the MySQL user for authentication.
  • -password mysql password: Specifies the MySQL password for authentication.
  • -tab: Use tabs as separators instead of spaces.
  • -verbose N: Sets the verbose level for extra information to STDERR.


Default behavior

By default, bedExtendRanges extends certain bps (as defined by the length argument) from the start of each region. In the following case, regions will be redefined as starting from their original starts and stopping at 250-bp downstream to the starts.

Here is the input file for the demostration:

$ head input.bed
chr1	500	525	.	100	+
chr1	1000	1025	.	100	-

Now let's do the extension:

$ bedExtendRanges hg18 250 input.bed > output.bed
Reading input.bed
chr1 500 750 . 100 +
chr1 775 1025 . 100 -
# this is equivalent to the following
bedExtendRanges -user=genome hg18 250 input.bed > output.bed

If you want to get rid of the line "Reading xxx", just redirect standard error to /dev/null:

$ cat input.bed | bedExtendRanges hg18 250 stdin 2> /dev/null
chr1 500 750 . 100 +
chr1 775 1025 . 100 -
Extend from the center of the input regions

If you leave the strand field in the input file as ., then bedExtendRanges extends certain bps (as defined by the $\frac{length}{2}$) from the center of each region.

$ head input.bed
chr1    500    526    .    100    .
chr1    1000    1126    .    100    .

$ cat input.bed | bedExtendRanges hg18 250 stdin
Reading stdin
chr1 388 638 . 100 .
chr1 938 1188 . 100 .

File formats this tool works with

Share your experience or ask a question