Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • IllumMiseq
    Junior Member
    • Oct 2017
    • 5

    #1

    Samtools: Problem Not Recognizing Sorted BAM File & Output Missing Contigs

    Hello!

    I converted my SAM file to BAM using this command:

    samtools view -S -b .SAM > M6X2D.BAM

    I need to calculate genome coverage, so I'm using this command:

    samtools depth .BAM > .txt

    But I got this error:

    [bam_pileup_core] the input is not sorted (chromosomes out of order)
    [bam_plp_destroy] memory leak: 1. Continue anyway.


    I did a google search and saw the following command could be used to sort my BAM file:

    samtools sort -n .BAM

    But it doesn't help. I would appreciate any advice and guidance on what I can do to get the depth command to work.

    I did get the depth command to work for one genome, but only 2 out of 46 contigs made it to the .txt file.

    Thank you!
  • GenoMax
    Senior Member
    • Feb 2008
    • 7142

    #2
    What version of samtools are you using? You should use the latest (v.1.5) if possible.

    Sort your BAM file this way "samtools sort -o sorted.bam original.bam". (-n will name sort based on reads which is not what you want here).

    Comment

    • IllumMiseq
      Junior Member
      • Oct 2017
      • 5

      #3
      Hi! I'm using samtools 1.6.

      I tried to sort the BAM file as suggested using "samtools sort -o sorted.bam original.bam", but I got this here:

      [E::hts_open] fail to open file 'Sorted.BAM'
      [bam_sort_core] fail to open file Sorted.BAM

      I tried to switch around the sorted and the original bam components like this:

      samtools sort original.BAM -o Sorted.BAM

      and my computer screen went crazy.

      Comment

      • GenoMax
        Senior Member
        • Feb 2008
        • 7142

        #4
        You need to use real file names (with full paths, if needed). So you would do "samtools sort -o M6X2D_sorted.BAM M6X2D.BAM" (if that is a real file name).

        Comment

        • IllumMiseq
          Junior Member
          • Oct 2017
          • 5

          #5
          Correct. That's what I did. I had the path set for my files. I did tab complete just to be sure. It just says:

          open: No such file or directory
          [bam_sort_core] fail to open file M6X2_Sorted.BAM

          My exact command was:

          samtools sort -o Strain_Sorted.BAM ../Novels_BAM/Strain.BAM

          Comment

          • GenoMax
            Senior Member
            • Feb 2008
            • 7142

            #6
            That is odd. Why is the error saying "fail to open file M6X2_Sorted.BAM" when your input file is called "Strain.BAM?

            Comment

            • IllumMiseq
              Junior Member
              • Oct 2017
              • 5

              #7
              I have multiple single genomes that I'm working on. I just replaced M6X2 with "Strain" to put a generic name to my files while we are chatting.

              samtools sort -o M6X2_Sorted.BAM ../Novels_BAM/M6X2.BAM

              is my literal command.

              Comment

              • GenoMax
                Senior Member
                • Feb 2008
                • 7142

                #8
                I see. You are trying to write M6X2_Sorted.BAM to the local directory from where you are running sort command and you do not seem to have write permissions there.

                So it would be best to either put the sorted file back in the directory where the original BAM is by doing "samtools sort -o ../Novels_BAM/M6X2_Sorted.BAM ../Novels_BAM/M6X2.BAM" or put it in another directory, where you have write permission.

                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
                • 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

                ad_right_rmr

                Collapse

                News

                Collapse

                Topics Statistics Last Post
                Started by SEQadmin2, 07-31-2026, 02:55 AM
                0 responses
                18 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 07-24-2026, 12:17 PM
                0 responses
                15 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 07-23-2026, 11:41 AM
                0 responses
                14 views
                0 reactions
                Last Post SEQadmin2  
                Started by SEQadmin2, 07-20-2026, 11:10 AM
                0 responses
                25 views
                0 reactions
                Last Post SEQadmin2  
                Working...