UPDATE: Partly solved. It works without sorted option and now I do not need this option. However, the original question remains the same - how to calculate coverage from .bam file using `-sorted` option. I added dummy region from MT to the .bed file - it did not work.

Have a problem with coverageBed. Run command:

    covBed -d -sorted -b Sample.realigned.dm.recalibrated.bam -a srt.bed

Get output:

```
ERROR: Database file Sample.realigned.dm.recalibrated.bam contains chromosome , but the query file does not.
       Please re-reun with the -g option for a genome file.
       See documentation for details.
```

How to solve it? (https://www.biostars.org/p/159721/ - was not really helpful). It works without `-sorted` option.

My **bed file** chromosomes:

```
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
X
Y
```

**Bam file**:

```
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
X
Y
MT
```
Have you actually tried to pass a genome file to coverageBed? As I remember, coverageBed will complain even if chrom names are the same and in the same order but one chrom is missing from one of the two inputs, as for example chrom MT in your case. You can obtain the genome file from UCSC with e.g:

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

Or from the bam file header with:

    samtools view -H aln.bam \
    | grep -P "@SQ\tSN:" \
    | sed 's/@SQ\tSN://' \
    | sed 's/\tLN:/\t/' > genome.txt

Then run `coverageBed -g genome.txt ...`