Question: Samtools error sorting
0
gravatar for Msadeghibiology91
3 months ago by
Msadeghibiology910 wrote:

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 • 340 views
ADD COMMENTlink modified 3 months ago • written 3 months ago by Msadeghibiology910
2

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 REPLYlink modified 3 months ago • written 3 months ago by genomax46k

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

Best

ADD REPLYlink modified 3 months ago • written 3 months ago by Titus590

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

ADD REPLYlink written 3 months ago by WouterDeCoster27k

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 REPLYlink modified 3 months ago • written 3 months ago by Msadeghibiology910

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 REPLYlink written 3 months ago by WouterDeCoster27k

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 REPLYlink written 3 months ago by Msadeghibiology910

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

Can you elaborate on how you opened the bam file?

ADD REPLYlink written 3 months ago by WouterDeCoster27k

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 REPLYlink written 3 months ago by Msadeghibiology910

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 REPLYlink written 3 months ago by WouterDeCoster27k

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

~
~
~
~
~
~
~
(END)

It might be my samtools have problem?

ADD REPLYlink modified 3 months ago • written 3 months ago by Msadeghibiology910

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 REPLYlink modified 3 months ago • written 3 months ago by WouterDeCoster27k

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 REPLYlink written 3 months ago by Msadeghibiology910
1

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 REPLYlink written 3 months ago by genomax46k

yes it is just an example.

ADD REPLYlink modified 3 months ago • written 3 months ago by Msadeghibiology910

Try again and see if it works this time.

ADD REPLYlink written 3 months ago by WouterDeCoster27k

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 REPLYlink written 12 weeks ago by Msadeghibiology910

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

ADD REPLYlink written 12 weeks ago by WouterDeCoster27k

How can I update my existing samtools?

ADD REPLYlink written 3 months ago by Msadeghibiology910

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 REPLYlink written 3 months ago by WouterDeCoster27k
0
gravatar for WouterDeCoster
3 months ago by
Belgium
WouterDeCoster27k wrote:

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 COMMENTlink modified 3 months ago • written 3 months ago by WouterDeCoster27k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 752 users visited in the last hour