does anyone know a quick uinx command to take the first N alignments from a BAM file? I tried viewing it as SAM, with headers, taking first N lines and then piping back to samtools but it fails:
samtools view -h big_bam -b | head -n 1000 | samtools view - -h -b > small_bam
it yields the error:
[main_samview] truncated file.