convert sam into paf format
3
0
Entering edit mode
6 months ago

I have to convert the aligned sam file to paf for miniasm. Can anyone suggest any tool?

genome alignment sequencing assembly SNP • 665 views
ADD COMMENT
0
Entering edit mode

I don't think you can see: https://bioinformatics.stackexchange.com/questions/10552/convert-paf-format-to-sam-bam-format

It would be best to realign with minimap2 and choose SAM output.

ADD REPLY
1
Entering edit mode
5 months ago
rlorigro ▴ 10

Looks like no one has actually read the question correctly. PAF is missing lots of information compared to SAM, because it is a summary of alignment, but it also has easy access to the alignment start and stop coordinates, sequences lengths, etc. Since PAF is less information-dense you cannot convert in both directions, but there's no reason why you can't convert from SAM to PAF.

There are several options:

  1. Use Heng Li's experimental toolkit, htsbox samview -p in.bam: https://github.com/lh3/htsbox
  2. Use paftools sam2paf: https://github.com/lh3/minimap2/blob/master/misc/README.md#introduction
  3. Use this python library: https://bioconvert.readthedocs.io/en/master/_modules/bioconvert/sam2paf.html

I've been looking for the answer to this question, and I am planning on using #2.

I'm not sure how "Matches" are interpreted, but the existence of a sam2paf converter implies that it probably counts all M operations (match "=" or mismatch "X") regardless of the true identity of the reference vs read within the Match block.

ADD COMMENT
0
Entering edit mode
6 months ago
ATpoint 50k

There is no direct way to do that. Realignment is necessary, see the developers (Ih3) answer here: https://github.com/lh3/minimap2/issues/493 (the first hit when searching for convert sam to paf by the way...).

Here is a section that explains how: https://github.com/lh3/miniasm#getting-started

ADD COMMENT
0
Entering edit mode

OP asked for SAM > PAF. And that's what you mention as well, but the Github issue you linked is PAF > SAM !

ADD REPLY
0
Entering edit mode
8 days ago
francois ▴ 20

Yeah 2 out 3 answers do not address the question!

Thanks @rlorigro for the lead.

Just to provide a (hopefully) straightforward answer, this seems to work well for me:

paftools.js sam2paf in.sam > out.paf

It comes with minimap2, I did not have to install anything on my system.


FYI, paftools.js sam2paf alone returns

Usage: paftools.js sam2paf [options] <in.sam>

Options:

-p convert primary or supplementary alignments only

-L output the cs tag in the long form

Good luck!

ADD COMMENT

Login before adding your answer.

Traffic: 1267 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6