Seqanswers Leaderboard Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • rwn
    jack of informatics
    • May 2011
    • 2

    Capturing bowtie stats / samtools pipe / file IO?

    Hi all,

    I've been working on tweaking our NGS analysis pipeline and came across this minor issue for which I could not find a solution.

    The current pipeline scripts do some I/O redirection (2>&1) to capture the stats from bowtie alignment (which are printed to stderr): This works fine if you simply issue a command to run bowtie.

    bowtie -q -S index fqsequence >> stats.txt 2>&1

    stats.txt
    # reads processed: 1679207
    # reads with at least one reported alignment: 1487157 (88.56%)
    # reads that failed to align: 155467 (9.26%)
    # reads with alignments suppressed due to -m: 36583 (2.18%)
    Reported 1487157 alignments to 1 output stream(s)

    As part of the upgrade, I want to pipe the bowtie output directly to SAMtools (instead of creating an intermediate SAM file) to produce the BAM file on the fly. No problem, this also works fine.

    bowtie -q -S index fqsequence | samtools view -bS -o testoutput.bam -

    [samopen] SAM header is present: 14543 sequences.
    # reads processed: 1679207
    # reads with at least one reported alignment: 1487157 (88.56%)
    # reads that failed to align: 155467 (9.26%)
    # reads with alignments suppressed due to -m: 36583 (2.18%)
    Reported 1487157 alignments to 1 output stream(s)

    I figured it would be easy to capture the stderr output from this pipe and send it to the stats file as before, but appending this command with >> stats.txt 2>&1 only shunts the SAMtools information to the file. The bowtie stats are still printed to the screen. I've played around with the i/o redirect commands and can't get it to work. Any suggestions?

    bowtie -q -S index fqsequence | samtools view -bS -o testoutput.bam - >> stats.txt 2>&1

    stats.txt
    [samopen] SAM header is present: 14543 sequences.

    screen output:
    # reads processed: 1679207
    # reads with at least one reported alignment: 1487157 (88.56%)
    # reads that failed to align: 155467 (9.26%)
    # reads with alignments suppressed due to -m: 36583 (2.18%)
    Reported 1487157 alignments to 1 output stream(s)
  • adamdeluca
    Member
    • Jul 2010
    • 95

    #2
    demo.pl
    Code:
    #! /usr/bin/perl
    print STDERR "error";
    print "out";
    Code:
    ./demo.pl 2> stderr.txt | cat > stdout.txt

    Comment

    • rwn
      jack of informatics
      • May 2011
      • 2

      #3
      Thanks for the example... hadn't thought of piping the output to cat, but unfortunately, that syntax didn't work either.

      Comment

      • mgogol
        Senior Member
        • Mar 2008
        • 197

        #4
        (bowtie genome --sam <(gunzip -c file.fastq.gz) | samtools view -bS -o results.bam - ) 2> bowtie.err

        This worked for me (with bash).

        There may also be some way to use tee here, but I don't know exactly.

        I know how to use tee to write the output (standard output) of aaa.sh to bbb.out, while still displaying it in the terminal: ./aaa.sh | tee bbb.out How would I now also write standard error to a f...
        Last edited by mgogol; 09-22-2011, 07:28 AM.

        Comment

        Latest Articles

        Collapse

        • seqadmin
          Pathogen Surveillance with Advanced Genomic Tools
          by seqadmin




          The COVID-19 pandemic highlighted the need for proactive pathogen surveillance systems. As ongoing threats like avian influenza and newly emerging infections continue to pose risks, researchers are working to improve how quickly and accurately pathogens can be identified and tracked. In a recent SEQanswers webinar, two experts discussed how next-generation sequencing (NGS) and machine learning are shaping efforts to monitor viral variation and trace the origins of infectious...
          Today, 11:48 AM
        • seqadmin
          New Genomics Tools and Methods Shared at AGBT 2025
          by seqadmin


          This year’s Advances in Genome Biology and Technology (AGBT) General Meeting commemorated the 25th anniversary of the event at its original venue on Marco Island, Florida. While this year’s event didn’t include high-profile musical performances, the industry announcements and cutting-edge research still drew the attention of leading scientists.

          The Headliner
          The biggest announcement was Roche stepping back into the sequencing platform market. In the years since...
          03-03-2025, 01:39 PM
        • seqadmin
          Investigating the Gut Microbiome Through Diet and Spatial Biology
          by seqadmin




          The human gut contains trillions of microorganisms that impact digestion, immune functions, and overall health1. Despite major breakthroughs, we’re only beginning to understand the full extent of the microbiome’s influence on health and disease. Advances in next-generation sequencing and spatial biology have opened new windows into this complex environment, yet many questions remain. This article highlights two recent studies exploring how diet influences microbial...
          02-24-2025, 06:31 AM

        ad_right_rmr

        Collapse

        News

        Collapse

        Topics Statistics Last Post
        Started by seqadmin, 03-20-2025, 05:03 AM
        0 responses
        26 views
        0 reactions
        Last Post seqadmin  
        Started by seqadmin, 03-19-2025, 07:27 AM
        0 responses
        33 views
        0 reactions
        Last Post seqadmin  
        Started by seqadmin, 03-18-2025, 12:50 PM
        0 responses
        25 views
        0 reactions
        Last Post seqadmin  
        Started by seqadmin, 03-03-2025, 01:15 PM
        0 responses
        190 views
        0 reactions
        Last Post seqadmin  
        Working...