Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

samtools coverage fails to parse the regions #1461

Closed
Lyn16 opened this issue Jul 1, 2021 · 2 comments · Fixed by #1462
Closed

samtools coverage fails to parse the regions #1461

Lyn16 opened this issue Jul 1, 2021 · 2 comments · Fixed by #1462
Assignees

Comments

@Lyn16
Copy link

Lyn16 commented Jul 1, 2021

Hello,
I am using samtools to get coverage for each chromosome and some specific region.
Here is the code:
samtools coverage -r chr1:1M-12M /Users/lyn/seq_data/WGSdata/tumor_sample_raw_data/Bam/CN9R1_1.final.bam

and error looks like this:

samtools coverage: Failed to parse region "chr1:1M-12M": No such file or directory

I wonder if the problem comes from how I write the specific region? Thanks!

@valeriuo valeriuo self-assigned this Jul 1, 2021
@valeriuo
Copy link
Contributor

valeriuo commented Jul 1, 2021

The most probable cause is that chr1 does not exist as a contig name in the BAM file header. You can inspect all the contig names with the following command (assuming SN is the 2nd column) :

samtools view -H /Users/lyn/seq_data/WGSdata/tumor_sample_raw_data/Bam/CN9R1_1.final.bam | grep "^@SQ" | cut -f2

Maybe the chr prefix has been dropped, in which case you should adjust your query to match it:
samtools coverage -r 1:1M-12M ...

However, the error message is misleading and this is on us to fix.

@Lyn16
Copy link
Author

Lyn16 commented Jul 2, 2021

Thanks! I checked the contig names with the code you provided, indeed the 'chr' prefix has been dropped in my bam files. And the code is working now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants