Hi
I am new to sequence analysis and am working on wheat to identify progenitor specific SNPs. I have GBS sequence reads mapped against the wild progenitor of wheat and in the first step, I have separated mapped and unmapped reads from these bam files. Next, I have realigned the unmapped reads from progenitor genome (diploid) to the bread wheat genome (hexaploid) with BWA using following commands:
Command Used for converting .bam files to .fastq files:
$ samtools bam2fq mapped.bam > mapped.fastq
Command Used for aligning mapped reads against bread wheat genome:
$ bwa aln –t 6 –k 2 –o 0 <IndexedReferenceFile> mapped.fastq > At3_m2.bam
where,
k — maximum difference in the seed (gaps + mismatches)
o — number of allowed gaps
The new mapping files were generated without any error. In the next step, I need to separate mapped and unmapped reads again, but when I am using the new bam files for next steps it is giving me following error:
[E::hts_hopen] Failed to open file At3_m2.bam
[E::hts_open_format] Failed to open file At3_m2.bam
samtools view: failed to open "At3_m2.bam" for reading: Exec format error
I have tried following command for separating mapped and unmapped reads:
$ samtools view -b -f 4 <file>.bam > <file>_unmapped.bam
$ samtools view -h -f 4 <file>.bam > <file>_unmapped.bam
$ samtools view -b -h -f 4 <file>.bam > <file>_unmapped.bam
Is something wrong with the set of commands I am using or something is wrong with the realigning? Could you please help me with this error. Thank you in advance!
Are the reads you have very short < 50-70bp? If not better use
bwa mem
for alignment and pipe it directly into a sorting command such as:bwa mem (options...) | samtools sort -o sorted.bam
That saves you from large (uncompressed) sam files and gives you the sorted bam file right away, which you'll need for variant calling later.
Hi ATpoint My read length is greater is around 130bp. I have not tried bwa mem with that. But I will surely try it. Thank you for your help:)
I suspect
bwa aln
writes a sam file, and not a bam file.Hi WouterDeCoster! I did check with my commands and bwa aln actually created .sai file. This .sai file could be further converted to .sam file using bwa samse. Thank you for your help:)