2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import jalview.analysis.AAFrequency;
24 import jalview.analysis.Conservation;
25 import jalview.commands.ChangeCaseCommand;
26 import jalview.commands.EditCommand;
27 import jalview.datamodel.AlignmentAnnotation;
28 import jalview.datamodel.Annotation;
29 import jalview.datamodel.DBRefEntry;
30 import jalview.datamodel.PDBEntry;
31 import jalview.datamodel.Sequence;
32 import jalview.datamodel.SequenceFeature;
33 import jalview.datamodel.SequenceGroup;
34 import jalview.datamodel.SequenceI;
35 import jalview.io.FormatAdapter;
36 import jalview.io.SequenceAnnotationReport;
37 import jalview.schemes.AnnotationColourGradient;
38 import jalview.schemes.Blosum62ColourScheme;
39 import jalview.schemes.BuriedColourScheme;
40 import jalview.schemes.ClustalxColourScheme;
41 import jalview.schemes.HelixColourScheme;
42 import jalview.schemes.HydrophobicColourScheme;
43 import jalview.schemes.NucleotideColourScheme;
44 import jalview.schemes.PIDColourScheme;
45 import jalview.schemes.PurinePyrimidineColourScheme;
46 import jalview.schemes.ResidueProperties;
47 import jalview.schemes.StrandColourScheme;
48 import jalview.schemes.TaylorColourScheme;
49 import jalview.schemes.TurnColourScheme;
50 import jalview.schemes.UserColourScheme;
51 import jalview.schemes.ZappoColourScheme;
52 import jalview.util.GroupUrlLink;
53 import jalview.util.GroupUrlLink.UrlStringTooLongException;
54 import jalview.util.MessageManager;
55 import jalview.util.UrlLink;
57 import java.awt.Color;
58 import java.awt.event.ActionEvent;
59 import java.awt.event.ActionListener;
60 import java.util.Hashtable;
61 import java.util.Vector;
63 import javax.swing.ButtonGroup;
64 import javax.swing.JCheckBoxMenuItem;
65 import javax.swing.JColorChooser;
66 import javax.swing.JMenu;
67 import javax.swing.JMenuItem;
68 import javax.swing.JOptionPane;
69 import javax.swing.JPopupMenu;
70 import javax.swing.JRadioButtonMenuItem;
76 * @version $Revision: 1.118 $
78 public class PopupMenu extends JPopupMenu
80 JMenu groupMenu = new JMenu();
82 JMenuItem groupName = new JMenuItem();
84 protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem();
86 protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
88 protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
90 protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem();
92 protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
94 protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
96 protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
98 protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
100 protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
102 protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem();
104 protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem();
106 protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();
108 protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem();
110 protected JRadioButtonMenuItem RNAInteractionColour = new JRadioButtonMenuItem();
112 // protected JRadioButtonMenuItem covariationColour = new
113 // JRadioButtonMenuItem();
115 JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();
117 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
121 JMenu sequenceMenu = new JMenu();
123 JMenuItem sequenceName = new JMenuItem();
125 JMenuItem sequenceDetails = new JMenuItem();
127 JMenuItem sequenceSelDetails = new JMenuItem();
129 JMenuItem chooseAnnotations = new JMenuItem();
133 JMenuItem createGroupMenuItem = new JMenuItem();
135 JMenuItem unGroupMenuItem = new JMenuItem();
137 JMenuItem outline = new JMenuItem();
139 JRadioButtonMenuItem nucleotideMenuItem = new JRadioButtonMenuItem();
141 JMenu colourMenu = new JMenu();
143 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
145 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
147 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
149 JCheckBoxMenuItem displayNonconserved = new JCheckBoxMenuItem();
151 JMenu editMenu = new JMenu();
153 JMenuItem cut = new JMenuItem();
155 JMenuItem copy = new JMenuItem();
157 JMenuItem upperCase = new JMenuItem();
159 JMenuItem lowerCase = new JMenuItem();
161 JMenuItem toggle = new JMenuItem();
163 JMenu pdbMenu = new JMenu();
165 JMenuItem pdbFromFile = new JMenuItem();
167 // JBPNote: Commented these out - Should add these services via the web
168 // services menu system.
169 // JMenuItem ContraFold = new JMenuItem();
171 // JMenuItem RNAFold = new JMenuItem();
173 JMenuItem enterPDB = new JMenuItem();
175 JMenuItem discoverPDB = new JMenuItem();
177 JMenu outputMenu = new JMenu();
179 JMenuItem sequenceFeature = new JMenuItem();
181 JMenuItem textColour = new JMenuItem();
183 JMenu jMenu1 = new JMenu();
185 JMenu structureMenu = new JMenu();
187 JMenu viewStructureMenu = new JMenu();
189 // JMenu colStructureMenu = new JMenu();
190 JMenuItem editSequence = new JMenuItem();
192 // JMenuItem annotationMenuItem = new JMenuItem();
194 JMenu groupLinksMenu;
197 * Creates a new PopupMenu object.
204 public PopupMenu(final AlignmentPanel ap, Sequence seq, Vector links)
206 this(ap, seq, links, null);
216 public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
217 Vector links, Vector groupLinks)
219 // /////////////////////////////////////////////////////////
220 // If this is activated from the sequence panel, the user may want to
221 // edit or annotate a particular residue. Therefore display the residue menu
223 // If from the IDPanel, we must display the sequence menu
224 // ////////////////////////////////////////////////////////
228 ButtonGroup colours = new ButtonGroup();
229 colours.add(noColourmenuItem);
230 colours.add(clustalColour);
231 colours.add(zappoColour);
232 colours.add(taylorColour);
233 colours.add(hydrophobicityColour);
234 colours.add(helixColour);
235 colours.add(strandColour);
236 colours.add(turnColour);
237 colours.add(buriedColour);
238 colours.add(abovePIDColour);
239 colours.add(userDefinedColour);
240 colours.add(PIDColour);
241 colours.add(BLOSUM62Colour);
242 colours.add(purinePyrimidineColour);
243 colours.add(RNAInteractionColour);
244 // colours.add(covariationColour);
246 for (int i = 0; i < jalview.io.FormatAdapter.WRITEABLE_FORMATS.length; i++)
248 JMenuItem item = new JMenuItem(
249 jalview.io.FormatAdapter.WRITEABLE_FORMATS[i]);
251 item.addActionListener(new java.awt.event.ActionListener()
254 public void actionPerformed(ActionEvent e)
256 outputText_actionPerformed(e);
260 outputMenu.add(item);
266 } catch (Exception e)
274 sequenceMenu.setText(sequence.getName());
276 if (seq.getDatasetSequence().getPDBId() != null
277 && seq.getDatasetSequence().getPDBId().size() > 0)
279 java.util.Enumeration e = seq.getDatasetSequence().getPDBId()
282 while (e.hasMoreElements())
284 final PDBEntry pdb = (PDBEntry) e.nextElement();
286 menuItem = new JMenuItem();
287 menuItem.setText(pdb.getId());
288 menuItem.addActionListener(new java.awt.event.ActionListener()
291 public void actionPerformed(ActionEvent e)
293 // TODO re JAL-860: optionally open dialog or provide a menu entry
294 // allowing user to open just one structure per sequence
295 // new AppJmol(pdb, ap.av.collateForPDB(new PDBEntry[]
296 // { pdb })[0], null, ap);
297 new StructureViewer(ap.getStructureSelectionManager())
299 ap.av.collateForPDB(new PDBEntry[]
300 { pdb })[0], null, ap);
304 viewStructureMenu.add(menuItem);
307 * menuItem = new JMenuItem(); menuItem.setText(pdb.getId());
308 * menuItem.addActionListener(new java.awt.event.ActionListener() {
309 * public void actionPerformed(ActionEvent e) {
310 * colourByStructure(pdb.getId()); } });
311 * colStructureMenu.add(menuItem);
317 if (ap.av.getAlignment().isNucleotide() == false)
319 structureMenu.remove(viewStructureMenu);
321 // structureMenu.remove(colStructureMenu);
324 if (ap.av.getAlignment().isNucleotide() == true)
326 AlignmentAnnotation[] aa = ap.av.getAlignment()
327 .getAlignmentAnnotation();
328 for (int i = 0; i < aa.length; i++)
330 if (aa[i].getRNAStruc() != null)
332 final String rnastruc = aa[i].getRNAStruc();
333 final String structureLine = aa[i].label;
334 menuItem = new JMenuItem();
335 menuItem.setText(MessageManager.formatMessage(
336 "label.2d_rna_structure_line", new String[]
338 menuItem.addActionListener(new java.awt.event.ActionListener()
342 public void actionPerformed(ActionEvent e)
344 // System.out.println("1:"+structureLine);
345 System.out.println("1:sname" + seq.getName());
346 System.out.println("2:seq" + seq);
348 // System.out.println("3:"+seq.getSequenceAsString());
349 System.out.println("3:strucseq" + rnastruc);
350 // System.out.println("4:struc"+seq.getRNA());
351 System.out.println("5:name" + seq.getName());
352 System.out.println("6:ap" + ap);
353 new AppVarna(structureLine, seq, seq.getSequenceAsString(),
354 rnastruc, seq.getName(), ap);
355 // new AppVarna(seq.getName(),seq,rnastruc,seq.getRNA(),
356 // seq.getName(), ap);
357 System.out.println("end");
360 viewStructureMenu.add(menuItem);
364 // SequenceFeatures[] test = seq.getSequenceFeatures();
366 if (seq.getAnnotation() != null)
368 AlignmentAnnotation seqAnno[] = seq.getAnnotation();
369 for (int i = 0; i < seqAnno.length; i++)
371 if (seqAnno[i].getRNAStruc() != null)
373 final String rnastruc = seqAnno[i].getRNAStruc();
375 // TODO: make rnastrucF a bit more nice
376 menuItem = new JMenuItem();
377 menuItem.setText(MessageManager.formatMessage(
378 "label.2d_rna_sequence_name", new String[]
380 menuItem.addActionListener(new java.awt.event.ActionListener()
383 public void actionPerformed(ActionEvent e)
385 // TODO: VARNA does'nt print gaps in the sequence
387 new AppVarna(seq.getName() + " structure", seq, seq
388 .getSequenceAsString(), rnastruc, seq.getName(),
392 viewStructureMenu.add(menuItem);
399 menuItem = new JMenuItem(
400 MessageManager.getString("action.hide_sequences"));
401 menuItem.addActionListener(new java.awt.event.ActionListener()
404 public void actionPerformed(ActionEvent e)
406 hideSequences(false);
411 if (ap.av.getSelectionGroup() != null
412 && ap.av.getSelectionGroup().getSize() > 1)
414 menuItem = new JMenuItem(MessageManager.formatMessage(
415 "label.represent_group_with", new String[]
417 menuItem.addActionListener(new java.awt.event.ActionListener()
420 public void actionPerformed(ActionEvent e)
425 sequenceMenu.add(menuItem);
428 if (ap.av.hasHiddenRows())
430 final int index = ap.av.getAlignment().findIndex(seq);
432 if (ap.av.adjustForHiddenSeqs(index)
433 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
435 menuItem = new JMenuItem(
436 MessageManager.getString("action.reveal_sequences"));
437 menuItem.addActionListener(new ActionListener()
440 public void actionPerformed(ActionEvent e)
442 ap.av.showSequence(index);
443 if (ap.overviewPanel != null)
445 ap.overviewPanel.updateOverviewImage();
453 // for the case when no sequences are even visible
454 if (ap.av.hasHiddenRows())
457 menuItem = new JMenuItem(
458 MessageManager.getString("action.reveal_all"));
459 menuItem.addActionListener(new ActionListener()
462 public void actionPerformed(ActionEvent e)
464 ap.av.showAllHiddenSeqs();
465 if (ap.overviewPanel != null)
467 ap.overviewPanel.updateOverviewImage();
477 SequenceGroup sg = ap.av.getSelectionGroup();
478 boolean isDefinedGroup = (sg != null) ? ap.av.getAlignment()
479 .getGroups().contains(sg) : false;
481 if (sg != null && sg.getSize() > 0)
483 groupName.setText(MessageManager.formatMessage("label.name_param",
486 groupName.setText(MessageManager
487 .getString("label.edit_name_and_description_current_group"));
489 if (sg.cs instanceof ZappoColourScheme)
491 zappoColour.setSelected(true);
493 else if (sg.cs instanceof TaylorColourScheme)
495 taylorColour.setSelected(true);
497 else if (sg.cs instanceof PIDColourScheme)
499 PIDColour.setSelected(true);
501 else if (sg.cs instanceof Blosum62ColourScheme)
503 BLOSUM62Colour.setSelected(true);
505 else if (sg.cs instanceof UserColourScheme)
507 userDefinedColour.setSelected(true);
509 else if (sg.cs instanceof HydrophobicColourScheme)
511 hydrophobicityColour.setSelected(true);
513 else if (sg.cs instanceof HelixColourScheme)
515 helixColour.setSelected(true);
517 else if (sg.cs instanceof StrandColourScheme)
519 strandColour.setSelected(true);
521 else if (sg.cs instanceof TurnColourScheme)
523 turnColour.setSelected(true);
525 else if (sg.cs instanceof BuriedColourScheme)
527 buriedColour.setSelected(true);
529 else if (sg.cs instanceof ClustalxColourScheme)
531 clustalColour.setSelected(true);
533 else if (sg.cs instanceof PurinePyrimidineColourScheme)
535 purinePyrimidineColour.setSelected(true);
539 * else if (sg.cs instanceof CovariationColourScheme) {
540 * covariationColour.setSelected(true); }
544 noColourmenuItem.setSelected(true);
547 if (sg.cs != null && sg.cs.conservationApplied())
549 conservationMenuItem.setSelected(true);
551 displayNonconserved.setSelected(sg.getShowNonconserved());
552 showText.setSelected(sg.getDisplayText());
553 showColourText.setSelected(sg.getColourText());
554 showBoxes.setSelected(sg.getDisplayBoxes());
555 // add any groupURLs to the groupURL submenu and make it visible
556 if (groupLinks != null && groupLinks.size() > 0)
558 buildGroupURLMenu(sg, groupLinks);
560 // Add a 'show all structures' for the current selection
561 Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>(), reppdb = new Hashtable<String, PDBEntry>();
562 SequenceI sqass = null;
563 for (SequenceI sq : ap.av.getSequenceSelection())
565 Vector<PDBEntry> pes = sq.getDatasetSequence()
567 if (pes != null && pes.size() > 0)
569 reppdb.put(pes.get(0).getId(), pes.get(0));
570 for (PDBEntry pe : pes)
572 pdbe.put(pe.getId(), pe);
582 final PDBEntry[] pe = pdbe.values().toArray(
583 new PDBEntry[pdbe.size()]), pr = reppdb.values().toArray(
584 new PDBEntry[reppdb.size()]);
585 final JMenuItem gpdbview, rpdbview;
586 if (pdbe.size() == 1)
588 structureMenu.add(gpdbview = new JMenuItem(MessageManager
589 .formatMessage("label.view_structure_for", new String[]
590 { sqass.getDisplayId(false) })));
594 structureMenu.add(gpdbview = new JMenuItem(MessageManager
595 .formatMessage("label.view_all_structures", new String[]
596 { new Integer(pdbe.size()).toString() })));
598 gpdbview.setToolTipText(MessageManager
599 .getString("label.open_new_jmol_view_with_all_structures_associated_current_selection_superimpose_using_alignment"));
600 gpdbview.addActionListener(new ActionListener()
604 public void actionPerformed(ActionEvent e)
606 new StructureViewer(ap.getStructureSelectionManager())
607 .viewStructures(ap, pe, ap.av.collateForPDB(pe));
610 if (reppdb.size() > 1 && reppdb.size() < pdbe.size())
612 structureMenu.add(rpdbview = new JMenuItem(MessageManager
614 "label.view_all_representative_structures",
616 { new Integer(reppdb.size()).toString() })));
617 rpdbview.setToolTipText(MessageManager
618 .getString("label.open_new_jmol_view_with_all_representative_structures_associated_current_selection_superimpose_using_alignment"));
619 rpdbview.addActionListener(new ActionListener()
623 public void actionPerformed(ActionEvent e)
625 new StructureViewer(ap.getStructureSelectionManager())
626 .viewStructures(ap, pr, ap.av.collateForPDB(pr));
634 groupMenu.setVisible(false);
635 editMenu.setVisible(false);
640 createGroupMenuItem.setVisible(true);
641 unGroupMenuItem.setVisible(false);
642 jMenu1.setText(MessageManager.getString("action.edit_new_group"));
646 createGroupMenuItem.setVisible(false);
647 unGroupMenuItem.setVisible(true);
648 jMenu1.setText(MessageManager.getString("action.edit_group"));
653 sequenceMenu.setVisible(false);
654 structureMenu.setVisible(false);
657 if (links != null && links.size() > 0)
660 JMenu linkMenu = new JMenu(MessageManager.getString("action.link"));
661 Vector linkset = new Vector();
662 for (int i = 0; i < links.size(); i++)
664 String link = links.elementAt(i).toString();
665 UrlLink urlLink = null;
668 urlLink = new UrlLink(link);
669 } catch (Exception foo)
671 jalview.bin.Cache.log.error("Exception for URLLink '" + link
676 if (!urlLink.isValid())
678 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
681 final String label = urlLink.getLabel();
682 if (seq != null && urlLink.isDynamic())
685 // collect matching db-refs
686 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
687 seq.getDBRef(), new String[]
688 { urlLink.getTarget() });
689 // collect id string too
690 String id = seq.getName();
691 String descr = seq.getDescription();
692 if (descr != null && descr.length() < 1)
699 for (int r = 0; r < dbr.length; r++)
701 if (id != null && dbr[r].getAccessionId().equals(id))
703 // suppress duplicate link creation for the bare sequence ID
704 // string with this link
707 // create Bare ID link for this RUL
708 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
712 for (int u = 0; u < urls.length; u += 2)
714 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
716 linkset.addElement(urls[u] + "|" + urls[u + 1]);
717 addshowLink(linkMenu, label + "|" + urls[u],
726 // create Bare ID link for this RUL
727 String[] urls = urlLink.makeUrls(id, true);
730 for (int u = 0; u < urls.length; u += 2)
732 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
734 linkset.addElement(urls[u] + "|" + urls[u + 1]);
735 addshowLink(linkMenu, label, urls[u + 1]);
740 // Create urls from description but only for URL links which are regex
742 if (descr != null && urlLink.getRegexReplace() != null)
744 // create link for this URL from description where regex matches
745 String[] urls = urlLink.makeUrls(descr, true);
748 for (int u = 0; u < urls.length; u += 2)
750 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
752 linkset.addElement(urls[u] + "|" + urls[u + 1]);
753 addshowLink(linkMenu, label, urls[u + 1]);
761 if (!linkset.contains(label + "|" + urlLink.getUrl_prefix()))
763 linkset.addElement(label + "|" + urlLink.getUrl_prefix());
764 // Add a non-dynamic link
765 addshowLink(linkMenu, label, urlLink.getUrl_prefix());
769 if (sequence != null)
771 sequenceMenu.add(linkMenu);
780 private void buildGroupURLMenu(SequenceGroup sg, Vector groupLinks)
783 // TODO: usability: thread off the generation of group url content so root
785 // sequence only URLs
786 // ID/regex match URLs
787 groupLinksMenu = new JMenu(
788 MessageManager.getString("action.group_link"));
789 JMenu[] linkMenus = new JMenu[]
790 { null, new JMenu(MessageManager.getString("action.ids")),
791 new JMenu(MessageManager.getString("action.sequences")),
792 new JMenu(MessageManager.getString("action.ids_sequences")) }; // three
799 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
800 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
801 Hashtable commonDbrefs = new Hashtable();
802 for (int sq = 0; sq < seqs.length; sq++)
805 int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
806 .findPosition(sg.getEndRes());
807 // just collect ids from dataset sequence
808 // TODO: check if IDs collected from selecton group intersects with the
809 // current selection, too
810 SequenceI sqi = seqs[sq];
811 while (sqi.getDatasetSequence() != null)
813 sqi = sqi.getDatasetSequence();
815 DBRefEntry[] dbr = sqi.getDBRef();
816 if (dbr != null && dbr.length > 0)
818 for (int d = 0; d < dbr.length; d++)
820 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
821 Object[] sarray = (Object[]) commonDbrefs.get(src);
824 sarray = new Object[2];
825 sarray[0] = new int[]
827 sarray[1] = new String[seqs.length];
829 commonDbrefs.put(src, sarray);
832 if (((String[]) sarray[1])[sq] == null)
835 || (dbr[d].getMap().locateMappedRange(start, end) != null))
837 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
838 ((int[]) sarray[0])[0]++;
844 // now create group links for all distinct ID/sequence sets.
845 boolean addMenu = false; // indicates if there are any group links to give
847 for (int i = 0; i < groupLinks.size(); i++)
849 String link = groupLinks.elementAt(i).toString();
850 GroupUrlLink urlLink = null;
853 urlLink = new GroupUrlLink(link);
854 } catch (Exception foo)
856 jalview.bin.Cache.log.error("Exception for GroupURLLink '" + link
861 if (!urlLink.isValid())
863 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
866 final String label = urlLink.getLabel();
867 boolean usingNames = false;
868 // Now see which parts of the group apply for this URL
869 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
870 Object[] idset = (Object[]) commonDbrefs.get(ltarget.toUpperCase());
871 String[] seqstr, ids; // input to makeUrl
874 int numinput = ((int[]) idset[0])[0];
875 String[] allids = ((String[]) idset[1]);
876 seqstr = new String[numinput];
877 ids = new String[numinput];
878 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
880 if (allids[sq] != null)
882 ids[idcount] = allids[sq];
883 seqstr[idcount++] = idandseqs[1][sq];
889 // just use the id/seq set
890 seqstr = idandseqs[1];
894 // and try and make the groupURL!
896 Object[] urlset = null;
899 urlset = urlLink.makeUrlStubs(ids, seqstr,
900 "FromJalview" + System.currentTimeMillis(), false);
901 } catch (UrlStringTooLongException e)
906 int type = urlLink.getGroupURLType() & 3;
907 // System.out.println(urlLink.getGroupURLType()
908 // +" "+((String[])urlset[3])[0]);
909 // first two bits ofurlLink type bitfield are sequenceids and sequences
910 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
911 addshowLink(linkMenus[type], label
912 + (((type & 1) == 1) ? ("("
913 + (usingNames ? "Names" : ltarget) + ")") : ""),
920 groupLinksMenu = new JMenu(
921 MessageManager.getString("action.group_link"));
922 for (int m = 0; m < linkMenus.length; m++)
924 if (linkMenus[m] != null
925 && linkMenus[m].getMenuComponentCount() > 0)
927 groupLinksMenu.add(linkMenus[m]);
931 groupMenu.add(groupLinksMenu);
936 * add a show URL menu item to the given linkMenu
940 * - menu label string
944 private void addshowLink(JMenu linkMenu, String label, final String url)
946 JMenuItem item = new JMenuItem(label);
947 item.setToolTipText(MessageManager.formatMessage(
948 "label.open_url_param", new String[]
950 item.addActionListener(new java.awt.event.ActionListener()
953 public void actionPerformed(ActionEvent e)
955 new Thread(new Runnable()
972 * add a late bound groupURL item to the given linkMenu
976 * - menu label string
977 * @param urlgenerator
978 * GroupURLLink used to generate URL
980 * Object array returned from the makeUrlStubs function.
982 private void addshowLink(JMenu linkMenu, String label,
983 final GroupUrlLink urlgenerator, final Object[] urlstub)
985 JMenuItem item = new JMenuItem(label);
986 item.setToolTipText(MessageManager.formatMessage(
987 "label.open_url_seqs_param",
989 { urlgenerator.getUrl_prefix(),
990 urlgenerator.getNumberInvolved(urlstub) }));
991 // TODO: put in info about what is being sent.
992 item.addActionListener(new java.awt.event.ActionListener()
995 public void actionPerformed(ActionEvent e)
997 new Thread(new Runnable()
1005 showLink(urlgenerator.constructFrom(urlstub));
1006 } catch (UrlStringTooLongException e)
1024 private void jbInit() throws Exception
1026 groupMenu.setText(MessageManager.getString("label.group"));
1027 groupMenu.setText(MessageManager.getString("label.selection"));
1028 groupName.setText(MessageManager.getString("label.name"));
1029 groupName.addActionListener(new java.awt.event.ActionListener()
1032 public void actionPerformed(ActionEvent e)
1034 groupName_actionPerformed();
1037 sequenceMenu.setText(MessageManager.getString("label.sequence"));
1038 sequenceName.setText(MessageManager
1039 .getString("label.edit_name_description"));
1040 sequenceName.addActionListener(new java.awt.event.ActionListener()
1043 public void actionPerformed(ActionEvent e)
1045 sequenceName_actionPerformed();
1048 chooseAnnotations.setText(MessageManager
1049 .getString("label.choose_annotations") + "...");
1051 .addActionListener(new java.awt.event.ActionListener()
1054 public void actionPerformed(ActionEvent e)
1056 chooseAnnotations_actionPerformed(e);
1059 sequenceDetails.setText(MessageManager
1060 .getString("label.sequence_details") + "...");
1061 sequenceDetails.addActionListener(new java.awt.event.ActionListener()
1064 public void actionPerformed(ActionEvent e)
1066 sequenceDetails_actionPerformed();
1069 sequenceSelDetails.setText(MessageManager
1070 .getString("label.sequence_details") + "...");
1072 .addActionListener(new java.awt.event.ActionListener()
1075 public void actionPerformed(ActionEvent e)
1077 sequenceSelectionDetails_actionPerformed();
1080 PIDColour.setFocusPainted(false);
1082 .setText(MessageManager.getString("action.remove_group"));
1083 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
1086 public void actionPerformed(ActionEvent e)
1088 unGroupMenuItem_actionPerformed();
1091 createGroupMenuItem.setText(MessageManager
1092 .getString("action.create_group"));
1094 .addActionListener(new java.awt.event.ActionListener()
1097 public void actionPerformed(ActionEvent e)
1099 createGroupMenuItem_actionPerformed();
1103 outline.setText(MessageManager.getString("action.border_colour"));
1104 outline.addActionListener(new java.awt.event.ActionListener()
1107 public void actionPerformed(ActionEvent e)
1109 outline_actionPerformed();
1113 .setText(MessageManager.getString("label.nucleotide"));
1114 nucleotideMenuItem.addActionListener(new ActionListener()
1117 public void actionPerformed(ActionEvent e)
1119 nucleotideMenuItem_actionPerformed();
1122 colourMenu.setText(MessageManager.getString("label.group_colour"));
1123 showBoxes.setText(MessageManager.getString("action.boxes"));
1124 showBoxes.setState(true);
1125 showBoxes.addActionListener(new ActionListener()
1128 public void actionPerformed(ActionEvent e)
1130 showBoxes_actionPerformed();
1133 showText.setText(MessageManager.getString("action.text"));
1134 showText.setState(true);
1135 showText.addActionListener(new ActionListener()
1138 public void actionPerformed(ActionEvent e)
1140 showText_actionPerformed();
1143 showColourText.setText(MessageManager.getString("label.colour_text"));
1144 showColourText.addActionListener(new ActionListener()
1147 public void actionPerformed(ActionEvent e)
1149 showColourText_actionPerformed();
1152 displayNonconserved.setText(MessageManager
1153 .getString("label.show_non_conversed"));
1154 displayNonconserved.setState(true);
1155 displayNonconserved.addActionListener(new ActionListener()
1158 public void actionPerformed(ActionEvent e)
1160 showNonconserved_actionPerformed();
1163 editMenu.setText(MessageManager.getString("action.edit"));
1164 cut.setText(MessageManager.getString("action.cut"));
1165 cut.addActionListener(new ActionListener()
1168 public void actionPerformed(ActionEvent e)
1170 cut_actionPerformed();
1173 upperCase.setText(MessageManager.getString("label.to_upper_case"));
1174 upperCase.addActionListener(new ActionListener()
1177 public void actionPerformed(ActionEvent e)
1182 copy.setText(MessageManager.getString("action.copy"));
1183 copy.addActionListener(new ActionListener()
1186 public void actionPerformed(ActionEvent e)
1188 copy_actionPerformed();
1191 lowerCase.setText(MessageManager.getString("label.to_lower_case"));
1192 lowerCase.addActionListener(new ActionListener()
1195 public void actionPerformed(ActionEvent e)
1200 toggle.setText(MessageManager.getString("label.toggle_case"));
1201 toggle.addActionListener(new ActionListener()
1204 public void actionPerformed(ActionEvent e)
1209 pdbMenu.setText(MessageManager
1210 .getString("label.associate_structure_with_sequence"));
1211 pdbFromFile.setText(MessageManager.getString("label.from_file"));
1212 pdbFromFile.addActionListener(new ActionListener()
1215 public void actionPerformed(ActionEvent e)
1217 pdbFromFile_actionPerformed();
1220 // RNAFold.setText("From RNA Fold with predict2D");
1221 // RNAFold.addActionListener(new ActionListener()
1223 // public void actionPerformed(ActionEvent e)
1226 // RNAFold_actionPerformed();
1227 // } catch (Exception e1) {
1228 // // TODO Auto-generated catch block
1229 // e1.printStackTrace();
1233 // ContraFold.setText("From Contra Fold with predict2D");
1234 // ContraFold.addActionListener(new ActionListener()
1236 // public void actionPerformed(ActionEvent e)
1239 // ContraFold_actionPerformed();
1240 // } catch (Exception e1) {
1241 // // TODO Auto-generated catch block
1242 // e1.printStackTrace();
1246 enterPDB.setText(MessageManager.getString("label.enter_pdb_id"));
1247 enterPDB.addActionListener(new ActionListener()
1250 public void actionPerformed(ActionEvent e)
1252 enterPDB_actionPerformed();
1255 discoverPDB.setText(MessageManager.getString("label.discover_pdb_ids"));
1256 discoverPDB.addActionListener(new ActionListener()
1259 public void actionPerformed(ActionEvent e)
1261 discoverPDB_actionPerformed();
1264 outputMenu.setText(MessageManager.getString("label.out_to_textbox")
1266 sequenceFeature.setText(MessageManager
1267 .getString("label.create_sequence_feature"));
1268 sequenceFeature.addActionListener(new ActionListener()
1271 public void actionPerformed(ActionEvent e)
1273 sequenceFeature_actionPerformed();
1276 textColour.setText(MessageManager.getString("label.text_colour"));
1277 textColour.addActionListener(new ActionListener()
1280 public void actionPerformed(ActionEvent e)
1282 textColour_actionPerformed();
1285 jMenu1.setText(MessageManager.getString("label.group"));
1286 structureMenu.setText(MessageManager.getString("label.structure"));
1287 viewStructureMenu.setText(MessageManager
1288 .getString("label.view_structure"));
1289 // colStructureMenu.setText("Colour By Structure");
1290 editSequence.setText(MessageManager.getString("label.edit_sequence")
1292 editSequence.addActionListener(new ActionListener()
1295 public void actionPerformed(ActionEvent actionEvent)
1297 editSequence_actionPerformed(actionEvent);
1302 * annotationMenuItem.setText("By Annotation");
1303 * annotationMenuItem.addActionListener(new ActionListener() { public void
1304 * actionPerformed(ActionEvent actionEvent) {
1305 * annotationMenuItem_actionPerformed(actionEvent); } });
1307 groupMenu.add(sequenceSelDetails);
1310 this.add(structureMenu);
1311 groupMenu.add(chooseAnnotations);
1312 groupMenu.add(editMenu);
1313 groupMenu.add(outputMenu);
1314 groupMenu.add(sequenceFeature);
1315 groupMenu.add(createGroupMenuItem);
1316 groupMenu.add(unGroupMenuItem);
1317 groupMenu.add(jMenu1);
1318 sequenceMenu.add(sequenceName);
1319 sequenceMenu.add(sequenceDetails);
1320 colourMenu.add(textColour);
1321 colourMenu.add(noColourmenuItem);
1322 colourMenu.add(clustalColour);
1323 colourMenu.add(BLOSUM62Colour);
1324 colourMenu.add(PIDColour);
1325 colourMenu.add(zappoColour);
1326 colourMenu.add(taylorColour);
1327 colourMenu.add(hydrophobicityColour);
1328 colourMenu.add(helixColour);
1329 colourMenu.add(strandColour);
1330 colourMenu.add(turnColour);
1331 colourMenu.add(buriedColour);
1332 colourMenu.add(nucleotideMenuItem);
1333 if (ap.getAlignment().isNucleotide())
1335 // JBPNote - commented since the colourscheme isn't functional
1336 // colourMenu.add(RNAInteractionColour);
1337 colourMenu.add(purinePyrimidineColour);
1339 // colourMenu.add(covariationColour);
1340 colourMenu.add(userDefinedColour);
1342 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
1344 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
1345 .getUserColourSchemes().keys();
1347 while (userColours.hasMoreElements())
1349 JMenuItem item = new JMenuItem(userColours.nextElement().toString());
1350 item.addActionListener(new ActionListener()
1353 public void actionPerformed(ActionEvent evt)
1355 userDefinedColour_actionPerformed(evt);
1358 colourMenu.add(item);
1362 colourMenu.addSeparator();
1363 colourMenu.add(abovePIDColour);
1364 colourMenu.add(conservationMenuItem);
1365 // colourMenu.add(annotationMenuItem);
1368 editMenu.add(editSequence);
1369 editMenu.add(upperCase);
1370 editMenu.add(lowerCase);
1371 editMenu.add(toggle);
1372 pdbMenu.add(pdbFromFile);
1373 // JBPNote: These shouldn't be added here - should appear in a generic
1374 // 'apply web service to this sequence menu'
1375 // pdbMenu.add(RNAFold);
1376 // pdbMenu.add(ContraFold);
1377 pdbMenu.add(enterPDB);
1378 pdbMenu.add(discoverPDB);
1379 jMenu1.add(groupName);
1380 jMenu1.add(colourMenu);
1381 jMenu1.add(showBoxes);
1382 jMenu1.add(showText);
1383 jMenu1.add(showColourText);
1384 jMenu1.add(outline);
1385 jMenu1.add(displayNonconserved);
1386 structureMenu.add(pdbMenu);
1387 structureMenu.add(viewStructureMenu);
1388 // structureMenu.add(colStructureMenu);
1389 noColourmenuItem.setText(MessageManager.getString("label.none"));
1390 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
1393 public void actionPerformed(ActionEvent e)
1395 noColourmenuItem_actionPerformed();
1399 clustalColour.setText(MessageManager
1400 .getString("label.clustalx_colours"));
1401 clustalColour.addActionListener(new java.awt.event.ActionListener()
1404 public void actionPerformed(ActionEvent e)
1406 clustalColour_actionPerformed();
1409 zappoColour.setText(MessageManager.getString("label.zappo"));
1410 zappoColour.addActionListener(new java.awt.event.ActionListener()
1413 public void actionPerformed(ActionEvent e)
1415 zappoColour_actionPerformed();
1418 taylorColour.setText(MessageManager.getString("label.taylor"));
1419 taylorColour.addActionListener(new java.awt.event.ActionListener()
1422 public void actionPerformed(ActionEvent e)
1424 taylorColour_actionPerformed();
1427 hydrophobicityColour.setText(MessageManager
1428 .getString("label.hydrophobicity"));
1429 hydrophobicityColour
1430 .addActionListener(new java.awt.event.ActionListener()
1433 public void actionPerformed(ActionEvent e)
1435 hydrophobicityColour_actionPerformed();
1438 helixColour.setText(MessageManager.getString("label.helix_propensity"));
1439 helixColour.addActionListener(new java.awt.event.ActionListener()
1442 public void actionPerformed(ActionEvent e)
1444 helixColour_actionPerformed();
1447 strandColour.setText(MessageManager
1448 .getString("label.strand_propensity"));
1449 strandColour.addActionListener(new java.awt.event.ActionListener()
1452 public void actionPerformed(ActionEvent e)
1454 strandColour_actionPerformed();
1457 turnColour.setText(MessageManager.getString("label.turn_propensity"));
1458 turnColour.addActionListener(new java.awt.event.ActionListener()
1461 public void actionPerformed(ActionEvent e)
1463 turnColour_actionPerformed();
1466 buriedColour.setText(MessageManager.getString("label.buried_index"));
1467 buriedColour.addActionListener(new java.awt.event.ActionListener()
1470 public void actionPerformed(ActionEvent e)
1472 buriedColour_actionPerformed();
1475 abovePIDColour.setText(MessageManager
1476 .getString("label.above_identity_percentage"));
1477 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
1480 public void actionPerformed(ActionEvent e)
1482 abovePIDColour_actionPerformed();
1485 userDefinedColour.setText(MessageManager
1486 .getString("action.user_defined"));
1487 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
1490 public void actionPerformed(ActionEvent e)
1492 userDefinedColour_actionPerformed(e);
1496 .setText(MessageManager.getString("label.percentage_identity"));
1497 PIDColour.addActionListener(new java.awt.event.ActionListener()
1500 public void actionPerformed(ActionEvent e)
1502 PIDColour_actionPerformed();
1505 BLOSUM62Colour.setText(MessageManager.getString("label.blosum62"));
1506 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
1509 public void actionPerformed(ActionEvent e)
1511 BLOSUM62Colour_actionPerformed();
1514 purinePyrimidineColour.setText(MessageManager
1515 .getString("label.purine_pyrimidine"));
1516 purinePyrimidineColour
1517 .addActionListener(new java.awt.event.ActionListener()
1520 public void actionPerformed(ActionEvent e)
1522 purinePyrimidineColour_actionPerformed();
1527 * covariationColour.addActionListener(new java.awt.event.ActionListener() {
1528 * public void actionPerformed(ActionEvent e) {
1529 * covariationColour_actionPerformed(); } });
1532 conservationMenuItem.setText(MessageManager
1533 .getString("label.conservation"));
1534 conservationMenuItem
1535 .addActionListener(new java.awt.event.ActionListener()
1538 public void actionPerformed(ActionEvent e)
1540 conservationMenuItem_actionPerformed();
1545 protected void sequenceSelectionDetails_actionPerformed()
1547 createSequenceDetailsReport(ap.av.getSequenceSelection());
1550 protected void sequenceDetails_actionPerformed()
1552 createSequenceDetailsReport(new SequenceI[]
1556 public void createSequenceDetailsReport(SequenceI[] sequences)
1558 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1559 StringBuffer contents = new StringBuffer();
1560 for (SequenceI seq : sequences)
1562 contents.append("<p><h2>"
1565 "label.create_sequence_details_report_annotation_for",
1567 { seq.getDisplayId(true) }) + "</h2></p><p>");
1568 new SequenceAnnotationReport(null)
1569 .createSequenceAnnotationReport(
1575 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
1577 contents.append("</p>");
1579 cap.setText("<html>" + contents.toString() + "</html>");
1581 Desktop.instance.addInternalFrame(cap, MessageManager.formatMessage(
1582 "label.sequece_details_for",
1583 (sequences.length == 1 ? new String[]
1584 { sequences[0].getDisplayId(true) } : new String[]
1585 { MessageManager.getString("label.selection") })), 500, 400);
1589 protected void showNonconserved_actionPerformed()
1591 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1596 * call to refresh view after settings change
1600 ap.updateAnnotation();
1601 ap.paintAlignment(true);
1603 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1612 protected void clustalColour_actionPerformed()
1614 SequenceGroup sg = getGroup();
1615 sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
1625 protected void zappoColour_actionPerformed()
1627 getGroup().cs = new ZappoColourScheme();
1637 protected void taylorColour_actionPerformed()
1639 getGroup().cs = new TaylorColourScheme();
1649 protected void hydrophobicityColour_actionPerformed()
1651 getGroup().cs = new HydrophobicColourScheme();
1661 protected void helixColour_actionPerformed()
1663 getGroup().cs = new HelixColourScheme();
1673 protected void strandColour_actionPerformed()
1675 getGroup().cs = new StrandColourScheme();
1685 protected void turnColour_actionPerformed()
1687 getGroup().cs = new TurnColourScheme();
1697 protected void buriedColour_actionPerformed()
1699 getGroup().cs = new BuriedColourScheme();
1709 public void nucleotideMenuItem_actionPerformed()
1711 getGroup().cs = new NucleotideColourScheme();
1715 protected void purinePyrimidineColour_actionPerformed()
1717 getGroup().cs = new PurinePyrimidineColourScheme();
1722 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1723 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1731 protected void abovePIDColour_actionPerformed()
1733 SequenceGroup sg = getGroup();
1739 if (abovePIDColour.isSelected())
1741 sg.cs.setConsensus(AAFrequency.calculate(
1742 sg.getSequences(ap.av.getHiddenRepSequences()),
1743 sg.getStartRes(), sg.getEndRes() + 1));
1745 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1748 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
1750 SliderPanel.showPIDSlider();
1753 // remove PIDColouring
1755 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
1767 protected void userDefinedColour_actionPerformed(ActionEvent e)
1769 SequenceGroup sg = getGroup();
1771 if (e.getSource().equals(userDefinedColour))
1773 new UserDefinedColours(ap, sg);
1777 UserColourScheme udc = (UserColourScheme) UserDefinedColours
1778 .getUserColourSchemes().get(e.getActionCommand());
1786 * Open a panel where the user can choose which types of sequence annotation
1791 protected void chooseAnnotations_actionPerformed(ActionEvent e)
1793 // todo correct way to guard against opening a duplicate panel?
1794 new AnnotationChooser(ap);
1802 protected void PIDColour_actionPerformed()
1804 SequenceGroup sg = getGroup();
1805 sg.cs = new PIDColourScheme();
1806 sg.cs.setConsensus(AAFrequency.calculate(
1807 sg.getSequences(ap.av.getHiddenRepSequences()),
1808 sg.getStartRes(), sg.getEndRes() + 1));
1818 protected void BLOSUM62Colour_actionPerformed()
1820 SequenceGroup sg = getGroup();
1822 sg.cs = new Blosum62ColourScheme();
1824 sg.cs.setConsensus(AAFrequency.calculate(
1825 sg.getSequences(ap.av.getHiddenRepSequences()),
1826 sg.getStartRes(), sg.getEndRes() + 1));
1837 protected void noColourmenuItem_actionPerformed()
1839 getGroup().cs = null;
1849 protected void conservationMenuItem_actionPerformed()
1851 SequenceGroup sg = getGroup();
1857 if (conservationMenuItem.isSelected())
1859 // JBPNote: Conservation name shouldn't be i18n translated
1860 Conservation c = new Conservation("Group",
1861 ResidueProperties.propHash, 3, sg.getSequences(ap.av
1862 .getHiddenRepSequences()), sg.getStartRes(),
1863 sg.getEndRes() + 1);
1866 c.verdict(false, ap.av.getConsPercGaps());
1868 sg.cs.setConservation(c);
1870 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1871 SliderPanel.showConservationSlider();
1874 // remove ConservationColouring
1876 sg.cs.setConservation(null);
1882 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1884 SequenceGroup sg = getGroup();
1890 AnnotationColourGradient acg = new AnnotationColourGradient(
1891 sequence.getAnnotation()[0], null,
1892 AnnotationColourGradient.NO_THRESHOLD);
1894 acg.setPredefinedColours(true);
1906 protected void groupName_actionPerformed()
1909 SequenceGroup sg = getGroup();
1910 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1911 sg.getDescription(), " "
1912 + MessageManager.getString("label.group_name") + " ",
1913 MessageManager.getString("label.group_description") + " ",
1914 MessageManager.getString("label.edit_group_name_description"),
1922 sg.setName(dialog.getName());
1923 sg.setDescription(dialog.getDescription());
1928 * Get selection group - adding it to the alignment if necessary.
1930 * @return sequence group to operate on
1932 SequenceGroup getGroup()
1934 SequenceGroup sg = ap.av.getSelectionGroup();
1935 // this method won't add a new group if it already exists
1938 ap.av.getAlignment().addGroup(sg);
1950 void sequenceName_actionPerformed()
1952 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1953 sequence.getDescription(),
1954 " " + MessageManager.getString("label.sequence_name")
1956 MessageManager.getString("label.sequence_description") + " ",
1958 .getString("label.edit_sequence_name_description"),
1966 if (dialog.getName() != null)
1968 if (dialog.getName().indexOf(" ") > -1)
1974 .getString("label.spaces_converted_to_backslashes"),
1976 .getString("label.no_spaces_allowed_sequence_name"),
1977 JOptionPane.WARNING_MESSAGE);
1980 sequence.setName(dialog.getName().replace(' ', '_'));
1981 ap.paintAlignment(false);
1984 sequence.setDescription(dialog.getDescription());
1986 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1997 void unGroupMenuItem_actionPerformed()
1999 SequenceGroup sg = ap.av.getSelectionGroup();
2000 ap.av.getAlignment().deleteGroup(sg);
2001 ap.av.setSelectionGroup(null);
2005 void createGroupMenuItem_actionPerformed()
2007 getGroup(); // implicitly creates group - note - should apply defaults / use
2008 // standard alignment window logic for this
2018 protected void outline_actionPerformed()
2020 SequenceGroup sg = getGroup();
2021 Color col = JColorChooser.showDialog(this,
2022 MessageManager.getString("label.select_outline_colour"),
2027 sg.setOutlineColour(col);
2039 public void showBoxes_actionPerformed()
2041 getGroup().setDisplayBoxes(showBoxes.isSelected());
2051 public void showText_actionPerformed()
2053 getGroup().setDisplayText(showText.isSelected());
2063 public void showColourText_actionPerformed()
2065 getGroup().setColourText(showColourText.isSelected());
2069 public void showLink(String url)
2073 jalview.util.BrowserLauncher.openURL(url);
2074 } catch (Exception ex)
2076 JOptionPane.showInternalMessageDialog(Desktop.desktop,
2077 MessageManager.getString("label.web_browser_not_found_unix"),
2078 MessageManager.getString("label.web_browser_not_found"),
2079 JOptionPane.WARNING_MESSAGE);
2081 ex.printStackTrace();
2085 void hideSequences(boolean representGroup)
2087 SequenceGroup sg = ap.av.getSelectionGroup();
2088 if (sg == null || sg.getSize() < 1)
2090 ap.av.hideSequence(new SequenceI[]
2095 ap.av.setSelectionGroup(null);
2099 ap.av.hideRepSequences(sequence, sg);
2104 int gsize = sg.getSize();
2107 hseqs = new SequenceI[gsize];
2110 for (int i = 0; i < gsize; i++)
2112 hseqs[index++] = sg.getSequenceAt(i);
2115 ap.av.hideSequence(hseqs);
2116 // refresh(); TODO: ? needed ?
2117 ap.av.sendSelection();
2120 public void copy_actionPerformed()
2122 ap.alignFrame.copy_actionPerformed(null);
2125 public void cut_actionPerformed()
2127 ap.alignFrame.cut_actionPerformed(null);
2130 void changeCase(ActionEvent e)
2132 Object source = e.getSource();
2133 SequenceGroup sg = ap.av.getSelectionGroup();
2137 int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
2138 sg.getEndRes() + 1);
2143 if (source == toggle)
2145 description = MessageManager.getString("label.toggle_case");
2146 caseChange = ChangeCaseCommand.TOGGLE_CASE;
2148 else if (source == upperCase)
2150 description = MessageManager.getString("label.to_upper_case");
2151 caseChange = ChangeCaseCommand.TO_UPPER;
2155 description = MessageManager.getString("label.to_lower_case");
2156 caseChange = ChangeCaseCommand.TO_LOWER;
2159 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
2160 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2161 startEnd, caseChange);
2163 ap.alignFrame.addHistoryItem(caseCommand);
2165 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
2171 public void outputText_actionPerformed(ActionEvent e)
2173 CutAndPasteTransfer cap = new CutAndPasteTransfer();
2174 cap.setForInput(null);
2175 Desktop.addInternalFrame(cap, MessageManager.formatMessage(
2176 "label.alignment_output_command", new String[]
2177 { e.getActionCommand() }), 600, 500);
2179 String[] omitHidden = null;
2181 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
2182 // or we simply trust the user wants
2183 // wysiwig behaviour
2185 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(), ap.av, true));
2188 public void pdbFromFile_actionPerformed()
2190 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
2191 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
2192 chooser.setFileView(new jalview.io.JalviewFileView());
2193 chooser.setDialogTitle(MessageManager.formatMessage(
2194 "label.select_pdb_file_for", new String[]
2195 { sequence.getDisplayId(false) }));
2196 chooser.setToolTipText(MessageManager.formatMessage(
2197 "label.load_pdb_file_associate_with_sequence", new String[]
2198 { sequence.getDisplayId(false) }));
2200 int value = chooser.showOpenDialog(null);
2202 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
2204 String choice = chooser.getSelectedFile().getPath();
2205 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
2206 new AssociatePdbFileWithSeq().associatePdbWithSeq(choice,
2207 jalview.io.AppletFormatAdapter.FILE, sequence, true);
2212 // JBNote: commented out - these won't be instantiated here...!
2213 // public void RNAFold_actionPerformed() throws Exception
2215 // Predict2D P2D = new Predict2D();
2216 // P2D.getStructure2DFromRNAFold("toto");
2219 // public void ContraFold_actionPerformed() throws Exception
2221 // Predict2D P2D = new Predict2D();
2222 // P2D.getStructure2DFromContraFold("toto");
2224 public void enterPDB_actionPerformed()
2226 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
2227 MessageManager.getString("label.enter_pdb_id"),
2228 MessageManager.getString("label.enter_pdb_id"),
2229 JOptionPane.QUESTION_MESSAGE);
2231 if (id != null && id.length() > 0)
2233 PDBEntry entry = new PDBEntry();
2234 entry.setId(id.toUpperCase());
2235 sequence.getDatasetSequence().addPDBId(entry);
2239 public void discoverPDB_actionPerformed()
2242 final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
2244 : ap.av.getSequenceSelection());
2245 Thread discpdb = new Thread(new Runnable()
2251 new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
2252 .fetchDBRefs(false);
2259 public void sequenceFeature_actionPerformed()
2261 SequenceGroup sg = ap.av.getSelectionGroup();
2267 int rsize = 0, gSize = sg.getSize();
2268 SequenceI[] rseqs, seqs = new SequenceI[gSize];
2269 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
2271 for (int i = 0; i < gSize; i++)
2273 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
2274 int end = sg.findEndRes(sg.getSequenceAt(i));
2277 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
2278 features[rsize] = new SequenceFeature(null, null, null, start, end,
2283 rseqs = new SequenceI[rsize];
2284 tfeatures = new SequenceFeature[rsize];
2285 System.arraycopy(seqs, 0, rseqs, 0, rsize);
2286 System.arraycopy(features, 0, tfeatures, 0, rsize);
2287 features = tfeatures;
2289 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
2290 features, true, ap))
2292 ap.alignFrame.setShowSeqFeatures(true);
2293 ap.highlightSearchResults(null);
2297 public void textColour_actionPerformed()
2299 SequenceGroup sg = getGroup();
2302 new TextColourChooser().chooseColour(ap, sg);
2306 public void colourByStructure(String pdbid)
2308 Annotation[] anots = ap.av.getStructureSelectionManager()
2309 .colourSequenceFromStructure(sequence, pdbid);
2311 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
2312 "Coloured by " + pdbid, anots);
2314 ap.av.getAlignment().addAnnotation(an);
2315 an.createSequenceMapping(sequence, 0, true);
2316 // an.adjustForAlignment();
2317 ap.av.getAlignment().setAnnotationIndex(an, 0);
2319 ap.adjustAnnotationHeight();
2321 sequence.addAlignmentAnnotation(an);
2325 public void editSequence_actionPerformed(ActionEvent actionEvent)
2327 SequenceGroup sg = ap.av.getSelectionGroup();
2331 if (sequence == null)
2332 sequence = sg.getSequenceAt(0);
2334 EditNameDialog dialog = new EditNameDialog(
2335 sequence.getSequenceAsString(sg.getStartRes(),
2336 sg.getEndRes() + 1), null,
2337 MessageManager.getString("label.edit_sequence"), null,
2338 MessageManager.getString("label.edit_sequence"),
2343 EditCommand editCommand = new EditCommand(
2344 MessageManager.getString("label.edit_sequences"),
2345 EditCommand.REPLACE, dialog.getName().replace(' ',
2346 ap.av.getGapCharacter()),
2347 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2348 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
2350 ap.alignFrame.addHistoryItem(editCommand);
2352 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()