A protein can be coded by several different codons. For example, the protein Leucine is coded by "TTA", "TTG", "CTT", "CTC", "CTA", and "CTG" whereas Tryptophan is only coded by "TGG".
Write the method proteinIndex
which returns the index
in parameter dna
at which the first
occurrence of a codon coding the protein
whose
one-letter code is specified occurs. If there is no occurrence of the
protein return -1. (We're ignoring ORFs in this problem.)
For example
method call | result returned | reason |
---|---|---|
proteinIndex("CCCCAATTTCCAGT","Q")
| 3 | "CAA" occurs at index 3, "Q" encodes Glutamine |
proteinIndex("CCCTAATTTCCAGT","Q")
| 10 | "CAG" occurs at index 10, "Q" encodes Glutamine |
proteinIndex("GGTGGCGGAGGG","G")
| 0 | "GGT" occurs at index 0, "G" encodes Glycine |
proteinIndex("CTTAGTAAGTTAGC", "R")
| -1 | Arginine, "R", coded by AGA and AGG, doesn't occur |
Write the method proteinIndex
.
You should not test with BlueJ/Eclipse, test by
reasoning about the code you write.
You can submit using Eclipse and the assignment name testpractice. Please include a README in your submission.