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

terminate called after throwing an instance of 'std::out_of_range' what(): basic_string::at #550

Closed
sammyjava opened this issue Jun 18, 2019 · 13 comments
Labels

Comments

@sammyjava
Copy link

Hiya. I've seen a number of issues relating to the terminal error 'std::out_of_range' which in my case included what(): basic_string::at but I cannot seem to glean what the problem is with my run. I'm calling against the standard B73v4 maize genome FASTA. My BAM file is sorted by genomic position. I'm getting variant calls up to

1	3662246	.	A	G	198.143	.	AB=0.212644;ABP=127.808;AC=1;AF=0.5;AN=2;AO=37;CIGAR=1X;DP=174;DPB=174;DPRA=0;EPP=16.2152;EPPR=86.137;GTI=0;LEN=1;MEANALT=3;MQM=34.2162;MQMR=27.1719;NS=1;NUMALT=1;ODDS=45.624;PAIRED=1;PAIREDR=1;PAO=0;PQA=0;PQR=0;PRO=0;QA=1143;QR=3944;RO=128;RPL=24;RPP=10.1116;RPPR=9.79615;RPR=13;RUN=1;SAF=18;SAP=3.06899;SAR=19;SRF=83;SRP=27.5072;SRR=45;TYPE=snp	GT:DP:AD:RO:QR:AO:QA:GL	0/1:174:128,37:128:3944:37:1143:-39.1581,0,-193.661

after which the run terminates with the following at the bottom of the -d output:

allele group S:3662267:1X:A
unknown:A00197:131:HKGFKDSXX:4:1612:13720:8343:snp:1:1:3662267:+:A:3662267:1X:-8.5:-2.5
allele group S:3662267:1X:T
unknown:A00197:131:HKGFKDSXX:4:1470:30454:16564:snp:1:1:3662267:+:T:3662267:1X:-8.5:-8.5|unknown:A00197:131:HKGFKDSXX:4:1322:18484:33035:snp:1:1:3662267:-:T:3662267:1X:-8.5:-8.5|unknown:A00261:128:HGVTKDSXX:4:2353:19750:24298:snp:1:1:3662267:-:T:3662268:1X:-8.5:-2.5|unknown:A00197:131:HKGFKDSXX:4:1474:29749:33505:snp:1:1:3662267:+:T:3662267:1X:-8.5:-8.5|unknown:A00261:128:HGVTKDSXX:4:1657:13413:18051:snp:1:1:3662267:-:T:3662267:1X:-8.5:-2.5|unknown:A00197:131:HKGFKDSXX:4:1470:28067:17628:snp:1:1:3662267:+:T:3662267:1X:-8.5:-8.5|unknown:A00197:131:HKGFKDSXX:4:1116:23041:12461:snp:1:1:3662267:-:T:3662267:1X:-8.5:-2.5
found genotype alleles
filtering genotype alleles which are not supported by at least 2 observations comprising at least 0.05000 of the observations in a single individual
genotype allele: reference:1M:3662267:1:C qsum 5889
reference:1M:3662267:1:C has support of 169 in individual unknown (177 obs) and fraction 0.95480
genotype allele: snp:1X:3662267:1:A qsum 11
genotype allele: snp:1X:3662267:1:T qsum 181
filtered genotype alleles
adding allele to result alleles C
built haplotype alleles, now there are 1 genotype alleles
reference:1M:3662267:1:C
no alternate genotype alleles passed filters at 1:3662267
processing position 3662269 in sequence 1
alignment: A00197:131:HKGFKDSXX:4:1304:9091:13228
position: 1:3662269 coverage: 177
insufficient alternate observations
processing position 3662270 in sequence 1
position: 1:3662270 coverage: 175
insufficient alternate observations
processing position 3662271 in sequence 1
alignment: A00197:131:HKGFKDSXX:4:2644:31548:14450
skipping alignment A00197:131:HKGFKDSXX:4:2644:31548:14450 because it is not marked primary
alignment: A00261:128:HGVTKDSXX:4:2506:21730:12947
alignment: A00197:131:HKGFKDSXX:4:1340:30472:29684
alignment: A00197:131:HKGFKDSXX:4:2314:29577:22592
position: 1:3662271 coverage: 176
insufficient alternate observations
processing position 3662272 in sequence 1
alignment: A00197:131:HKGFKDSXX:4:2153:19407:24111
terminate called after throwing an instance of 'std::out_of_range'
  what():  basic_string::at

Any suggestions on what I can do to get a full variant call to complete? FWIW, bcftools mpileup works fine with the following command line:

