This is a test version of Biostars. For the public version, visit https://www.biostars.org.
python posterior probability in stockholm file

I want to parse a multiple sequence alignment stockholm file by columns.

Is there any library or package in python to parse a multiple sequence alignment stockholm file and especially get the columns posterior probabilities??

P.s I went through AlignIo object from biopython, I couldn't find a way to get the posterior probability

python probability biopython msa alignment

Can you post an example alignment file (here or using something like gist.github.com) which contains the per-column posterior probability numbers you want?

1 answer

These are present in the Stockholm file as per-colum annotation on each sequence, thus:

from Bio import AlignIO
align = AlignIO.read("alignment.sto", "stockholm")
for record in align:
    print(record.id)
    print(record.seq)
    print(record.letter_annotations["posterior_probability"])

Update: See https://github.com/biopython/biopython/issues/357 on not recording the per-column information in Stockholm files.

I need #GC pp_cons which is per column pp for all sequences and not #GR pp which is per residue pp for each sequence

This will be supported in Biopython 1.66

Log in to answer this question.