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.
psl2sam.pl solution no longer works very well. I verified this by uploading the input psl and the output sam (converted to bam) to the UCSC genome browser.
Since this page comes up as the first hit on Google, here's a better solution using bedtools, which you can
apt-get on ubuntu
(or look around on that site for your operating system)
Get a list of chromosome sizes, for instance
pslToBed input.psl input.bed
bedtools bedtobam -bed12 -i input.bed -g hg38.chrom.sizes > output.bam
samtools view output.bam > output.sam
Using this, my input.psl matches my output.bam file when uploaded as a track.