bcftools mpileup -f $FASTA $PREFIX.f2.sorted.bam | bcftools call -mv -Ov -o $PREFIX.f2.sorted.vcf\
@ekg
Copy link
Collaborator

ekg commented Jun 18, 2019 via email

@sammyjava
Copy link
Author

sammyjava commented Jun 18, 2019

$ freebayes --version
version:  v1.3.1-12-g06fe585

The FASTA can be the maize chromosome 1 FASTA,
ftp://ftp.ensemblgenomes.org/pub/plants/release-43/fasta/zea_mays/dna/Zea_mays.B73_RefGen_v4.dna.chromosome.1.fa.gz

The BAM file is rather large, 230 GB. I'm not sure how to reliably thin it down to reproduce the problem. If you'd like to download such a big BAM, I can make it available, let me know.

Oh, and I'm running freebayes -d -f $FASTA $PREFIX.bam > "freebayes-${PREFIX}.vcf", so defaults all the way.

@ekg
Copy link
Collaborator

ekg commented Jun 18, 2019 via email

@sammyjava
Copy link
Author

Here ya go. I'm calling against the FASTA given above.

freebayes-test.bam.gz

Reproduces the error.

@ekg
Copy link
Collaborator

ekg commented Jun 19, 2019 via email

@github-actions
Copy link

This issue is marked stale because it has been open 120 days with no activity. Remove stale label or comment or this will be closed in 5 days

@github-actions github-actions bot added the Stale label Dec 11, 2020
@github-actions
Copy link

This issue was closed for lack of activity. Feel free to re-open if someone feels like working on it.

@BowenXiao123
Copy link

hi, i get the same error, i already use the same ref-gemone run with atct.bam file , it work good, but when i try the same code to the gex.bam then raise a error. could you help me?
freebayes -f chr6.grch38.fasta -iXu -C 2 -q 20 -n 3 -E 1 -m 30 --min-coverage 6 chr6.gex.bam -v chr6.gex.vcf
-d print on screen
processing position 1852794 in sequence chr6
terminate called after throwing an instance of 'std::out_of_range
what(): basic_string::substr
zsh: abort freebayes -f chr6.grch38.fasta -iXu -C 2 -q 20 -n 3 -E 1 -m 30 --min-coverage

@jhl667
Copy link

jhl667 commented Feb 14, 2023

Just placing this information here, in case it helps anyone else troubleshoot this error (v1.3.5):

terminate called after throwing an instance of 'std::out_of_range'  what():  basic_string::at: __n (which is 0) >= this->size() (which is 0)

First, attempt to isolate the problematic region, you can see where the last variant call was made in the output and look in that region. We are using a targeted approach so I used samtools view on the BAM file in the target region where the last variant call was made. Then, I looked for anything that might be weird about the BAM. Based on error, I thought maybe something was wrong with the sequence length, so I cut out the SEQ column and looked at the uniq sequences. I noticed one was an asterisk "*", thought that might be causing FreeBayes problems. For us, this error was not related to specifying the targets file, it was just related to there being an asterisk in the SEQ column. Removing these entries caused the error to go away.

@pjotrp I believe the asterisk is legal according to this BAM specification. Therefore, I'd classify this as a bug (assuming I'm correct about the cause). It seems like reasonable behavior would be to simply ignore these "asterisk" SEQs. Here's an example of what these BAM entries look like:

<BAM_ID> 675 5 39074211 48 * = 39074211 1 * * RG:Z:XXXXXX.1 AS:i:24 XS:i:0 MQ:i:48 MC:Z :*

@ayavuzcakir
Copy link

Today I also encountered the same issue with freebayes on Single cell data. I checked the last point from Freebayes with the "-d" flag and then looked at that region in the BAM file, and I saw "55M40N22M2I11M11S" in the Cigar tag. It is the only field different than other read positions so the problem might be related to Freebayes not handling this kind of Cigar Tags :/

@ayavuzcakir
Copy link

Today I also encountered the same issue with freebayes on Single cell data. I checked the last point from Freebayes with the "-d" flag and then looked at that region in the BAM file, and I saw "55M40N22M2I11M11S" in the Cigar tag. It is the only field different than other read positions so the problem might be related to Freebayes not handling this kind of Cigar Tags :/

  • I updated Freebayes to a newer version(1.3.6) then it worked properly!

@zhangjy859
Copy link

@ayavuzcakir, I got this error at version 1.3.6 too

@vera-gomes
Copy link

I am getting the same error too at version 1.3.6

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

No branches or pull requests

7 participants