Quote:
Originally Posted by thh32
This would work if I wanted a SAM file output but I am aiming for a similar output to that provided with bowtie where you get a file of the reads that align to the indexed file and a seperate file for reads that dont align to the indexed file.
Is there a way to do this with BWA?
|
Untested, but it should work in bash:
Code:
bwa mem myIndex myReads.fq.gz \
| tee >(samtools view -Sh -f4 - > unmapped.sam) \
| tee >(samtools view -Sh -F4 - > mapped.sam) > /dev/null
This sends unmapped reads (-f4) to unmapped.sam and mapped reads (-F4) to mapped.sam. You could customize the samtools commands in the subshells to decide what goes in each file (e.g. by using -q options). In fact, while you are at it, I would convert to bam and sort the mapped reads.
Dario