(This is sort of a follow up question to one I asked before)
So I have a DNA string
e.g.
acagatgaaggaggacgcgcccccgccgctgtcctgcgcctcagccatcctatgagacgg
and I have 20 different 3 letter patterns (each combination corresponds to an amino acid) I want to match to the data. My java program looks at 3 letters at a time and tries to match it to one of the patterns. I want to eventually count the number of times each amino acid appears, so when I find a match I need to increment a particular counter. I want to implement this using java regex, so I have:
Pattern A = Pattern.compile("(gct)|(gcc)|(gca)|(gcg)");
Pattern C = Pattern.compile("(tgt) | (tgc)");
Pattern D = Pattern.compile("(gat) | (gac)");
etc.
However, I now realise that you need to make a matcher for EACH pattern and you can't use one matcher to search for ALL patterns; what is the best way for me to achieve what I am trying to do?