DNA Sequencing

PHOTO EMBED

Sun Nov 06 2022 05:04:03 GMT+0000 (Coordinated Universal Time)

Saved by @cruz #javascript

public class DNA {
 
  public static void main(String[] args) {
 
    //  -. .-.   .-. .-.   .
    //    \   \ /   \   \ / 
    //   / \   \   / \   \  
    //  ~   `-~ `-`   `-~ `-
 String dna1 = "ATGCGATACGCTTGA";
 String dna2 = "ATGCGATACGTGA";
 String dna3 = "ATTAATATGTACTGA";
 
 String dna = dna3;
 //System.out.println(dna.length());

int start = dna.indexOf("ATG");
int end = dna.indexOf("TGA");


 if (start != -1 && end != -1 && (end - start) % 3 == 0){
   System.out.println("Condition 1, 2 and 3 are satisfied.");

   String protein = dna.substring(start, end+3);
   //+3 is because int end cuts off at where TGA begins
   System.out.println("Protein: " + protein);
 }else{
   System.out.println("No protein.");
 }
  }
 
}
content_copyCOPY