Entering edit mode
6.7 years ago
sambioinfo2018
▴
20
Hi all, I get the following error when reading the sample.bam. The file was converted from sam to bam using the following command:
samtools view -bS sample.sam > sample.bam.
[E::bgzf_read] bgzf_read_block error -1 after 194938 of 8572040 bytes
[E::bam_hdr_read] error reading BGZF stream
[main_samview] fail to read the header from sample.bam
Looking forward to get your suggestion.
thanks in advance
sam
Does your sam file have a valid header? If yes, then have you tried reconverting the file? Perhaps something happened to corrupt the file first time around.
Yes, a valid header is present in sam file. I could not understand about reconverting?
What is the output of:
while running samtools view -H sample.sam, it result is following: [main_samview] fail to read the header from sample.sam
That is your problem then. With what program was the sam file generated?
When i looked the same file with head command i could see the first 10 header lines. However with the above command its showed as failed to read. I have rerun the alignment once again. And now its reading the sam file. Thanks!! Shall convert to bam file now.
i have also tried converting using samtools view -h -b sample.sam > sample.bam
I am having a similar issue. I'm following the CapSim tutorial, and when I'm trying to run this command:
I'm getting the error:
I have checked the file header with the commands above, and I do see it:
So what am I doing wrong here?
Probably you are using an ancient samtools version that did not have the
-o
option yet. Output ofsamtools --version
?It's samtools v1.11. Sorry, I should've added that. Does that mean I have to do the
>
then?No, that should be fine with v1.11. I just see that there is
-U
(capital U) rather than-u
inview
. That is probably wrong. You do not need view anyway, sort can read a SAM file directly and output bam.That's exactly the problem: The
-U
option is to Output reads not selected by filters to FILE, but the option you want is the-u
to get Uncompressed BAM output, which already implies-b
so you don't need to specify it. Also, the-S
option to indicate that your input is SAM rather than BAM is deprecated, but samtools doesn't complain if you use it.samtools view -u probes.sam
should be enough to feed any tool that would need a probes.sam in BAM format.ATpoint you're right about not having to use a previous samtools view in order to convert SAM to BAM, as
samtools sort
already understands SAM, BAM and CRAM inputs. Online documentation does state this, although unfortunatelysamtools
's man page doesn't.Hey, I have one question.
What does an empty flag mean after probes.bam
Thank you!