I have aligned my fastq files to hg19 using this command:
bwa mem hg19.fa /DATA/myfile.fastq.gz
then I made bam files from sam files using:
samtools view -Sb myfile.sam > myfile.bam
then I sorted the bam files using:
samtools sort myfile.bam myfile.sorted.bam
and now I am trying to index the sorted bam files using:
samtools index myfile.sorted.bam
but I got this error:
[bam_header_read] EOF marker is absent. The input is probably truncated.
[bam_header_read] invalid BAM binary header (this is not a BAM file).
[bam_index_core] Invalid BAM header.[bam_index_build2] fail to index the BAM file.
do you know what the problem is?
What you should actually be doing is:
and avoid all manual intermediate steps and unnecessary intermediate files.
Should add
-h
to everysamtools view
to get the headers. Not sure about the truncation