Basically it is a program that holds 64 triple letters sets as string
the program needs to search each three letter and display aminoAcid letter that matches the triple letter.
My question to experts and guru is that how to add all my work into a GUI form?
i did a sample of my GUI.
Another question is how can i use a triple letter like "ATG" as a string to be placed as a stop string to end the letter search?
any other tips to make program nicer is helpful too?
example: where user enter string sequence: ATGGCAACG on a textfield, the other textfield display the second static string aminoAcids: MetAlaThr on the second textfield.
when user enter letter: ATG it should return Met.
then user enter next string letter: GCA it should return Ala.
import java.awt.*; // importing tools for program
import javax.swing.*;
import java.awt.event.*;
import java.util.Scanner;
//name of my program
public class ProteinFinder{
//Strings are set up as One-dimensional array to be used by user
private static String[] Sequences = {"ATG", "GCA", "ACG", "TGA", "ATT", "TAG", "TAA","TTA", "TTT", "TTC", "TTG", "CTT", "CTC", "ATC", "ATA", "GTT", "GTC", "GTA", "GTG", "TCT", "TCC","TCA","TCG","CCT", "CCC","CCA","CCG","ACT","ACC","ACA","ACG","GCT","GCC","GCG","TAT","TAC","CAT","CAC","CAA", "CAG","AAT","AAC","AAA","AAG","GAT","GAC","GAA","GAG","TGT","TGC","TGG","CGT","CGC","CGA","CGG","AGT","AGC","AGA","AGG","GGT","GGC","GGA","GGG"}; //assign string to variable
//second word that shows after user input three letters
private static String [] aminoAcids = {"Met", "Ala", "Thr", "STOP", "Ile", "STOP", "STOP", "Leu", "Phe", "Phe", "Leu", "Leu", "Leu", "Ile", "Ile", "Val", "Val", "Val", "Ser", "Ser", "Ser", "Ser", "Pro", "Pro", "Pro", "Pro", "Thr", "Thr", "Thr", "Ala", "Ala", "Ala", "Tyr", "His", "Gln", "Gln", "Asn", "Asn", "Lys", "Lys", "Asp", "Asp", "Glu", "Glu", "Cys", "Cys", "Trp", "Arg", "Arg", "Arg", "Ser", "Ser", "Arg", "Arg", "Gly", "Gly", "Gly", "Gly"};
private static String Proteins = "";
//initiate string as proteins
public static String find(String dna){
dna.toUpperCase(); //convert the string into uppercase triplet letter
int i = 0; //for loop to find triplet letters
for(i = 0; i<7; i+=3){
for(int n = 0; n < 3; n++){
if(dna.substring(i, i+3).equals( Sequences[n]))
Proteins += aminoAcids[n];
}
}
return Proteins; //give the user the protein letters program finds
}
public static void main(String[] args){ //program needs to execute action
String result = find("ATGGCAACG");
System.out.println(result);
}
}
GUI
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class dnaGUI extends JFrame implements ActionListener{
private JButton button1;
private JPanel panel;
private JTextField field1, field2;
public static void main()
{
dnaGUI myFrame = new dnaGUI();
myFrame.setSize(400,310);
myFrame.dnaGUI();
myFrame.setTitle("DNA Graphic User Inteface");
myFrame.setVisible(true);
}
private void dnaGUI ()
{
setDefaultCloseOperation(EXIT_ON_CLOSE);
Container window = getContentPane();
window.setLayout(new FlowLayout());
// use one class to handle all of the buttons
button1 = new JButton("CLICK HERE");
field1 = new JTextField(10);
field2 = new JTextField(10);
button1.addActionListener(this);
// add buttons to the window
window.add(button1);
window.add(field1);
window.add(field2);
// add the panel to the window
panel = new JPanel();
panel.setPreferredSize(new Dimension(300,200));
panel.setBackground(Color.green);
window.add(panel);
}
public void actionPerformed(ActionEvent event){ //initializing the action
if (event.getSource().equals(field1)){ //finding event of the source for field 2
field1.setText("");
}else if(event.getSource().equals(field2)){ //finding event of the source for field 3
field2.setText("");
}
}
}

New Topic/Question
Reply



MultiQuote



|