I have some short reads aligned using BLAT, the output is in tabular psl format (including the sequences) for each alignment. Is it possible to convert the blat output to SAM/BAM format. Myself, I would think it is not because of the lack of some data fields in psl which is required for SAM format (mainly the CIGAR string), but please proove me wrong! Normally I would advise myself to use a different tool (bwa, bowtie, lastz) and align getting a SAM file, but what if that wasn't an option (say because you really want to use BLAT or you don't have the input) is there a way to do the conversion. I can possibly code that in perl and share it if someone had an idea how to do it.
Yeah, thanks a lot. Tested, that seems to work. Even without the sequences included. I wonder what more nice things are there hidden in samtools. btw, the script has some options (-a,-b, -q, -r) but they are seemingly ignored.
This script would not add the header to the sam file. Here is how to add header to your sam file.
If you want some additions on top of that (for example to view in IGV) I just did the following oneliner:
where this script is add_seq_info_to_psl2sam.py: