Skip to content

Instantly share code, notes, and snippets.

@francisco-perez-sorrosal
Last active July 10, 2016 21:40
Show Gist options
  • Save francisco-perez-sorrosal/1468599 to your computer and use it in GitHub Desktop.
Save francisco-perez-sorrosal/1468599 to your computer and use it in GitHub Desktop.
FB Ribosome
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