[FIXED] Java DNA Sequencing Project


Why is this sequence:


Not a valid protein?

it meets all the criteria:

  1. t begins with a “start codon”: ATG .
  2. It ends with a “stop codon”: TGA .
  3. In between, each additional codon is a sequence of three nucleotides.


I went back through the hints and the only thing i can figure out is that the instructions were supposed to add an additional constraint

the code given thinks this is a protein

if (start != -1 &&
stop != -1 &&
(stop - start) % 3 == 0) {

String protein = dna.substring(start, stop+3); 
System.out.println("Protein: " + protein);

} else {

System.out.println("No protein.");


guessing this was just mislabled and should have been marked “Protein”
or the code should have added a different check:
if (start != 0 &&
stop != -1 &&
(stop - start) % 3 == 0)


Hello, @cwnoel

That’s a very good question. It definitely meets the stated criteria. @ionatan, what do you think?


wuh why me ._.
I agree with you, there’s a protein in that.


I’ll file a bug to change the expected outcome for that one…

Thanks guys!

I’ve just reported this issue too.


The dna3 example “ATTAATATGTACTGA”

Contains the start codon ATG and index 6 and stop codon TGA at index 12 and has 3 nucleotides TAC between them, which is divisible by 3, which makes them a protein by the definition provided in the Objective…

"A protein has the following qualities:

It begins with a “start codon”: ATG.
It ends with a “stop codon”: TGA.
In between, each additional codon is a sequence of three nucleotides."

Which conflicts with the solution…

"Let’s test your code with each DNA strand. These should be the results:

dna1: Protein.
dna2: Not a protein.
dna3: Not a protein."

I this this is also reported here: Java DNA Sequencing Project

It isn’t explicitly stated in the instructions that you have to create a primary condition in the if/else statement to test the String for its beginning and end.
So IF your string starts with “ATG” AND ends with TGA then you move onto the next condition.

The instructions have been corrected. Thanks again, @cwnoel, for bringing this to our attention.