Entering edit mode
4.3 years ago
storm1907
▴
30
Hi, Is there a way to get SAM files into readable FASTA format without samtools? I have a bunch of SAM files, and I need to read header and at least first lines of them. SAM files are gunzipped files, but gunzipping is not working with them.
SAM files are not "gunzipped". Also, if a file is already decompressed, decompressing again won't work.
Do you want to make a SAM become a FASTA?
Did you gzip the SAM files? It would be more convenient if they were converted to a BAM file.
check http://seqanswers.com/forums/showthread.php?t=6169
What you want might be done by:
Hmm, I tried this, and got text file with symbols like these
What do you see when you try
file <your.bam>
in the command line? If it happens to be a BAM file, you will seegzip compressed data, extra field
whereas it will showASCII text, with very long lines
for a SAM file. You will get a clue as to what kind of compression it is if it's neither.The thing is that I am not even able to get bam files from sam with samtools. My theory is that bwa mem somehow changes the header in sam, therefore I need to see sam file.
This is the header of one of my PE files after adapter trimming. Looks OK at the moment.
But after BWA, I get error message from Samtools about "failed to read header"
what is the BWA command you are running?
Why are you doing this? You are gzipping your file no wonder you get those binary characters. You can directly feed the output of
bwa mem
tosamtools
to generate the sorted BAM files.Yep, I removed it from code. Now it looks like BWA MEM is adding filename before header
This does not look right. You should get an output that is in SAM format (if you just removed the
gzip
). Page 2 in SAM format spec.Problem solved. -R option is necessary in BWA MEM - to add read groups header (important for samtools), otherwise I could not get any further