## Utilities / Convert BAM to BED

### Description

Converts BAM alignments to BED6, BED12 or BEDPE format.

### Parameters

- Output type (BED6, BED12, BEDPE) [BED6]
- Report split BAM alignments as separate BED entries (yes, no) [no]
- Use BAM edit distance for BED score (yes, no) [no]
- Color string (0-255,0-255,0-255) [255,0,0]
- Add the CIGAR string (yes,no) [no]

### Details

bamToBed is a general purpose tool that will convert sequence alignments in BAM format to either BED6, BED12 or BEDPE format. This enables one to convert BAM files for use with all of the other BEDTools. The CIGAR string is used to compute the alignment end coordinate in an “ungapped” fashion. That is, match (“M”), deletion (“D”), and splice (“N”) operations are observed when computing alignment ends.

Note that when selecting BEDPE format, it is required that the BAM file is sorted/grouped by the read name. This allows bamToBed to extract correct alignment coordinates for each end based on their respective CIGAR strings. It also assumes that the alignments for a given pair come in groups of twos.

### Output

The output is a BED6, BED12 or BEDPE format depending on the selected parameter.

### References

This tool uses the BEDTools package. Please cite the article:

Quinlan AR and Hall IM, 2010. BEDTools: a flexible suite of utilities for comparing genomic features. Bioinformatics. 26, 6, pp. 841–842.

Please see the BEDTools homepage for more details.