Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am wanting to count how many times synonymous and non- synonymous mutations appear in a sequence of DNA, given the number of synonymous and non- synonymous mutations in each 3 letter codon. ie given that AAA has 7 synonymous and 1 non- synonymous equations, and CCC has 6 and 3 respectively, then the sequence AAACCC would have 13 synonymous and 4 non- synonymous mutations. However, these sequences could have 10k + letters with a total of 64 different 3 letter combinations... How could I set up an M file, using for / else if statements to count the mutations? Thanks

share|cite|improve this question
Just a sidenote, looping through 100k letters or should mean that your computation time will be a few seconds at most. – Dennis Jaheruddin Feb 22 '13 at 16:28

Assuming you have filtered out the data errors and each time you nicely have three letter, here is one approach:

1) Make your data look like this:


2) Count how many times each of the 64 options occurs.

3) Multiply that found number of times with the corresponding syn and non-sym mutations.

That should be it!

Note that step 2 and 3 can easily be achieved with Excel as well. If you are not fluent in matlab it will probably even be quicker.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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