Header Leaderboard Ad

Collapse

samtools sort stdout

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • samtools sort stdout

    Hello

    I am mapping reads from bacterial sequences to reference genomes and I am using bwa and samtools. I am trying to set up a pipeline and want to use stdin and stdout and pipe the data to avoid temporary files. I am using samtools-0.1.13.

    Do you know if you can get the output of samtools sort to stdout?

    The manual pages says that the -o option means stdout for samtools sort , but it doesn't seem to work on my system.

    Here is the command line I have used to make quality filtering and sorting in one line and the error message I get:
    >samtools view -b -q 30 5139_6_7.paired_ends.bam | samtools sort -o - > temp
    Usage: samtools sort [-on] [-m <maxMem>] <in.bam> <out.prefix>

    >samtools view -b -q 30 5139_6_7.paired_ends.bam | samtools sort - - > temp
    And this makes as expected an empty temp file and the sorted alignment in "-.bam"

    Do you know how I can avoid the *.bam output file?

    Thanks
    Peder Worning

  • #2
    Try providing an output prefix anyway. Even if you specify -o, I think samtools will use that prefix to create temp files if the BAM to be sorted won't fit in memory.

    So to modify your example,

    Code:
    samtools view -b -q 30 in.bam | samtools sort -o - deleteme > out.bam
    should result in a new out.bam file; deleteme.* may be created as intermediate files but will be cleaned up after the sort
    Last edited by daler; 04-09-2011, 07:08 AM. Reason: (edit: forgot the -o!)

    Comment


    • #3
      Originally posted by pederworning View Post
      Do you know how I can avoid the *.bam output file?

      Thanks
      Peder Worning
      AFAIK there's no way to do that. samtools sort doesn't handle stdout.

      d

      Comment


      • #4
        Originally posted by pederworning View Post
        Do you know how I can avoid the *.bam output file?

        Thanks
        Peder Worning
        AFAIK there's no way to do that. samtools sort doesn't handle stdout.

        d

        Comment


        • #5
          The samtools "Working on a stream" page (http://samtools.sourceforge.net/pipe.shtml) says:

          "In fact, most of samtools commands, except indexing and external sorting, recognize an input file `-' as stdin and an output file `-' as stdout."

          I suppose the rationale is if you're sorting an input list, you can't send items away before you know which position in the output list they will have, making working on the stream trickier.

          Comment

          Latest Articles

          Collapse

          • seqadmin
            Improved Targeted Sequencing: A Comprehensive Guide to Amplicon Sequencing
            by seqadmin



            Amplicon sequencing is a targeted approach that allows researchers to investigate specific regions of the genome. This technique is routinely used in applications such as variant identification, clinical research, and infectious disease surveillance. The amplicon sequencing process begins by designing primers that flank the regions of interest. The DNA sequences are then amplified through PCR (typically multiplex PCR) to produce amplicons complementary to the targets. RNA targets...
            03-21-2023, 01:49 PM
          • seqadmin
            Targeted Sequencing: Choosing Between Hybridization Capture and Amplicon Sequencing
            by seqadmin




            Targeted sequencing is an effective way to sequence and analyze specific genomic regions of interest. This method enables researchers to focus their efforts on their desired targets, as opposed to other methods like whole genome sequencing that involve the sequencing of total DNA. Utilizing targeted sequencing is an attractive option for many researchers because it is often faster, more cost-effective, and only generates applicable data. While there are many approaches...
            03-10-2023, 05:31 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, Yesterday, 12:26 PM
          0 responses
          7 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 03-17-2023, 12:32 PM
          0 responses
          14 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 03-15-2023, 12:42 PM
          0 responses
          21 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 03-09-2023, 10:17 AM
          0 responses
          68 views
          1 like
          Last Post seqadmin  
          Working...
          X