nonamecheck not working in bedtools coverage
1
0
Entering edit mode
6.4 years ago
roalva1 ▴ 90

Hello,

I am running this command line in bedtools 2.27.1

bedtools coverage -nonamecheck -d -sorted -a file.bed -b file.bam  > file.cov

and I get this error

ERROR: Database file file.bam contains chromosome chrM, but the query file does not.
       Please rerun with the -g option for a genome file.
       See documentation for details.

I don't have access to the genome file and I guess nonamecheck is not working,

Thanks a lot

Best regards

bedtools • 3.1k views
ADD COMMENT
3
Entering edit mode
6.4 years ago

Hello,

the genome file is need if you want to use -sorted. You can extract this information from your bam file as all informations are in the header.

$ samtools view -H file.bam|grep @SQ|sed 's/@SQ\tSN://'|sed 's/LN://' > genome.txt

fin swimmer

(I'm sure there is more beautiful sed command ;) )


Edit: Just for documentation the sed commands can be combined in one:

sed 's/@SQ\tSN:\|LN://g'
ADD COMMENT
0
Entering edit mode

Wouldn't be -nonamecheck enaugh for this?

-nonamecheck    For sorted data, don't throw an error if the file has different naming conventions
        for the same chromosome. ex. "chr1" vs "chr01".
ADD REPLY
0
Entering edit mode

Are you mixing and matching the genomes by any chance? BED file from one provider where as BAM aligned to a different one?

ADD REPLY
0
Entering edit mode

No no, I have got just a bam

ADD REPLY
0
Entering edit mode

Hm, I don't know what -nonamecheck does behind the scene.. Maybe it just ignores lower/upper cases and leading zeros?

genomax suggested to me, that it also could be a naming mismatch between the bam file and your bed file. How is the name for chrM in the bed file? Maybe chrMT or just MT.?

fin swimmer

ADD REPLY
0
Entering edit mode

My bed file doesn't have any region in chrMT nor chrM

ADD REPLY
0
Entering edit mode

Interesting. Then why are you getting this? Or you just don't have any chrM regions in your bed file (and that is just a warning).

Database file file.bam contains chromosome chrM, but the query file does not.

ADD REPLY
0
Entering edit mode

Yes, I don't have any chrM regions in my bed file, but I do have in my bam. The message of bedtools should be a warning but it is not. Bedtools stops and the coverage in chrX regions are not calculated.

ADD REPLY
0
Entering edit mode

This has solved my problem, but still, with bedtools 2.17 we didn't need this, and I think it is not intuitive.

ADD REPLY
0
Entering edit mode

You can accept @fin swimmer's answer (green check mark) to provide to closure to this thread since your problem is solved.

ADD REPLY

Login before adding your answer.

Traffic: 1704 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6