Hi, I am trying to extract unmapped reads from my BWA sorted BAM file (paired end reads);
First I filter for the following things using these command lines which seems to work fine:
1) An unmapped read whose mate is mapped.
samtools view -u -f 4 -F264 alignments.bam > temp1.bam
2) A mapped read who's mate is unmapped
samtools view -u -f 8 -F 260 alignments.bam > temp2.bam
3) Both reads of the pair are unmapped
samtools view -u -f 12 -F 256 alignments.bam > temp3.bam
Then I try to merge the files and sort it so it's ordered by read name using the following command
samtools merge -u - temp[123].bam | samtools sort -n - unmapped
BUT I get this error message:
[bam_header_read] EOF marker is absent. The input is probably truncated.
[bam_header_read] EOF marker is absent. The input is probably truncated.
[bam_header_read] EOF marker is absent. The input is probably truncated.
My next step would be to convert the BAM to fastq but I can't seem to get past this error despite trying out various other options. I get the same message after just trying to samtools merge comman on its own?
I also tried the bam2fastq script from Hudson alpha but it only seemed to output reads where both in the pair had not mapped, but I want to extract all unmapped reads?
Any help MUCH appreciated!
First I filter for the following things using these command lines which seems to work fine:
1) An unmapped read whose mate is mapped.
samtools view -u -f 4 -F264 alignments.bam > temp1.bam
2) A mapped read who's mate is unmapped
samtools view -u -f 8 -F 260 alignments.bam > temp2.bam
3) Both reads of the pair are unmapped
samtools view -u -f 12 -F 256 alignments.bam > temp3.bam
Then I try to merge the files and sort it so it's ordered by read name using the following command
samtools merge -u - temp[123].bam | samtools sort -n - unmapped
BUT I get this error message:
[bam_header_read] EOF marker is absent. The input is probably truncated.
[bam_header_read] EOF marker is absent. The input is probably truncated.
[bam_header_read] EOF marker is absent. The input is probably truncated.
My next step would be to convert the BAM to fastq but I can't seem to get past this error despite trying out various other options. I get the same message after just trying to samtools merge comman on its own?
I also tried the bam2fastq script from Hudson alpha but it only seemed to output reads where both in the pair had not mapped, but I want to extract all unmapped reads?
Any help MUCH appreciated!
Comment