Samtools error sorting
1
0
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?

RNA-Seq • 5.9k views
ADD COMMENT
2
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Hi you should realign your fastq it seems something wrong append in your header.

Best

ADD REPLY
0
Entering edit mode

I have changed your title and post to remove the ALL CAPS PARTS. There is no need for shouting.

ADD REPLY
0
Entering edit mode

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?

ADD REPLY
0
Entering edit mode

Please use ADD COMMENT or ADD 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

samtools --version

If it's older than 1.5 you should update.

ADD REPLY
0
Entering edit mode

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?

ADD REPLY
0
Entering edit mode

l opened bam file didn't see anything on my screen.

Can you elaborate on how you opened the bam file?

ADD REPLY
0
Entering edit mode

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?

ADD REPLY
0
Entering edit mode

No, no, bam is a binary format and cannot be opened with gedit. You can however use something like

samtools view yourfile.bam | less -S
ADD REPLY
0
Entering edit mode

I am inserting samtools view alignments.bam | less -S and I see :

~
~
~
~
~
~
~
(END)

It might be my samtools have problem?

ADD REPLY
0
Entering edit mode

Your samtools version is recent? Does it work on your sam file?

samtools view yourfile.sam | less -S

What's the (disk) size of your bam file? And what about the sam file?

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
1
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

yes it is just an example.

ADD REPLY
0
Entering edit mode

Try again and see if it works this time.

ADD REPLY
0
Entering edit mode

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?

ADD REPLY
0
Entering edit mode

See the sam specifications. Bam is just binary/compressed sam.

ADD REPLY
0
Entering edit mode

How can I update my existing samtools?

ADD REPLY
0
Entering edit mode

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.

ADD REPLY
0
Entering edit mode

Your Problem is with the options. Your command should be like this,

samtools view -S -b KY_1.sam > KY_1.bam
samtools sort KY_1.bam KY_1.sorted

Although, others mentioned how you can get your desirable output format in new versions of samtools.

ADD REPLY
0
Entering edit mode
6.9 years ago

For sorting and conversion to bam in one step you could just use:

samtools sort -o KY_1_sorted.bam KY_1.sam

(assuming a recent version of samtools)

ADD COMMENT

Login before adding your answer.

Traffic: 1916 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6