def count_mutations(codon, AA, alleles, counts, nucs, trans_table):
<EOL>obs_codons = [] <EOL>for pos, pos_mutations in enumerate(alleles):<EOL><INDENT>mutations = [b for b in pos_mutations if b in nucs]<EOL>for mutation in mutations:<EOL><INDENT>alt_codon = codon[:]<EOL>alt_codon[pos] = mutation<EOL>obs_codons.append(alt_codon)<EOL><DEDENT><DEDENT>obs_codons = [i for i in obs_codons if i != codon]<EOL>obs_AAs = [codon2aa(i, trans_table) for i in obs_codons]<EOL>obs_AAs = [i for i in obs_AAs if i != AA]<EOL>num_mutations = len(obs_codons)<EOL>num_nonSyn    = len(obs_AAs)<EOL>num_syn       = num_mutations - num_nonSyn<EOL>counts['<STR_LIT>']     += num_syn<EOL>counts['<STR_LIT>'] += num_nonSyn<EOL>pos_codons = [] <EOL>for pos in range(<NUM_LIT:0>, <NUM_LIT:3>):<EOL><INDENT>for nuc in nucs:<EOL><INDENT>pos_codon = codon[:]<EOL>pos_codon[pos] = nuc<EOL>pos_codons.append(pos_codon)<EOL><DEDENT><DEDENT>pos_codons = [i for i in pos_codons if i != codon]<EOL>pos_AAs = [codon2aa(i, trans_table) for i in pos_codons]<EOL>pos_AAs = [i for i in pos_AAs if i != AA]<EOL>num_mutations = len(pos_codons)<EOL>num_nonSyn    = len(pos_AAs)<EOL>num_syn       = num_mutations - num_nonSyn<EOL>counts['<STR_LIT>']     += num_syn<EOL>counts['<STR_LIT>'] += num_nonSyn<EOL>return counts<EOL>
count types of mutations in codon
counts = {'obs syn':#, 'pos syn':#, 'obs non-syn':#, 'pos non-syn':#}