Question: Short Read Aligner - Output To Bam/Sam Only Aligned Reads
3
gravatar for Leszek
7.8 years ago by
Leszek4.0k
IIMCB, Poland
Leszek4.0k wrote:

I want to align PE Illumina reads (FastQ) onto very short reference (mitochondrial). I'm not interested in reads that didn't align...
Do you know any short read aligner that can output BAM file? Or how to limit SAM output to aligned sequences only?

short aligner bam • 2.5k views
ADD COMMENTlink written 7.8 years ago by Leszek4.0k
1

Often it is counterproductive to filter the output right away. You may need the information on unaligned/upaired reads at some point. Usually it is better to first generate the full SAM file, then filter it as the answers below show it.

ADD REPLYlink written 7.8 years ago by Istvan Albert ♦♦ 80k
7
gravatar for brentp
7.8 years ago by
brentp23k
Salt Lake City, UT
brentp23k wrote:

Please refer to this question

Any aligner will probably send alignments to stdout, so you can do something like:

aligner input.fastq ... | samtools view -SF 0x04 -b - > only.aligned.bam

(And use -f 0x02 to require properly paired reads).

Where the -F flag removes unaligned reads. See the manual.

ADD COMMENTlink modified 7.8 years ago • written 7.8 years ago by brentp23k
1

Just a minor tweak: you'll need the -S flag for samtools to indicate that it is accepting SAM (not BAM) as input.

ADD REPLYlink written 7.8 years ago by Aaronquinlan11k

Right you are. Thanks.

ADD REPLYlink written 7.8 years ago by brentp23k

does samtools view read from stdin? In my case it didn't.

ADD REPLYlink written 7.8 years ago by Leszek4.0k

@Leszek, I updated the example command if you use '-' as the filename, samtools view will read from stdin.

ADD REPLYlink written 7.8 years ago by brentp23k
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: 1111 users visited in the last hour