I have an MSA from MAFFT (as a FASTA file; there are several sequences in the MSA), and I would like to quantify the "variants" between these sequences.

What is the standard tool to do something like this?

I would prefer to know the non-consensus variants in the the entire MSA, but that may be too tricky, so I would like to figure out the non-consensus variants between those select sequences.

I'm familiar with calculating an MSA, and then visualizing it---but I would like an output file with all of the different bases.

  • 1
    $\begingroup$ This is surprisingly not done or requested in the community, I'm also struggling. $\endgroup$ Commented Oct 20, 2021 at 14:00

1 Answer 1


A very basic solution in python:

from Bio import SeqIO
seq_dict = {i : rec.seq for i,rec in enumerate(SeqIO.parse("your_msa.aln", "fasta"))}
for pos in range(len(seq_dict[0])):
    pos_bases = ([seqio[i] for seqio in [*seq_dict.values()]])
    # If position contains more than one unique base
    if len([*set(pos_bases)])>1:
        print(pos, pos_bases)        # prints the position and alternative bases there

If you need something more useful, just leave a comment here and I'll develop this further.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.