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
                Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                by SEQadmin2


                I’m not a sequencing expert. I’m a purification scientist who uses NGS to evaluate workflows my group develops. With this perspective, we think about the sample first and the NGS workflow second. The sequencer is an exceptionally honest reporter, but it can only report on what you give it, so whether you get clean, interpretable data from an NGS workflow is largely determined before you begin.

                Here are nine questions we think about, in roughly the order they matter, before...
                06-18-2026, 07:11 AM
              • SEQadmin2
                From Collection to Sequencing: Why Sample Preparation and Preservation Define Sequencing Data
                by SEQadmin2


                Data variability is still an issue in sequencing technologies despite the advances in reproducibility and accuracy of these platforms. But the problem does not originate in the sequencing itself, but in the previous steps, before the sample reaches the sequencer.


                The first step is collection, followed by preservation and sample preparation for analysis. Most scientists overlook those steps, but not being careful might just be skewing the experiment’s results.
                ...
                06-02-2026, 10:05 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by SEQadmin2, 06-17-2026, 06:09 AM
              0 responses
              36 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 06-09-2026, 11:58 AM
              0 responses
              99 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 06-05-2026, 10:09 AM
              0 responses
              120 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 06-04-2026, 08:59 AM
              0 responses
              113 views
              0 reactions
              Last Post SEQadmin2  
              Working...