Last active
July 10, 2016 21:40
-
-
Save francisco-perez-sorrosal/1468599 to your computer and use it in GitHub Desktop.
FB Ribosome
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static String translateToProteins(String dna) { | |
String result = ""; | |
int idx = dna.indexOf(START_CODON, 0); | |
while (idx < dna.length() && idx != -1) { | |
String dnaChunk = dna.substring(idx, idx + 3); | |
if (dnaChunk.equals(END_CODON_1) || dnaChunk.equals(END_CODON_2) | |
|| dnaChunk.equals(END_CODON_3)) { | |
idx = dna.indexOf(START_CODON, idx); | |
result += "\n"; | |
} else { | |
result += codonToProteinMap.get(dnaChunk); | |
idx += 3; | |
} | |
} | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment