I tried this but I got no output. It had something to do with the SRA not being aligned.
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?
1 answer
I am trying to convert some SRA files to BAM format
You can convert SRA directly into SAM. The SRA toolkit offers the program sam-dump for this purpose, see here.
As fastq-dump is intended to extract fastq from SRA files, sam-dump can be used to convert SRA into SAM. An SRA file is already much like a SAM file, it comprises a mapping of some reads to a reference sequence.
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.
/usr/local/lib/SRA-toolkit/sam-dump.2.5.4 SRR1927226 | samtools view -bS - > SRR1927226.bam
I tried this with SRR1302886.sra but got only this:
sam-dump SRR1302886.sra | /usr/bin/samtools view -bS - > SRR1302886.bam
[samopen] no @SQ lines in the header.
[sam_read1] missing header? Abort!
add manually from some SAM file. Shouldn't really mess anything if you look closely what is in the header
Log in to answer this question.