This is a test version of Biostars. For the public version, visit https://www.biostars.org.
No @SQ lines in the header

Hi all

I'm stuck at the path where I'm about to call mitochondrial region (ChrM) from the whole genome sequencing data.

I have gone through the fastq, alignment and now I'm going deeper; calling ChrM out (because I'm specifically want to use mitochondrial region only for my study).

What I did was;

  1. I have sorted .bam file, the command was like: samtools sort unsorted_in.bam sorted_out
  2. Then I converted the sorted .bam file into .sam. The command was: samtools view -h file.bam > file.sam
  3. After that, I have indexed sorted.bam file and the command was: samtools index sorted.bam

Everything seems okay until I run the command to call ChrM region. The command for calling ChrM that I have used was this one:

samtools view -h sorted.bam | awk '$3== "chrM" || /n@/' | samtools view -Sb -> chrM.bam.sorted.bam

So, I typed this in the terminal and it appeared:

ws04@empress:/srv/disk01/Tools/samtools-0.1.19$ samtools view -h /srv/disk01/Postgraduates/OrangAsli/KS12R/Alignments/KS12R_sorted.bam.bam | awk '$3=="chrM" || /n@/' | samtools view -Sb -> /srv/disk01/Postgraduates/OrangAsli/KS12R/ChrM/KS12R_chrM.bam.sorted.bam
[samopen] no @SQ lines in the header.
[sam_read1] missing header? Abort!

I have tried more than twice but it's still the same. What does it mean with no @SQ lines in the header?

I hope you guys can help me. Thank you in advance and glad to hear from you guys soon.

Thanks again,
Lynn.

sequence

I think that this is should be posted as "question" not forum. :)

You are correct, I've moved it.

Hi. Sorry that I have posted at the wrong section :)

Thanks for your suggestion. I'll do it!

Thanks again ^_^

1 answer

  1. There's no need to make a SAM file (step 2), especially since you're not using it.
  2. Just use samtools view -b sorted.bam chrM > chrM.sorted.bam

BTW, the problem was the /n@/ part of your command. Had you used /^@/ then you would have been fine, though that's still much slower than what I showed above.

Log in to answer this question.