I am trying to convert some SRA files to BAM format but I have a problem. How do I convert a FASTQ file to BAM file? I've been trying for some time and I wrote the following script:
#!/bin/bash
bin/fastq-dump $1 -Z > $1.fastq
picard-tools FastqToSam F1=$1.fastq O=$1.bam SM=sampleName SO=unsorted Validation_STRINGENCY=LENIENT
DIR=`dirname $1`
NAME=`basename $1 .sra`
samtools sort $1.bam ${DIR}/foo
samtools index ${DIR}/foo.bam
rm $1.fastq $1.bam
I get a BAM file but it has no header:
samtools view -H foo.bam
@HD VN:1.4 SO:coordinate
@RG ID:A SM:sampleName
How do I fix a header? I guess I have to give a reference sequence when converting from FASTQ to BAM?
I tried this but I got no output. It had something to do with the SRA not being aligned.
I have made a test run with SRR1927226 (download size about 400 MB) and it worked flawlessly. The reads in SRR1927226 are not aligned to a refsequence. Due to the download size, the command needs more than 5 minutes to finish.
I tried this with
SRR1302886.sra
but got only this:add manually from some SAM file. Shouldn't really mess anything if you look closely what is in the header