2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
3 * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
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 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
23 import java.awt.event.*;
27 import jalview.analysis.*;
28 import jalview.commands.*;
29 import jalview.datamodel.*;
31 import jalview.schemes.*;
32 import jalview.util.GroupUrlLink;
33 import jalview.util.GroupUrlLink.UrlStringTooLongException;
34 import jalview.util.UrlLink;
40 * @version $Revision: 1.118 $
42 public class PopupMenu extends JPopupMenu
44 JMenu groupMenu = new JMenu();
46 JMenuItem groupName = new JMenuItem();
48 protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem();
50 protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
52 protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
54 protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem();
56 protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
58 protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
60 protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
62 protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
64 protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
66 protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem();
68 protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem();
70 protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();
72 protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem();
73 protected JRadioButtonMenuItem RNAInteractionColour = new JRadioButtonMenuItem();
75 // protected JRadioButtonMenuItem covariationColour = new
76 // JRadioButtonMenuItem();
78 JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();
80 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
84 JMenu sequenceMenu = new JMenu();
86 JMenuItem sequenceName = new JMenuItem();
88 JMenuItem sequenceDetails = new JMenuItem();
90 JMenuItem sequenceSelDetails = new JMenuItem();
93 JMenuItem createGroupMenuItem = new JMenuItem();
94 JMenuItem unGroupMenuItem = new JMenuItem();
96 JMenuItem outline = new JMenuItem();
98 JRadioButtonMenuItem nucleotideMenuItem = new JRadioButtonMenuItem();
100 JMenu colourMenu = new JMenu();
102 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
104 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
106 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
108 JCheckBoxMenuItem displayNonconserved = new JCheckBoxMenuItem();
110 JMenu editMenu = new JMenu();
112 JMenuItem cut = new JMenuItem();
114 JMenuItem copy = new JMenuItem();
116 JMenuItem upperCase = new JMenuItem();
118 JMenuItem lowerCase = new JMenuItem();
120 JMenuItem toggle = new JMenuItem();
122 JMenu pdbMenu = new JMenu();
124 JMenuItem pdbFromFile = new JMenuItem();
125 // JBPNote: Commented these out - Should add these services via the web services menu system.
126 // JMenuItem ContraFold = new JMenuItem();
128 // JMenuItem RNAFold = new JMenuItem();
130 JMenuItem enterPDB = new JMenuItem();
132 JMenuItem discoverPDB = new JMenuItem();
134 JMenu outputMenu = new JMenu();
136 JMenuItem sequenceFeature = new JMenuItem();
138 JMenuItem textColour = new JMenuItem();
140 JMenu jMenu1 = new JMenu();
142 JMenu structureMenu = new JMenu();
144 JMenu viewStructureMenu = new JMenu();
146 // JMenu colStructureMenu = new JMenu();
147 JMenuItem editSequence = new JMenuItem();
149 // JMenuItem annotationMenuItem = new JMenuItem();
151 JMenu groupLinksMenu;
154 * Creates a new PopupMenu object.
161 public PopupMenu(final AlignmentPanel ap, Sequence seq, Vector links)
163 this(ap, seq, links, null);
173 public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
174 Vector links, Vector groupLinks)
176 // /////////////////////////////////////////////////////////
177 // If this is activated from the sequence panel, the user may want to
178 // edit or annotate a particular residue. Therefore display the residue menu
180 // If from the IDPanel, we must display the sequence menu
181 // ////////////////////////////////////////////////////////
185 ButtonGroup colours = new ButtonGroup();
186 colours.add(noColourmenuItem);
187 colours.add(clustalColour);
188 colours.add(zappoColour);
189 colours.add(taylorColour);
190 colours.add(hydrophobicityColour);
191 colours.add(helixColour);
192 colours.add(strandColour);
193 colours.add(turnColour);
194 colours.add(buriedColour);
195 colours.add(abovePIDColour);
196 colours.add(userDefinedColour);
197 colours.add(PIDColour);
198 colours.add(BLOSUM62Colour);
199 colours.add(purinePyrimidineColour);
200 colours.add(RNAInteractionColour);
201 // colours.add(covariationColour);
203 for (int i = 0; i < jalview.io.FormatAdapter.WRITEABLE_FORMATS.length; i++)
205 JMenuItem item = new JMenuItem(
206 jalview.io.FormatAdapter.WRITEABLE_FORMATS[i]);
208 item.addActionListener(new java.awt.event.ActionListener()
210 public void actionPerformed(ActionEvent e)
212 outputText_actionPerformed(e);
216 outputMenu.add(item);
222 } catch (Exception e)
230 sequenceMenu.setText(sequence.getName());
232 if (seq.getDatasetSequence().getPDBId() != null
233 && seq.getDatasetSequence().getPDBId().size() > 0)
235 java.util.Enumeration e = seq.getDatasetSequence().getPDBId()
238 while (e.hasMoreElements())
240 final PDBEntry pdb = (PDBEntry) e.nextElement();
242 menuItem = new JMenuItem();
243 menuItem.setText(pdb.getId());
244 menuItem.addActionListener(new java.awt.event.ActionListener()
246 public void actionPerformed(ActionEvent e)
248 // TODO re JAL-860: optionally open dialog or provide a menu entry
249 // allowing user to open just one structure per sequence
250 new AppJmol(pdb, ap.av.collateForPDB(new PDBEntry[]
251 { pdb })[0], null, ap);
252 // new PDBViewer(pdb, seqs2, null, ap, AppletFormatAdapter.FILE);
256 viewStructureMenu.add(menuItem);
259 * menuItem = new JMenuItem(); menuItem.setText(pdb.getId());
260 * menuItem.addActionListener(new java.awt.event.ActionListener() {
261 * public void actionPerformed(ActionEvent e) {
262 * colourByStructure(pdb.getId()); } });
263 * colStructureMenu.add(menuItem);
269 if (ap.av.getAlignment().isNucleotide() == false)
271 structureMenu.remove(viewStructureMenu);
273 // structureMenu.remove(colStructureMenu);
276 if (ap.av.getAlignment().isNucleotide() == true)
278 AlignmentAnnotation[] aa = ap.av.getAlignment()
279 .getAlignmentAnnotation();
280 for (int i = 0; i < aa.length; i++)
282 if (aa[i].getRNAStruc() != null)
284 final String rnastruc = aa[i].getRNAStruc();
285 final String structureLine = aa[i].label;
286 menuItem = new JMenuItem();
287 menuItem.setText("2D RNA " + structureLine);
288 menuItem.addActionListener(new java.awt.event.ActionListener()
291 public void actionPerformed(ActionEvent e)
293 //System.out.println("1:"+structureLine);
294 System.out.println("1:sname"+seq.getName());
295 System.out.println("2:seq"+seq);
297 //System.out.println("3:"+seq.getSequenceAsString());
298 System.out.println("3:strucseq"+rnastruc);
299 //System.out.println("4:struc"+seq.getRNA());
300 System.out.println("5:name"+seq.getName());
301 System.out.println("6:ap"+ap);
302 new AppVarna(structureLine, seq, seq.getSequenceAsString(), rnastruc, seq
304 //new AppVarna(seq.getName(),seq,rnastruc,seq.getRNA(), seq.getName(), ap);
305 System.out.println("end");
308 viewStructureMenu.add(menuItem);
312 // SequenceFeatures[] test = seq.getSequenceFeatures();
314 if (seq.getAnnotation() != null)
316 AlignmentAnnotation seqAnno[] = seq.getAnnotation();
317 for (int i = 0; i < seqAnno.length; i++)
319 if (seqAnno[i].getRNAStruc() != null)
321 final String rnastruc = seqAnno[i].getRNAStruc();
323 // TODO: make rnastrucF a bit more nice
324 menuItem = new JMenuItem();
325 menuItem.setText("2D RNA - " + seq.getName());
326 menuItem.addActionListener(new java.awt.event.ActionListener()
328 public void actionPerformed(ActionEvent e)
330 // TODO: VARNA does'nt print gaps in the sequence
332 new AppVarna(seq.getName() + " structure", seq, seq
333 .getSequenceAsString(), rnastruc, seq.getName(),
337 viewStructureMenu.add(menuItem);
344 menuItem = new JMenuItem("Hide Sequences");
345 menuItem.addActionListener(new java.awt.event.ActionListener()
347 public void actionPerformed(ActionEvent e)
349 hideSequences(false);
354 if (ap.av.getSelectionGroup() != null
355 && ap.av.getSelectionGroup().getSize() > 1)
357 menuItem = new JMenuItem("Represent Group with " + seq.getName());
358 menuItem.addActionListener(new java.awt.event.ActionListener()
360 public void actionPerformed(ActionEvent e)
365 sequenceMenu.add(menuItem);
368 if (ap.av.hasHiddenRows())
370 final int index = ap.av.getAlignment().findIndex(seq);
372 if (ap.av.adjustForHiddenSeqs(index)
373 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
375 menuItem = new JMenuItem("Reveal Sequences");
376 menuItem.addActionListener(new ActionListener()
378 public void actionPerformed(ActionEvent e)
380 ap.av.showSequence(index);
381 if (ap.overviewPanel != null)
383 ap.overviewPanel.updateOverviewImage();
391 // for the case when no sequences are even visible
392 if (ap.av.hasHiddenRows())
395 menuItem = new JMenuItem("Reveal All");
396 menuItem.addActionListener(new ActionListener()
398 public void actionPerformed(ActionEvent e)
400 ap.av.showAllHiddenSeqs();
401 if (ap.overviewPanel != null)
403 ap.overviewPanel.updateOverviewImage();
413 SequenceGroup sg = ap.av.getSelectionGroup();
414 boolean isDefinedGroup = (sg!=null) ? ap.av.getAlignment().getGroups().contains(sg) : false;
416 if (sg != null && sg.getSize() > 0)
418 groupName.setText("Name: " + sg.getName());
419 groupName.setText("Edit name and description of current group.");
421 if (sg.cs instanceof ZappoColourScheme)
423 zappoColour.setSelected(true);
425 else if (sg.cs instanceof TaylorColourScheme)
427 taylorColour.setSelected(true);
429 else if (sg.cs instanceof PIDColourScheme)
431 PIDColour.setSelected(true);
433 else if (sg.cs instanceof Blosum62ColourScheme)
435 BLOSUM62Colour.setSelected(true);
437 else if (sg.cs instanceof UserColourScheme)
439 userDefinedColour.setSelected(true);
441 else if (sg.cs instanceof HydrophobicColourScheme)
443 hydrophobicityColour.setSelected(true);
445 else if (sg.cs instanceof HelixColourScheme)
447 helixColour.setSelected(true);
449 else if (sg.cs instanceof StrandColourScheme)
451 strandColour.setSelected(true);
453 else if (sg.cs instanceof TurnColourScheme)
455 turnColour.setSelected(true);
457 else if (sg.cs instanceof BuriedColourScheme)
459 buriedColour.setSelected(true);
461 else if (sg.cs instanceof ClustalxColourScheme)
463 clustalColour.setSelected(true);
465 else if (sg.cs instanceof PurinePyrimidineColourScheme)
467 purinePyrimidineColour.setSelected(true);
472 * else if (sg.cs instanceof CovariationColourScheme) {
473 * covariationColour.setSelected(true); }
477 noColourmenuItem.setSelected(true);
480 if (sg.cs != null && sg.cs.conservationApplied())
482 conservationMenuItem.setSelected(true);
484 displayNonconserved.setSelected(sg.getShowNonconserved());
485 showText.setSelected(sg.getDisplayText());
486 showColourText.setSelected(sg.getColourText());
487 showBoxes.setSelected(sg.getDisplayBoxes());
488 // add any groupURLs to the groupURL submenu and make it visible
489 if (groupLinks != null && groupLinks.size() > 0)
491 buildGroupURLMenu(sg, groupLinks);
493 // Add a 'show all structures' for the current selection
494 Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>();
495 SequenceI sqass = null;
496 for (SequenceI sq : ap.av.getSequenceSelection())
498 Vector<PDBEntry> pes = (Vector<PDBEntry>) sq.getDatasetSequence()
502 for (PDBEntry pe : pes)
504 pdbe.put(pe.getId(), pe);
514 final PDBEntry[] pe = pdbe.values().toArray(
515 new PDBEntry[pdbe.size()]);
516 final JMenuItem gpdbview;
517 if (pdbe.size() == 1)
519 structureMenu.add(gpdbview = new JMenuItem("View structure for "
520 + sqass.getDisplayId(false)));
524 structureMenu.add(gpdbview = new JMenuItem("View all "
525 + pdbe.size() + " structures."));
527 gpdbview.setToolTipText("Open a new Jmol view with all structures associated with the current selection and superimpose them using the alignment.");
528 gpdbview.addActionListener(new ActionListener()
532 public void actionPerformed(ActionEvent e)
534 new AppJmol(ap, pe, ap.av.collateForPDB(pe));
541 groupMenu.setVisible(false);
542 editMenu.setVisible(false);
547 createGroupMenuItem.setVisible(true);
548 unGroupMenuItem.setVisible(false);
549 jMenu1.setText("Edit New Group");
551 createGroupMenuItem.setVisible(false);
552 unGroupMenuItem.setVisible(true);
553 jMenu1.setText("Edit Group");
558 sequenceMenu.setVisible(false);
559 structureMenu.setVisible(false);
562 if (links != null && links.size() > 0)
565 JMenu linkMenu = new JMenu("Link");
566 Vector linkset = new Vector();
567 for (int i = 0; i < links.size(); i++)
569 String link = links.elementAt(i).toString();
570 UrlLink urlLink = null;
573 urlLink = new UrlLink(link);
574 } catch (Exception foo)
576 jalview.bin.Cache.log.error("Exception for URLLink '" + link
581 if (!urlLink.isValid())
583 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
586 final String label = urlLink.getLabel();
587 if (seq != null && urlLink.isDynamic())
590 // collect matching db-refs
591 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
592 seq.getDBRef(), new String[]
593 { urlLink.getTarget() });
594 // collect id string too
595 String id = seq.getName();
596 String descr = seq.getDescription();
597 if (descr != null && descr.length() < 1)
604 for (int r = 0; r < dbr.length; r++)
606 if (id != null && dbr[r].getAccessionId().equals(id))
608 // suppress duplicate link creation for the bare sequence ID
609 // string with this link
612 // create Bare ID link for this RUL
613 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
617 for (int u = 0; u < urls.length; u += 2)
619 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
621 linkset.addElement(urls[u] + "|" + urls[u + 1]);
622 addshowLink(linkMenu, label + "|" + urls[u],
631 // create Bare ID link for this RUL
632 String[] urls = urlLink.makeUrls(id, true);
635 for (int u = 0; u < urls.length; u += 2)
637 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
639 linkset.addElement(urls[u] + "|" + urls[u + 1]);
640 addshowLink(linkMenu, label, urls[u + 1]);
645 // Create urls from description but only for URL links which are regex
647 if (descr != null && urlLink.getRegexReplace() != null)
649 // create link for this URL from description where regex matches
650 String[] urls = urlLink.makeUrls(descr, true);
653 for (int u = 0; u < urls.length; u += 2)
655 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
657 linkset.addElement(urls[u] + "|" + urls[u + 1]);
658 addshowLink(linkMenu, label, urls[u + 1]);
666 if (!linkset.contains(label + "|" + urlLink.getUrl_prefix()))
668 linkset.addElement(label + "|" + urlLink.getUrl_prefix());
669 // Add a non-dynamic link
670 addshowLink(linkMenu, label, urlLink.getUrl_prefix());
674 if (sequence != null)
676 sequenceMenu.add(linkMenu);
685 private void buildGroupURLMenu(SequenceGroup sg, Vector groupLinks)
688 // TODO: usability: thread off the generation of group url content so root
690 // sequence only URLs
691 // ID/regex match URLs
692 groupLinksMenu = new JMenu("Group Link");
693 JMenu[] linkMenus = new JMenu[]
694 { null, new JMenu("IDS"), new JMenu("Sequences"),
695 new JMenu("IDS and Sequences") }; // three types of url that might be
697 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
698 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
699 Hashtable commonDbrefs = new Hashtable();
700 for (int sq = 0; sq < seqs.length; sq++)
703 int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
704 .findPosition(sg.getEndRes());
705 // just collect ids from dataset sequence
706 // TODO: check if IDs collected from selecton group intersects with the
707 // current selection, too
708 SequenceI sqi = seqs[sq];
709 while (sqi.getDatasetSequence() != null)
711 sqi = sqi.getDatasetSequence();
713 DBRefEntry[] dbr = sqi.getDBRef();
714 if (dbr != null && dbr.length > 0)
716 for (int d = 0; d < dbr.length; d++)
718 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
719 Object[] sarray = (Object[]) commonDbrefs.get(src);
722 sarray = new Object[2];
723 sarray[0] = new int[]
725 sarray[1] = new String[seqs.length];
727 commonDbrefs.put(src, sarray);
730 if (((String[]) sarray[1])[sq] == null)
733 || (dbr[d].getMap().locateMappedRange(start, end) != null))
735 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
736 ((int[]) sarray[0])[0]++;
742 // now create group links for all distinct ID/sequence sets.
743 boolean addMenu = false; // indicates if there are any group links to give
745 for (int i = 0; i < groupLinks.size(); i++)
747 String link = groupLinks.elementAt(i).toString();
748 GroupUrlLink urlLink = null;
751 urlLink = new GroupUrlLink(link);
752 } catch (Exception foo)
754 jalview.bin.Cache.log.error("Exception for GroupURLLink '" + link
759 if (!urlLink.isValid())
761 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
764 final String label = urlLink.getLabel();
765 boolean usingNames = false;
766 // Now see which parts of the group apply for this URL
767 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
768 Object[] idset = (Object[]) commonDbrefs.get(ltarget.toUpperCase());
769 String[] seqstr, ids; // input to makeUrl
772 int numinput = ((int[]) idset[0])[0];
773 String[] allids = ((String[]) idset[1]);
774 seqstr = new String[numinput];
775 ids = new String[numinput];
776 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
778 if (allids[sq] != null)
780 ids[idcount] = allids[sq];
781 seqstr[idcount++] = idandseqs[1][sq];
787 // just use the id/seq set
788 seqstr = idandseqs[1];
792 // and try and make the groupURL!
794 Object[] urlset = null;
797 urlset = urlLink.makeUrlStubs(ids, seqstr,
798 "FromJalview" + System.currentTimeMillis(), false);
799 } catch (UrlStringTooLongException e)
804 int type = urlLink.getGroupURLType() & 3;
805 // System.out.println(urlLink.getGroupURLType()
806 // +" "+((String[])urlset[3])[0]);
807 // first two bits ofurlLink type bitfield are sequenceids and sequences
808 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
809 addshowLink(linkMenus[type], label
810 + (((type & 1) == 1) ? ("("
811 + (usingNames ? "Names" : ltarget) + ")") : ""),
818 groupLinksMenu = new JMenu("Group Links");
819 for (int m = 0; m < linkMenus.length; m++)
821 if (linkMenus[m] != null
822 && linkMenus[m].getMenuComponentCount() > 0)
824 groupLinksMenu.add(linkMenus[m]);
828 groupMenu.add(groupLinksMenu);
833 * add a show URL menu item to the given linkMenu
837 * - menu label string
841 private void addshowLink(JMenu linkMenu, String label, final String url)
843 JMenuItem item = new JMenuItem(label);
844 item.setToolTipText("open URL: " + url);
845 item.addActionListener(new java.awt.event.ActionListener()
847 public void actionPerformed(ActionEvent e)
849 new Thread(new Runnable()
865 * add a late bound groupURL item to the given linkMenu
869 * - menu label string
870 * @param urlgenerator
871 * GroupURLLink used to generate URL
873 * Object array returned from the makeUrlStubs function.
875 private void addshowLink(JMenu linkMenu, String label,
876 final GroupUrlLink urlgenerator, final Object[] urlstub)
878 JMenuItem item = new JMenuItem(label);
879 item.setToolTipText("open URL (" + urlgenerator.getUrl_prefix()
880 + "..) (" + urlgenerator.getNumberInvolved(urlstub) + " seqs)"); // TODO:
889 item.addActionListener(new java.awt.event.ActionListener()
891 public void actionPerformed(ActionEvent e)
893 new Thread(new Runnable()
900 showLink(urlgenerator.constructFrom(urlstub));
901 } catch (UrlStringTooLongException e)
919 private void jbInit() throws Exception
921 groupMenu.setText("Group");
922 groupMenu.setText("Selection");
923 groupName.setText("Name");
924 groupName.addActionListener(new java.awt.event.ActionListener()
926 public void actionPerformed(ActionEvent e)
928 groupName_actionPerformed();
931 sequenceMenu.setText("Sequence");
932 sequenceName.setText("Edit Name/Description");
933 sequenceName.addActionListener(new java.awt.event.ActionListener()
935 public void actionPerformed(ActionEvent e)
937 sequenceName_actionPerformed();
940 sequenceDetails.setText("Sequence Details ...");
941 sequenceDetails.addActionListener(new java.awt.event.ActionListener()
943 public void actionPerformed(ActionEvent e)
945 sequenceDetails_actionPerformed();
948 sequenceSelDetails.setText("Sequence Details ...");
950 .addActionListener(new java.awt.event.ActionListener()
952 public void actionPerformed(ActionEvent e)
954 sequenceSelectionDetails_actionPerformed();
957 PIDColour.setFocusPainted(false);
958 unGroupMenuItem.setText("Remove Group");
959 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
961 public void actionPerformed(ActionEvent e)
963 unGroupMenuItem_actionPerformed();
966 createGroupMenuItem.setText("Create Group");
967 createGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
969 public void actionPerformed(ActionEvent e)
971 createGroupMenuItem_actionPerformed();
975 outline.setText("Border colour");
976 outline.addActionListener(new java.awt.event.ActionListener()
978 public void actionPerformed(ActionEvent e)
980 outline_actionPerformed();
983 nucleotideMenuItem.setText("Nucleotide");
984 nucleotideMenuItem.addActionListener(new ActionListener()
986 public void actionPerformed(ActionEvent e)
988 nucleotideMenuItem_actionPerformed();
991 colourMenu.setText("Group Colour");
992 showBoxes.setText("Boxes");
993 showBoxes.setState(true);
994 showBoxes.addActionListener(new ActionListener()
996 public void actionPerformed(ActionEvent e)
998 showBoxes_actionPerformed();
1001 showText.setText("Text");
1002 showText.setState(true);
1003 showText.addActionListener(new ActionListener()
1005 public void actionPerformed(ActionEvent e)
1007 showText_actionPerformed();
1010 showColourText.setText("Colour Text");
1011 showColourText.addActionListener(new ActionListener()
1013 public void actionPerformed(ActionEvent e)
1015 showColourText_actionPerformed();
1018 displayNonconserved.setText("Show Nonconserved");
1019 displayNonconserved.setState(true);
1020 displayNonconserved.addActionListener(new ActionListener()
1022 public void actionPerformed(ActionEvent e)
1024 showNonconserved_actionPerformed();
1027 editMenu.setText("Edit");
1029 cut.addActionListener(new ActionListener()
1031 public void actionPerformed(ActionEvent e)
1033 cut_actionPerformed();
1036 upperCase.setText("To Upper Case");
1037 upperCase.addActionListener(new ActionListener()
1039 public void actionPerformed(ActionEvent e)
1044 copy.setText("Copy");
1045 copy.addActionListener(new ActionListener()
1047 public void actionPerformed(ActionEvent e)
1049 copy_actionPerformed();
1052 lowerCase.setText("To Lower Case");
1053 lowerCase.addActionListener(new ActionListener()
1055 public void actionPerformed(ActionEvent e)
1060 toggle.setText("Toggle Case");
1061 toggle.addActionListener(new ActionListener()
1063 public void actionPerformed(ActionEvent e)
1068 pdbMenu.setText("Associate Structure with Sequence");
1069 pdbFromFile.setText("From File");
1070 pdbFromFile.addActionListener(new ActionListener()
1072 public void actionPerformed(ActionEvent e)
1074 pdbFromFile_actionPerformed();
1077 // RNAFold.setText("From RNA Fold with predict2D");
1078 // RNAFold.addActionListener(new ActionListener()
1080 // public void actionPerformed(ActionEvent e)
1083 // RNAFold_actionPerformed();
1084 // } catch (Exception e1) {
1085 // // TODO Auto-generated catch block
1086 // e1.printStackTrace();
1090 // ContraFold.setText("From Contra Fold with predict2D");
1091 // ContraFold.addActionListener(new ActionListener()
1093 // public void actionPerformed(ActionEvent e)
1096 // ContraFold_actionPerformed();
1097 // } catch (Exception e1) {
1098 // // TODO Auto-generated catch block
1099 // e1.printStackTrace();
1103 enterPDB.setText("Enter PDB Id");
1104 enterPDB.addActionListener(new ActionListener()
1106 public void actionPerformed(ActionEvent e)
1108 enterPDB_actionPerformed();
1111 discoverPDB.setText("Discover PDB ids");
1112 discoverPDB.addActionListener(new ActionListener()
1114 public void actionPerformed(ActionEvent e)
1116 discoverPDB_actionPerformed();
1119 outputMenu.setText("Output to Textbox...");
1120 sequenceFeature.setText("Create Sequence Feature");
1121 sequenceFeature.addActionListener(new ActionListener()
1123 public void actionPerformed(ActionEvent e)
1125 sequenceFeature_actionPerformed();
1128 textColour.setText("Text Colour");
1129 textColour.addActionListener(new ActionListener()
1131 public void actionPerformed(ActionEvent e)
1133 textColour_actionPerformed();
1136 jMenu1.setText("Group");
1137 structureMenu.setText("Structure");
1138 viewStructureMenu.setText("View Structure");
1139 // colStructureMenu.setText("Colour By Structure");
1140 editSequence.setText("Edit Sequence...");
1141 editSequence.addActionListener(new ActionListener()
1143 public void actionPerformed(ActionEvent actionEvent)
1145 editSequence_actionPerformed(actionEvent);
1150 * annotationMenuItem.setText("By Annotation");
1151 * annotationMenuItem.addActionListener(new ActionListener() { public void
1152 * actionPerformed(ActionEvent actionEvent) {
1153 * annotationMenuItem_actionPerformed(actionEvent); } });
1155 groupMenu.add(sequenceSelDetails);
1158 this.add(structureMenu);
1159 groupMenu.add(editMenu);
1160 groupMenu.add(outputMenu);
1161 groupMenu.add(sequenceFeature);
1162 groupMenu.add(createGroupMenuItem);
1163 groupMenu.add(unGroupMenuItem);
1164 groupMenu.add(jMenu1);
1165 sequenceMenu.add(sequenceName);
1166 sequenceMenu.add(sequenceDetails);
1167 colourMenu.add(textColour);
1168 colourMenu.add(noColourmenuItem);
1169 colourMenu.add(clustalColour);
1170 colourMenu.add(BLOSUM62Colour);
1171 colourMenu.add(PIDColour);
1172 colourMenu.add(zappoColour);
1173 colourMenu.add(taylorColour);
1174 colourMenu.add(hydrophobicityColour);
1175 colourMenu.add(helixColour);
1176 colourMenu.add(strandColour);
1177 colourMenu.add(turnColour);
1178 colourMenu.add(buriedColour);
1179 colourMenu.add(nucleotideMenuItem);
1180 if (ap.getAlignment().isNucleotide()) {
1181 // JBPNote - commented since the colourscheme isn't functional
1182 // colourMenu.add(RNAInteractionColour);
1183 colourMenu.add(purinePyrimidineColour);
1185 // colourMenu.add(covariationColour);
1186 colourMenu.add(userDefinedColour);
1188 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
1190 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
1191 .getUserColourSchemes().keys();
1193 while (userColours.hasMoreElements())
1195 JMenuItem item = new JMenuItem(userColours.nextElement().toString());
1196 item.addActionListener(new ActionListener()
1198 public void actionPerformed(ActionEvent evt)
1200 userDefinedColour_actionPerformed(evt);
1203 colourMenu.add(item);
1207 colourMenu.addSeparator();
1208 colourMenu.add(abovePIDColour);
1209 colourMenu.add(conservationMenuItem);
1210 // colourMenu.add(annotationMenuItem);
1213 editMenu.add(editSequence);
1214 editMenu.add(upperCase);
1215 editMenu.add(lowerCase);
1216 editMenu.add(toggle);
1217 pdbMenu.add(pdbFromFile);
1218 // JBPNote: These shouldn't be added here - should appear in a generic 'apply web service to this sequence menu'
1219 // pdbMenu.add(RNAFold);
1220 // pdbMenu.add(ContraFold);
1221 pdbMenu.add(enterPDB);
1222 pdbMenu.add(discoverPDB);
1223 jMenu1.add(groupName);
1224 jMenu1.add(colourMenu);
1225 jMenu1.add(showBoxes);
1226 jMenu1.add(showText);
1227 jMenu1.add(showColourText);
1228 jMenu1.add(outline);
1229 jMenu1.add(displayNonconserved);
1230 structureMenu.add(pdbMenu);
1231 structureMenu.add(viewStructureMenu);
1232 // structureMenu.add(colStructureMenu);
1233 noColourmenuItem.setText("None");
1234 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
1236 public void actionPerformed(ActionEvent e)
1238 noColourmenuItem_actionPerformed();
1242 clustalColour.setText("Clustalx colours");
1243 clustalColour.addActionListener(new java.awt.event.ActionListener()
1245 public void actionPerformed(ActionEvent e)
1247 clustalColour_actionPerformed();
1250 zappoColour.setText("Zappo");
1251 zappoColour.addActionListener(new java.awt.event.ActionListener()
1253 public void actionPerformed(ActionEvent e)
1255 zappoColour_actionPerformed();
1258 taylorColour.setText("Taylor");
1259 taylorColour.addActionListener(new java.awt.event.ActionListener()
1261 public void actionPerformed(ActionEvent e)
1263 taylorColour_actionPerformed();
1266 hydrophobicityColour.setText("Hydrophobicity");
1267 hydrophobicityColour
1268 .addActionListener(new java.awt.event.ActionListener()
1270 public void actionPerformed(ActionEvent e)
1272 hydrophobicityColour_actionPerformed();
1275 helixColour.setText("Helix propensity");
1276 helixColour.addActionListener(new java.awt.event.ActionListener()
1278 public void actionPerformed(ActionEvent e)
1280 helixColour_actionPerformed();
1283 strandColour.setText("Strand propensity");
1284 strandColour.addActionListener(new java.awt.event.ActionListener()
1286 public void actionPerformed(ActionEvent e)
1288 strandColour_actionPerformed();
1291 turnColour.setText("Turn propensity");
1292 turnColour.addActionListener(new java.awt.event.ActionListener()
1294 public void actionPerformed(ActionEvent e)
1296 turnColour_actionPerformed();
1299 buriedColour.setText("Buried Index");
1300 buriedColour.addActionListener(new java.awt.event.ActionListener()
1302 public void actionPerformed(ActionEvent e)
1304 buriedColour_actionPerformed();
1307 abovePIDColour.setText("Above % Identity");
1308 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
1310 public void actionPerformed(ActionEvent e)
1312 abovePIDColour_actionPerformed();
1315 userDefinedColour.setText("User Defined...");
1316 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
1318 public void actionPerformed(ActionEvent e)
1320 userDefinedColour_actionPerformed(e);
1323 PIDColour.setText("Percentage Identity");
1324 PIDColour.addActionListener(new java.awt.event.ActionListener()
1326 public void actionPerformed(ActionEvent e)
1328 PIDColour_actionPerformed();
1331 BLOSUM62Colour.setText("BLOSUM62");
1332 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
1334 public void actionPerformed(ActionEvent e)
1336 BLOSUM62Colour_actionPerformed();
1339 purinePyrimidineColour.setText("Purine/Pyrimidine");
1340 purinePyrimidineColour
1341 .addActionListener(new java.awt.event.ActionListener()
1343 public void actionPerformed(ActionEvent e)
1345 purinePyrimidineColour_actionPerformed();
1351 * covariationColour.addActionListener(new java.awt.event.ActionListener() {
1352 * public void actionPerformed(ActionEvent e) {
1353 * covariationColour_actionPerformed(); } });
1356 conservationMenuItem.setText("Conservation");
1357 conservationMenuItem
1358 .addActionListener(new java.awt.event.ActionListener()
1360 public void actionPerformed(ActionEvent e)
1362 conservationMenuItem_actionPerformed();
1367 protected void sequenceSelectionDetails_actionPerformed()
1369 createSequenceDetailsReport(ap.av.getSequenceSelection());
1372 protected void sequenceDetails_actionPerformed()
1374 createSequenceDetailsReport(new SequenceI[]
1378 public void createSequenceDetailsReport(SequenceI[] sequences)
1380 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1381 StringBuffer contents = new StringBuffer();
1382 for (SequenceI seq : sequences)
1384 contents.append("<p><h2>Annotation for " + seq.getDisplayId(true)
1386 new SequenceAnnotationReport(null)
1387 .createSequenceAnnotationReport(
1393 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
1395 contents.append("</p>");
1397 cap.setText("<html>" + contents.toString() + "</html>");
1399 Desktop.instance.addInternalFrame(cap, "Sequence Details for "
1400 + (sequences.length == 1 ? sequences[0].getDisplayId(true)
1401 : "Selection"), 500, 400);
1405 protected void showNonconserved_actionPerformed()
1407 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1412 * call to refresh view after settings change
1416 ap.updateAnnotation();
1417 ap.paintAlignment(true);
1419 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1428 protected void clustalColour_actionPerformed()
1430 SequenceGroup sg = getGroup();
1431 sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
1441 protected void zappoColour_actionPerformed()
1443 getGroup().cs = new ZappoColourScheme();
1453 protected void taylorColour_actionPerformed()
1455 getGroup().cs = new TaylorColourScheme();
1465 protected void hydrophobicityColour_actionPerformed()
1467 getGroup().cs = new HydrophobicColourScheme();
1477 protected void helixColour_actionPerformed()
1479 getGroup().cs = new HelixColourScheme();
1489 protected void strandColour_actionPerformed()
1491 getGroup().cs = new StrandColourScheme();
1501 protected void turnColour_actionPerformed()
1503 getGroup().cs = new TurnColourScheme();
1513 protected void buriedColour_actionPerformed()
1515 getGroup().cs = new BuriedColourScheme();
1525 public void nucleotideMenuItem_actionPerformed()
1527 getGroup().cs = new NucleotideColourScheme();
1531 protected void purinePyrimidineColour_actionPerformed()
1533 getGroup().cs = new PurinePyrimidineColourScheme();
1539 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1540 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1548 protected void abovePIDColour_actionPerformed()
1550 SequenceGroup sg = getGroup();
1556 if (abovePIDColour.isSelected())
1558 sg.cs.setConsensus(AAFrequency.calculate(
1559 sg.getSequences(ap.av.getHiddenRepSequences()),
1560 sg.getStartRes(), sg.getEndRes() + 1));
1562 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1565 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
1567 SliderPanel.showPIDSlider();
1570 // remove PIDColouring
1572 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
1584 protected void userDefinedColour_actionPerformed(ActionEvent e)
1586 SequenceGroup sg = getGroup();
1588 if (e.getActionCommand().equals("User Defined..."))
1590 new UserDefinedColours(ap, sg);
1594 UserColourScheme udc = (UserColourScheme) UserDefinedColours
1595 .getUserColourSchemes().get(e.getActionCommand());
1608 protected void PIDColour_actionPerformed()
1610 SequenceGroup sg = getGroup();
1611 sg.cs = new PIDColourScheme();
1612 sg.cs.setConsensus(AAFrequency.calculate(
1613 sg.getSequences(ap.av.getHiddenRepSequences()),
1614 sg.getStartRes(), sg.getEndRes() + 1));
1624 protected void BLOSUM62Colour_actionPerformed()
1626 SequenceGroup sg = getGroup();
1628 sg.cs = new Blosum62ColourScheme();
1630 sg.cs.setConsensus(AAFrequency.calculate(
1631 sg.getSequences(ap.av.getHiddenRepSequences()),
1632 sg.getStartRes(), sg.getEndRes() + 1));
1643 protected void noColourmenuItem_actionPerformed()
1645 getGroup().cs = null;
1655 protected void conservationMenuItem_actionPerformed()
1657 SequenceGroup sg = getGroup();
1663 if (conservationMenuItem.isSelected())
1665 Conservation c = new Conservation("Group",
1666 ResidueProperties.propHash, 3, sg.getSequences(ap.av
1667 .getHiddenRepSequences()), sg.getStartRes(),
1668 sg.getEndRes() + 1);
1671 c.verdict(false, ap.av.getConsPercGaps());
1673 sg.cs.setConservation(c);
1675 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1676 SliderPanel.showConservationSlider();
1679 // remove ConservationColouring
1681 sg.cs.setConservation(null);
1687 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1689 SequenceGroup sg = getGroup();
1695 AnnotationColourGradient acg = new AnnotationColourGradient(
1696 sequence.getAnnotation()[0], null,
1697 AnnotationColourGradient.NO_THRESHOLD);
1699 acg.setPredefinedColours(true);
1711 protected void groupName_actionPerformed()
1714 SequenceGroup sg = getGroup();
1715 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1716 sg.getDescription(), " Group Name ",
1717 "Group Description ", "Edit Group Name/Description",
1725 sg.setName(dialog.getName());
1726 sg.setDescription(dialog.getDescription());
1731 * Get selection group - adding it to the alignment if necessary.
1733 * @return sequence group to operate on
1735 SequenceGroup getGroup()
1737 SequenceGroup sg = ap.av.getSelectionGroup();
1738 // this method won't add a new group if it already exists
1741 ap.av.getAlignment().addGroup(sg);
1753 void sequenceName_actionPerformed()
1755 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1756 sequence.getDescription(), " Sequence Name ",
1757 "Sequence Description ", "Edit Sequence Name/Description",
1765 if (dialog.getName() != null)
1767 if (dialog.getName().indexOf(" ") > -1)
1769 JOptionPane.showMessageDialog(ap,
1770 "Spaces have been converted to \"_\"",
1771 "No spaces allowed in Sequence Name",
1772 JOptionPane.WARNING_MESSAGE);
1775 sequence.setName(dialog.getName().replace(' ', '_'));
1776 ap.paintAlignment(false);
1779 sequence.setDescription(dialog.getDescription());
1781 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1792 void unGroupMenuItem_actionPerformed()
1794 SequenceGroup sg = ap.av.getSelectionGroup();
1795 ap.av.getAlignment().deleteGroup(sg);
1796 ap.av.setSelectionGroup(null);
1799 void createGroupMenuItem_actionPerformed()
1801 getGroup(); // implicitly creates group - note - should apply defaults / use standard alignment window logic for this
1811 protected void outline_actionPerformed()
1813 SequenceGroup sg = getGroup();
1814 Color col = JColorChooser.showDialog(this, "Select Outline Colour",
1819 sg.setOutlineColour(col);
1831 public void showBoxes_actionPerformed()
1833 getGroup().setDisplayBoxes(showBoxes.isSelected());
1843 public void showText_actionPerformed()
1845 getGroup().setDisplayText(showText.isSelected());
1855 public void showColourText_actionPerformed()
1857 getGroup().setColourText(showColourText.isSelected());
1861 public void showLink(String url)
1865 jalview.util.BrowserLauncher.openURL(url);
1866 } catch (Exception ex)
1869 .showInternalMessageDialog(
1871 "Unixers: Couldn't find default web browser."
1872 + "\nAdd the full path to your browser in Preferences.",
1873 "Web browser not found", JOptionPane.WARNING_MESSAGE);
1875 ex.printStackTrace();
1879 void hideSequences(boolean representGroup)
1881 SequenceGroup sg = ap.av.getSelectionGroup();
1882 if (sg == null || sg.getSize() < 1)
1884 ap.av.hideSequence(new SequenceI[]
1889 ap.av.setSelectionGroup(null);
1893 ap.av.hideRepSequences(sequence, sg);
1898 int gsize = sg.getSize();
1901 hseqs = new SequenceI[gsize];
1904 for (int i = 0; i < gsize; i++)
1906 hseqs[index++] = sg.getSequenceAt(i);
1909 ap.av.hideSequence(hseqs);
1910 // refresh(); TODO: ? needed ?
1911 ap.av.sendSelection();
1914 public void copy_actionPerformed()
1916 ap.alignFrame.copy_actionPerformed(null);
1919 public void cut_actionPerformed()
1921 ap.alignFrame.cut_actionPerformed(null);
1924 void changeCase(ActionEvent e)
1926 Object source = e.getSource();
1927 SequenceGroup sg = ap.av.getSelectionGroup();
1931 int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
1932 sg.getEndRes() + 1);
1937 if (source == toggle)
1939 description = "Toggle Case";
1940 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1942 else if (source == upperCase)
1944 description = "To Upper Case";
1945 caseChange = ChangeCaseCommand.TO_UPPER;
1949 description = "To Lower Case";
1950 caseChange = ChangeCaseCommand.TO_LOWER;
1953 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1954 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1955 startEnd, caseChange);
1957 ap.alignFrame.addHistoryItem(caseCommand);
1959 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1965 public void outputText_actionPerformed(ActionEvent e)
1967 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1968 cap.setForInput(null);
1969 Desktop.addInternalFrame(cap,
1970 "Alignment output - " + e.getActionCommand(), 600, 500);
1972 String[] omitHidden = null;
1974 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1975 // or we simply trust the user wants
1976 // wysiwig behaviour
1977 SequenceGroup sg = ap.av.getSelectionGroup();
1978 ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection());
1979 omitHidden = ap.av.getViewAsString(true);
1980 Alignment oal = new Alignment(ap.av.getSequenceSelection());
1981 AlignmentAnnotation[] nala = ap.av.getAlignment()
1982 .getAlignmentAnnotation();
1985 for (int i = 0; i < nala.length; i++)
1987 AlignmentAnnotation na = nala[i];
1988 oal.addAnnotation(na);
1991 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
1992 oal, omitHidden, csel, sg));
1996 public void pdbFromFile_actionPerformed()
1998 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
1999 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
2000 chooser.setFileView(new jalview.io.JalviewFileView());
2001 chooser.setDialogTitle("Select a PDB file for "
2002 + sequence.getDisplayId(false));
2003 chooser.setToolTipText("Load a PDB file and associate it with sequence '"
2004 + sequence.getDisplayId(false) + "'");
2006 int value = chooser.showOpenDialog(null);
2008 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
2010 String choice = chooser.getSelectedFile().getPath();
2011 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
2012 new AssociatePdbFileWithSeq().associatePdbWithSeq(choice,
2013 jalview.io.AppletFormatAdapter.FILE, sequence, true);
2017 // JBNote: commented out - these won't be instantiated here...!
2018 // public void RNAFold_actionPerformed() throws Exception
2020 // Predict2D P2D = new Predict2D();
2021 // P2D.getStructure2DFromRNAFold("toto");
2024 // public void ContraFold_actionPerformed() throws Exception
2026 // Predict2D P2D = new Predict2D();
2027 // P2D.getStructure2DFromContraFold("toto");
2029 public void enterPDB_actionPerformed()
2031 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
2032 "Enter PDB Id", "Enter PDB Id", JOptionPane.QUESTION_MESSAGE);
2034 if (id != null && id.length() > 0)
2036 PDBEntry entry = new PDBEntry();
2037 entry.setId(id.toUpperCase());
2038 sequence.getDatasetSequence().addPDBId(entry);
2042 public void discoverPDB_actionPerformed()
2045 final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
2047 : ap.av.getSequenceSelection());
2048 Thread discpdb = new Thread(new Runnable()
2053 new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
2054 .fetchDBRefs(false);
2061 public void sequenceFeature_actionPerformed()
2063 SequenceGroup sg = ap.av.getSelectionGroup();
2069 int rsize = 0, gSize = sg.getSize();
2070 SequenceI[] rseqs, seqs = new SequenceI[gSize];
2071 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
2073 for (int i = 0; i < gSize; i++)
2075 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
2076 int end = sg.findEndRes(sg.getSequenceAt(i));
2079 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
2080 features[rsize] = new SequenceFeature(null, null, null, start, end,
2085 rseqs = new SequenceI[rsize];
2086 tfeatures = new SequenceFeature[rsize];
2087 System.arraycopy(seqs, 0, rseqs, 0, rsize);
2088 System.arraycopy(features, 0, tfeatures, 0, rsize);
2089 features = tfeatures;
2091 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
2092 features, true, ap))
2094 ap.alignFrame.setShowSeqFeatures(true);
2095 ap.highlightSearchResults(null);
2099 public void textColour_actionPerformed()
2101 SequenceGroup sg = getGroup();
2104 new TextColourChooser().chooseColour(ap, sg);
2108 public void colourByStructure(String pdbid)
2110 Annotation[] anots = ap.av.getStructureSelectionManager()
2111 .colourSequenceFromStructure(sequence, pdbid);
2113 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
2114 "Coloured by " + pdbid, anots);
2116 ap.av.getAlignment().addAnnotation(an);
2117 an.createSequenceMapping(sequence, 0, true);
2118 // an.adjustForAlignment();
2119 ap.av.getAlignment().setAnnotationIndex(an, 0);
2121 ap.adjustAnnotationHeight();
2123 sequence.addAlignmentAnnotation(an);
2127 public void editSequence_actionPerformed(ActionEvent actionEvent)
2129 SequenceGroup sg = ap.av.getSelectionGroup();
2133 if (sequence == null)
2134 sequence = (Sequence) sg.getSequenceAt(0);
2136 EditNameDialog dialog = new EditNameDialog(
2137 sequence.getSequenceAsString(sg.getStartRes(),
2138 sg.getEndRes() + 1), null, "Edit Sequence ", null,
2139 "Edit Sequence", ap.alignFrame);
2143 EditCommand editCommand = new EditCommand("Edit Sequences",
2144 EditCommand.REPLACE, dialog.getName().replace(' ',
2145 ap.av.getGapCharacter()),
2146 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2147 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
2149 ap.alignFrame.addHistoryItem(editCommand);
2151 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()