Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • kjsalimian
    Junior Member
    • Dec 2011
    • 5

    Segmentation Fault sorting a BAM file

    Hi,

    I mapped paired end reads with Bowtie2 to produce a SAM file. Any reason why the following happens???

    I run the following commands:

    samtools view -bS myfile.sam > myfile.bam
    samtools sort myfile.bam myfile.sorted

    I get the following output:


    [samopen] SAM header is present: 25 sequences.
    [bam_sort_core] merging from 87 files...
    [bam_header_read] EOF marker is absent. The input is probably truncated.
    [bam_header_read] bgzf_check_EOF: Invalid argument
    [bam_header_read] invalid BAM binary header (this is not a BAM file).
    Segmentation fault

    Thanks!
  • maubp
    Peter (Biopython etc)
    • Jul 2009
    • 1544

    #2
    One guess is it is running out of space wherever the temporary files are, resulting in a truncated temporary file and thus the EOF marking missing warning.

    Comment

    • kjsalimian
      Junior Member
      • Dec 2011
      • 5

      #3
      It turns out you were right! Thanks for responding. It was due to a memory issue. However, I got a new error this time.
      After generating the sam file I ran the following codes, the goal being to create a sam file that is namesorted and containing a region of chr4 only.



      Code:
      samtools view -bS myfile.sam > myfile.bam
      samtools sort myfile.bam myfile.sorted
      samtools index myfile.sorted.bam
      samtools view myfile.sorted.bam 'chr4: 1-1000000' -o myfileextracted.sorted.bam
      samtools sort -n myfileextracted.sorted.bam myfile.namesorted
      samtools view myfile.namesorted > myfilenamesorted.sam
      I got the following errors though:


      Code:
      [bam_sort_core] merging from 87 files...
      [bam_header_read] EOF marker is absent. The input is probably truncated.
      [bam_header_read] invalid BAM binary header (this is not a BAM file).
      [bam_sort_core] truncated file. Continue anyway.
      Segmentation fault
      It seems to have gone on to try to write the sorted bam file but the size of the sorted bam file is significantly smaller than the original (17.1 gb vs 14.3 gb). Any thoughts on why this may be happening???

      Comment

      • GenoMax
        Senior Member
        • Feb 2008
        • 7142

        #4
        This has been discussed before. See this thread: http://seqanswers.com/forums/showthread.php?t=13652

        Originally posted by kjsalimian View Post

        It seems to have gone on to try to write the sorted bam file but the size of the sorted bam file is significantly smaller than the original (17.1 gb vs 14.3 gb). Any thoughts on why this may be happening???

        Comment

        • maubp
          Peter (Biopython etc)
          • Jul 2009
          • 1544

          #5
          A sorted BAM file should be smaller than an unsorted BAM file, however if samtools merge crashed it is quite likely that the file is incomplete.

          One simple check would be to count the number of reads in the input and output BAM files.

          Comment

          • Lv Ray
            Member
            • Jun 2014
            • 42

            #6
            Originally posted by kjsalimian View Post
            It turns out you were right! Thanks for responding. It was due to a memory issue. However, I got a new error this time.
            After generating the sam file I ran the following codes, the goal being to create a sam file that is namesorted and containing a region of chr4 only.



            Code:
            samtools view -bS myfile.sam > myfile.bam
            samtools sort myfile.bam myfile.sorted
            samtools index myfile.sorted.bam
            samtools view myfile.sorted.bam 'chr4: 1-1000000' -o myfileextracted.sorted.bam
            samtools sort -n myfileextracted.sorted.bam myfile.namesorted
            samtools view myfile.namesorted > myfilenamesorted.sam
            I got the following errors though:


            Code:
            [bam_sort_core] merging from 87 files...
            [bam_header_read] EOF marker is absent. The input is probably truncated.
            [bam_header_read] invalid BAM binary header (this is not a BAM file).
            [bam_sort_core] truncated file. Continue anyway.
            Segmentation fault
            It seems to have gone on to try to write the sorted bam file but the size of the sorted bam file is significantly smaller than the original (17.1 gb vs 14.3 gb). Any thoughts on why this may be happening???
            I got the similar wrong!
            I didn't have [bam_header_read] EOF marker is absent. The input is probably truncated.
            But I directly got
            [bam_header_read] invalid BAM binary header (this is not a BAM file).
            [bam_sort_core] truncated file. Continue anyway.
            Segmentation fault(core dumped)

            could anyone tell me how to deal with this problem! I did another SEQanswers:http://seqanswers.com/forums/showthread.php?t=44875

            Comment

            Latest Articles

            Collapse

            • 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
            • GATTACAT
              Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
              by GATTACAT
              Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
              07-01-2026, 11:43 AM

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by SEQadmin2, Yesterday, 10:26 AM
            0 responses
            13 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 07-09-2026, 10:04 AM
            0 responses
            26 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 07-08-2026, 10:08 AM
            0 responses
            16 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 07-07-2026, 11:05 AM
            0 responses
            33 views
            0 reactions
            Last Post SEQadmin2  
            Working...