Counting letters in phylip alignment columns with Biopython I have been using python 3.6 and biopython 1.72 to work with protein data files. I am using a protein sequence file (phylip format), for example:

    14    678
Zebrafish  LSSCGVVSGD LISVILPASS LEETQTSSAA AHQTHTDQQA GGSHVSSSSS 
Fugu       LASCGIVSGD LIRVALIRAA LMAADAPDRA DDGGGHSEQA VAMATNQVS- 
Chicken    LASCGIVSGD LIRVALIRAA LMAADAPDRA DDGGGHSEQA VAMATNQVS- 
Zebra      LASYGIVPGD LICLLLEETD AKSSLPPPSS SSPPSLQNGR ETSTLTPKNQ


I want to manipulate the file in a way so that;


I may get the number of columns which have all the same letters (amino acids)
The number of columns which have at least 2 different amino acids (with no dashes).
The number of columns which have any single dash.


I have iterated over the columns of the file with:

alignment = AlignIO.read(open("example.phy"), "phylip") 
def column(alignment):
    n = len(alignment[0].seq)

    for i in range(n):
        c = []

        for record in alignment:
            c.append(record.seq[i])

        yield c


This returns the columns of the file, but I don't understand how I can manipulate them further.

Can I get some helpful suggestions?
using something like for col in column(alignment):


I may get the number of columns which have all the same letters (amino acids)

len(set(col)) == 1

The number of columns which have at least 2 different amino acids (with no dashes):

len(set(col)) &gt; 1 and '-' not in col

The number of columns which have any single dash:

'-' in col



or if you really want columns with a single dash:

    col.count('-') == 1