SEQanswers

Go Back   SEQanswers > Bioinformatics > Bioinformatics



Similar Threads
Thread Thread Starter Forum Replies Last Post
velvet- stats.txt file vani s kulkarni Bioinformatics 4 12-10-2019 08:42 PM
Galaxy Bowtie alignment stats report ericguo Bioinformatics 1 12-08-2011 11:57 AM
SAMTools index stats strange result? tatinhawk Bioinformatics 3 09-01-2011 08:29 AM
bowtie mapping stats mapper Bioinformatics 1 11-29-2010 06:22 AM
samtools flagstat mismatch in stats rcorbett Bioinformatics 3 09-09-2010 05:36 PM

Reply
 
Thread Tools
Old 05-19-2011, 07:22 AM   #1
rwn
jack of informatics
 
Location: Portland, OR

Join Date: May 2011
Posts: 2
Default 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)
rwn is offline   Reply With Quote
Old 05-19-2011, 11:51 AM   #2
adamdeluca
Member
 
Location: Iowa City, IA

Join Date: Jul 2010
Posts: 95
Default

demo.pl
Code:
#! /usr/bin/perl
print STDERR "error";
print "out";
Code:
./demo.pl 2> stderr.txt | cat > stdout.txt
adamdeluca is offline   Reply With Quote
Old 05-20-2011, 06:16 AM   #3
rwn
jack of informatics
 
Location: Portland, OR

Join Date: May 2011
Posts: 2
Default

Thanks for the example... hadn't thought of piping the output to cat, but unfortunately, that syntax didn't work either.
rwn is offline   Reply With Quote
Old 09-22-2011, 07:25 AM   #4
mgogol
Senior Member
 
Location: Kansas City

Join Date: Mar 2008
Posts: 197
Default

(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.

http://stackoverflow.com/questions/6...ee-with-a-pipe

Last edited by mgogol; 09-22-2011 at 07:28 AM.
mgogol is offline   Reply With Quote
Reply

Tags
samtools, samtools bowtie

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off




All times are GMT -8. The time now is 06:25 AM.


Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2020, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO