Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • sam to bam conversion error, no @SQ lines in the header, missing header?

    I have a sam file that I want to convert to a bam file:

    samtools view -b -S in.sam > out.bam

    I get this error:

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

    My sam file looks perfectly normal to me. Does anyone see what I'm doing wrong?

    Thanks.

    Eric

  • #2
    To add to my previous post: I also tried the following command but I got the same error message:

    samtools view -h -b -S in.sam > out.bam

    Comment


    • #3
      I think you might need to specify a reference file containing the names of the sequences and the total sequence lengths. This is done with the "-t" flag. Here is a description from samtools:

      -t FILE
      This file is TAB-delimited. Each line must contain the reference name and the length of the reference, one line for each distinct reference;

      Comment


      • #4
        Or from memory -T can specify a FASTA file of the references.

        Comment


        • #5
          Originally posted by maubp View Post
          Or from memory -T can specify a FASTA file of the references.
          samtools view doesn't require -T. It works fine without a reference fasta.

          Maybe your headers aren't right?

          Here's what mine look like:

          @SQ SN:SNP_8787 LN:161
          @SQ SN:vector LN:13078

          Comment


          • #6
            Originally posted by swbarnes2 View Post
            samtools view doesn't require -T. It works fine without a reference fasta.

            Maybe your headers aren't right?

            Here's what mine look like:

            @SQ SN:SNP_8787 LN:161
            @SQ SN:vector LN:13078
            Yes - it was the headers. I see that when I made my sam file, I didn't use the -h option, so then when I went to convert it back to a bam file, I couldn't fix things simply by adding the -h option. I had to go back and remake the sam file with -h and then convert it back to a bam file with -h, and now everything is working fine. Thanks very much, everyone, for the help.

            Eric

            Comment


            • #7
              Originally posted by efoss View Post
              Yes - it was the headers. I see that when I made my sam file, I didn't use the -h option, so then when I went to convert it back to a bam file, I couldn't fix things simply by adding the -h option. I had to go back and remake the sam file with -h and then convert it back to a bam file with -h, and now everything is working fine. Thanks very much, everyone, for the help.

              Eric
              Hey efoss,

              I am also facing the same problem. I couldn't undertsood this line of yours "I didn't use the -h option, so then when I went to convert it back to a bam file, I couldn't fix things simply by adding the -h option. I had to go back and remake the sam file with -h" how to did you make same file with -h? Did you use Bwa to create sam file.?

              Comment


              • #8
                Originally posted by prasadg View Post
                Hey efoss,

                I am also facing the same problem. I couldn't undertsood this line of yours "I didn't use the -h option, so then when I went to convert it back to a bam file, I couldn't fix things simply by adding the -h option. I had to go back and remake the sam file with -h" how to did you make same file with -h? Did you use Bwa to create sam file.?
                Hi prasadg,

                It's been a while, but I think that I created a sam file with samtools' view command and that that command accepts a -h flag, which will create a sam file with appropriate headers.

                Eric

                Comment


                • #9
                  Originally posted by efoss View Post
                  Hi prasadg,

                  It's been a while, but I think that I created a sam file with samtools' view command and that that command accepts a -h flag, which will create a sam file with appropriate headers.

                  Eric
                  Okay . I will look into it . I have the sam file created by bwa. So I was using samtools to convert sam to bam but I am getting same answer as you have got

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

                  So I wanted to know how did you do it .

                  Thanks

                  Comment


                  • #10
                    Originally posted by prasadg View Post
                    Okay . I will look into it . I have the sam file created by bwa. So I was using samtools to convert sam to bam but I am getting same answer as you have got

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

                    So I wanted to know how did you do it .

                    Thanks
                    Hi prasadg,

                    Another thing to try if that doesn't work is using the -r option in bwa to add read group information when you create your original alignment file.

                    Eric

                    Comment


                    • #11
                      Originally posted by efoss View Post
                      Hi prasadg,

                      Another thing to try if that doesn't work is using the -r option in bwa to add read group information when you create your original alignment file.

                      Eric
                      I will give it a shot. by -r you mean -R ? cause as I see the alignment options -r is with uppercase. There is no lower case 'r' option.

                      Comment


                      • #12
                        Originally posted by prasadg View Post
                        I will give it a shot. by -r you mean -R ? cause as I see the alignment options -r is with uppercase. There is no lower case 'r' option.
                        No - I mean -r. Look under sampe and you'll see the option.

                        Eric

                        Comment


                        • #13
                          Originally posted by efoss View Post
                          No - I mean -r. Look under sampe and you'll see the option.

                          Eric
                          Thanks alot . It certainly made my day. I certainly was on wrong track .

                          Really appreciate you replys.

                          Comment


                          • #14
                            I converted sam file to bam, then removes PCR duplicates, then convert bam to sam. It showed the same error msg:

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

                            I tried -h option, still didn't work...

                            Comment


                            • #15
                              Hi bbm,

                              You might want to try Picard's AddOrReplaceReadGroups:

                              Comment

                              Latest Articles

                              Collapse

                              • seqadmin
                                Strategies for Sequencing Challenging Samples
                                by seqadmin


                                Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
                                03-22-2024, 06:39 AM
                              • seqadmin
                                Techniques and Challenges in Conservation Genomics
                                by seqadmin



                                The field of conservation genomics centers on applying genomics technologies in support of conservation efforts and the preservation of biodiversity. This article features interviews with two researchers who showcase their innovative work and highlight the current state and future of conservation genomics.

                                Avian Conservation
                                Matthew DeSaix, a recent doctoral graduate from Kristen Ruegg’s lab at The University of Colorado, shared that most of his research...
                                03-08-2024, 10:41 AM

                              ad_right_rmr

                              Collapse

                              News

                              Collapse

                              Topics Statistics Last Post
                              Started by seqadmin, Yesterday, 06:37 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, Yesterday, 06:07 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 03-22-2024, 10:03 AM
                              0 responses
                              49 views
                              0 likes
                              Last Post seqadmin  
                              Started by seqadmin, 03-21-2024, 07:32 AM
                              0 responses
                              66 views
                              0 likes
                              Last Post seqadmin  
                              Working...
                              X