Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // The "DNA" class.
- import java.awt.*;
- import hsa.Console;
- /*
- Name: Mujtaba Meher
- Teacher: S. Drajner
- Description: This program finds the
- */
- public class DNA
- {
- static Console c; // The output console
- public static void main (String[] args)
- {
- c = new Console ();
- String[] codons =
- {
- "TTT", "TTC", "TTA", "TTG", "TCT", "TCC", "TCA", "TCG", "TAT", "TAC",
- "TAA", "TAG", "TGT", "TGC", "TGA", "TGG", "CTT", "CTC", "CTA", "CTG",
- "CCT", "CCC", "CCA", "CCG", "CAT", "CAC", "CAA", "CAG", "CGT", "CGC",
- "CGA", "CGG", "ATT", "ATC", "ATA", "ATG", "ACT", "ACC", "ACA", "ACG",
- "AAT", "AAC", "AAA", "AAG", "AGT", "AGC", "AGA", "AGG", "GTT", "GTC",
- "GTA", "GTG", "GCT", "GCC", "GCA", "GCG", "GAT", "GAC", "GAA", "GAG",
- "GGT", "GGC", "GGA", "GGG"
- };
- String[] aminoAcids =
- {
- "F", "F", "L", "L", "S", "S", "S", "S", "S", "Y", "Y", "STOP", "STOP", "C", "C", "STOP",
- "W", "L", "L", "L", "L", "P", "P", "P", "P", "H", "H", "Q", "Q", "R", "R", "R", "R", "I",
- "I", "I", "M", "T", "T", "T", "T", "N", "N", "K", "K", "S", "S", "R", "R", "V", "V", "V",
- "V", "A", "A", "A", "A", "D", "D", "E", "G", "G", "G", "G", "G"
- };
- String dna, converted, index;
- int check, counter = 0, offset = 0;
- //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^VARIABLE_DECLARATION^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
- c.print ("Enter the DNA sequence: ");
- dna = c.readString ();
- do
- {
- for (int x = offset ; x <= dna.length () ; x += 3)
- {
- if (dna.substring (x, x + 3).compareTo (codons [35]) == 0)
- {
- for (int y = x ; y < dna.length () ; y += 3)
- {
- counter++;
- 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)
- {
- c.print ("The dna starts at " + x / 3 + " and ends at " + y / 3);
- y = dna.length ();
- }
- }
- }
- if ((x + 3) > dna.length ())
- x = dna.length ();
- }
- offset++;
- }
- while (offset != 2);
- } // main method
- } // DNA class
Add Comment
Please, Sign In to add comment