bedtools2
bedtools2 copied to clipboard
terminate called after throwing an instance of 'std::out_of_range'
I'm having an issue with bedtools coverage throwing this error:
terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::substr Aborted
The command is as follows: bedtools coverage -counts -a in.gtf -b in.bam > out.counts
Its happening with multiple data sources, not limited to a specific bam file. The input files were mapped with bowtie, and can be viewed without a problem in IGV. I can find a little bit of documentation for this error for a different bedtools command, but nothing that addresses this problem.
What version of bedtools? Could you see if the problem exists with the current version (2.28.0)? Could you share a minimal bam file and gtf that create this problem? Without test data, it will be difficult to track down.
Hi @signor-molevol and @arq5x,
Wondering whether you were able to sort this issue out. Does the new version of bedtools
had this fixed? I'm facing the same issue processing a cellranger output bam
file with bedtools/2.26.0
.
The error specifically is:
terminate called after throwing an instance of 'std::out_of_range'
what(): basic_string::substr
Aborted (core dumped)
My sorted x.bam
file` looks like this:
NB500916:538:H53VMBGXB:2:12112:24730:13694 1107 1 9997 0 8S64M = 10052 -9 TAGTCAAACCGATACCCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCC <//////E/////E/E<EEEEEEAEE/AEEEE//AEEE/EEAEEEEEEEEAEEAEEEEEEAEEEEE6AAAAA NM:i:1 MD:Z:6A57 MC:Z:59M13S AS:i:59 XS:i:59 CR:Z:TAGCCGGCACGTACAT CY:Z:EEEEEEAEEEEA/AAA CB:Z:TAGCCGGCACGTACAT-1 BC:Z:CAGTCTGG QT:Z:AAAAAEEE GP:i:10060 MP:i:10051 MQ:i:0 RG:Z:cellmix_ATACseq:MissingLibrary:1:H53VMBGXB:2
NB500916:538:H53VMBGXB:3:11401:25100:3089 99 1 9998 0 51M21S = 10183 236 CCATAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCGTGGCACTTAGACTCATCGAC AA/AAEAEEEEEEEEAEEEEAE/AAEEAEEEEEEEEAEEEA/EE<</E//<////E//////////A////A NM:i:1 MD:Z:1G49 MC:Z:21S51M AS:i:49 XS:i:49 CR:Z:ATGTAGACAAAGTAAG CY:Z:/EEE//EEAEEA6AAA CB:Z:ATGTCGACAAAGGAAG-1 BC:Z:TCACACTC QT:Z:AAAAAEEE GP:i:9997 MP:i:10233 MQ:i:0 RG:Z:cellmix_ATACseq:MissingLibrary:1:H53VMBGXB:3
NB500916:538:H53VMBGXB:4:13505:6021:18953 163 1 9998 0 49M23S = 10005 79 CCATAACCCTAACCCTAACCCTAACCCTAACCATAACCCTAACCCTAACAATAACACTAACACAAAAAAAAA AA/AAEEEEAEEEEEAEEEEEEEAEAAEEAEE//EAEA<AE//A//</A///E/EE6/E/////<A/<//EE NM:i:2 MD:Z:1G30C16 MC:Z:72M AS:i:42 XS:i:43 CR:Z:CGCAGGTAGTGTAATG CY:Z:EAAAEAE/EA/AA/A6 CB:Z:CGCAGGTAGTGTAATG-1 BC:Z:ATTGGGAA QT:Z:AAAAAEEE GP:i:9997 MP:i:10076 MQ:i:0 RG:Z:cellmix_ATACseq:MissingLibrary:1:H53VMBGXB:4
NB500916:538:H53VMBGXB:4:23608:22302:19204 147 1 9998 0 9S63M = 10021 -40 ATACCTAATCGATAACCCTATCCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCCTAACCC <//////A/////////////E///A/A//////66//E//EE/EEAE//EEEEEEEEEEEEEEEEEAAAAA NM:i:1 MD:Z:11A51 MC:Z:72M AS:i:58 XS:i:55 CR:Z:CCAGAATAGGTTAGTA CY:Z:EEEEEEAEAEEAAAAA CB:Z:CCAGAATAGGTTAGTA-1 BC:Z:CTTTCGAC QT:Z:AAAAAEAE GP:i:10060 MP:i:10020 MQ:i:0 RG:Z:cellmix_ATACseq_Lib10:MissingLibrary:1:H53VMBGXB:4
NB500916:538:H53VMBGXB:4:11408:6721:18214 147 1 9998 0 40S32M = 10010 -20 TTTATCCTAATTGTCTTTTTACTGATAACCCTATCCTTATCGATAACCCTAACCCTAACCCTAACCCTAACC ///////E/////E///////////E////66///</E////////////E///AEE/E6EAEEEEEAA//6 NM:i:0 MD:Z:32 MC:Z:72M AS:i:32 XS:i:30 CR:Z:TGAGTCAGTATCCTTT CY:Z:EAEEEAEEAAEAAAAA CB:Z:TGAGTCAGTATCCTTT-1 BC:Z:ATTGGGAA QT:Z:A/AAAEEA GP:i:10029 MP:i:10009 MQ:i:0 RG:Z:cellmix_ATACseq:MissingLibrary:1:H53VMBGXB:4
My custom sorted y.bed
file looks like this:
1 135211 135302 . . + new exon . exon_id=exon:135212_135302;Parent=transcript:ENSG00000015171.19_135212_248990_1;rank=1
1 135454 135559 . . + new exon . exon_id=exon:135455_135559;Parent=transcript:ENSG00000015171.19_135455_211023_1;rank=1
1 135454 135559 . . + new exon . exon_id=exon:135455_135559;Parent=transcript:ENSG00000015171.19_135455_248608_1;rank=1
1 135522 135559 . . + new exon . exon_id=exon:135523_135559;Parent=transcript:ENSG00000015171.19_135523_210993_1;rank=1
1 248973 249088 . . + new exon . exon_id=exon:248974_249088;Parent=transcript:ENSG00000015171.19_248974_254634_1;rank=1
1 814945 815060 . . - new exon . exon_id=exon:814946_815060;Parent=transcript:ENSG00000107929.14_811213_815060_1;rank=3
1 829384 829496 . . - new exon . exon_id=exon:829385_829496;Parent=transcript:ENSG00000107929.14_811806_829496_1;rank=8
1 988433 988527 . . + new exon . exon_id=exon:988434_988527;Parent=transcript:ENSG00000107937.18_988434_1010517_1;rank=1
1 988433 988527 . . + new exon . exon_id=exon:988434_988527;Parent=transcript:ENSG00000107937.18_988434_1017691_1;rank=1
1 988433 988527 . . + new exon . exon_id=exon:988434_988527;Parent=transcript:ENSG00000107937.18_988434_1017691_3;rank=1
I used the following script to get the output
bedtools coverage -hist -abam x.bam -b y.bed > coverage.tab
Also ran into this issue on version v2.26.0:
what(): vector::_M_range_check: __n (which is 21840194) >= this->size() (which is 2779)
Aborted
Using version v2.29.0 fixed the issue.
I use this script bamToBed -i test.sort.bam -cigar -bed12 > test.bed get same error ! on version 2.23.0