3 import jalview.datamodel.*;
\r
4 import jalview.analysis.*;
\r
5 import jalview.schemes.*;
\r
6 import javax.swing.*;
\r
7 import java.awt.event.*;
\r
11 public class PopupMenu extends JPopupMenu
\r
13 JMenu groupMenu = new JMenu();
\r
14 JMenuItem analyze = new JMenuItem();
\r
15 JMenu defineMenu = new JMenu();
\r
16 JMenuItem groupName = new JMenuItem();
\r
17 JMenuItem groupAnnotation = new JMenuItem();
\r
18 protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem();
\r
19 protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
\r
20 protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
\r
21 protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem();
\r
22 protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
\r
23 protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
\r
24 protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
\r
25 protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
\r
26 protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
\r
27 protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem();
\r
28 protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem();
\r
29 protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();
\r
30 JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();
\r
31 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
\r
35 JMenu sequenceMenu = new JMenu();
\r
36 JMenuItem sequenceName = new JMenuItem();
\r
37 JMenu residueMenu = new JMenu();
\r
38 JMenuItem annotateResidue = new JMenuItem();
\r
41 JMenuItem unGroupMenuItem = new JMenuItem();
\r
42 JMenuItem pdbMenuItem = new JMenuItem();
\r
44 public PopupMenu(AlignmentPanel ap, Sequence seq)
\r
46 ///////////////////////////////////////////////////////////
\r
47 // If this is activated from the sequence panel, the user may want to
\r
48 // edit or annotate a particular residue. Therefore display the residue menu
\r
50 // If from the IDPanel, we must display the sequence menu
\r
51 //////////////////////////////////////////////////////////
\r
56 ButtonGroup colours = new ButtonGroup();
\r
57 colours.add(noColourmenuItem);
\r
58 colours.add(clustalColour);
\r
59 colours.add(zappoColour);
\r
60 colours.add(taylorColour);
\r
61 colours.add(hydrophobicityColour);
\r
62 colours.add(helixColour);
\r
63 colours.add(strandColour);
\r
64 colours.add(turnColour);
\r
65 colours.add(buriedColour);
\r
66 colours.add(abovePIDColour);
\r
67 colours.add(userDefinedColour);
\r
68 colours.add(PIDColour);
\r
69 colours.add(BLOSUM62Colour);
\r
74 { e.printStackTrace(); }
\r
76 SequenceGroup sg = ap.av.getSelectionGroup();
\r
79 groupName.setText(sg.getName());
\r
80 if(sg.cs instanceof ZappoColourScheme)
\r
81 zappoColour.setSelected(true);
\r
82 else if(sg.cs instanceof TaylorColourScheme)
\r
83 taylorColour.setSelected(true);
\r
84 else if (sg.cs instanceof PIDColourScheme)
\r
85 PIDColour.setSelected(true);
\r
86 else if (sg.cs instanceof Blosum62ColourScheme)
\r
87 BLOSUM62Colour.setSelected(true);
\r
88 else if (sg.cs instanceof UserColourScheme)
\r
89 userDefinedColour.setSelected(true);
\r
90 else if (sg.cs instanceof HydrophobicColourScheme)
\r
91 hydrophobicityColour.setSelected(true);
\r
92 else if (sg.cs instanceof HelixColourScheme)
\r
93 helixColour.setSelected(true);
\r
94 else if (sg.cs instanceof StrandColourScheme)
\r
95 strandColour.setSelected(true);
\r
96 else if (sg.cs instanceof TurnColourScheme)
\r
97 turnColour.setSelected(true);
\r
98 else if (sg.cs instanceof BuriedColourScheme)
\r
99 buriedColour.setSelected(true);
\r
100 else if (sg.cs instanceof ClustalxColourScheme)
\r
101 clustalColour.setSelected(true);
\r
103 noColourmenuItem.setSelected(true);
\r
105 if (sg.cs instanceof ConservationColourScheme)
\r
106 conservationMenuItem.setSelected(true);
\r
111 residueMenu.setVisible(false);
\r
113 sequenceMenu.setVisible(false);
\r
116 private void jbInit() throws Exception
\r
118 groupMenu.setText("Group");
\r
119 analyze.setText("Analyze");
\r
120 analyze.addActionListener(new java.awt.event.ActionListener()
\r
122 public void actionPerformed(ActionEvent e)
\r
124 analyze_actionPerformed(e);
\r
127 defineMenu.setText("Define");
\r
128 groupName.setText("Name");
\r
129 groupName.addActionListener(new java.awt.event.ActionListener()
\r
131 public void actionPerformed(ActionEvent e)
\r
133 groupName_actionPerformed(e);
\r
136 groupAnnotation.setText("Annotation");
\r
137 groupAnnotation.addActionListener(new java.awt.event.ActionListener()
\r
139 public void actionPerformed(ActionEvent e)
\r
141 groupAnnotation_actionPerformed(e);
\r
144 sequenceMenu.setText("Sequence");
\r
145 sequenceName.setText("Edit name");
\r
146 sequenceName.addActionListener(new java.awt.event.ActionListener()
\r
148 public void actionPerformed(ActionEvent e)
\r
150 sequenceName_actionPerformed(e);
\r
153 residueMenu.setText("Residue");
\r
154 annotateResidue.setText("annotate residue???");
\r
155 PIDColour.setFocusPainted(false);
\r
156 unGroupMenuItem.setText("Remove Group");
\r
157 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
\r
159 public void actionPerformed(ActionEvent e)
\r
161 unGroupMenuItem_actionPerformed(e);
\r
164 pdbMenuItem.setText("View PDB structure");
\r
165 pdbMenuItem.addActionListener(new java.awt.event.ActionListener()
\r
167 public void actionPerformed(ActionEvent e)
\r
169 pdbMenuItem_actionPerformed(e);
\r
173 this.add(sequenceMenu);
\r
174 this.add(residueMenu);
\r
175 groupMenu.add(defineMenu);
\r
176 groupMenu.add(unGroupMenuItem);
\r
177 groupMenu.addSeparator();
\r
178 groupMenu.add(analyze);
\r
179 defineMenu.add(groupName);
\r
180 defineMenu.add(groupAnnotation);
\r
181 defineMenu.addSeparator();
\r
182 defineMenu.add(noColourmenuItem);
\r
183 defineMenu.add(clustalColour);
\r
184 defineMenu.add(zappoColour);
\r
185 defineMenu.add(taylorColour);
\r
186 defineMenu.add(hydrophobicityColour);
\r
187 defineMenu.add(helixColour);
\r
188 defineMenu.add(strandColour);
\r
189 defineMenu.add(turnColour);
\r
190 defineMenu.add(buriedColour);
\r
191 defineMenu.add(userDefinedColour);
\r
192 defineMenu.add(PIDColour);
\r
193 defineMenu.add(BLOSUM62Colour);
\r
194 defineMenu.addSeparator();
\r
195 defineMenu.add(abovePIDColour);
\r
196 defineMenu.add(conservationMenuItem);
\r
198 sequenceMenu.add(sequenceName);
\r
199 sequenceMenu.add(pdbMenuItem);
\r
200 residueMenu.add(annotateResidue);
\r
202 noColourmenuItem.setText("None");
\r
203 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
\r
205 public void actionPerformed(ActionEvent e)
\r
207 noColourmenuItem_actionPerformed(e);
\r
211 clustalColour.setText("Clustalx colours");
\r
212 clustalColour.addActionListener(new java.awt.event.ActionListener()
\r
214 public void actionPerformed(ActionEvent e)
\r
216 clustalColour_actionPerformed(e);
\r
219 zappoColour.setText("Zappo colour scheme");
\r
220 zappoColour.addActionListener(new java.awt.event.ActionListener()
\r
222 public void actionPerformed(ActionEvent e)
\r
224 zappoColour_actionPerformed(e);
\r
227 taylorColour.setText("Taylor colour scheme");
\r
228 taylorColour.addActionListener(new java.awt.event.ActionListener()
\r
230 public void actionPerformed(ActionEvent e)
\r
232 taylorColour_actionPerformed(e);
\r
235 hydrophobicityColour.setText("By hydrophobicity");
\r
236 hydrophobicityColour.addActionListener(new java.awt.event.ActionListener()
\r
238 public void actionPerformed(ActionEvent e)
\r
240 hydrophobicityColour_actionPerformed(e);
\r
243 helixColour.setText("Helix propensity");
\r
244 helixColour.addActionListener(new java.awt.event.ActionListener()
\r
246 public void actionPerformed(ActionEvent e)
\r
248 helixColour_actionPerformed(e);
\r
251 strandColour.setText("Strand propensity");
\r
252 strandColour.addActionListener(new java.awt.event.ActionListener()
\r
254 public void actionPerformed(ActionEvent e)
\r
256 strandColour_actionPerformed(e);
\r
259 turnColour.setText("Turn propensity");
\r
260 turnColour.addActionListener(new java.awt.event.ActionListener()
\r
262 public void actionPerformed(ActionEvent e)
\r
264 turnColour_actionPerformed(e);
\r
267 buriedColour.setText("Buried index");
\r
268 buriedColour.addActionListener(new java.awt.event.ActionListener()
\r
270 public void actionPerformed(ActionEvent e)
\r
272 buriedColour_actionPerformed(e);
\r
275 abovePIDColour.setText("Above PID threshold only");
\r
276 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
\r
278 public void actionPerformed(ActionEvent e)
\r
280 abovePIDColour_actionPerformed(e);
\r
283 userDefinedColour.setText("User defined colours");
\r
284 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
\r
286 public void actionPerformed(ActionEvent e)
\r
288 userDefinedColour_actionPerformed(e);
\r
291 PIDColour.setText("Percentage Identity");
\r
292 PIDColour.addActionListener(new java.awt.event.ActionListener()
\r
294 public void actionPerformed(ActionEvent e)
\r
296 PIDColour_actionPerformed(e);
\r
299 BLOSUM62Colour.setText("BLOSUM62 score");
\r
300 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
\r
302 public void actionPerformed(ActionEvent e)
\r
304 BLOSUM62Colour_actionPerformed(e);
\r
307 conservationMenuItem.setText("By conservation");
\r
308 conservationMenuItem.addActionListener(new java.awt.event.ActionListener()
\r
310 public void actionPerformed(ActionEvent e)
\r
312 conservationMenuItem_actionPerformed(e);
\r
322 SequenceGroup sg = getGroup();
\r
323 SuperGroup superG = ap.av.alignment.getSuperGroup( sg );
\r
325 superG.setSuperGroupProperties( sg );
\r
327 ap.seqPanel.seqCanvas.paintFlag=true;
\r
328 ap.seqPanel.repaint();
\r
331 protected void clustalColour_actionPerformed(ActionEvent e)
\r
333 SequenceGroup sg = getGroup();
\r
334 sg.cs = new ClustalxColourScheme(sg.sequences, ap.av.alignment.getWidth());
\r
338 protected void zappoColour_actionPerformed(ActionEvent e)
\r
340 getGroup().cs = new ZappoColourScheme();
\r
344 protected void taylorColour_actionPerformed(ActionEvent e)
\r
346 getGroup().cs = new TaylorColourScheme();
\r
351 protected void hydrophobicityColour_actionPerformed(ActionEvent e)
\r
353 getGroup().cs = new HydrophobicColourScheme();
\r
357 protected void helixColour_actionPerformed(ActionEvent e)
\r
359 getGroup().cs = new HelixColourScheme();
\r
363 protected void strandColour_actionPerformed(ActionEvent e)
\r
365 getGroup().cs = new StrandColourScheme();
\r
369 protected void turnColour_actionPerformed(ActionEvent e)
\r
371 getGroup().cs = new TurnColourScheme();
\r
375 protected void buriedColour_actionPerformed(ActionEvent e)
\r
377 getGroup().cs = new BuriedColourScheme();
\r
382 protected void abovePIDColour_actionPerformed(ActionEvent e)
\r
384 Desktop.setPIDSliderSource(ap, getGroup().cs, getGroup().getName());
\r
388 protected void userDefinedColour_actionPerformed(ActionEvent e)
\r
390 JInternalFrame frame = new JInternalFrame();
\r
391 UserDefinedColours chooser = new UserDefinedColours( frame, ap, getGroup());
\r
392 frame.setContentPane(chooser);
\r
393 Desktop.addInternalFrame(frame,"User defined colours ("+getGroup().getName()+")", 450,540 );
\r
394 frame.setResizable(false);
\r
395 frame.setIconifiable(false);
\r
396 frame.setMaximizable(false);
\r
400 protected void PIDColour_actionPerformed(ActionEvent e)
\r
405 protected void BLOSUM62Colour_actionPerformed(ActionEvent e)
\r
407 getGroup().cs = new Blosum62ColourScheme(ap.av);
\r
412 protected void noColourmenuItem_actionPerformed(ActionEvent e)
\r
414 getGroup().cs = null;
\r
418 protected void conservationMenuItem_actionPerformed(ActionEvent e)
\r
420 SequenceGroup sg = getGroup();
\r
422 if(conservationMenuItem.isSelected())
\r
425 Conservation c = new Conservation("Group",
\r
426 ResidueProperties.propHash, 3,
\r
428 ap.av.alignment.getWidth());
\r
431 c.verdict(false, 100);
\r
432 ConservationColourScheme ccs = new ConservationColourScheme(c, sg.cs);
\r
437 Desktop.setConservationSliderSource(ap, ccs, sg.getName());
\r
439 else // remove ConservationColouring
\r
441 ConservationColourScheme ccs = (ConservationColourScheme)sg.cs;
\r
448 protected void groupAnnotation_actionPerformed(ActionEvent e)
\r
453 protected void groupName_actionPerformed(ActionEvent e)
\r
455 SequenceGroup sg = getGroup();
\r
456 String reply = JOptionPane.showInternalInputDialog(Desktop.desktop, "Enter new group name", "Edit group name", JOptionPane.QUESTION_MESSAGE);
\r
461 groupName.setText(reply);
\r
465 protected void analyze_actionPerformed(ActionEvent e)
\r
467 CutAndPasteTransfer cap = new CutAndPasteTransfer(false);
\r
468 JInternalFrame frame = new JInternalFrame();
\r
469 cap.formatForOutput();
\r
470 frame.setContentPane(cap);
\r
471 Desktop.addInternalFrame(frame, "Analyze this - ", 400, 300);
\r
472 SequenceGroup sg = getGroup();
\r
473 StringBuffer sb = new StringBuffer();
\r
475 for(int i=0; i<sg.sequences.size(); i++)
\r
477 Sequence tmp = (Sequence)sg.sequences.get(i);
\r
478 sb.append( tmp.getSequence(sg.getStartRes(), sg.getEndRes()+1));
\r
482 sb.append("Something amazing will happen soon");
\r
483 cap.setText( sb.toString() );
\r
487 SequenceGroup getGroup()
\r
489 SequenceGroup sg = ap.av.getSelectionGroup();
\r
491 // this method won't add a new group if it already exists
\r
492 ap.av.alignment.addGroup(sg);
\r
497 void sequenceName_actionPerformed(ActionEvent e)
\r
499 String id = sequence.getName();
\r
500 String s = (String)JOptionPane.showInternalInputDialog(
\r
502 "Edit sequence name",
\r
503 "Edit sequence name ("+sequence.getName()+")",
\r
504 JOptionPane.PLAIN_MESSAGE,
\r
511 sequence.setName(s);
\r
512 ap.RefreshPanels();
\r
517 void unGroupMenuItem_actionPerformed(ActionEvent e)
\r
519 SequenceGroup sg = ap.av.getSelectionGroup();
\r
520 ap.av.alignment.deleteGroup(sg);
\r
521 ap.av.setSelectionGroup(null);
\r
522 ap.RefreshPanels();
\r
525 void pdbMenuItem_actionPerformed(ActionEvent e)
\r
527 if(sequence.getPDBId()==null)
\r
532 EBIFetchClient ebi = new EBIFetchClient();
\r
533 String[] result = ebi.fetchData("pdb:" + sequence.getPDBId(), null, null);
\r
535 PDBfile pdb = new PDBfile(result);
\r
536 sequence.setPDBfile(pdb);
\r
538 ( (PDBChain) pdb.chains.elementAt(sequence.maxchain)).isVisible = true;
\r
539 ( (PDBChain) pdb.chains.elementAt(sequence.maxchain)).sequence = sequence;
\r
540 // ( (PDBChain)pdb.chains.elementAt(sequence.maxchain)).colourBySequence();
\r
542 rotCanvas rc = new rotCanvas(pdb);
\r
543 JInternalFrame frame = new JInternalFrame();
\r
544 frame.setContentPane(rc);
\r
545 Desktop.addInternalFrame(frame,sequence.getName()+" "+ sequence.getPDBId(), 400, 400);
\r
547 catch (Exception ex)
\r
549 ex.printStackTrace();
\r