Failed Due To Truncated File Or Corrupt Bam Index File Error When Downloading Bam File From Samtools
Hi. I'm trying to open a fragment of a bam file using "samtools view" but I get "failed due to truncated file or corrupt BAM index file" trying to do the following error:
samtools view -hb <ftp://ftp-trace.ncbi.nih.gov/1000genomes/ftp/data/NA12878/alignment/NA12878.chrom1.ILLUMINA.bwa.CEU.high_coverage.20100311.bam> 1:150,000,000-151,000,000 > NA12878.chrom1.ILLUMINA.bwa.CEU.high_coverage.20100311_150M-151M.bam
[main_samview] retrieval of region "1:150,000,000-151,000,000" failed due to truncated file or corrupt BAM index file
I've tried to let samtools downloading the bai file and also to download it myself beforehand but it always give me the same error.
Regards.
• 5,831 views
•
link
0 answers
No answers yet.
Log in to answer this question.
Just to mention that after the failure I have in the working directory a bam file of size 14848000 bytes but I don't know whether it is complete or not.
UPDATE: I re-run a couple of times the very same command line and at my last attempt there was no error ?! and the file seems to be downloaded completly. IMHO the error message I report is related to a connection error.
Actually this is a bug. The network library does not retry when it fails to establish the connection, and this happens randomly.
Oh I apologize for that question: I should have consulted samtools bug reporting system but I was very fram from suspecting this was a bug. Regards.