# Convert PAF format to SAM/BAM format

I have a bunch of PAF files resulting from the alignments of fastq files on a reference genome with minimap2. I would like to convert them into SAM/BAM format so I can use samtools mpileup to recover the read coverage at filtered positions

So far I've looked at paftools.js and found sam2paf but no paf2sam

I am open to suggestions but I'd like to avoid mapping the reads again.

Edit

I have opened an issue on minimap2's github

You need to rerun alignment. No tools exist to convert paf to sam.

why there is no paf2sam in paftools.js


It is technically possible, but someone needs to write the code.

• I'm not sure the question is answerable in its current format, there doesn't appear to be enough background information and this often results in substancial misunderstanding between OP and the reply. Lets see what the other think.
– M__
Oct 9, 2019 at 12:38
• Thanks for the feedback. So, as far I as know mpileup can take an alignment file and a list of genomic positions (eg BED) and return statistics for each positions, such as the read coverage. mpileup doesn't work with PAF file so I am looking to convert PAF format to SAM/BAM format. If there are alternatives to mpileup, I am open to the suggestions. Is this better ? Oct 9, 2019 at 13:17
• It's really weird that they provide sam2paf but not paf2sam. Could it be that the conversion in that direction isn't possible? Perhaps paf is missing information that would be essential for sam? Oct 9, 2019 at 17:39
• @terdon I am not a specialist but it's stated that CIGAR can take different format depending on the input/output options. It might also be not written in the PAF in some case. Is that CIGAR essential to sam ? Oct 10, 2019 at 8:17
• I would take Heng Li's advice. minimap2 is fast. Just add the -a option when you re-run, which outputs the alignment in sam instead of paf Oct 11, 2019 at 3:02