Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • maasha
    Senior Member
    • Apr 2009
    • 153

    BWA sam and Samtools sam->bam conversion problem

    Hello all,

    I have a SAM file create with BWA, but I cannot convert it to BAM because of the following:

    samtools view -S foo.sam -b -o foo.bam
    [samopen] no @SQ lines in the header.
    [main_samview] random alignment retrieval only works for indexed BAM files.



    The SAM file looks like this:


    head foo.sam
    5_gECOjxwXsN1 0 contig00025 28520 37 35M = 28520 0 AACGNTACTATCGTGACATGCGTGCAGGATTACAC abb^D[a`ab^`Y`a_[___^[ON\X`_Y]`_aa\ XT:A:U NM:i:1 X0:i:1 X1:i:0 XM:i:1 XO:i:0 XG:i:0 MD:Z:4T30
    3_8ICOjxwXsN1 4 * 0 0 * * 0 0 ACTCNAGGGTTCGATTCCCTTCAACCGCCCCATAA a`WYD[aaaW_^_[^^W`]`]\^`\V][[_]QV\\
    3_GUCOjxwXsN1 4 * 0 0 * * 0 0 TTGCNTCCTTCTTCTGCCTTCGTTGGCTCAGATTG `aaYDRb_a[a`]^X^`]`aa`]XVT]R[^`TZVY
    5_BWCOjxwXsN1 0 contig00138 59297 37 35M = 59297 0 TATATACAGGAATCCATTGTTGTTTAGATTCAGTT ab`b`baaaa`b``ZY]YW^aS[_]OLT_VRS]UZ XT:A:U NM:i:0 X0:i:1 X1:i:0 XM:i:0 XO:i:0 XG:i:0 MD:Z:35
    7_NZCOjxwXsN1 16 contig00115 1617 37 35M = 1617 0 AGGTAGCCGTATCGGAAGGTGCGGCTGGATCACCT MSKNT\V^TSWW`\`Z^Z\Q\\___a`a_`ZDY`] XT:A:U NM:i:0 X0:i:1 X1:i:0 XM:i:0 XO:i:0 XG:i:0 MD:Z:35
    3_2VCOjxwXsN1 16 contig00005 66001 37 35M = 66001 0 CTTAATGGGTGAAGATGTCTACACACCTGGAAAAG aaaaa`a``aa_aaaa`aab_b`b[aabaaaabaa XT:A:U NM:i:0 X0:i:1 X1:i:0 XM:i:0 XO:i:0 XG:i:0 MD:Z:35
    5_kVCOjxwXsN1 4 * 0 0 * * 0 0 CTACACCTAAGTTACATCGTCCATTATTTTCCAAT aaaaaaaabaa_aa_a__a^a[[``\a`a][\`[_
    1_GbCOjxwXsN1 0 contig00105 1098 37 35M = 1098 0 CCAGACAACTAGGATGTTGGCTTAGAAGCAGCCAT ```_aabaaa`ba`Y`S[_`_^]a^a`_YaYSUXT XT:A:U NM:i:0 X0:i:1 X1:i:0 XM:i:0 XO:i:0 XG:i:0 MD:Z:35
    5_fTCOjxwXsN1 4 * 0 0 * * 0 0 TTAGCTTTAACCATTTTCTTTTTGTCTAAAGCAAA aabb__\_aaabU_^^[^`[\_`aWaa``_^a``_
    3_VWCOjxwXsN1 16 contig00027 14175 37 35M = 14175 0 GTTTAACGCGTTCACGTTCGCCACGCGCATCATAA T\`a\\a]]V]aa_aaaaaaaaY`abab_aaabba XT:A:U NM:i:0 X0:i:1 X1:i:0 XM:i:0 XO:i:0 XG:i:0 MD:Z:35



    Suggestions are welcome.



    Martin
  • nilshomer
    Nils Homer
    • Nov 2008
    • 1283

    #2
    Originally posted by maasha View Post
    samtools view -S foo.sam -b -o foo.bam
    Try
    Code:
    samtools view -S -b foo.sam > foo.bam
    There is no argument to the -S option.

    Comment

    • lh3
      Senior Member
      • Feb 2008
      • 686

      #3
      In addition, please use the latest bwa-0.5.4. 0.4.9 does not print SAM header.

      Comment

      • maasha
        Senior Member
        • Apr 2009
        • 153

        #4
        Yup, it was a BWA version problem. I did not realize that BWA now have its own spot on Sourceforge - with newer versions than 0.5.0. The Maq website is misleading (at least it mislead me ).

        All is good now. Thanks.

        Comment

        • saraoh
          Junior Member
          • May 2013
          • 1

          #5
          Hi
          I used your command, but seems it is not working properly
          samtools view -S -b SAM.sam' > bam1.bam
          Why I got the following line:
          [samopen] SAM header is present: 94 sequences.

          Finally I got the BAM file, but it is empty

          Comment

          • Chulab4121
            Junior Member
            • May 2013
            • 2

            #6
            i use the latest SRA tool kit to convert sra to sam but also no header. (-S -b -r )

            Comment

            • abi
              Member
              • May 2013
              • 18

              #7
              I am using the latest version of BWA and SAMTOOLS. I get following error when trying to convert from SAM to BAM with the following command:

              samtools view -bS chunkalign.1.sam > chunkalign.1.bam

              Parse warning at line 27: mapped sequence without CIGAR
              Parse error at line 27: sequence and quality are inconsistent
              Aborted

              Comment

              Latest Articles

              Collapse

              • SEQadmin2
                Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
                by SEQadmin2


                Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

                The systematic characterization of the human proteome has
                ...
                07-20-2026, 11:48 AM
              • SEQadmin2
                Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                by SEQadmin2



                Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                ...
                07-09-2026, 11:10 AM
              • SEQadmin2
                Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                by SEQadmin2



                Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                07-08-2026, 05:17 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by SEQadmin2, 07-20-2026, 11:10 AM
              0 responses
              14 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 07-13-2026, 10:26 AM
              0 responses
              31 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 07-09-2026, 10:04 AM
              0 responses
              42 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 07-08-2026, 10:08 AM
              0 responses
              28 views
              0 reactions
              Last Post SEQadmin2  
              Working...