Question: Piping bowtie2 output directly into BAM
0
gravatar for hersh
6 months ago by
hersh0
hersh0 wrote:

I am using bowtie2, and due to the size of the SAM output, I would like to entirely avoid the SAM file, and pipe the results into samtools to convert the output to a BAM file. I am getting a little bit hung up on how to accomplish this.

I have tried a few different options:

The approach here: http://slhogle.github.io/2014/bowtie-and-samtools/

and here: http://www.metagenomics.wiki/tools/samtools/breadth-of-coverage

are both giving me an empty BAM file.

I have also tried:

bowtie2 -x [index] -U [reads] -S ${TMPDIR}/temp.sam | samtools view -bS > out.bam

To see if I would get anything different using the temp directory to store the SAM temporarily.

Edit in response to a comment to add the commands I have tried:

bowtie2 -x [index] -U [reads] -S - | samtools view -bS > out.bam

And

bowtie2 -x [index] -U [reads] -S - | samtools view -bS -  > out.bam

I'm sure this has been done before, is there an obvious way to accomplish this task?

Thanks.

alignment • 1.5k views
ADD COMMENTlink modified 6 months ago by cmdcolin1.2k • written 6 months ago by hersh0

A: Alignment with bowtie2 but empty .fastq files

ADD REPLYlink written 6 months ago by genomax73k

Why don't you write all the command lines you tried. It seems to me that the one you did write won't work, because it's not going to send output to samtools, it's writing it to temp.sam. Your first link is to bowtie, which might not work with bowtie2.

ADD REPLYlink written 6 months ago by swbarnes26.7k
3
gravatar for cmdcolin
6 months ago by
cmdcolin1.2k
United States
cmdcolin1.2k wrote:

You shouldn't need to use the -S command for the output, just omit this arguement

bowtie2 -x genomeindex -U out.fq|samtools view -bS - > out.bam

Versions

% bowtie2 --version
/usr/bin/bowtie2-align-s version 2.3.4.2
64-bit
% samtools --version
samtools 1.7
Using htslib 1.7-2
Copyright (C) 2018 Genome Research Ltd.
ADD COMMENTlink modified 6 months ago • written 6 months ago by cmdcolin1.2k

Thanks! I tried this string and my BAM was correct. Was the issue just that I was using the -S flag?

ADD REPLYlink written 6 months ago by hersh0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 3572 users visited in the last hour