Unconfigured Ad

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

    #1

    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

                      • SEQadmin2
                        Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
                        by SEQadmin2



                        Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

                        Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
                        ...
                        10-14-2026, 09:55 AM
                      • SEQadmin2
                        New Genomics Technologies Take Aim at Long-Standing Limits
                        by SEQadmin2


                        Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

                        We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
                        ...
                        09-28-2026, 10:25 AM

                      ad_right_rmr

                      Collapse

                      News

                      Collapse

                      Topics Statistics Last Post
                      Started by SEQadmin2, Today, 11:13 AM
                      0 responses
                      11 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, Today, 10:48 AM
                      0 responses
                      10 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 10-15-2026, 10:52 AM
                      0 responses
                      32 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 10-14-2026, 05:39 AM
                      0 responses
                      40 views
                      0 reactions
                      Last Post SEQadmin2  
                      Working...