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();
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();
415 if (sg != null && sg.getSize() > 0)
417 groupName.setText("Name: " + sg.getName());
418 groupName.setText("Edit name and description of current group.");
420 if (sg.cs instanceof ZappoColourScheme)
422 zappoColour.setSelected(true);
424 else if (sg.cs instanceof TaylorColourScheme)
426 taylorColour.setSelected(true);
428 else if (sg.cs instanceof PIDColourScheme)
430 PIDColour.setSelected(true);
432 else if (sg.cs instanceof Blosum62ColourScheme)
434 BLOSUM62Colour.setSelected(true);
436 else if (sg.cs instanceof UserColourScheme)
438 userDefinedColour.setSelected(true);
440 else if (sg.cs instanceof HydrophobicColourScheme)
442 hydrophobicityColour.setSelected(true);
444 else if (sg.cs instanceof HelixColourScheme)
446 helixColour.setSelected(true);
448 else if (sg.cs instanceof StrandColourScheme)
450 strandColour.setSelected(true);
452 else if (sg.cs instanceof TurnColourScheme)
454 turnColour.setSelected(true);
456 else if (sg.cs instanceof BuriedColourScheme)
458 buriedColour.setSelected(true);
460 else if (sg.cs instanceof ClustalxColourScheme)
462 clustalColour.setSelected(true);
464 else if (sg.cs instanceof PurinePyrimidineColourScheme)
466 purinePyrimidineColour.setSelected(true);
471 * else if (sg.cs instanceof CovariationColourScheme) {
472 * covariationColour.setSelected(true); }
476 noColourmenuItem.setSelected(true);
479 if (sg.cs != null && sg.cs.conservationApplied())
481 conservationMenuItem.setSelected(true);
483 displayNonconserved.setSelected(sg.getShowNonconserved());
484 showText.setSelected(sg.getDisplayText());
485 showColourText.setSelected(sg.getColourText());
486 showBoxes.setSelected(sg.getDisplayBoxes());
487 // add any groupURLs to the groupURL submenu and make it visible
488 if (groupLinks != null && groupLinks.size() > 0)
490 buildGroupURLMenu(sg, groupLinks);
492 // Add a 'show all structures' for the current selection
493 Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>();
494 SequenceI sqass = null;
495 for (SequenceI sq : ap.av.getSequenceSelection())
497 Vector<PDBEntry> pes = (Vector<PDBEntry>) sq.getDatasetSequence()
501 for (PDBEntry pe : pes)
503 pdbe.put(pe.getId(), pe);
513 final PDBEntry[] pe = pdbe.values().toArray(
514 new PDBEntry[pdbe.size()]);
515 final JMenuItem gpdbview;
516 if (pdbe.size() == 1)
518 structureMenu.add(gpdbview = new JMenuItem("View structure for "
519 + sqass.getDisplayId(false)));
523 structureMenu.add(gpdbview = new JMenuItem("View all "
524 + pdbe.size() + " structures."));
526 gpdbview.setToolTipText("Open a new Jmol view with all structures associated with the current selection and superimpose them using the alignment.");
527 gpdbview.addActionListener(new ActionListener()
531 public void actionPerformed(ActionEvent e)
533 new AppJmol(ap, pe, ap.av.collateForPDB(pe));
540 groupMenu.setVisible(false);
541 editMenu.setVisible(false);
544 if (!ap.av.getAlignment().getGroups().contains(sg))
546 unGroupMenuItem.setVisible(false);
551 sequenceMenu.setVisible(false);
552 structureMenu.setVisible(false);
555 if (links != null && links.size() > 0)
558 JMenu linkMenu = new JMenu("Link");
559 Vector linkset = new Vector();
560 for (int i = 0; i < links.size(); i++)
562 String link = links.elementAt(i).toString();
563 UrlLink urlLink = null;
566 urlLink = new UrlLink(link);
567 } catch (Exception foo)
569 jalview.bin.Cache.log.error("Exception for URLLink '" + link
574 if (!urlLink.isValid())
576 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
579 final String label = urlLink.getLabel();
580 if (seq != null && urlLink.isDynamic())
583 // collect matching db-refs
584 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
585 seq.getDBRef(), new String[]
586 { urlLink.getTarget() });
587 // collect id string too
588 String id = seq.getName();
589 String descr = seq.getDescription();
590 if (descr != null && descr.length() < 1)
597 for (int r = 0; r < dbr.length; r++)
599 if (id != null && dbr[r].getAccessionId().equals(id))
601 // suppress duplicate link creation for the bare sequence ID
602 // string with this link
605 // create Bare ID link for this RUL
606 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
610 for (int u = 0; u < urls.length; u += 2)
612 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
614 linkset.addElement(urls[u] + "|" + urls[u + 1]);
615 addshowLink(linkMenu, label + "|" + urls[u],
624 // create Bare ID link for this RUL
625 String[] urls = urlLink.makeUrls(id, true);
628 for (int u = 0; u < urls.length; u += 2)
630 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
632 linkset.addElement(urls[u] + "|" + urls[u + 1]);
633 addshowLink(linkMenu, label, urls[u + 1]);
638 // Create urls from description but only for URL links which are regex
640 if (descr != null && urlLink.getRegexReplace() != null)
642 // create link for this URL from description where regex matches
643 String[] urls = urlLink.makeUrls(descr, true);
646 for (int u = 0; u < urls.length; u += 2)
648 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
650 linkset.addElement(urls[u] + "|" + urls[u + 1]);
651 addshowLink(linkMenu, label, urls[u + 1]);
659 if (!linkset.contains(label + "|" + urlLink.getUrl_prefix()))
661 linkset.addElement(label + "|" + urlLink.getUrl_prefix());
662 // Add a non-dynamic link
663 addshowLink(linkMenu, label, urlLink.getUrl_prefix());
667 if (sequence != null)
669 sequenceMenu.add(linkMenu);
678 private void buildGroupURLMenu(SequenceGroup sg, Vector groupLinks)
681 // TODO: usability: thread off the generation of group url content so root
683 // sequence only URLs
684 // ID/regex match URLs
685 groupLinksMenu = new JMenu("Group Link");
686 JMenu[] linkMenus = new JMenu[]
687 { null, new JMenu("IDS"), new JMenu("Sequences"),
688 new JMenu("IDS and Sequences") }; // three types of url that might be
690 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
691 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
692 Hashtable commonDbrefs = new Hashtable();
693 for (int sq = 0; sq < seqs.length; sq++)
696 int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
697 .findPosition(sg.getEndRes());
698 // just collect ids from dataset sequence
699 // TODO: check if IDs collected from selecton group intersects with the
700 // current selection, too
701 SequenceI sqi = seqs[sq];
702 while (sqi.getDatasetSequence() != null)
704 sqi = sqi.getDatasetSequence();
706 DBRefEntry[] dbr = sqi.getDBRef();
707 if (dbr != null && dbr.length > 0)
709 for (int d = 0; d < dbr.length; d++)
711 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
712 Object[] sarray = (Object[]) commonDbrefs.get(src);
715 sarray = new Object[2];
716 sarray[0] = new int[]
718 sarray[1] = new String[seqs.length];
720 commonDbrefs.put(src, sarray);
723 if (((String[]) sarray[1])[sq] == null)
726 || (dbr[d].getMap().locateMappedRange(start, end) != null))
728 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
729 ((int[]) sarray[0])[0]++;
735 // now create group links for all distinct ID/sequence sets.
736 boolean addMenu = false; // indicates if there are any group links to give
738 for (int i = 0; i < groupLinks.size(); i++)
740 String link = groupLinks.elementAt(i).toString();
741 GroupUrlLink urlLink = null;
744 urlLink = new GroupUrlLink(link);
745 } catch (Exception foo)
747 jalview.bin.Cache.log.error("Exception for GroupURLLink '" + link
752 if (!urlLink.isValid())
754 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
757 final String label = urlLink.getLabel();
758 boolean usingNames = false;
759 // Now see which parts of the group apply for this URL
760 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
761 Object[] idset = (Object[]) commonDbrefs.get(ltarget.toUpperCase());
762 String[] seqstr, ids; // input to makeUrl
765 int numinput = ((int[]) idset[0])[0];
766 String[] allids = ((String[]) idset[1]);
767 seqstr = new String[numinput];
768 ids = new String[numinput];
769 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
771 if (allids[sq] != null)
773 ids[idcount] = allids[sq];
774 seqstr[idcount++] = idandseqs[1][sq];
780 // just use the id/seq set
781 seqstr = idandseqs[1];
785 // and try and make the groupURL!
787 Object[] urlset = null;
790 urlset = urlLink.makeUrlStubs(ids, seqstr,
791 "FromJalview" + System.currentTimeMillis(), false);
792 } catch (UrlStringTooLongException e)
797 int type = urlLink.getGroupURLType() & 3;
798 // System.out.println(urlLink.getGroupURLType()
799 // +" "+((String[])urlset[3])[0]);
800 // first two bits ofurlLink type bitfield are sequenceids and sequences
801 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
802 addshowLink(linkMenus[type], label
803 + (((type & 1) == 1) ? ("("
804 + (usingNames ? "Names" : ltarget) + ")") : ""),
811 groupLinksMenu = new JMenu("Group Links");
812 for (int m = 0; m < linkMenus.length; m++)
814 if (linkMenus[m] != null
815 && linkMenus[m].getMenuComponentCount() > 0)
817 groupLinksMenu.add(linkMenus[m]);
821 groupMenu.add(groupLinksMenu);
826 * add a show URL menu item to the given linkMenu
830 * - menu label string
834 private void addshowLink(JMenu linkMenu, String label, final String url)
836 JMenuItem item = new JMenuItem(label);
837 item.setToolTipText("open URL: " + url);
838 item.addActionListener(new java.awt.event.ActionListener()
840 public void actionPerformed(ActionEvent e)
842 new Thread(new Runnable()
858 * add a late bound groupURL item to the given linkMenu
862 * - menu label string
863 * @param urlgenerator
864 * GroupURLLink used to generate URL
866 * Object array returned from the makeUrlStubs function.
868 private void addshowLink(JMenu linkMenu, String label,
869 final GroupUrlLink urlgenerator, final Object[] urlstub)
871 JMenuItem item = new JMenuItem(label);
872 item.setToolTipText("open URL (" + urlgenerator.getUrl_prefix()
873 + "..) (" + urlgenerator.getNumberInvolved(urlstub) + " seqs)"); // TODO:
882 item.addActionListener(new java.awt.event.ActionListener()
884 public void actionPerformed(ActionEvent e)
886 new Thread(new Runnable()
893 showLink(urlgenerator.constructFrom(urlstub));
894 } catch (UrlStringTooLongException e)
912 private void jbInit() throws Exception
914 groupMenu.setText("Group");
915 groupMenu.setText("Selection");
916 groupName.setText("Name");
917 groupName.addActionListener(new java.awt.event.ActionListener()
919 public void actionPerformed(ActionEvent e)
921 groupName_actionPerformed();
924 sequenceMenu.setText("Sequence");
925 sequenceName.setText("Edit Name/Description");
926 sequenceName.addActionListener(new java.awt.event.ActionListener()
928 public void actionPerformed(ActionEvent e)
930 sequenceName_actionPerformed();
933 sequenceDetails.setText("Sequence Details ...");
934 sequenceDetails.addActionListener(new java.awt.event.ActionListener()
936 public void actionPerformed(ActionEvent e)
938 sequenceDetails_actionPerformed();
941 sequenceSelDetails.setText("Sequence Details ...");
943 .addActionListener(new java.awt.event.ActionListener()
945 public void actionPerformed(ActionEvent e)
947 sequenceSelectionDetails_actionPerformed();
950 PIDColour.setFocusPainted(false);
951 unGroupMenuItem.setText("Remove Group");
952 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
954 public void actionPerformed(ActionEvent e)
956 unGroupMenuItem_actionPerformed();
960 outline.setText("Border colour");
961 outline.addActionListener(new java.awt.event.ActionListener()
963 public void actionPerformed(ActionEvent e)
965 outline_actionPerformed();
968 nucleotideMenuItem.setText("Nucleotide");
969 nucleotideMenuItem.addActionListener(new ActionListener()
971 public void actionPerformed(ActionEvent e)
973 nucleotideMenuItem_actionPerformed();
976 colourMenu.setText("Group Colour");
977 showBoxes.setText("Boxes");
978 showBoxes.setState(true);
979 showBoxes.addActionListener(new ActionListener()
981 public void actionPerformed(ActionEvent e)
983 showBoxes_actionPerformed();
986 showText.setText("Text");
987 showText.setState(true);
988 showText.addActionListener(new ActionListener()
990 public void actionPerformed(ActionEvent e)
992 showText_actionPerformed();
995 showColourText.setText("Colour Text");
996 showColourText.addActionListener(new ActionListener()
998 public void actionPerformed(ActionEvent e)
1000 showColourText_actionPerformed();
1003 displayNonconserved.setText("Show Nonconserved");
1004 displayNonconserved.setState(true);
1005 displayNonconserved.addActionListener(new ActionListener()
1007 public void actionPerformed(ActionEvent e)
1009 showNonconserved_actionPerformed();
1012 editMenu.setText("Edit");
1014 cut.addActionListener(new ActionListener()
1016 public void actionPerformed(ActionEvent e)
1018 cut_actionPerformed();
1021 upperCase.setText("To Upper Case");
1022 upperCase.addActionListener(new ActionListener()
1024 public void actionPerformed(ActionEvent e)
1029 copy.setText("Copy");
1030 copy.addActionListener(new ActionListener()
1032 public void actionPerformed(ActionEvent e)
1034 copy_actionPerformed();
1037 lowerCase.setText("To Lower Case");
1038 lowerCase.addActionListener(new ActionListener()
1040 public void actionPerformed(ActionEvent e)
1045 toggle.setText("Toggle Case");
1046 toggle.addActionListener(new ActionListener()
1048 public void actionPerformed(ActionEvent e)
1053 pdbMenu.setText("Associate Structure with Sequence");
1054 pdbFromFile.setText("From File");
1055 pdbFromFile.addActionListener(new ActionListener()
1057 public void actionPerformed(ActionEvent e)
1059 pdbFromFile_actionPerformed();
1062 // RNAFold.setText("From RNA Fold with predict2D");
1063 // RNAFold.addActionListener(new ActionListener()
1065 // public void actionPerformed(ActionEvent e)
1068 // RNAFold_actionPerformed();
1069 // } catch (Exception e1) {
1070 // // TODO Auto-generated catch block
1071 // e1.printStackTrace();
1075 // ContraFold.setText("From Contra Fold with predict2D");
1076 // ContraFold.addActionListener(new ActionListener()
1078 // public void actionPerformed(ActionEvent e)
1081 // ContraFold_actionPerformed();
1082 // } catch (Exception e1) {
1083 // // TODO Auto-generated catch block
1084 // e1.printStackTrace();
1088 enterPDB.setText("Enter PDB Id");
1089 enterPDB.addActionListener(new ActionListener()
1091 public void actionPerformed(ActionEvent e)
1093 enterPDB_actionPerformed();
1096 discoverPDB.setText("Discover PDB ids");
1097 discoverPDB.addActionListener(new ActionListener()
1099 public void actionPerformed(ActionEvent e)
1101 discoverPDB_actionPerformed();
1104 outputMenu.setText("Output to Textbox...");
1105 sequenceFeature.setText("Create Sequence Feature");
1106 sequenceFeature.addActionListener(new ActionListener()
1108 public void actionPerformed(ActionEvent e)
1110 sequenceFeature_actionPerformed();
1113 textColour.setText("Text Colour");
1114 textColour.addActionListener(new ActionListener()
1116 public void actionPerformed(ActionEvent e)
1118 textColour_actionPerformed();
1121 jMenu1.setText("Group");
1122 structureMenu.setText("Structure");
1123 viewStructureMenu.setText("View Structure");
1124 // colStructureMenu.setText("Colour By Structure");
1125 editSequence.setText("Edit Sequence...");
1126 editSequence.addActionListener(new ActionListener()
1128 public void actionPerformed(ActionEvent actionEvent)
1130 editSequence_actionPerformed(actionEvent);
1135 * annotationMenuItem.setText("By Annotation");
1136 * annotationMenuItem.addActionListener(new ActionListener() { public void
1137 * actionPerformed(ActionEvent actionEvent) {
1138 * annotationMenuItem_actionPerformed(actionEvent); } });
1140 groupMenu.add(sequenceSelDetails);
1143 this.add(structureMenu);
1144 groupMenu.add(editMenu);
1145 groupMenu.add(outputMenu);
1146 groupMenu.add(sequenceFeature);
1147 groupMenu.add(jMenu1);
1148 sequenceMenu.add(sequenceName);
1149 sequenceMenu.add(sequenceDetails);
1150 colourMenu.add(textColour);
1151 colourMenu.add(noColourmenuItem);
1152 colourMenu.add(clustalColour);
1153 colourMenu.add(BLOSUM62Colour);
1154 colourMenu.add(PIDColour);
1155 colourMenu.add(zappoColour);
1156 colourMenu.add(taylorColour);
1157 colourMenu.add(hydrophobicityColour);
1158 colourMenu.add(helixColour);
1159 colourMenu.add(strandColour);
1160 colourMenu.add(turnColour);
1161 colourMenu.add(buriedColour);
1162 colourMenu.add(nucleotideMenuItem);
1163 if (ap.getAlignment().isNucleotide()) {
1164 // JBPNote - commented since the colourscheme isn't functional
1165 // colourMenu.add(RNAInteractionColour);
1166 colourMenu.add(purinePyrimidineColour);
1168 // colourMenu.add(covariationColour);
1169 colourMenu.add(userDefinedColour);
1171 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
1173 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
1174 .getUserColourSchemes().keys();
1176 while (userColours.hasMoreElements())
1178 JMenuItem item = new JMenuItem(userColours.nextElement().toString());
1179 item.addActionListener(new ActionListener()
1181 public void actionPerformed(ActionEvent evt)
1183 userDefinedColour_actionPerformed(evt);
1186 colourMenu.add(item);
1190 colourMenu.addSeparator();
1191 colourMenu.add(abovePIDColour);
1192 colourMenu.add(conservationMenuItem);
1193 // colourMenu.add(annotationMenuItem);
1196 editMenu.add(editSequence);
1197 editMenu.add(upperCase);
1198 editMenu.add(lowerCase);
1199 editMenu.add(toggle);
1200 pdbMenu.add(pdbFromFile);
1201 // JBPNote: These shouldn't be added here - should appear in a generic 'apply web service to this sequence menu'
1202 // pdbMenu.add(RNAFold);
1203 // pdbMenu.add(ContraFold);
1204 pdbMenu.add(enterPDB);
1205 pdbMenu.add(discoverPDB);
1206 jMenu1.add(groupName);
1207 jMenu1.add(unGroupMenuItem);
1208 jMenu1.add(colourMenu);
1209 jMenu1.add(showBoxes);
1210 jMenu1.add(showText);
1211 jMenu1.add(showColourText);
1212 jMenu1.add(outline);
1213 jMenu1.add(displayNonconserved);
1214 structureMenu.add(pdbMenu);
1215 structureMenu.add(viewStructureMenu);
1216 // structureMenu.add(colStructureMenu);
1217 noColourmenuItem.setText("None");
1218 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
1220 public void actionPerformed(ActionEvent e)
1222 noColourmenuItem_actionPerformed();
1226 clustalColour.setText("Clustalx colours");
1227 clustalColour.addActionListener(new java.awt.event.ActionListener()
1229 public void actionPerformed(ActionEvent e)
1231 clustalColour_actionPerformed();
1234 zappoColour.setText("Zappo");
1235 zappoColour.addActionListener(new java.awt.event.ActionListener()
1237 public void actionPerformed(ActionEvent e)
1239 zappoColour_actionPerformed();
1242 taylorColour.setText("Taylor");
1243 taylorColour.addActionListener(new java.awt.event.ActionListener()
1245 public void actionPerformed(ActionEvent e)
1247 taylorColour_actionPerformed();
1250 hydrophobicityColour.setText("Hydrophobicity");
1251 hydrophobicityColour
1252 .addActionListener(new java.awt.event.ActionListener()
1254 public void actionPerformed(ActionEvent e)
1256 hydrophobicityColour_actionPerformed();
1259 helixColour.setText("Helix propensity");
1260 helixColour.addActionListener(new java.awt.event.ActionListener()
1262 public void actionPerformed(ActionEvent e)
1264 helixColour_actionPerformed();
1267 strandColour.setText("Strand propensity");
1268 strandColour.addActionListener(new java.awt.event.ActionListener()
1270 public void actionPerformed(ActionEvent e)
1272 strandColour_actionPerformed();
1275 turnColour.setText("Turn propensity");
1276 turnColour.addActionListener(new java.awt.event.ActionListener()
1278 public void actionPerformed(ActionEvent e)
1280 turnColour_actionPerformed();
1283 buriedColour.setText("Buried Index");
1284 buriedColour.addActionListener(new java.awt.event.ActionListener()
1286 public void actionPerformed(ActionEvent e)
1288 buriedColour_actionPerformed();
1291 abovePIDColour.setText("Above % Identity");
1292 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
1294 public void actionPerformed(ActionEvent e)
1296 abovePIDColour_actionPerformed();
1299 userDefinedColour.setText("User Defined...");
1300 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
1302 public void actionPerformed(ActionEvent e)
1304 userDefinedColour_actionPerformed(e);
1307 PIDColour.setText("Percentage Identity");
1308 PIDColour.addActionListener(new java.awt.event.ActionListener()
1310 public void actionPerformed(ActionEvent e)
1312 PIDColour_actionPerformed();
1315 BLOSUM62Colour.setText("BLOSUM62");
1316 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
1318 public void actionPerformed(ActionEvent e)
1320 BLOSUM62Colour_actionPerformed();
1323 purinePyrimidineColour.setText("Purine/Pyrimidine");
1324 purinePyrimidineColour
1325 .addActionListener(new java.awt.event.ActionListener()
1327 public void actionPerformed(ActionEvent e)
1329 purinePyrimidineColour_actionPerformed();
1335 * covariationColour.addActionListener(new java.awt.event.ActionListener() {
1336 * public void actionPerformed(ActionEvent e) {
1337 * covariationColour_actionPerformed(); } });
1340 conservationMenuItem.setText("Conservation");
1341 conservationMenuItem
1342 .addActionListener(new java.awt.event.ActionListener()
1344 public void actionPerformed(ActionEvent e)
1346 conservationMenuItem_actionPerformed();
1351 protected void sequenceSelectionDetails_actionPerformed()
1353 createSequenceDetailsReport(ap.av.getSequenceSelection());
1356 protected void sequenceDetails_actionPerformed()
1358 createSequenceDetailsReport(new SequenceI[]
1362 public void createSequenceDetailsReport(SequenceI[] sequences)
1364 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1365 StringBuffer contents = new StringBuffer();
1366 for (SequenceI seq : sequences)
1368 contents.append("<p><h2>Annotation for " + seq.getDisplayId(true)
1370 new SequenceAnnotationReport(null)
1371 .createSequenceAnnotationReport(
1377 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
1379 contents.append("</p>");
1381 cap.setText("<html>" + contents.toString() + "</html>");
1383 Desktop.instance.addInternalFrame(cap, "Sequence Details for "
1384 + (sequences.length == 1 ? sequences[0].getDisplayId(true)
1385 : "Selection"), 500, 400);
1389 protected void showNonconserved_actionPerformed()
1391 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1396 * call to refresh view after settings change
1400 ap.updateAnnotation();
1401 ap.paintAlignment(true);
1403 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1412 protected void clustalColour_actionPerformed()
1414 SequenceGroup sg = getGroup();
1415 sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
1425 protected void zappoColour_actionPerformed()
1427 getGroup().cs = new ZappoColourScheme();
1437 protected void taylorColour_actionPerformed()
1439 getGroup().cs = new TaylorColourScheme();
1449 protected void hydrophobicityColour_actionPerformed()
1451 getGroup().cs = new HydrophobicColourScheme();
1461 protected void helixColour_actionPerformed()
1463 getGroup().cs = new HelixColourScheme();
1473 protected void strandColour_actionPerformed()
1475 getGroup().cs = new StrandColourScheme();
1485 protected void turnColour_actionPerformed()
1487 getGroup().cs = new TurnColourScheme();
1497 protected void buriedColour_actionPerformed()
1499 getGroup().cs = new BuriedColourScheme();
1509 public void nucleotideMenuItem_actionPerformed()
1511 getGroup().cs = new NucleotideColourScheme();
1515 protected void purinePyrimidineColour_actionPerformed()
1517 getGroup().cs = new PurinePyrimidineColourScheme();
1523 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1524 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1532 protected void abovePIDColour_actionPerformed()
1534 SequenceGroup sg = getGroup();
1540 if (abovePIDColour.isSelected())
1542 sg.cs.setConsensus(AAFrequency.calculate(
1543 sg.getSequences(ap.av.getHiddenRepSequences()),
1544 sg.getStartRes(), sg.getEndRes() + 1));
1546 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1549 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
1551 SliderPanel.showPIDSlider();
1554 // remove PIDColouring
1556 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
1568 protected void userDefinedColour_actionPerformed(ActionEvent e)
1570 SequenceGroup sg = getGroup();
1572 if (e.getActionCommand().equals("User Defined..."))
1574 new UserDefinedColours(ap, sg);
1578 UserColourScheme udc = (UserColourScheme) UserDefinedColours
1579 .getUserColourSchemes().get(e.getActionCommand());
1592 protected void PIDColour_actionPerformed()
1594 SequenceGroup sg = getGroup();
1595 sg.cs = new PIDColourScheme();
1596 sg.cs.setConsensus(AAFrequency.calculate(
1597 sg.getSequences(ap.av.getHiddenRepSequences()),
1598 sg.getStartRes(), sg.getEndRes() + 1));
1608 protected void BLOSUM62Colour_actionPerformed()
1610 SequenceGroup sg = getGroup();
1612 sg.cs = new Blosum62ColourScheme();
1614 sg.cs.setConsensus(AAFrequency.calculate(
1615 sg.getSequences(ap.av.getHiddenRepSequences()),
1616 sg.getStartRes(), sg.getEndRes() + 1));
1627 protected void noColourmenuItem_actionPerformed()
1629 getGroup().cs = null;
1639 protected void conservationMenuItem_actionPerformed()
1641 SequenceGroup sg = getGroup();
1647 if (conservationMenuItem.isSelected())
1649 Conservation c = new Conservation("Group",
1650 ResidueProperties.propHash, 3, sg.getSequences(ap.av
1651 .getHiddenRepSequences()), sg.getStartRes(),
1652 sg.getEndRes() + 1);
1655 c.verdict(false, ap.av.getConsPercGaps());
1657 sg.cs.setConservation(c);
1659 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1660 SliderPanel.showConservationSlider();
1663 // remove ConservationColouring
1665 sg.cs.setConservation(null);
1671 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1673 SequenceGroup sg = getGroup();
1679 AnnotationColourGradient acg = new AnnotationColourGradient(
1680 sequence.getAnnotation()[0], null,
1681 AnnotationColourGradient.NO_THRESHOLD);
1683 acg.predefinedColours = true;
1695 protected void groupName_actionPerformed()
1698 SequenceGroup sg = getGroup();
1699 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1700 sg.getDescription(), " Group Name ",
1701 "Group Description ", "Edit Group Name/Description",
1709 sg.setName(dialog.getName());
1710 sg.setDescription(dialog.getDescription());
1715 * Get selection group - adding it to the alignment if necessary.
1717 * @return sequence group to operate on
1719 SequenceGroup getGroup()
1721 SequenceGroup sg = ap.av.getSelectionGroup();
1722 // this method won't add a new group if it already exists
1725 ap.av.getAlignment().addGroup(sg);
1737 void sequenceName_actionPerformed()
1739 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1740 sequence.getDescription(), " Sequence Name ",
1741 "Sequence Description ", "Edit Sequence Name/Description",
1749 if (dialog.getName() != null)
1751 if (dialog.getName().indexOf(" ") > -1)
1753 JOptionPane.showMessageDialog(ap,
1754 "Spaces have been converted to \"_\"",
1755 "No spaces allowed in Sequence Name",
1756 JOptionPane.WARNING_MESSAGE);
1759 sequence.setName(dialog.getName().replace(' ', '_'));
1760 ap.paintAlignment(false);
1763 sequence.setDescription(dialog.getDescription());
1765 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1776 void unGroupMenuItem_actionPerformed()
1778 SequenceGroup sg = ap.av.getSelectionGroup();
1779 ap.av.getAlignment().deleteGroup(sg);
1780 ap.av.setSelectionGroup(null);
1790 protected void outline_actionPerformed()
1792 SequenceGroup sg = getGroup();
1793 Color col = JColorChooser.showDialog(this, "Select Outline Colour",
1798 sg.setOutlineColour(col);
1810 public void showBoxes_actionPerformed()
1812 getGroup().setDisplayBoxes(showBoxes.isSelected());
1822 public void showText_actionPerformed()
1824 getGroup().setDisplayText(showText.isSelected());
1834 public void showColourText_actionPerformed()
1836 getGroup().setColourText(showColourText.isSelected());
1840 public void showLink(String url)
1844 jalview.util.BrowserLauncher.openURL(url);
1845 } catch (Exception ex)
1848 .showInternalMessageDialog(
1850 "Unixers: Couldn't find default web browser."
1851 + "\nAdd the full path to your browser in Preferences.",
1852 "Web browser not found", JOptionPane.WARNING_MESSAGE);
1854 ex.printStackTrace();
1858 void hideSequences(boolean representGroup)
1860 SequenceGroup sg = ap.av.getSelectionGroup();
1861 if (sg == null || sg.getSize() < 1)
1863 ap.av.hideSequence(new SequenceI[]
1868 ap.av.setSelectionGroup(null);
1872 ap.av.hideRepSequences(sequence, sg);
1877 int gsize = sg.getSize();
1880 hseqs = new SequenceI[gsize];
1883 for (int i = 0; i < gsize; i++)
1885 hseqs[index++] = sg.getSequenceAt(i);
1888 ap.av.hideSequence(hseqs);
1889 // refresh(); TODO: ? needed ?
1890 ap.av.sendSelection();
1893 public void copy_actionPerformed()
1895 ap.alignFrame.copy_actionPerformed(null);
1898 public void cut_actionPerformed()
1900 ap.alignFrame.cut_actionPerformed(null);
1903 void changeCase(ActionEvent e)
1905 Object source = e.getSource();
1906 SequenceGroup sg = ap.av.getSelectionGroup();
1910 int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
1911 sg.getEndRes() + 1);
1916 if (source == toggle)
1918 description = "Toggle Case";
1919 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1921 else if (source == upperCase)
1923 description = "To Upper Case";
1924 caseChange = ChangeCaseCommand.TO_UPPER;
1928 description = "To Lower Case";
1929 caseChange = ChangeCaseCommand.TO_LOWER;
1932 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1933 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1934 startEnd, caseChange);
1936 ap.alignFrame.addHistoryItem(caseCommand);
1938 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1944 public void outputText_actionPerformed(ActionEvent e)
1946 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1947 cap.setForInput(null);
1948 Desktop.addInternalFrame(cap,
1949 "Alignment output - " + e.getActionCommand(), 600, 500);
1951 String[] omitHidden = null;
1953 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1954 // or we simply trust the user wants
1955 // wysiwig behaviour
1956 SequenceGroup sg = ap.av.getSelectionGroup();
1957 ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection());
1958 omitHidden = ap.av.getViewAsString(true);
1959 Alignment oal = new Alignment(ap.av.getSequenceSelection());
1960 AlignmentAnnotation[] nala = ap.av.getAlignment()
1961 .getAlignmentAnnotation();
1964 for (int i = 0; i < nala.length; i++)
1966 AlignmentAnnotation na = nala[i];
1967 oal.addAnnotation(na);
1970 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
1971 oal, omitHidden, csel, sg));
1975 public void pdbFromFile_actionPerformed()
1977 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
1978 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
1979 chooser.setFileView(new jalview.io.JalviewFileView());
1980 chooser.setDialogTitle("Select a PDB file for "
1981 + sequence.getDisplayId(false));
1982 chooser.setToolTipText("Load a PDB file and associate it with sequence '"
1983 + sequence.getDisplayId(false) + "'");
1985 int value = chooser.showOpenDialog(null);
1987 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
1989 String choice = chooser.getSelectedFile().getPath();
1990 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
1991 new AssociatePdbFileWithSeq().associatePdbWithSeq(choice,
1992 jalview.io.AppletFormatAdapter.FILE, sequence, true);
1996 // JBNote: commented out - these won't be instantiated here...!
1997 // public void RNAFold_actionPerformed() throws Exception
1999 // Predict2D P2D = new Predict2D();
2000 // P2D.getStructure2DFromRNAFold("toto");
2003 // public void ContraFold_actionPerformed() throws Exception
2005 // Predict2D P2D = new Predict2D();
2006 // P2D.getStructure2DFromContraFold("toto");
2008 public void enterPDB_actionPerformed()
2010 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
2011 "Enter PDB Id", "Enter PDB Id", JOptionPane.QUESTION_MESSAGE);
2013 if (id != null && id.length() > 0)
2015 PDBEntry entry = new PDBEntry();
2016 entry.setId(id.toUpperCase());
2017 sequence.getDatasetSequence().addPDBId(entry);
2021 public void discoverPDB_actionPerformed()
2024 final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
2026 : ap.av.getSequenceSelection());
2027 Thread discpdb = new Thread(new Runnable()
2032 new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
2033 .fetchDBRefs(false);
2040 public void sequenceFeature_actionPerformed()
2042 SequenceGroup sg = ap.av.getSelectionGroup();
2048 int rsize = 0, gSize = sg.getSize();
2049 SequenceI[] rseqs, seqs = new SequenceI[gSize];
2050 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
2052 for (int i = 0; i < gSize; i++)
2054 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
2055 int end = sg.findEndRes(sg.getSequenceAt(i));
2058 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
2059 features[rsize] = new SequenceFeature(null, null, null, start, end,
2064 rseqs = new SequenceI[rsize];
2065 tfeatures = new SequenceFeature[rsize];
2066 System.arraycopy(seqs, 0, rseqs, 0, rsize);
2067 System.arraycopy(features, 0, tfeatures, 0, rsize);
2068 features = tfeatures;
2070 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
2071 features, true, ap))
2073 ap.alignFrame.setShowSeqFeatures(true);
2074 ap.highlightSearchResults(null);
2078 public void textColour_actionPerformed()
2080 SequenceGroup sg = getGroup();
2083 new TextColourChooser().chooseColour(ap, sg);
2087 public void colourByStructure(String pdbid)
2089 Annotation[] anots = ap.av.getStructureSelectionManager()
2090 .colourSequenceFromStructure(sequence, pdbid);
2092 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
2093 "Coloured by " + pdbid, anots);
2095 ap.av.getAlignment().addAnnotation(an);
2096 an.createSequenceMapping(sequence, 0, true);
2097 // an.adjustForAlignment();
2098 ap.av.getAlignment().setAnnotationIndex(an, 0);
2100 ap.adjustAnnotationHeight();
2102 sequence.addAlignmentAnnotation(an);
2106 public void editSequence_actionPerformed(ActionEvent actionEvent)
2108 SequenceGroup sg = ap.av.getSelectionGroup();
2112 if (sequence == null)
2113 sequence = (Sequence) sg.getSequenceAt(0);
2115 EditNameDialog dialog = new EditNameDialog(
2116 sequence.getSequenceAsString(sg.getStartRes(),
2117 sg.getEndRes() + 1), null, "Edit Sequence ", null,
2118 "Edit Sequence", ap.alignFrame);
2122 EditCommand editCommand = new EditCommand("Edit Sequences",
2123 EditCommand.REPLACE, dialog.getName().replace(' ',
2124 ap.av.getGapCharacter()),
2125 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2126 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
2128 ap.alignFrame.addHistoryItem(editCommand);
2130 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()