Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Axel
    Junior Member
    • Feb 2014
    • 8

    samtools view segmentation fault

    Hi all,

    I am trying to convert a sorted .bam file back into a .sam file for downstream programs
    but when I run the command:

    samtools view -h in_sorted.bam > out_sorted.sam

    I get the error:

    zsh: segmentation fault samtools view -h in_sorted.bam > out_sorted.sam

    I am on a Ubuntu 12.04 desktop machine (BioLinux), with 8 GB RAM and 1 TB Hard-disk space.

    I could convert from a .sam file to a .bam file through samtools sort to get the sorted .bam file on the same machine so I don't think I'm running out of memory.

    I wonder if anyone could help me figure out what is going wrong.
  • Axel
    Junior Member
    • Feb 2014
    • 8

    #2
    Hi again,
    I thought I'd write and say I've sorted it out.
    Instead of trying to write a new .sam file I pipe the contents of the .bam file straight to the downstream programs in .sam format

    e.g.
    Code:
    samtools view -h in_sorted.bam | htseq-count - features.gtf

    Comment

    • arundurvasula
      Member
      • Jun 2014
      • 16

      #3
      Hi, I figured I'd just comment on this thread since I was going to name my thread the same thing. I'm trying to go from sam -> bam with
      Code:
      samtools view -bS ../results/Y920/Y920-trimmed-idba_ud/alignment.sam > ../results/Y920/Y920-trimmed-idba_ud/alignment.bam
      but I'm getting a segmentation fault. I have 8 GB of RAM, which I guess could be a problem. My sam file is ~300Mb. Do I need more RAM or is this a problem with samtools? I'm running 0.1.19 from the Ubuntu Software Repository.

      Also I'm using a virtual machine.
      Last edited by arundurvasula; 07-08-2014, 12:41 PM.

      Comment

      • swbarnes2
        Senior Member
        • May 2008
        • 910

        #4
        Can you confirm that you .bam really is a .bam file? That's the first thing I'd check.

        Comment

        • dpryan
          Devon Ryan
          • Jul 2011
          • 3478

          #5
          swbarnes2 meant ".sam" rather than ".bam". It's likely that a line is corrupt in the SAM file. If the file looks correct, then use "head -n some_number ... | samtools view -Sb - > ..." to determine if you can find the line triggering the problem (or just run the thing in a debugger).

          Comment

          • WhatsOEver
            Senior Member
            • Apr 2012
            • 215

            #6
            @arundurvasular: using the view command requires indeed more RAM (though 300Mb is actually a really small file) Try the following instead:

            Build an index of your genome
            Code:
            samtools faidx genomeFile.fasta
            Use the import command to convert from sam to bam
            Code:
            samtools import $samIndex $samFile $bamFile

            Comment

            • dpryan
              Devon Ryan
              • Jul 2011
              • 3478

              #7
              The "import" command was removed years ago. It's an alias for "samtools view" now.
              Code:
              int main_import(int argc, char *argv[])
              {
                      int argc2, ret;
                      char **argv2;
                      if (argc != 4) {
                              fprintf(stderr, "Usage: bamtk import <in.ref_list> <in.sam> <out.bam>\n");
                              return 1;
                      }
                      argc2 = 6;
                      argv2 = calloc(6, sizeof(char*));
                      argv2[0] = "import", argv2[1] = "-o", argv2[2] = argv[3], argv2[3] = "-bt", argv2[4] = argv[1], argv2[5] = argv[2];
                      ret = main_samview(argc2, argv2);
                      free(argv2);
                      return ret;
              }

              Comment

              • WhatsOEver
                Senior Member
                • Apr 2012
                • 215

                #8
                oh, good to know

                It's then just the provided index that results in less memory consumption?! Cause my command works faster and requires less RAM on my dataset then the previously posted command.

                Comment

                • dpryan
                  Devon Ryan
                  • Jul 2011
                  • 3478

                  #9
                  I'd be a bit surprised if it used less memory (at least if there's a significant difference). The only difference is the reheadering that's done with samtools import. A header doesn't really take that much RAM, at least unless it's filled with lots of small contigs.

                  Comment

                  • WhatsOEver
                    Senior Member
                    • Apr 2012
                    • 215

                    #10
                    yes, sry, my fault - indeed my header is kind of extremely big (17M contigs)
                    But nevertheless: Memory shouldn't actually be an issue here. The sam file is really small and although arundurvasular is running a virtual machine, 8Gb should be enough.

                    Comment

                    • dpryan
                      Devon Ryan
                      • Jul 2011
                      • 3478

                      #11
                      Yeah, 8 gigs should be way more than could possibly be needed.

                      @arundurvasular: If you're unable to find a way around this, then try posting the file somewhere (dropbox, google drive, etc.) and one of us can run samtools in a debugger (unless you're familiar with doing that yourself). It's possible that this is an obscure bug, but I suspect the original file is just malformed.

                      Comment

                      Latest Articles

                      Collapse

                      • mylaser
                        Reply to Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                        by mylaser
                        Kheloyar – Everything You Need to Know About Kheloyaar Login and Kheoyar Id
                        If you are looking for an online gaming platform that offers a user-friendly experience, Kheloyar has become a name that many users search for. Whether you're interested in creating a new account, accessing your dashboard through Kheloyaar Login, or learning how to obtain a Kheoyar Id, understanding the platform's features and account process is essential.
                        This guide explains everything you need to know about...
                        Today, 01:13 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
                      • 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

                      ad_right_rmr

                      Collapse

                      News

                      Collapse

                      Topics Statistics Last Post
                      Started by SEQadmin2, 07-09-2026, 10:04 AM
                      0 responses
                      15 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 07-08-2026, 10:08 AM
                      0 responses
                      10 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 07-07-2026, 11:05 AM
                      0 responses
                      22 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 07-02-2026, 11:08 AM
                      0 responses
                      31 views
                      0 reactions
                      Last Post SEQadmin2  
                      Working...