Short Read Aligner - Output To Bam/Sam Only Aligned Reads
1
3
Entering edit mode
13.3 years ago
Leszek 4.2k

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?

aligner short bam • 4.0k views
ADD COMMENT
1
Entering edit mode

Often it is counterproductive to filter the output right away. You may need the information on unaligned/unpaired 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 REPLY
7
Entering edit mode
13.3 years ago
brentp 24k

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 COMMENT
1
Entering edit mode

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

ADD REPLY
0
Entering edit mode

Right you are. Thanks.

ADD REPLY
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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

ADD REPLY

Login before adding your answer.

Traffic: 1880 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