This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Change biopython pairwise2 output format alignment ?

Hi all, Whenever I use pairwise2 to align two sequences with at the end:

print (pairwise2.format_alignment(*aln[0]))

I get a output result that looks like:

Alignement

Is it possible to get the output in a different format, like for example an output where there is only two rows, removing the pipe and dot ( ||.|…| ) line ?

I could not find the info on https://biopython.org/docs/1.75/api/Bio.pairwise2.html?highlight=bio.pairwise2.format_alignment#Bio.pairwise2.format_alignment , at the end there is a mention on the formatting but either I did not understood how it works or there is no explanation on how to change the format (if possible).

Thanks

biopython pairwise2 alignment format output

1 answer

You can split the resulting text output into lines, then replace the characters as needed.

It is a bit hacky but provides the most flexibility.

Log in to answer this question.