This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Bowtie2-output to file

Hi,

I need to get the result from a Bowtie-run to file. I dont meen the sam-file, but the results that says how many read were aligned ect.

I've done it before, but now I cant get it to work... :(

Any suggestions

Kim

bowtie

3 answers

This command is working fine for me

(bowtie2 -p 10 -x genome -U sample.fastq -S sample.sam) 2>file.log

I think, the trick is to place the bowtie command in brackets. In case you have multiple samples via shell script, you can place all alignment details in one file using 2>>file.log.

Hi Satyajeet

I am trying to get this log to work for batch processing multiple files - would something like this work?

#!/bin/bash
#Alignment using bowtie2
for file in *.fq ; do

    (bowtie2 -p60 --met-file "path/to/metrics/$file_metrics.txt"  -x path/to/refgenome -U "$file" -S "path/to/output/$file.sam") 2>$file.log

done

Thanks!

I don't think the double quotes will work. Can you try without them?

P.S. May I know why you plan to use --met-file?

Thanks

Hi Satyajeet,

I was able to get it working! The command above worked, and saved log files per sample. The main issue I had was with encoding between linux and microsoft (\r).

The met file was a just in-case we needed - It was a first instance of running on a new cluster, so if there were performance issues we were recommended to save it by a colleague.

Thanks again, A

The log output of Bowtie is sent to stderr, completely illogically.
So, just direct the output of stderr to a log file.
Since stdout is the sam file produced by Bowtie, you'll need to distinguish between stdout and stderr.

bowtie ... 1> file.sam 2> bowtie.log

bowtie.log will contain the statistics on the alignment.

Almost all bioinformatic tools write to stderr for some reason.
I guess the logic is that if they output data on stdout it can be piped to something else, whilst info messages go to stderr - but I agree this is totally un-POSIX, and would never fly outside of bioinformatics. But hey - its not a big deal at the end of the day.

Great - thanks!

Ill try that.

Log in to answer this question.