Hi all! I'm trying to find common reads between two bam files. I first sorted the bam files by read name and then used comm (https://linux.die.net/man/1/comm). Here is my code:
samtools sort -n unmapped_reads1.bam -o unmapped_reads1_sorted.bam samtools sort -n unmapped_reads2.bam -o unmapped_reads2_sorted.bam comm -12 unmapped_reads1_sorted.bam unmapped_reads2_sorted.bam > common_seqs.bam
Comm spits out these two messages:
comm: file 2 is not in sorted order
comm: file 1 is not in sorted order
and the resulting output file (common_seqs.bam) is empty. Anyone experienced this? or recommend any other ways to do this task?