Created
June 24, 2020 03:33
-
-
Save JohnsonLuu/4bd4490587cf4889290d984c912580aa to your computer and use it in GitHub Desktop.
DNA Sequencing - Java - Code Academy
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
// This program recieves a given string in DNA and checks if any proteins are within. | |
// Does not consider that multiple proteins could be present. | |
// -. .-. .-. .-. . | |
// \ \ / \ \ / | |
// / \ \ / \ \ | |
// ~ `-~ `-` `-~ `- | |
public class DNA { | |
public static void main(String[] args) { | |
String dna1 = "ATGCGATACGCTTGA"; | |
String dna2 = "ATGCGATACGTGA"; | |
String dna3 = "ATTAATATGTACTGA"; | |
// Change the value of DNA to check other strings | |
String dna = dna1; | |
int start = dna.indexOf("ATG"); | |
int stop = dna.indexOf("TGA"); | |
System.out.println(start + " " + stop); | |
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."); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment