text: user2594: 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.
  
  user7153: 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
  
  
original_text: 2594: <p>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 <code>htslib</code> for parsing sam/bam files and extracting based on any flags. Any help on how to start will be appreciated.</p>
   7153: <p>This is how I do it.</p>
  <pre><code>samtools view -@5 -f 0x800 -hb /path/sample.bam &gt; sup.bam
  </code></pre>
  <p>Then if you want it as a fasta</p>
  <pre><code>samtools view -F 0x1 -hb sup.bam | samtools fasta -F 0x1 - &gt; sup.fa
  </code></pre>
  