/*************************************** * * CodonTable.java 12/26/96 * * Atsuko Kubota and Nobuyuki Miyajima * Kazusa DNA Research Inst. * e-mail: miyajima@kazusa.or.jp ***************************************/ import java.applet.Applet; import java.awt.*; import java.io.*; import java.lang.*; import java.util.StringTokenizer; public class CodonTable extends Applet { CheckboxGroup cg; Fractions fr; Results rs; Table ta; TextField tf; static String colors[], frq, put, org, chk, check; String codons[], aminos[]; static int mark; /** init() method */ public void init() { String s; s = getParameter("orga"); if (s != null) chk = s; s = getParameter("freq"); if (s != null) org = s; set1(); set2(); set3(); } /** set1() method --- Input panel */ public void set1() { setFont(new Font("TimesRoman", Font.BOLD, 17)); // TextField Panel p1 = new Panel(); p1.setFont(new Font("TimesRoman", Font.PLAIN, 20)); p1.add(new Label("Enter 3 nucleotides: (e.g. agc)")); p1.add(tf = new TextField(8)); p1.add(new Button("reset")); // CheckboxGroup CheckboxGroup cg = new CheckboxGroup(); Checkbox c1 = new Checkbox("1. Ala", cg, false); Checkbox c2 = new Checkbox("2. Arg", cg, false); Checkbox c3 = new Checkbox("3. Asn", cg, false); Checkbox c4 = new Checkbox("4. Asp", cg, false); Checkbox c5 = new Checkbox("5. Cys", cg, false); Checkbox c6 = new Checkbox("6. Gln", cg, false); Checkbox c7 = new Checkbox("7. Glu", cg, false); Checkbox c8 = new Checkbox("8. Gly", cg, false); Checkbox c9 = new Checkbox("9. His", cg, false); Checkbox c10 = new Checkbox("10. Ile", cg, false); Checkbox c11 = new Checkbox("11. Leu", cg, false); Checkbox c12 = new Checkbox("12. Lys", cg, false); Checkbox c13 = new Checkbox("13. Met", cg, false); Checkbox c14 = new Checkbox("14. Phe", cg, false); Checkbox c15 = new Checkbox("15. Pro", cg, false); Checkbox c16 = new Checkbox("16. Ser", cg, false); Checkbox c17 = new Checkbox("17. Thr", cg, false); Checkbox c18 = new Checkbox("18. Trp", cg, false); Checkbox c19 = new Checkbox("19. Tyr", cg, false); Checkbox c20 = new Checkbox("20. Val", cg, false); Checkbox c21 = new Checkbox("21. TERM", cg, false); Panel p2 = new Panel(); p2.setLayout(new GridLayout(21, 1)); p2.add(c1); p2.add(c2); p2.add(c3); p2.add(c4); p2.add(c5); p2.add(c6); p2.add(c7); p2.add(c8); p2.add(c9); p2.add(c10); p2.add(c11); p2.add(c12); p2.add(c13); p2.add(c14); p2.add(c15); p2.add(c16); p2.add(c17); p2.add(c18); p2.add(c19); p2.add(c20); p2.add(c21); setLayout(new BorderLayout()); add("North", p1); add("East", p2); add("Center", ta = new Table()); } /** set2() method --- colors[], aminos[], codons[] */ public void set2() { put = "rst"; mark = 21; checkarea(put); Results rs = new Results(); rs.clrs(); rs.cdns(); rs.amns(); } /** set3() method --- fracs[] */ public void set3() { Fractions fr = new Fractions(); if("Universal".equals(chk)) { fr.frac(); } if("Mitochondorial".equals(chk)) { fr.fnull(); } } /** action() method */ public boolean action(Event e, Object o) { Table ta = new Table(); // TextField event if (e.target instanceof TextField) { TextField tf = (TextField)(e.target); String txt = new String(o.toString()); if (txt.length() > 3) { tf.setText("only 3!"); } String set = txt.toUpperCase(); for (int i = 0; i < 64; i++) { StringTokenizer st = new StringTokenizer(rs.codons[i], ":"); String cdn = st.nextToken(); if (cdn.equals(set)) { mark = Integer.parseInt(st.nextToken()); put = st.nextToken(); checkarea(put); i = 0; break; } } return true; } /** Checkbox event */ if (e.target instanceof Checkbox) { Checkbox cb = (Checkbox)(e.target); String set = (cb.getLabel()).toLowerCase(); tf.setText(""); StringTokenizer st = new StringTokenizer(set, ". "); int i = Integer.parseInt(st.nextToken()); mark = i - 1; put = rs.aminos[mark]; checkarea(put); return true; } /** Button event */ if (e.target instanceof Button) { Button bt = (Button)(e.target); if (bt.getLabel().equals("reset")) { tf.setText(""); put = "rst"; mark = 21; checkarea(put); } return true; } return false; } /** checkarea() method */ public void checkarea(String s) { check = "update"; ta.repaint(); } /** changeorg method */ public void changeorg() { check = "change"; put = "rst"; mark = 21; checkarea(put); ta.repaint(); } }