This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Conversion of sam to bam using samtools

Hello,

The alignment with the whole human genome and my data, the sam files are genertaed but when I tried to use the samtools for conversion sam to bam facing problem of header. with the reference sequence also am not able to do it.

Any other way to do it?

output:

[sam_header_line_parse] expected '@XY', got [@A00306:15:H3WG3DMXX:1:1101:14705:1000 2:N:0:TAGCTTAT]
Hint: The header tags must be tab-separated.
[sam_header_read2] 0 sequences loaded.
[samopen] no @SQ lines in the header.
[main_samview] random alignment retrieval only works for indexed BAM files.
samtools rna-seq ngs sam bam

Can you post the command you are using to convert sam to bam? Typical command would be: samtools view -S -bh sample.sam > sample.bam

Hello,

  • Please use the formatting bar (especially the code option) to present your post better. I've done it for you this time.
    code_formatting

  • Also it isn't necessary to answer to each post with the same content. Everyone who already posted here is informed about new messages.

Thank you!

fin swimmer

to the above command suggested

 [samopen] no @SQ lines in the header.
 [sam_read1] missing header? Abort!

I've changed your post type to a question. Tools are for promoting new pieces of software etc, not for questions regarding tools.

1 answer

Hello abhilashreddy495,

what was the exact command use for the alignment? Also please post the beginning of your sam file e.g. with head input.sam.

fin swimmer

head '/media/abhilash/Abhilash/grch38/outputn.sam' 

�BC!sr�ed�|�t�

Your sam file is already a binary file.

What happens here?

samtools view -H outputn.sam

fin swimmer

That's sounds like your file is broken or it isn't a bam/sam file. One last try:

$ samtools view outputn.sam|head

You haven't answer the question how your alignment file was created. For more help we need to know this.

fin swimmer

It sounds a little like its already converted to a BAM, but the headers haven't been preserved?

That was my intention ;)

Exact command please.

But at all it looks like your data is corrupted and you have to start from the beginning.

Log in to answer this question.