Your method should find the first protein (if there is one) and return the number of base-pairs in the protein. If the digital representation of the DNA is good, this number will be a multiple of three since there are three base-pairs per codon.
If there is no protein in the DNA, return -1.
String
int
int length(String dna)(be sure your method is public)
indexOf, one that
takes a single parameter and one that has a String and an int parameter
that specifies where the search will start.
See
javadoc for java.lang.String which is part of Javadoc for all
all classes
dna contains only the
characters 'A', 'G', 'T', 'C' (uppercase).
dna is between 0 and 1000 characters long
(inclusive).
CGATGCATCCCTTTACTTAACCAGReturns: 12, here is the DNA exploded to show the protein between the start and stop codons.
CG ATG CATCCCTTTACT TAA CCAG
^^^ ^^^
start stop
CCCCATGAAATTTCCCGGGReturns: -1, there is a start codon, but no stop codon.
CCCCTAACCCATGAAATTTCCCGGGReturns: -1, there is a start codon, but no stop codon after the start codon --- note that there is a stop codon before the start codon, but this strand doesn't code for a protein.
ATGTGAReturns 0, there is no protein, but there are start and stop codons.