-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKEGGBrowser.java
355 lines (316 loc) · 14 KB
/
KEGGBrowser.java
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
/**
* KEGGBrowser.java
*
* # Compiler KEGGBrowser.java
* javac -cp lib/swingbox-1.1-bin.jar Reactor.java GenomeBrowser.java PathwayBrowser.java InformationPanel.java InvolvePanel.java KEGGBrowser.java
*
* # Lancer l'appli KEGGBrowser
* java -cp lib/swingbox-1.1-bin.jar:. KEGGBrowser
*
**/
import org.fit.cssbox.swingbox.BrowserPane;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JSplitPane;
import javax.swing.BoxLayout;
import javax.swing.DefaultListModel;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.ListSelectionEvent;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.io.IOException;
/**
* La classe KEGGBrowser est une application intéractive JAVA développée à l'intention des Biologistes
* et BioInformaticiens. Cet outil fait le lien entre des données génomiques et des données métaboliques
* téléchargées automatiquement depuis la plateforme en ligne KEGG.
* Le panneau supérieur intègre des données génomiques pour un gène donné en affichant informations et
* contexte génomique. Le panneau inférieur intègre des données pour une voie métabolique données ;
* L'utilisateur peut intéragir avec le réseau réactionnel affiché pour définir une réaction particulière
* et connaitre les gènes éventuels qui catalysent cette réaction, pour un organisme donné.
* Les menus déroulants placés sous les fenetres d'information permettent de faire le lien entre le
* GenomeBrowser et le PathwayBrowser à l'initiative de l'utilisateur.
*
* @author Alfred Goumou, Karl-Stephan Baczkowski
*/
public class KEGGBrowser extends JFrame implements ActionListener, MouseListener, ListSelectionListener {
//------------------------------------------------------------------//
// Variables d'instance spécifiques de la classe KEGGBrowser //
//------------------------------------------------------------------//
/** leftPanel contenant genome browser et pathway browser **/
private JPanel leftPanel;
/** fenetre d'affichage du contexte génomique, genome browser **/
private GenomeBrowser genomebrowser;
/** fenetre d'affichage de la voie métabolique, pathway browser **/
private PathwayBrowser pathwaybrowser;
/** rightPanel contenant Gene Information et Reaction Information **/
private JPanel rightPanel;
/** Gene InformationPanel **/
private InformationPanel gene_info;
/** Reaction InformationPanel **/
private InformationPanel reaction_info;
/** Involved in reaction(s) Panel **/
private InvolvePanel inv_reaction;
/** Involves gene(s) Panel **/
private InvolvePanel inv_gene;
/** JSplitPane divise la frame en deux JPanels droit et gauche **/
private JSplitPane splitPane;
/** Identifiant de l'organisme pour le gène **/
private String GeneSp = "eco";
/** Identifiant du gène **/
private String GeneID = "b0628";
/** Identifiant de l'organisme pour la voie métabolique **/
private String MapSp = "eco";
/** Identifiant de la voie métabolique **/
private String MapID = "00785";
/** Réaction affichée par défaut ou définie par l'utilisateur **/
private Reactor reactor_def;
/** Redimensionnage de la fenetre et des InvolvePanels **/
public void MAJ_redimensioning() {
splitPane.setDividerLocation((int) (getWidth()*0.7));
//~ splitPane.setDividerLocation(getWidth()-300);
inv_reaction.reSize(new Dimension((int) rightPanel.getWidth(), (int) (rightPanel.getHeight()/4 - 35)));
inv_gene.reSize(new Dimension((int) rightPanel.getWidth(), (int) (rightPanel.getHeight()/4 - 35)));
}
/** Implementer la methode actionPerformed(ActionEvent e) pour l'interface ActionListener permet :
* 1. si bouton du GenomeBrowser pressé
* - Mettre à jour la page web dans la fenetre genomebrowser
* - Importer les informations sur le gene
* - Afficher dans quelle(s) réaction(s) est impliqué ce gène
* - OU afficher un message d'erreur si info.txt introuvable
* 2. si bouton du PathwayBrowser pressé
* - Mettre à jour l'image affichée dans pathwaybrowser
* - Importer les information sur un réaction par défaut
* - Afficher les gène(s) qui catalyse(nt) cette réaction
* - OU Afficher un message d'erreur si image.png introuvable
* 3. si bouton Image du GeneInformationPanel pressé
* - Afficher détails de la réaction dans pathwaybrowser
* @param e ActionEvent particulier déclenché dans la frame KEGGBrowser
**/
public void actionPerformed(ActionEvent e) {
if (e.getSource() == genomebrowser.bouton) {
String gene_sp = genomebrowser.getFieldSp();
String gene_id = genomebrowser.getFieldID();
genomebrowser.updatePage(gene_sp, gene_id);
try {
gene_info.updateInfo(gene_sp, gene_id);
genomebrowser.Parsing(gene_sp, gene_id);
inv_reaction.updateJList(genomebrowser.reacList);
this.GeneSp = gene_sp;
this.GeneID = gene_id;
} catch (IOException ioe) {
ioe.printStackTrace();
gene_info.errorInfo("ERROR: incorrect gene entry");
inv_reaction.updateJList(new DefaultListModel<String>());
}
}
if (e.getSource() == pathwaybrowser.bouton) {
String map_sp = pathwaybrowser.getFieldSp();
String map_id = pathwaybrowser.getFieldID();
try {
pathwaybrowser.updateImg(map_sp, map_id);
pathwaybrowser.Parsing(map_sp, map_id, "");
reactor_def = pathwaybrowser.reactor_def;
reaction_info.updateInfo("rn", reactor_def.reacID);
inv_gene.updateJList(reactor_def.geneList);
this.MapSp = map_sp;
this.MapID = map_id;
} catch (IOException ioe) {
ioe.printStackTrace();
reaction_info.errorInfo("ERROR: incorrect pathway entry");
inv_gene.updateJList(new DefaultListModel<String>());
}
}
if (e.getSource() == reaction_info.bouton) {
try {
pathwaybrowser.updateReac(reactor_def.reacID);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
/** Redéfinir la méthode MouseEntered(MouseEvent me)
* @param me MouseEvent déclenché uniquement sur l'imagelabel dans pathwaybrowser
**/
public void mouseEntered(MouseEvent me) {}
/** Redéfinir la méthode MouseExited(MouseEvent me)
* @param me MouseEvent déclenché uniquement sur l'imagelabel dans pathwaybrowser
**/
public void mouseExited(MouseEvent me) {}
/** Redéfinir la méthode MousePressed(MouseEvent me)
* @param me MouseEvent déclenché uniquement sur l'imagelabel dans pathwaybrowser
**/
public void mousePressed(MouseEvent me) {}
/** Redéfinir la méthode MouseReleased(MouseEvent me)
* @param me MouseEvent déclenché uniquement sur l'imagelabel dans pathwaybrowser
**/
public void mouseReleased(MouseEvent me) {}
/** Redéfinir la méthode MouseClicked(MouseEvent me)
* Elle permet de changer de reaction_def et de redéssiner le rectangle rouge associé
* @param me MouseEvent déclenché uniquement sur l'imagelabel dans pathwaybrowser
**/
public void mouseClicked(MouseEvent me) {
if (me.getSource() == pathwaybrowser.imglabel) {
Point p = me.getPoint();
int xM = (int) (p.getX() - (pathwaybrowser.imglabel.getWidth() - pathwaybrowser.image.getWidth(null)) / 2);
int yM = (int) (p.getY() - (pathwaybrowser.imglabel.getHeight() - pathwaybrowser.image.getHeight(null)) / 2);
for (Reactor reactor : pathwaybrowser.reactorList) {
if (reactor.contains(xM, yM)) {
reactor_def = pathwaybrowser.reactor_def = reactor;
try {
reaction_info.updateInfo("rn", reactor_def.reacID);
inv_gene.updateJList(reactor_def.geneList);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
}
}
/** Implementer la methode valueChanged(ListSelectionEvent e) pour l'interface ListSelectionListener permet :
* 1. si l'évenement vient du InvolvesGenes Panel
* - Inscrit les identifiants d'organisme et de gène dans les champs de texte de GenomeBrowser
* - Mettre à jour la page web dans la fenetre genomebrowser
* - Importer les informations sur le gene
* - Afficher dans quelle(s) réaction(s) est impliqué ce gène
* 2. si l'évenement vient du InvolvedInReactions Panel
* - Inscrit les identifiants d'organisme et de voie métabolique dans les champs de texte de PathwayBrowser
* - Mettre à jour l'image affichée dans pathwaybrowser
* - Importer les information sur un réaction par défaut
* - Afficher les gène(s) qui catalyse(nt) cette réaction
* @param e ListSelectionEvent déclenché dans la JList d'un des InvolvePanels
**/
public void valueChanged(ListSelectionEvent e) {
if (e.getSource() == inv_gene.jlist) {
if (!inv_gene.jlist.isSelectionEmpty() && (e.getValueIsAdjusting() == false)) {
// Get gene species et gene ID and rewrite textfields in Genome Browser Menu
this.GeneSp = this.MapSp;
this.GeneID = inv_gene.jlist.getSelectedValue();
genomebrowser.setFieldSp(GeneSp);
genomebrowser.setFieldID(GeneID);
// Update Genome Browser, de Gene Information et de InvolvedInReactions Panels
genomebrowser.updatePage(GeneSp,GeneID);
try {
gene_info.updateInfo(GeneSp, GeneID);
genomebrowser.Parsing(GeneSp, GeneID);
inv_reaction.updateJList(genomebrowser.reacList);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
if (e.getSource() == inv_reaction.jlist) {
if (!inv_reaction.jlist.isSelectionEmpty() && (e.getValueIsAdjusting() == false)) {
// Get map species et map ID and rewrite textfields in Pathway Browser Menu
this.MapSp = this.GeneSp;
this.MapID = inv_reaction.jlist.getSelectedValue().substring(12);
String reacID = inv_reaction.jlist.getSelectedValue().substring(0,6);
pathwaybrowser.setFieldSp(MapSp);
pathwaybrowser.setFieldID(MapID);
// Update Pathway Browser, de Reaction Information et de InvolvesGenes Panels
try {
pathwaybrowser.updateImg(MapSp, MapID);
pathwaybrowser.Parsing(MapSp, MapID, reacID);
reactor_def = pathwaybrowser.reactor_def;
reaction_info.updateInfo("rn", reactor_def.reacID);
inv_gene.updateJList(reactor_def.geneList);
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}
}
/** Constructeur de la classe KEGGBrowser
* @throws IOException KEGGBrowser laisse l'intérpréteur gérer l'IOException
**/
public KEGGBrowser() throws IOException {
setTitle("KEGG Browser");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(900, 600);
// Creation of leftPanel containg both genome browser and pathway browser
leftPanel = new JPanel();
leftPanel.setLayout(new GridLayout(2,1));
// Creation des fenetres de recherche génomique et MAJ de la reacList
genomebrowser = new GenomeBrowser();
genomebrowser.bouton.addActionListener(this);
genomebrowser.setFieldSp(GeneSp);
genomebrowser.setFieldID(GeneID);
genomebrowser.Parsing(GeneSp, GeneID);
genomebrowser.updatePage(GeneSp, GeneID);
// Creation des fenetres de recherche métabolique et MAJ de la reactorList
pathwaybrowser = new PathwayBrowser();
pathwaybrowser.bouton.addActionListener(this);
pathwaybrowser.setFieldSp(MapSp);
pathwaybrowser.setFieldID(MapID);
pathwaybrowser.imglabel.addMouseListener(this);
try {
pathwaybrowser.updateImg(MapSp, MapID);
pathwaybrowser.Parsing(MapSp, MapID, "");
reactor_def = pathwaybrowser.reactor_def;
} catch (IOException ioe) {
ioe.printStackTrace();
}
// Repartition de JPanel leftPanel
leftPanel.add(genomebrowser);
leftPanel.add(pathwaybrowser);
// Creation of rightPanel containing gene and reaction information
rightPanel = new JPanel();
rightPanel.setLayout(new GridLayout(4,1));
// Creation des JPanel d'information sur gènes et réaction
gene_info = new InformationPanel("Gene information");
try {
gene_info.updateInfo(GeneSp, GeneID);
} catch (IOException ioe) {
ioe.printStackTrace();
}
reaction_info = new InformationPanel("Reaction information");
reaction_info.bouton.addActionListener(this);
try {
reaction_info.updateInfo("rn", reactor_def.reacID);
} catch (IOException ioe) {
ioe.printStackTrace();
}
// Creation de JPanel pour les champs Involde in reaction(s) et Involves gene(s)
inv_reaction = new InvolvePanel("Involved in reaction(s)");
inv_reaction.jlist.addListSelectionListener(this);
inv_reaction.updateJList(genomebrowser.reacList);
inv_gene = new InvolvePanel("Involves gene(s)");
inv_gene.jlist.addListSelectionListener(this);
inv_gene.updateJList(reactor_def.geneList);
// Repartition du JPanel rightPanel
rightPanel.add(gene_info);
rightPanel.add(inv_reaction);
rightPanel.add(reaction_info);
rightPanel.add(inv_gene);
// JSplitPane devides the window in two components (here: left and right)
splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel); // split the window verticaly
splitPane.setDividerLocation((int) (getWidth()*0.7)); // relative position of splitPane separator relative to frame width
//~ splitPane.setDividerLocation(getWidth()-300); // the initial position of the divider is 600 (our window is 900 pixels high)
getContentPane().setLayout(new GridLayout());
getContentPane().add(splitPane);
}
/** Méthode main qui crée la frame KEGGBrowser et redimensionne à tout moment :
* - la frame de l'application KEGGBrowser
* - la JList des fenetres InvolvePanels
* @param args laissé vide par l'utilisateur
* @throws IOException laisse l'interpréteur gérer l'IOException
**/
public static void main(String[] args) throws IOException {
KEGGBrowser keggbrowser = new KEGGBrowser();
keggbrowser.setVisible(true);
while (true) {
keggbrowser.MAJ_redimensioning();
}
}
}