def FilterAlignedPairForPositions(seq1, seq2, method):

    l1 = len(seq1)
    l2 = len(seq2)

    if method == "all":
        return seq1, seq2
    elif method == "codon1":
        return ("".join([seq1[x] for x in range(0, l1, 3)]),
                "".join([seq2[x] for x in range(0, l2, 3)]))
    elif method == "codon2":
        return ("".join([seq1[x] for x in range(1, l1, 3)]),
                "".join([seq2[x] for x in range(1, l2, 3)]))
    elif method == "codon3":
        return ("".join([seq1[x] for x in range(2, l1, 3)]),
                "".join([seq2[x] for x in range(2, l2, 3)]))
    elif method == "d4":
        s1 = []
        s2 = []
        for x in range(0, l1, 3):
            codon1 = seq1[x:x + 3]
            codon2 = seq2[x:x + 3]
            try:
                aa1, deg11, deg12, deg13 = Genomics.GetDegeneracy(codon1)
                aa2, deg11, deg22, deg23 = Genomics.GetDegeneracy(codon2)
            except KeyError:
                continue
            if aa1 == aa2 and deg13 == 4 and deg23 == 4:
                s1.append(codon1[2])
                s2.append(codon2[2])
        return "".join(s1), "".join(s2)


# ------------------------------------------------------------------------
given the method, return a set of aligned sequences
dataset/ETHPy150Open CGATOxford/cgat/scripts/fasta2distances.py/FilterAlignedPairForPositions