Thanks.
Hi,
I need to do a complement between two bam files. I have tried to use the diff function in bamUtils to find the differences between the two, but when I'm trying to use samtools to run further analyses it is telling me that I have a truncated file. I haven't been able to find out if bamUtils is using a different end of file character than samtools is looking for or not. That is the only reason that I can think of as to why it would come up with a truncated file and not find the EOF character. Is there a way to do a complement between two bam files with samtools or possibly picard? I have not been able to find any sites online where they have said if they can or not.
Thanks!
1 answer
I wrote the following tool https://github.com/lindenb/jvarkit/wiki/CmpBams but it doesn't produce a BAM.
UPDATE: according to your comment:
- use
samtools view -H file1.bam > out.samto save header - sort your BAM on read names using
samtools sort -n, save as SAM (not BAM) withsamtools viewwithout the header - use unix
join -t '\t' -a 1 -1 1 -2 1 sorted1.sam sorted2.sam >> out.samto find the read in one file but not in the other - convert the sam file back to bam with samtools.
Log in to answer this question.
I don't understand what you mean by complement? Are you referring to coverage?
I mean complement as in the set operator. I need to see what is in one file that is not in the other.
what do you mean 'one file is not in the other ' ? A read named R123456 is found in file 1 but not in file 2 ? or a read named R123456 s found a chr1:98798 in file 1 but the same R123456 was mapped on chrX:9879 in file2
The first. I have to see what reads are in one and not in the other.