Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • Can't sort BAM file ("not a BAM file")

    Dear everyone,

    I try to convert some SAM files to BAM files following the Samtools FAQ method :
    First indexing my reference fasta file (I have no header in my SAM file) :
    Code:
    samtools faidx ref.fa
    Then converting my SAM file to BAM file :
    Code:
    samtools view -bt ref.fa.fai aln.sam > aln.bam
    Until here, everything seems fine, but...

    When trying to sort my BAM file :
    Code:
    samtools sort aln.bam aln-sorted
    I instantly get :
    [bam_header_read] invalid BAM binary header (this is not a BAM file).
    [bam_sort_core] truncated file. Continue anyway.
    Seegmentation fault (core dumped)


    The problem seems to be in the SAM-->BAM conversion... My SAM file seems OK (obtained with the Illumina script : illumina_export2sam.pl). It only contains one "@PG" line at its beginning, that's why I followed the Samtools FAQ method.

    I've already once done that on another data and everything went fine...So I really don't understand what is happening now.
    Could someone tell me what is wrong ?
    I'd be very grateful if someone could help me !!!

    Best regards,

    Marine

  • #2
    Hi Marine,
    I assume your SAM file consists of non-aligned reads. Thus, trying to sort your reads according to their chromosomal locations might lead to the error. If you want to sort the BAM file anyway, try
    Code:
    samtools sort -n aln.bam aln-sorted
    Cheers,
    Michael

    Comment


    • #3
      Which version of samtools are you using? Can you "samtools view aln.bam"? I'm guessing not. Also, what happens if you instead use "samtools view -Sbt ref.fa.fai aln.sam > aln.bam"?

      BTW, am I correct in assuming you're the same person that just emailed the samtools-help email list?

      Comment


      • #4
        Thank you for your quick answer !!
        My SAM file is about aligned reads. But the names of each feature in my reference file (ref.fa, to which I aligned the reads) are not like "Chr..." but rather like "15648-ref" ... Is this supposed to be a problem ?

        Whatsmore, trying what you proposed gives me exactly the same error message

        Comment


        • #5
          Originally posted by MarinePAM View Post
          My SAM file is about aligned reads. But the names of each feature in my reference file (ref.fa, to which I aligned the reads) are not like "Chr..." but rather like "15648-ref" ... Is this supposed to be a problem ?
          That should be fine.

          Whatsmore, trying what you proposed gives me exactly the same error message
          Try the "samtools view -Sbt blah.fa.fai foo.sam > foo.bam" command that I suggested above and see if you can even "samtools view foo.bam" then (I'm assuming you get the error if you try that on the current BAM file).

          Comment


          • #6
            Dear dpryan,

            Thank you for your answer !

            The version is : Version: 0.1.18 (r982:295)

            Indeed, "samtools view aln.bam" gives me the same error message...

            I've just ran : "samtools view -Sbt ref.fa.fai aln.sam > aln.bam". It worked (as well as without the -S option). When running the next sort step, it seems to work !! I thought the "-S" option was forced by the "-t" option as described in the help, but maybe not ?
            While currently still running, this message appears : "merging from 10 files..." Do you know what are these 10 files ?

            (Yes I am the same person as on the mailing list !)

            Comment


            • #7
              0.1.18 is an older version, so perhaps -S wasn't forced by -t in that version.

              When samtools sorts a BAM file, it breaks it into smaller sorted files and then merges them. This drastically decreases memory requirements (otherwise, you have to hold the whole thing in memory!) and is quick because merging sorted files is quite fast.

              Let me know once that's done if it works and I'll leave a note on the samtools list about the cause/solution.

              Comment


              • #8
                It worked ! I've done the "sort" and "index" steps with success !!
                Many many thanks to you, I'm very happy !

                So it was the -S option. I'm surprised because I read the help corresponding to this older version !
                Thank you also for leaving a note on the samtools list (I was about to ask you if I need to do so) !

                Comment

                Latest Articles

                Collapse

                • seqadmin
                  Current Approaches to Protein Sequencing
                  by seqadmin


                  Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
                  04-04-2024, 04:25 PM
                • 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

                ad_right_rmr

                Collapse

                News

                Collapse

                Topics Statistics Last Post
                Started by seqadmin, 04-11-2024, 12:08 PM
                0 responses
                30 views
                0 likes
                Last Post seqadmin  
                Started by seqadmin, 04-10-2024, 10:19 PM
                0 responses
                32 views
                0 likes
                Last Post seqadmin  
                Started by seqadmin, 04-10-2024, 09:21 AM
                0 responses
                28 views
                0 likes
                Last Post seqadmin  
                Started by seqadmin, 04-04-2024, 09:00 AM
                0 responses
                52 views
                0 likes
                Last Post seqadmin  
                Working...
                X