Guest User

Untitled

a guest
Apr 22nd, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. // The "DNA" class.
  2. import java.awt.*;
  3. import hsa.Console;
  4. /*
  5. Name: Mujtaba Meher
  6. Teacher: S. Drajner
  7. Description: This program finds the
  8. */
  9.  
  10. public class DNA
  11. {
  12. static Console c; // The output console
  13.  
  14. public static void main (String[] args)
  15. {
  16. c = new Console ();
  17.  
  18. String[] codons =
  19. {
  20. "TTT", "TTC", "TTA", "TTG", "TCT", "TCC", "TCA", "TCG", "TAT", "TAC",
  21. "TAA", "TAG", "TGT", "TGC", "TGA", "TGG", "CTT", "CTC", "CTA", "CTG",
  22. "CCT", "CCC", "CCA", "CCG", "CAT", "CAC", "CAA", "CAG", "CGT", "CGC",
  23. "CGA", "CGG", "ATT", "ATC", "ATA", "ATG", "ACT", "ACC", "ACA", "ACG",
  24. "AAT", "AAC", "AAA", "AAG", "AGT", "AGC", "AGA", "AGG", "GTT", "GTC",
  25. "GTA", "GTG", "GCT", "GCC", "GCA", "GCG", "GAT", "GAC", "GAA", "GAG",
  26. "GGT", "GGC", "GGA", "GGG"
  27. };
  28.  
  29. String[] aminoAcids =
  30. {
  31. "F", "F", "L", "L", "S", "S", "S", "S", "S", "Y", "Y", "STOP", "STOP", "C", "C", "STOP",
  32. "W", "L", "L", "L", "L", "P", "P", "P", "P", "H", "H", "Q", "Q", "R", "R", "R", "R", "I",
  33. "I", "I", "M", "T", "T", "T", "T", "N", "N", "K", "K", "S", "S", "R", "R", "V", "V", "V",
  34. "V", "A", "A", "A", "A", "D", "D", "E", "G", "G", "G", "G", "G"
  35. };
  36.  
  37. String dna, converted, index;
  38. int check, counter = 0, offset = 0;
  39.  
  40. //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^VARIABLE_DECLARATION^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
  41.  
  42. c.print ("Enter the DNA sequence: ");
  43. dna = c.readString ();
  44.  
  45.  
  46. do
  47. {
  48. for (int x = offset ; x <= dna.length () ; x += 3)
  49. {
  50.  
  51.  
  52.  
  53. if (dna.substring (x, x + 3).compareTo (codons [35]) == 0)
  54. {
  55.  
  56. for (int y = x ; y < dna.length () ; y += 3)
  57. {
  58.  
  59. counter++;
  60.  
  61. if (dna.substring (y, y + 3).compareTo (codons [11]) == 0 || dna.substring (y, y + 3).compareTo (codons [12]) == 0 || dna.substring (y, y + 3).compareTo (codons [15]) == 0)
  62. {
  63. c.print ("The dna starts at " + x / 3 + " and ends at " + y / 3);
  64. y = dna.length ();
  65.  
  66. }
  67. }
  68. }
  69.  
  70. if ((x + 3) > dna.length ())
  71.  
  72. x = dna.length ();
  73.  
  74. }
  75.  
  76. offset++;
  77. }
  78. while (offset != 2);
  79.  
  80. } // main method
  81. } // DNA class
Add Comment
Please, Sign In to add comment