Repository navigation
Expand file tree
/
Copy pathWindow.java
More file actions
177 lines (150 loc) · 6.21 KB
/
Copy pathWindow.java
File metadata and controls
177 lines (150 loc) · 6.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
import javax.swing.*;
import javax.swing.text.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class Window extends JFrame implements ActionListener
{
private JLabel motifLabel, sequenceLabel;
private JTextField helpField, motifField, sequenceField, outputField;
private JButton findButton;
private JFileChooser fc;
private JMenuItem motifItem, sequenceItem;
private String motif, sequence;
private JComboBox motifCombo;
public Window()
{
super("Kinase Site Finder");
setSize (600,400);
Container container = getContentPane();
container.setLayout(new GridLayout(8,1));
// motif label and short explaination
motifLabel = new JLabel("Kinase Motif: ");
container.add(motifLabel);
helpField = new JTextField
("(Use lowercase to indicate phosphoacceptor residue.)",50);
helpField.setEditable(false);
container.add(helpField);
//JcomboBox for selecting common motifs
String[] motif = {"Select a common kinase motif","PKA - R-X-s/t",
"CKI - S-X-X-s/t","CKII - s/t-X-X-E",
"GSK3 - s-X-X-X-S","CDC2 - s/t-P-X-R/K",
"CaMKII - R-X-X-s/t","MAPK - X-X-s/t-P"};
motifCombo = new JComboBox(motif);
motifCombo.setSelectedIndex(0);
container.add(motifCombo);
motifCombo.addActionListener(this);
motifField = new JTextField (40);
container.add(motifField);
//sequence field displaying the chosen sequence
sequenceLabel = new JLabel("Amino acid sequence: ");
container.add(sequenceLabel);
sequenceField = new JTextField (40);
container.add(sequenceField);
//output field displaying the result
outputField = new JTextField(30);
outputField.setEditable(false);
container.add(outputField);
findButton = new JButton("Find");
container.add(findButton);
findButton.addActionListener(this);
// menu bar for importing files of motif and sequence
JMenu fileMenu = new JMenu("File");
motifItem = new JMenuItem("Open Motif from File");
motifItem.addActionListener(this);
fileMenu.add(motifItem);
sequenceItem = new JMenuItem("Open AA sequence from File");
sequenceItem.addActionListener(this);
fileMenu.add(sequenceItem);
JMenuBar mBar = new JMenuBar();
mBar.add(fileMenu);
setJMenuBar(mBar);
}
public void actionPerformed(ActionEvent e)
{
// listener for find button
if (e.getActionCommand().equals("Find"))
{
String motif = motifField.getText();
String sequence = sequenceField.getText();
Kinase kinase = new Kinase(motif);
//Substrate substrate = new Substrate(sequence);
kinase.findPhosphateSite(sequence);
if (kinase.getFound() == true) {
String output = "Match Found! Phosphoacceptor residue at ";
for (int i = 0; i < kinase.getNumFound(); i++) {
output = output.concat(kinase.getStart()[i] + ", ");
}
outputField.setText(output);
}
else if (kinase.getFound() == false)
outputField.setText("No match found");
}
//listerner for open motif file
else if (e.getActionCommand().equals("Open Motif from File"))
{
fc = new JFileChooser();
int returnVal = fc.showOpenDialog(motifItem);
if (returnVal == JFileChooser.APPROVE_OPTION)
{
File motifFile = fc.getSelectedFile();
try
{
BufferedReader motifBuf = new BufferedReader
(new FileReader(motifFile));
motif = motifBuf.readLine();
motifField.setText(motif);
}
catch (IOException exception)
{
outputField.setText("No motif file found!");
}
}
}
//listener for open amino acide sequence file
else if (e.getActionCommand().equals("Open AA sequence from File"))
{
fc = new JFileChooser();
int returnVal = fc.showOpenDialog(sequenceItem);
if (returnVal == JFileChooser.APPROVE_OPTION)
{
File sequenceFile = fc.getSelectedFile();
try
{
BufferedReader sequenceBuf = new BufferedReader
(new FileReader(sequenceFile));
sequence = sequenceBuf.readLine();
sequenceField.setText(sequence);
}
catch (IOException exception)
{
outputField.setText("No sequence file found!");
}
}
}
//listener for combobox of motifs
else if ("comboBoxChanged".equals(e.getActionCommand()))
{
switch(motifCombo.getSelectedIndex())
{
case 0: break;
case 1: motifField.setText("R-X-s/t");break;
case 2: motifField.setText("S-X-X-s/t");break;
case 3: motifField.setText("s/t-X-X-E");break;
case 4: motifField.setText("s-X-X-X-S");break;
case 5: motifField.setText("s/t-P-X-R/K");break;
case 6: motifField.setText("R-X-X-s/t");break;
case 7: motifField.setText("X-X-s/t-P");break;
default: motifField.setText("Select a motif.");
}
}
}
public static void main(String[] args)
{
JFrame.setDefaultLookAndFeelDecorated(true);
Window window = new Window();
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.pack();
window.setVisible(true);
}
}