Entering edit mode
6.9 years ago
Hello everyone,
I wanted to invert SAM file to BAM file SO I type these command:
samtools view -b -S KY_1.sam > KY_1.bam
samtools sort KY_1.bam KY_1.sorted
then got this error...EOF marker is absent .The input is truncated. invalid BAM binary header. could you help me?
If you are using the latest version of samtools then the sort command should be
samtools sort -o KY_1.sorted.bam KY_1.bam
Hi you should realign your fastq it seems something wrong append in your header.
Best
I have changed your title and post to remove the ALL CAPS PARTS. There is no need for shouting.
I insert it samtools sort -o alignments_sorted.bam alignments.sam then got it: open: No such file or directory [bam_sort_core] fail to open file alignments_sorted.bam
what should I do?what does it mean?
Please use
ADD COMMENT
orADD REPLY
to answer to previous reactions, as such this thread remains logically structured and easy to follow. I have now moved your post but as you can see it's not optimal. Adding an answer should only be used for providing a solution to the question asked.The above command works on my machine. Can you first have a look at your samtools version using
If it's older than 1.5 you should update.
Thank you dear Wouter DeCoster for your guidance to write comments. Cuase I'm not at work all right so I'll check my samtools version and if needed I'llupdate it.
But another problem that I have ,when l inverted sam file to bam file and l opened bam file didn't see anything on my screen. So do you have any suggestion?
Can you elaborate on how you opened the bam file?
now I updated samtools and due of opening sam file with gedit.I opended bam file with gedit . but I think I have misstake. you know should i see bam file like sam file with gedit?
No, no, bam is a binary format and cannot be opened with gedit. You can however use something like
I am inserting samtools view alignments.bam | less -S and I see :
It might be my samtools have problem?
Your samtools version is recent? Does it work on your sam file?
What's the (disk) size of your bam file? And what about the sam file?
I checked the size of sam file is 138.5 kB but unfortunately for bam file is 0 KB ,so it means i could not make bam file.
138 kb SAM file sounds suspicious, unless this is a small test file. Is the correct? If you have a normal dataset with millions of reads the file should be tens of MB.
yes it is just an example.
Try again and see if it works this time.
many thanks ,It worked let me know that what does bam file give me? I want to understand description details in bam file. would you please help me?
See the sam specifications. Bam is just binary/compressed sam.
How can I update my existing samtools?
You could remove your current installation and follow the installation instructions on the samtools website.
If you haven't already I'd suggest you to start using conda for installation of software. It's amazingly convenient.
Your Problem is with the options. Your command should be like this,
Although, others mentioned how you can get your desirable output format in new versions of samtools.