Unconfigured Ad

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

    #1

    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
              Beyond CRISPR/Cas9: Understand, Choose, and Use the Right Genome Editing Tool
              by SEQadmin2



              CRISPR/Cas9 sparked the gene editing revolution for both research and therapeutics.1 But this system still showed severe issues that limited its applications. The most prominent were the heavy reliance on PAM sequences, delivery limitations, double-stranded breaks that prompt unintended edits and cell death, and editing inefficiency (both in targeting and in knock-in reliability).

              Despite this, “CRISPR helped turn genome editing from a specialized technique into
              ...
              07-31-2026, 11:01 AM
            • 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

            ad_right_rmr

            Collapse

            News

            Collapse

            Topics Statistics Last Post
            Started by SEQadmin2, Today, 12:22 PM
            0 responses
            8 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 08-11-2026, 10:35 AM
            0 responses
            11 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 08-06-2026, 07:41 AM
            0 responses
            30 views
            0 reactions
            Last Post SEQadmin2  
            Started by SEQadmin2, 08-03-2026, 10:13 AM
            0 responses
            48 views
            0 reactions
            Last Post SEQadmin2  
            Working...