Question: Please help me with samtools
0
gravatar for seta
3.4 years ago by
seta1.1k
Sweden
seta1.1k wrote:

Hi friends,

Please help me with the samtools. I used the command of "./samtools view -b –u /home/seta/software/files1_1/8_test.sam | samtools  sort -@ 7 -m 10G -T temp.bam  -o 8_test.bam" for converting the SAM mapping file (generated by bowtie2) to BAM followed by sorting. But after few second, it gives me an error that “sort: invalid option -- 'T'

[bam_header_read] EOF marker is absent. The input is probably truncated.

[bam_header_read] invalid BAM binary header (this is not a BAM file).

Segmentation fault (core dumped)”

This is my first experience on samtools, even reading the corresponding manual did not help me much. I would be highly appreciated for your help to figure out the error and solve it.

bam sam samtools alignment bowtie2 • 3.2k views
ADD COMMENTlink modified 2.5 years ago by Biostar ♦♦ 20 • written 3.4 years ago by seta1.1k

See this thread http://seqanswers.com/forums/showthread.php?t=28183

ADD REPLYlink written 3.4 years ago by Renesh1.6k
2
gravatar for Pierre Lindenbaum
3.4 years ago by
France/Nantes/Institut du Thorax - INSERM UMR1087
Pierre Lindenbaum118k wrote:

"(this is not a BAM file)"

tell samtools to read a SAM, not a BAM with option -S :

./samtools view -S -bu /home/seta/software/files1_1/8_test.sam
ADD COMMENTlink written 3.4 years ago by Pierre Lindenbaum118k

Thanks Pierre for being here

 

ADD REPLYlink written 3.4 years ago by seta1.1k

Sorry for many question. I'm trying to convert and sort with  ./samtools view -S -bu /home/seta/software /file1_1/8_test.sam | samtools sort -o 8_test.sorted.bam -m 10G -@ 7 8_test.bam

but the error says that: 

open: No such file or directory
[bam_sort_core] fail to open file 8_test.sorted.bam

I read the manual several times, but fail to understand the error. please help me how to solve it?

 

ADD REPLYlink modified 3.4 years ago • written 3.4 years ago by seta1.1k
1

Try below commands, These should work 

./samtools view -S -bu /home/seta/software /file1_1/8_test.sam -o 8_test.bam

./samtools  sort -n -m 10G -@ 7 -l 9   8_test.bam 8_test.sorted

ADD REPLYlink written 3.4 years ago by Renesh1.6k

Thanks for your comment. Actually, I tried the command of "./samtools view -S -bu /home/seta/software/file1_1/8_test.sam -o 8_test.bam | samtools sort -m 10G -@ 4 -l 9 8_test.bam 8_test.sorted.bam". But, it generated the 8_test.bam file with about 97 Gb (the sam file was 120 Gb) and the error that says "open: No such file or directory
[bam_sort_core] fail to open file 8_test.bam

It sound that the error refer to second part of command (sorting), yes? how to solve it?

However, based on what I read, I thought that the bam file should be very smaller than sam file. Please kindly let me know if the 97 GB bam file is usual in my case?

This is my first experience with samtools, so I would like to make sure about the results. Many thanks in advance.

 

ADD REPLYlink modified 3.4 years ago • written 3.4 years ago by seta1.1k

Use the commands as written by PyPerl. Your incorrect usage of pipes are what caused the problem.

ADD REPLYlink written 3.4 years ago by Devon Ryan88k

Thanks. Actually I used the command of Pyperl as pipes that I prefer. Could you please correct my comand with using pipes?

Devon, please kindly tell me resulting 97 GB bam file from 120 GB sam file is usual?

ADD REPLYlink written 3.4 years ago by seta1.1k
samtools view -Su /home/seta/software/file1_1/8_test.sam | samtools sort -m 10G -@ 4 - 8_test.sorted

This won't create the large BAM file. Your previous attempt didn't work because you were piping nothing into samtools sort and thereby running it at the same time as the samtools view command (I imagine you got the error almost immediately). The BAM file was so large because it was uncompressed.

ADD REPLYlink written 3.4 years ago by Devon Ryan88k

Unfortunately, it sounds that it did not work as the usage of program was appeared. why??

ADD REPLYlink written 3.4 years ago by seta1.1k

Try copying and pasting, or removing the "-m 10G" part. That command will not produce an error if typed correctly and the SAM file exists and can be read.

ADD REPLYlink written 3.4 years ago by Devon Ryan88k

Hi Devon, I copy and pasted your suggested command and removed "-m 10G" as you kindly told me. But, after few second, these appeared:

[bam_header_read] EOF marker is absent. The input is probably truncated.

[samopen] SAM header is present: 87358 sequences

However, the tool works and after generating a sorted.bam file with about 16 G the work was stopped with the following error:

[bam_header_read] EOF marker is absent. The input is probably truncated.
[bam_sort_core] merging from 177 files...

I really confused what is wrong. Please help me out to solve the problem and finally create a sorted bam file.

 

ADD REPLYlink modified 3.4 years ago • written 3.4 years ago by seta1.1k

The "EOF" thing can be ignored. I see no actual error, check with "samtools -c" if the expected number of entries are there.

ADD REPLYlink written 3.4 years ago by Devon Ryan88k

It was OK. Thank you very much for helping me to solve the problem.

ADD REPLYlink written 3.4 years ago by seta1.1k

Unfortunately, it sounds that it did not work as the usage of samtools sort program was appeared. why??

ADD REPLYlink written 3.4 years ago by seta1.1k
2
gravatar for John Marshall
3.4 years ago by
John Marshall1.5k
Glasgow, Scotland
John Marshall1.5k wrote:

You are reading the manual for current samtools (version 1.2), but you are using samtools 0.1.18 or so from several years ago.  (This is indicated by the various non-existent options and the "this is not a BAM file" message -- with current samtools, SAM/BAM/CRAM is automatically detected and you don't need view -S.)

So you will want to build and install up to date tools.

ADD COMMENTlink written 3.4 years ago by John Marshall1.5k

How you said the version of 0.1.18, I'm working on current version (1.2).

ADD REPLYlink modified 3.4 years ago • written 3.4 years ago by seta1.1k
1

The error message that you reported seeing ("invalid BAM binary header (this is not a BAM file)") exists in samtools 0.1.8 through 0.1.19.  It does not exist in samtools 1.0 and later.

Therefore you are in fact not running the current version.  You may have built the current version, but it is not (always) being used.  So you need to use  which samtools  and check your $PATH settings.

ADD REPLYlink written 3.4 years ago by John Marshall1.5k

Thanks John, just the current version of samtools (1.2) has been installed on server. However, this error was solved. But the another error appeared that refer to using pipes as Devon also mentioned. I posted it in the comments of this post. I would be highly appreciate if you could help me to solve it.

ADD REPLYlink written 3.4 years ago by seta1.1k
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: 793 users visited in the last hour