0
$\begingroup$

I am trying to extract all chimeric and multi-map reads from either SAM/BAM file. Is there any simple command to do that? Can I use htslib for parsing sam/bam files and extracting based on any flags. Any help on how to start will be appreciated.

$\endgroup$
1
$\begingroup$

This is how I do it.

samtools view -@5 -f 0x800 -hb /path/sample.bam > sup.bam

Then if you want it as a fasta

samtools view -F 0x1 -hb sup.bam | samtools fasta -F 0x1 - > sup.fa
$\endgroup$
2
  • $\begingroup$ Thanks !! It works great. I will use samtools source code to write a small program to extract the reads based on flag. $\endgroup$ – SBDK8219 Feb 18 at 5:52
  • $\begingroup$ Pysam wraps it pretty well, just fyi $\endgroup$ – Liam McIntyre Feb 18 at 7:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.