Bowtie2-output to file
3
2
Entering edit mode
8.2 years ago
kimaebeloe ▴ 20

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 • 15k views
ADD COMMENT
5
Entering edit mode
7.6 years ago
Satyajeet Khare ★ 1.6k

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.

ADD COMMENT
0
Entering edit mode

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!

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY
3
Entering edit mode
8.2 years ago
ablanchetcohen ★ 1.2k

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.

ADD COMMENT
1
Entering edit mode

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.

ADD REPLY
0
Entering edit mode
8.2 years ago
kimaebeloe ▴ 20

Great - thanks!

Ill try that.

ADD COMMENT

Login before adding your answer.

Traffic: 2477 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6