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.*;
26 import javax.xml.parsers.ParserConfigurationException;
28 import org.xml.sax.SAXException;
30 import fr.orsay.lri.varna.exceptions.ExceptionFileFormatOrSyntax;
31 import fr.orsay.lri.varna.exceptions.ExceptionLoadingFailed;
32 import fr.orsay.lri.varna.exceptions.ExceptionPermissionDenied;
33 import fr.orsay.lri.varna.exceptions.ExceptionUnmatchedClosingParentheses;
35 import jalview.analysis.*;
36 import jalview.commands.*;
37 import jalview.datamodel.*;
39 import jalview.schemes.*;
40 import jalview.util.GroupUrlLink;
41 import jalview.util.GroupUrlLink.UrlStringTooLongException;
42 import jalview.util.UrlLink;
48 * @version $Revision: 1.118 $
50 public class PopupMenu extends JPopupMenu
52 JMenu groupMenu = new JMenu();
54 JMenuItem groupName = new JMenuItem();
56 protected JRadioButtonMenuItem clustalColour = new JRadioButtonMenuItem();
58 protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
60 protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
62 protected JRadioButtonMenuItem hydrophobicityColour = new JRadioButtonMenuItem();
64 protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
66 protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
68 protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
70 protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
72 protected JCheckBoxMenuItem abovePIDColour = new JCheckBoxMenuItem();
74 protected JRadioButtonMenuItem userDefinedColour = new JRadioButtonMenuItem();
76 protected JRadioButtonMenuItem PIDColour = new JRadioButtonMenuItem();
78 protected JRadioButtonMenuItem BLOSUM62Colour = new JRadioButtonMenuItem();
80 protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem();
81 protected JRadioButtonMenuItem RNAInteractionColour = new JRadioButtonMenuItem();
83 // protected JRadioButtonMenuItem covariationColour = new
84 // JRadioButtonMenuItem();
86 JRadioButtonMenuItem noColourmenuItem = new JRadioButtonMenuItem();
88 protected JCheckBoxMenuItem conservationMenuItem = new JCheckBoxMenuItem();
92 JMenu sequenceMenu = new JMenu();
94 JMenuItem sequenceName = new JMenuItem();
96 JMenuItem sequenceDetails = new JMenuItem();
98 JMenuItem sequenceSelDetails = new JMenuItem();
102 JMenuItem unGroupMenuItem = new JMenuItem();
104 JMenuItem outline = new JMenuItem();
106 JRadioButtonMenuItem nucleotideMenuItem = new JRadioButtonMenuItem();
108 JMenu colourMenu = new JMenu();
110 JCheckBoxMenuItem showBoxes = new JCheckBoxMenuItem();
112 JCheckBoxMenuItem showText = new JCheckBoxMenuItem();
114 JCheckBoxMenuItem showColourText = new JCheckBoxMenuItem();
116 JCheckBoxMenuItem displayNonconserved = new JCheckBoxMenuItem();
118 JMenu editMenu = new JMenu();
120 JMenuItem cut = new JMenuItem();
122 JMenuItem copy = new JMenuItem();
124 JMenuItem upperCase = new JMenuItem();
126 JMenuItem lowerCase = new JMenuItem();
128 JMenuItem toggle = new JMenuItem();
130 JMenu pdbMenu = new JMenu();
132 JMenuItem pdbFromFile = new JMenuItem();
134 JMenuItem enterPDB = new JMenuItem();
136 JMenuItem discoverPDB = new JMenuItem();
138 JMenu outputMenu = new JMenu();
140 JMenuItem sequenceFeature = new JMenuItem();
142 JMenuItem textColour = new JMenuItem();
144 JMenu jMenu1 = new JMenu();
146 JMenu structureMenu = new JMenu();
148 JMenu viewStructureMenu = new JMenu();
150 // JMenu colStructureMenu = new JMenu();
151 JMenuItem editSequence = new JMenuItem();
153 // JMenuItem annotationMenuItem = new JMenuItem();
155 JMenu groupLinksMenu;
158 * Creates a new PopupMenu object.
165 public PopupMenu(final AlignmentPanel ap, Sequence seq, Vector links)
167 this(ap, seq, links, null);
177 public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
178 Vector links, Vector groupLinks)
180 // /////////////////////////////////////////////////////////
181 // If this is activated from the sequence panel, the user may want to
182 // edit or annotate a particular residue. Therefore display the residue menu
184 // If from the IDPanel, we must display the sequence menu
185 // ////////////////////////////////////////////////////////
189 ButtonGroup colours = new ButtonGroup();
190 colours.add(noColourmenuItem);
191 colours.add(clustalColour);
192 colours.add(zappoColour);
193 colours.add(taylorColour);
194 colours.add(hydrophobicityColour);
195 colours.add(helixColour);
196 colours.add(strandColour);
197 colours.add(turnColour);
198 colours.add(buriedColour);
199 colours.add(abovePIDColour);
200 colours.add(userDefinedColour);
201 colours.add(PIDColour);
202 colours.add(BLOSUM62Colour);
203 colours.add(purinePyrimidineColour);
204 colours.add(RNAInteractionColour);
205 // colours.add(covariationColour);
207 for (int i = 0; i < jalview.io.FormatAdapter.WRITEABLE_FORMATS.length; i++)
209 JMenuItem item = new JMenuItem(
210 jalview.io.FormatAdapter.WRITEABLE_FORMATS[i]);
212 item.addActionListener(new java.awt.event.ActionListener()
214 public void actionPerformed(ActionEvent e)
216 outputText_actionPerformed(e);
220 outputMenu.add(item);
226 } catch (Exception e)
234 sequenceMenu.setText(sequence.getName());
236 if (seq.getDatasetSequence().getPDBId() != null
237 && seq.getDatasetSequence().getPDBId().size() > 0)
239 java.util.Enumeration e = seq.getDatasetSequence().getPDBId()
242 while (e.hasMoreElements())
244 final PDBEntry pdb = (PDBEntry) e.nextElement();
246 menuItem = new JMenuItem();
247 menuItem.setText(pdb.getId());
248 menuItem.addActionListener(new java.awt.event.ActionListener()
250 public void actionPerformed(ActionEvent e)
252 // TODO re JAL-860: optionally open dialog or provide a menu entry
253 // allowing user to open just one structure per sequence
254 new AppJmol(pdb, ap.av.collateForPDB(new PDBEntry[]
255 { pdb })[0], null, ap);
256 // new PDBViewer(pdb, seqs2, null, ap, AppletFormatAdapter.FILE);
260 viewStructureMenu.add(menuItem);
263 * menuItem = new JMenuItem(); menuItem.setText(pdb.getId());
264 * menuItem.addActionListener(new java.awt.event.ActionListener() {
265 * public void actionPerformed(ActionEvent e) {
266 * colourByStructure(pdb.getId()); } });
267 * colStructureMenu.add(menuItem);
273 if (ap.av.getAlignment().isNucleotide() == false)
275 structureMenu.remove(viewStructureMenu);
277 // structureMenu.remove(colStructureMenu);
280 if (ap.av.getAlignment().isNucleotide() == true)
282 AlignmentAnnotation[] aa = ap.av.getAlignment()
283 .getAlignmentAnnotation();
284 for (int i = 0; i < aa.length; i++)
286 if (aa[i].getRNAStruc() != null)
288 final String rnastruc = aa[i].getRNAStruc();
289 final String structureLine = aa[i].label;
290 menuItem = new JMenuItem();
291 menuItem.setText("2D RNA " + structureLine);
292 menuItem.addActionListener(new java.awt.event.ActionListener()
295 public void actionPerformed(ActionEvent e)
297 //System.out.println("1:"+structureLine);
298 System.out.println("1:sname"+seq.getName());
299 System.out.println("2:seq"+seq);
301 //System.out.println("3:"+seq.getSequenceAsString());
302 System.out.println("3:strucseq"+rnastruc);
303 //System.out.println("4:struc"+seq.getRNA());
304 System.out.println("5:name"+seq.getName());
305 System.out.println("6:ap"+ap);
306 new AppVarna(structureLine, seq, seq.getSequenceAsString(), rnastruc, seq
308 //new AppVarna(seq.getName(),seq,rnastruc,seq.getRNA(), seq.getName(), ap);
309 System.out.println("end");
312 viewStructureMenu.add(menuItem);
316 // SequenceFeatures[] test = seq.getSequenceFeatures();
318 if (seq.getAnnotation() != null)
320 AlignmentAnnotation seqAnno[] = seq.getAnnotation();
321 for (int i = 0; i < seqAnno.length; i++)
323 if (seqAnno[i].getRNAStruc() != null)
325 final String rnastruc = seqAnno[i].getRNAStruc();
327 // TODO: make rnastrucF a bit more nice
328 menuItem = new JMenuItem();
329 menuItem.setText("2D RNA - " + seq.getName());
330 menuItem.addActionListener(new java.awt.event.ActionListener()
332 public void actionPerformed(ActionEvent e)
334 // TODO: VARNA does'nt print gaps in the sequence
336 new AppVarna(seq.getName() + " structure", seq, seq
337 .getSequenceAsString(), rnastruc, seq.getName(),
341 viewStructureMenu.add(menuItem);
348 menuItem = new JMenuItem("Hide Sequences");
349 menuItem.addActionListener(new java.awt.event.ActionListener()
351 public void actionPerformed(ActionEvent e)
353 hideSequences(false);
358 if (ap.av.getSelectionGroup() != null
359 && ap.av.getSelectionGroup().getSize() > 1)
361 menuItem = new JMenuItem("Represent Group with " + seq.getName());
362 menuItem.addActionListener(new java.awt.event.ActionListener()
364 public void actionPerformed(ActionEvent e)
369 sequenceMenu.add(menuItem);
372 if (ap.av.hasHiddenRows())
374 final int index = ap.av.getAlignment().findIndex(seq);
376 if (ap.av.adjustForHiddenSeqs(index)
377 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
379 menuItem = new JMenuItem("Reveal Sequences");
380 menuItem.addActionListener(new ActionListener()
382 public void actionPerformed(ActionEvent e)
384 ap.av.showSequence(index);
385 if (ap.overviewPanel != null)
387 ap.overviewPanel.updateOverviewImage();
395 // for the case when no sequences are even visible
396 if (ap.av.hasHiddenRows())
399 menuItem = new JMenuItem("Reveal All");
400 menuItem.addActionListener(new ActionListener()
402 public void actionPerformed(ActionEvent e)
404 ap.av.showAllHiddenSeqs();
405 if (ap.overviewPanel != null)
407 ap.overviewPanel.updateOverviewImage();
417 SequenceGroup sg = ap.av.getSelectionGroup();
419 if (sg != null && sg.getSize() > 0)
421 groupName.setText("Name: " + sg.getName());
422 groupName.setText("Edit name and description of current group.");
424 if (sg.cs instanceof ZappoColourScheme)
426 zappoColour.setSelected(true);
428 else if (sg.cs instanceof TaylorColourScheme)
430 taylorColour.setSelected(true);
432 else if (sg.cs instanceof PIDColourScheme)
434 PIDColour.setSelected(true);
436 else if (sg.cs instanceof Blosum62ColourScheme)
438 BLOSUM62Colour.setSelected(true);
440 else if (sg.cs instanceof UserColourScheme)
442 userDefinedColour.setSelected(true);
444 else if (sg.cs instanceof HydrophobicColourScheme)
446 hydrophobicityColour.setSelected(true);
448 else if (sg.cs instanceof HelixColourScheme)
450 helixColour.setSelected(true);
452 else if (sg.cs instanceof StrandColourScheme)
454 strandColour.setSelected(true);
456 else if (sg.cs instanceof TurnColourScheme)
458 turnColour.setSelected(true);
460 else if (sg.cs instanceof BuriedColourScheme)
462 buriedColour.setSelected(true);
464 else if (sg.cs instanceof ClustalxColourScheme)
466 clustalColour.setSelected(true);
468 else if (sg.cs instanceof PurinePyrimidineColourScheme)
470 purinePyrimidineColour.setSelected(true);
475 * else if (sg.cs instanceof CovariationColourScheme) {
476 * covariationColour.setSelected(true); }
480 noColourmenuItem.setSelected(true);
483 if (sg.cs != null && sg.cs.conservationApplied())
485 conservationMenuItem.setSelected(true);
487 displayNonconserved.setSelected(sg.getShowNonconserved());
488 showText.setSelected(sg.getDisplayText());
489 showColourText.setSelected(sg.getColourText());
490 showBoxes.setSelected(sg.getDisplayBoxes());
491 // add any groupURLs to the groupURL submenu and make it visible
492 if (groupLinks != null && groupLinks.size() > 0)
494 buildGroupURLMenu(sg, groupLinks);
496 // Add a 'show all structures' for the current selection
497 Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>();
498 SequenceI sqass = null;
499 for (SequenceI sq : ap.av.getSequenceSelection())
501 Vector<PDBEntry> pes = (Vector<PDBEntry>) sq.getDatasetSequence()
505 for (PDBEntry pe : pes)
507 pdbe.put(pe.getId(), pe);
517 final PDBEntry[] pe = pdbe.values().toArray(
518 new PDBEntry[pdbe.size()]);
519 final JMenuItem gpdbview;
520 if (pdbe.size() == 1)
522 structureMenu.add(gpdbview = new JMenuItem("View structure for "
523 + sqass.getDisplayId(false)));
527 structureMenu.add(gpdbview = new JMenuItem("View all "
528 + pdbe.size() + " structures."));
530 gpdbview.setToolTipText("Open a new Jmol view with all structures associated with the current selection and superimpose them using the alignment.");
531 gpdbview.addActionListener(new ActionListener()
535 public void actionPerformed(ActionEvent e)
537 new AppJmol(ap, pe, ap.av.collateForPDB(pe));
544 groupMenu.setVisible(false);
545 editMenu.setVisible(false);
548 if (!ap.av.getAlignment().getGroups().contains(sg))
550 unGroupMenuItem.setVisible(false);
555 sequenceMenu.setVisible(false);
556 structureMenu.setVisible(false);
559 if (links != null && links.size() > 0)
562 JMenu linkMenu = new JMenu("Link");
563 Vector linkset = new Vector();
564 for (int i = 0; i < links.size(); i++)
566 String link = links.elementAt(i).toString();
567 UrlLink urlLink = null;
570 urlLink = new UrlLink(link);
571 } catch (Exception foo)
573 jalview.bin.Cache.log.error("Exception for URLLink '" + link
578 if (!urlLink.isValid())
580 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
583 final String label = urlLink.getLabel();
584 if (seq != null && urlLink.isDynamic())
587 // collect matching db-refs
588 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
589 seq.getDBRef(), new String[]
590 { urlLink.getTarget() });
591 // collect id string too
592 String id = seq.getName();
593 String descr = seq.getDescription();
594 if (descr != null && descr.length() < 1)
601 for (int r = 0; r < dbr.length; r++)
603 if (id != null && dbr[r].getAccessionId().equals(id))
605 // suppress duplicate link creation for the bare sequence ID
606 // string with this link
609 // create Bare ID link for this RUL
610 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
614 for (int u = 0; u < urls.length; u += 2)
616 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
618 linkset.addElement(urls[u] + "|" + urls[u + 1]);
619 addshowLink(linkMenu, label + "|" + urls[u],
628 // create Bare ID link for this RUL
629 String[] urls = urlLink.makeUrls(id, true);
632 for (int u = 0; u < urls.length; u += 2)
634 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
636 linkset.addElement(urls[u] + "|" + urls[u + 1]);
637 addshowLink(linkMenu, label, urls[u + 1]);
642 // Create urls from description but only for URL links which are regex
644 if (descr != null && urlLink.getRegexReplace() != null)
646 // create link for this URL from description where regex matches
647 String[] urls = urlLink.makeUrls(descr, true);
650 for (int u = 0; u < urls.length; u += 2)
652 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
654 linkset.addElement(urls[u] + "|" + urls[u + 1]);
655 addshowLink(linkMenu, label, urls[u + 1]);
663 if (!linkset.contains(label + "|" + urlLink.getUrl_prefix()))
665 linkset.addElement(label + "|" + urlLink.getUrl_prefix());
666 // Add a non-dynamic link
667 addshowLink(linkMenu, label, urlLink.getUrl_prefix());
671 if (sequence != null)
673 sequenceMenu.add(linkMenu);
682 private void buildGroupURLMenu(SequenceGroup sg, Vector groupLinks)
685 // TODO: usability: thread off the generation of group url content so root
687 // sequence only URLs
688 // ID/regex match URLs
689 groupLinksMenu = new JMenu("Group Link");
690 JMenu[] linkMenus = new JMenu[]
691 { null, new JMenu("IDS"), new JMenu("Sequences"),
692 new JMenu("IDS and Sequences") }; // three types of url that might be
694 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
695 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
696 Hashtable commonDbrefs = new Hashtable();
697 for (int sq = 0; sq < seqs.length; sq++)
700 int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
701 .findPosition(sg.getEndRes());
702 // just collect ids from dataset sequence
703 // TODO: check if IDs collected from selecton group intersects with the
704 // current selection, too
705 SequenceI sqi = seqs[sq];
706 while (sqi.getDatasetSequence() != null)
708 sqi = sqi.getDatasetSequence();
710 DBRefEntry[] dbr = sqi.getDBRef();
711 if (dbr != null && dbr.length > 0)
713 for (int d = 0; d < dbr.length; d++)
715 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
716 Object[] sarray = (Object[]) commonDbrefs.get(src);
719 sarray = new Object[2];
720 sarray[0] = new int[]
722 sarray[1] = new String[seqs.length];
724 commonDbrefs.put(src, sarray);
727 if (((String[]) sarray[1])[sq] == null)
730 || (dbr[d].getMap().locateMappedRange(start, end) != null))
732 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
733 ((int[]) sarray[0])[0]++;
739 // now create group links for all distinct ID/sequence sets.
740 boolean addMenu = false; // indicates if there are any group links to give
742 for (int i = 0; i < groupLinks.size(); i++)
744 String link = groupLinks.elementAt(i).toString();
745 GroupUrlLink urlLink = null;
748 urlLink = new GroupUrlLink(link);
749 } catch (Exception foo)
751 jalview.bin.Cache.log.error("Exception for GroupURLLink '" + link
756 if (!urlLink.isValid())
758 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
761 final String label = urlLink.getLabel();
762 boolean usingNames = false;
763 // Now see which parts of the group apply for this URL
764 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
765 Object[] idset = (Object[]) commonDbrefs.get(ltarget.toUpperCase());
766 String[] seqstr, ids; // input to makeUrl
769 int numinput = ((int[]) idset[0])[0];
770 String[] allids = ((String[]) idset[1]);
771 seqstr = new String[numinput];
772 ids = new String[numinput];
773 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
775 if (allids[sq] != null)
777 ids[idcount] = allids[sq];
778 seqstr[idcount++] = idandseqs[1][sq];
784 // just use the id/seq set
785 seqstr = idandseqs[1];
789 // and try and make the groupURL!
791 Object[] urlset = null;
794 urlset = urlLink.makeUrlStubs(ids, seqstr,
795 "FromJalview" + System.currentTimeMillis(), false);
796 } catch (UrlStringTooLongException e)
801 int type = urlLink.getGroupURLType() & 3;
802 // System.out.println(urlLink.getGroupURLType()
803 // +" "+((String[])urlset[3])[0]);
804 // first two bits ofurlLink type bitfield are sequenceids and sequences
805 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
806 addshowLink(linkMenus[type], label
807 + (((type & 1) == 1) ? ("("
808 + (usingNames ? "Names" : ltarget) + ")") : ""),
815 groupLinksMenu = new JMenu("Group Links");
816 for (int m = 0; m < linkMenus.length; m++)
818 if (linkMenus[m] != null
819 && linkMenus[m].getMenuComponentCount() > 0)
821 groupLinksMenu.add(linkMenus[m]);
825 groupMenu.add(groupLinksMenu);
830 * add a show URL menu item to the given linkMenu
834 * - menu label string
838 private void addshowLink(JMenu linkMenu, String label, final String url)
840 JMenuItem item = new JMenuItem(label);
841 item.setToolTipText("open URL: " + url);
842 item.addActionListener(new java.awt.event.ActionListener()
844 public void actionPerformed(ActionEvent e)
846 new Thread(new Runnable()
862 * add a late bound groupURL item to the given linkMenu
866 * - menu label string
867 * @param urlgenerator
868 * GroupURLLink used to generate URL
870 * Object array returned from the makeUrlStubs function.
872 private void addshowLink(JMenu linkMenu, String label,
873 final GroupUrlLink urlgenerator, final Object[] urlstub)
875 JMenuItem item = new JMenuItem(label);
876 item.setToolTipText("open URL (" + urlgenerator.getUrl_prefix()
877 + "..) (" + urlgenerator.getNumberInvolved(urlstub) + " seqs)"); // TODO:
886 item.addActionListener(new java.awt.event.ActionListener()
888 public void actionPerformed(ActionEvent e)
890 new Thread(new Runnable()
897 showLink(urlgenerator.constructFrom(urlstub));
898 } catch (UrlStringTooLongException e)
916 private void jbInit() throws Exception
918 groupMenu.setText("Group");
919 groupMenu.setText("Selection");
920 groupName.setText("Name");
921 groupName.addActionListener(new java.awt.event.ActionListener()
923 public void actionPerformed(ActionEvent e)
925 groupName_actionPerformed();
928 sequenceMenu.setText("Sequence");
929 sequenceName.setText("Edit Name/Description");
930 sequenceName.addActionListener(new java.awt.event.ActionListener()
932 public void actionPerformed(ActionEvent e)
934 sequenceName_actionPerformed();
937 sequenceDetails.setText("Sequence Details ...");
938 sequenceDetails.addActionListener(new java.awt.event.ActionListener()
940 public void actionPerformed(ActionEvent e)
942 sequenceDetails_actionPerformed();
945 sequenceSelDetails.setText("Sequence Details ...");
947 .addActionListener(new java.awt.event.ActionListener()
949 public void actionPerformed(ActionEvent e)
951 sequenceSelectionDetails_actionPerformed();
954 PIDColour.setFocusPainted(false);
955 unGroupMenuItem.setText("Remove Group");
956 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
958 public void actionPerformed(ActionEvent e)
960 unGroupMenuItem_actionPerformed();
964 outline.setText("Border colour");
965 outline.addActionListener(new java.awt.event.ActionListener()
967 public void actionPerformed(ActionEvent e)
969 outline_actionPerformed();
972 nucleotideMenuItem.setText("Nucleotide");
973 nucleotideMenuItem.addActionListener(new ActionListener()
975 public void actionPerformed(ActionEvent e)
977 nucleotideMenuItem_actionPerformed();
980 colourMenu.setText("Group Colour");
981 showBoxes.setText("Boxes");
982 showBoxes.setState(true);
983 showBoxes.addActionListener(new ActionListener()
985 public void actionPerformed(ActionEvent e)
987 showBoxes_actionPerformed();
990 showText.setText("Text");
991 showText.setState(true);
992 showText.addActionListener(new ActionListener()
994 public void actionPerformed(ActionEvent e)
996 showText_actionPerformed();
999 showColourText.setText("Colour Text");
1000 showColourText.addActionListener(new ActionListener()
1002 public void actionPerformed(ActionEvent e)
1004 showColourText_actionPerformed();
1007 displayNonconserved.setText("Show Nonconserved");
1008 displayNonconserved.setState(true);
1009 displayNonconserved.addActionListener(new ActionListener()
1011 public void actionPerformed(ActionEvent e)
1013 showNonconserved_actionPerformed();
1016 editMenu.setText("Edit");
1018 cut.addActionListener(new ActionListener()
1020 public void actionPerformed(ActionEvent e)
1022 cut_actionPerformed();
1025 upperCase.setText("To Upper Case");
1026 upperCase.addActionListener(new ActionListener()
1028 public void actionPerformed(ActionEvent e)
1033 copy.setText("Copy");
1034 copy.addActionListener(new ActionListener()
1036 public void actionPerformed(ActionEvent e)
1038 copy_actionPerformed();
1041 lowerCase.setText("To Lower Case");
1042 lowerCase.addActionListener(new ActionListener()
1044 public void actionPerformed(ActionEvent e)
1049 toggle.setText("Toggle Case");
1050 toggle.addActionListener(new ActionListener()
1052 public void actionPerformed(ActionEvent e)
1057 pdbMenu.setText("Associate Structure with Sequence");
1058 pdbFromFile.setText("From File");
1059 pdbFromFile.addActionListener(new ActionListener()
1061 public void actionPerformed(ActionEvent e)
1064 pdbFromFile_actionPerformed();
1065 } catch (ExceptionFileFormatOrSyntax e1) {
1066 // TODO Auto-generated catch block
1067 e1.printStackTrace();
1068 } catch (ParserConfigurationException e1) {
1069 // TODO Auto-generated catch block
1070 e1.printStackTrace();
1071 } catch (SAXException e1) {
1072 // TODO Auto-generated catch block
1073 e1.printStackTrace();
1074 } catch (ExceptionPermissionDenied e1) {
1075 // TODO Auto-generated catch block
1076 e1.printStackTrace();
1077 } catch (ExceptionLoadingFailed e1) {
1078 // TODO Auto-generated catch block
1079 e1.printStackTrace();
1080 } catch (InterruptedException e1) {
1081 // TODO Auto-generated catch block
1082 e1.printStackTrace();
1083 } catch (ExceptionUnmatchedClosingParentheses e1) {
1084 // TODO Auto-generated catch block
1085 e1.printStackTrace();
1089 enterPDB.setText("Enter PDB Id");
1090 enterPDB.addActionListener(new ActionListener()
1092 public void actionPerformed(ActionEvent e)
1094 enterPDB_actionPerformed();
1097 discoverPDB.setText("Discover PDB ids");
1098 discoverPDB.addActionListener(new ActionListener()
1100 public void actionPerformed(ActionEvent e)
1102 discoverPDB_actionPerformed();
1105 outputMenu.setText("Output to Textbox...");
1106 sequenceFeature.setText("Create Sequence Feature");
1107 sequenceFeature.addActionListener(new ActionListener()
1109 public void actionPerformed(ActionEvent e)
1111 sequenceFeature_actionPerformed();
1114 textColour.setText("Text Colour");
1115 textColour.addActionListener(new ActionListener()
1117 public void actionPerformed(ActionEvent e)
1119 textColour_actionPerformed();
1122 jMenu1.setText("Group");
1123 structureMenu.setText("Structure");
1124 viewStructureMenu.setText("View Structure");
1125 // colStructureMenu.setText("Colour By Structure");
1126 editSequence.setText("Edit Sequence...");
1127 editSequence.addActionListener(new ActionListener()
1129 public void actionPerformed(ActionEvent actionEvent)
1131 editSequence_actionPerformed(actionEvent);
1136 * annotationMenuItem.setText("By Annotation");
1137 * annotationMenuItem.addActionListener(new ActionListener() { public void
1138 * actionPerformed(ActionEvent actionEvent) {
1139 * annotationMenuItem_actionPerformed(actionEvent); } });
1141 groupMenu.add(sequenceSelDetails);
1144 this.add(structureMenu);
1145 groupMenu.add(editMenu);
1146 groupMenu.add(outputMenu);
1147 groupMenu.add(sequenceFeature);
1148 groupMenu.add(jMenu1);
1149 sequenceMenu.add(sequenceName);
1150 sequenceMenu.add(sequenceDetails);
1151 colourMenu.add(textColour);
1152 colourMenu.add(noColourmenuItem);
1153 colourMenu.add(clustalColour);
1154 colourMenu.add(BLOSUM62Colour);
1155 colourMenu.add(PIDColour);
1156 colourMenu.add(zappoColour);
1157 colourMenu.add(taylorColour);
1158 colourMenu.add(hydrophobicityColour);
1159 colourMenu.add(helixColour);
1160 colourMenu.add(strandColour);
1161 colourMenu.add(turnColour);
1162 colourMenu.add(buriedColour);
1163 colourMenu.add(nucleotideMenuItem);
1164 if (ap.getAlignment().isNucleotide()) {
1165 // JBPNote - commented since the colourscheme isn't functional
1166 // colourMenu.add(RNAInteractionColour);
1167 colourMenu.add(purinePyrimidineColour);
1169 // colourMenu.add(covariationColour);
1170 colourMenu.add(userDefinedColour);
1172 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
1174 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
1175 .getUserColourSchemes().keys();
1177 while (userColours.hasMoreElements())
1179 JMenuItem item = new JMenuItem(userColours.nextElement().toString());
1180 item.addActionListener(new ActionListener()
1182 public void actionPerformed(ActionEvent evt)
1184 userDefinedColour_actionPerformed(evt);
1187 colourMenu.add(item);
1191 colourMenu.addSeparator();
1192 colourMenu.add(abovePIDColour);
1193 colourMenu.add(conservationMenuItem);
1194 // colourMenu.add(annotationMenuItem);
1197 editMenu.add(editSequence);
1198 editMenu.add(upperCase);
1199 editMenu.add(lowerCase);
1200 editMenu.add(toggle);
1201 pdbMenu.add(pdbFromFile);
1202 pdbMenu.add(enterPDB);
1203 pdbMenu.add(discoverPDB);
1204 jMenu1.add(groupName);
1205 jMenu1.add(unGroupMenuItem);
1206 jMenu1.add(colourMenu);
1207 jMenu1.add(showBoxes);
1208 jMenu1.add(showText);
1209 jMenu1.add(showColourText);
1210 jMenu1.add(outline);
1211 jMenu1.add(displayNonconserved);
1212 structureMenu.add(pdbMenu);
1213 structureMenu.add(viewStructureMenu);
1214 // structureMenu.add(colStructureMenu);
1215 noColourmenuItem.setText("None");
1216 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
1218 public void actionPerformed(ActionEvent e)
1220 noColourmenuItem_actionPerformed();
1224 clustalColour.setText("Clustalx colours");
1225 clustalColour.addActionListener(new java.awt.event.ActionListener()
1227 public void actionPerformed(ActionEvent e)
1229 clustalColour_actionPerformed();
1232 zappoColour.setText("Zappo");
1233 zappoColour.addActionListener(new java.awt.event.ActionListener()
1235 public void actionPerformed(ActionEvent e)
1237 zappoColour_actionPerformed();
1240 taylorColour.setText("Taylor");
1241 taylorColour.addActionListener(new java.awt.event.ActionListener()
1243 public void actionPerformed(ActionEvent e)
1245 taylorColour_actionPerformed();
1248 hydrophobicityColour.setText("Hydrophobicity");
1249 hydrophobicityColour
1250 .addActionListener(new java.awt.event.ActionListener()
1252 public void actionPerformed(ActionEvent e)
1254 hydrophobicityColour_actionPerformed();
1257 helixColour.setText("Helix propensity");
1258 helixColour.addActionListener(new java.awt.event.ActionListener()
1260 public void actionPerformed(ActionEvent e)
1262 helixColour_actionPerformed();
1265 strandColour.setText("Strand propensity");
1266 strandColour.addActionListener(new java.awt.event.ActionListener()
1268 public void actionPerformed(ActionEvent e)
1270 strandColour_actionPerformed();
1273 turnColour.setText("Turn propensity");
1274 turnColour.addActionListener(new java.awt.event.ActionListener()
1276 public void actionPerformed(ActionEvent e)
1278 turnColour_actionPerformed();
1281 buriedColour.setText("Buried Index");
1282 buriedColour.addActionListener(new java.awt.event.ActionListener()
1284 public void actionPerformed(ActionEvent e)
1286 buriedColour_actionPerformed();
1289 abovePIDColour.setText("Above % Identity");
1290 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
1292 public void actionPerformed(ActionEvent e)
1294 abovePIDColour_actionPerformed();
1297 userDefinedColour.setText("User Defined...");
1298 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
1300 public void actionPerformed(ActionEvent e)
1302 userDefinedColour_actionPerformed(e);
1305 PIDColour.setText("Percentage Identity");
1306 PIDColour.addActionListener(new java.awt.event.ActionListener()
1308 public void actionPerformed(ActionEvent e)
1310 PIDColour_actionPerformed();
1313 BLOSUM62Colour.setText("BLOSUM62");
1314 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
1316 public void actionPerformed(ActionEvent e)
1318 BLOSUM62Colour_actionPerformed();
1321 purinePyrimidineColour.setText("Purine/Pyrimidine");
1322 purinePyrimidineColour
1323 .addActionListener(new java.awt.event.ActionListener()
1325 public void actionPerformed(ActionEvent e)
1327 purinePyrimidineColour_actionPerformed();
1333 * covariationColour.addActionListener(new java.awt.event.ActionListener() {
1334 * public void actionPerformed(ActionEvent e) {
1335 * covariationColour_actionPerformed(); } });
1338 conservationMenuItem.setText("Conservation");
1339 conservationMenuItem
1340 .addActionListener(new java.awt.event.ActionListener()
1342 public void actionPerformed(ActionEvent e)
1344 conservationMenuItem_actionPerformed();
1349 protected void sequenceSelectionDetails_actionPerformed()
1351 createSequenceDetailsReport(ap.av.getSequenceSelection());
1354 protected void sequenceDetails_actionPerformed()
1356 createSequenceDetailsReport(new SequenceI[]
1360 public void createSequenceDetailsReport(SequenceI[] sequences)
1362 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1363 StringBuffer contents = new StringBuffer();
1364 for (SequenceI seq : sequences)
1366 contents.append("<p><h2>Annotation for " + seq.getDisplayId(true)
1368 new SequenceAnnotationReport(null)
1369 .createSequenceAnnotationReport(
1375 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
1377 contents.append("</p>");
1379 cap.setText("<html>" + contents.toString() + "</html>");
1381 Desktop.instance.addInternalFrame(cap, "Sequence Details for "
1382 + (sequences.length == 1 ? sequences[0].getDisplayId(true)
1383 : "Selection"), 500, 400);
1387 protected void showNonconserved_actionPerformed()
1389 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1394 * call to refresh view after settings change
1398 ap.updateAnnotation();
1399 ap.paintAlignment(true);
1401 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1410 protected void clustalColour_actionPerformed()
1412 SequenceGroup sg = getGroup();
1413 sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
1423 protected void zappoColour_actionPerformed()
1425 getGroup().cs = new ZappoColourScheme();
1435 protected void taylorColour_actionPerformed()
1437 getGroup().cs = new TaylorColourScheme();
1447 protected void hydrophobicityColour_actionPerformed()
1449 getGroup().cs = new HydrophobicColourScheme();
1459 protected void helixColour_actionPerformed()
1461 getGroup().cs = new HelixColourScheme();
1471 protected void strandColour_actionPerformed()
1473 getGroup().cs = new StrandColourScheme();
1483 protected void turnColour_actionPerformed()
1485 getGroup().cs = new TurnColourScheme();
1495 protected void buriedColour_actionPerformed()
1497 getGroup().cs = new BuriedColourScheme();
1507 public void nucleotideMenuItem_actionPerformed()
1509 getGroup().cs = new NucleotideColourScheme();
1513 protected void purinePyrimidineColour_actionPerformed()
1515 getGroup().cs = new PurinePyrimidineColourScheme();
1521 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1522 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1530 protected void abovePIDColour_actionPerformed()
1532 SequenceGroup sg = getGroup();
1538 if (abovePIDColour.isSelected())
1540 sg.cs.setConsensus(AAFrequency.calculate(
1541 sg.getSequences(ap.av.getHiddenRepSequences()),
1542 sg.getStartRes(), sg.getEndRes() + 1));
1544 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1547 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
1549 SliderPanel.showPIDSlider();
1552 // remove PIDColouring
1554 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
1566 protected void userDefinedColour_actionPerformed(ActionEvent e)
1568 SequenceGroup sg = getGroup();
1570 if (e.getActionCommand().equals("User Defined..."))
1572 new UserDefinedColours(ap, sg);
1576 UserColourScheme udc = (UserColourScheme) UserDefinedColours
1577 .getUserColourSchemes().get(e.getActionCommand());
1590 protected void PIDColour_actionPerformed()
1592 SequenceGroup sg = getGroup();
1593 sg.cs = new PIDColourScheme();
1594 sg.cs.setConsensus(AAFrequency.calculate(
1595 sg.getSequences(ap.av.getHiddenRepSequences()),
1596 sg.getStartRes(), sg.getEndRes() + 1));
1606 protected void BLOSUM62Colour_actionPerformed()
1608 SequenceGroup sg = getGroup();
1610 sg.cs = new Blosum62ColourScheme();
1612 sg.cs.setConsensus(AAFrequency.calculate(
1613 sg.getSequences(ap.av.getHiddenRepSequences()),
1614 sg.getStartRes(), sg.getEndRes() + 1));
1625 protected void noColourmenuItem_actionPerformed()
1627 getGroup().cs = null;
1637 protected void conservationMenuItem_actionPerformed()
1639 SequenceGroup sg = getGroup();
1645 if (conservationMenuItem.isSelected())
1647 Conservation c = new Conservation("Group",
1648 ResidueProperties.propHash, 3, sg.getSequences(ap.av
1649 .getHiddenRepSequences()), sg.getStartRes(),
1650 sg.getEndRes() + 1);
1653 c.verdict(false, ap.av.getConsPercGaps());
1655 sg.cs.setConservation(c);
1657 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1658 SliderPanel.showConservationSlider();
1661 // remove ConservationColouring
1663 sg.cs.setConservation(null);
1669 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1671 SequenceGroup sg = getGroup();
1677 AnnotationColourGradient acg = new AnnotationColourGradient(
1678 sequence.getAnnotation()[0], null,
1679 AnnotationColourGradient.NO_THRESHOLD);
1681 acg.predefinedColours = true;
1693 protected void groupName_actionPerformed()
1696 SequenceGroup sg = getGroup();
1697 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1698 sg.getDescription(), " Group Name ",
1699 "Group Description ", "Edit Group Name/Description",
1707 sg.setName(dialog.getName());
1708 sg.setDescription(dialog.getDescription());
1713 * Get selection group - adding it to the alignment if necessary.
1715 * @return sequence group to operate on
1717 SequenceGroup getGroup()
1719 SequenceGroup sg = ap.av.getSelectionGroup();
1720 // this method won't add a new group if it already exists
1723 ap.av.getAlignment().addGroup(sg);
1735 void sequenceName_actionPerformed()
1737 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1738 sequence.getDescription(), " Sequence Name ",
1739 "Sequence Description ", "Edit Sequence Name/Description",
1747 if (dialog.getName() != null)
1749 if (dialog.getName().indexOf(" ") > -1)
1751 JOptionPane.showMessageDialog(ap,
1752 "Spaces have been converted to \"_\"",
1753 "No spaces allowed in Sequence Name",
1754 JOptionPane.WARNING_MESSAGE);
1757 sequence.setName(dialog.getName().replace(' ', '_'));
1758 ap.paintAlignment(false);
1761 sequence.setDescription(dialog.getDescription());
1763 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1774 void unGroupMenuItem_actionPerformed()
1776 SequenceGroup sg = ap.av.getSelectionGroup();
1777 ap.av.getAlignment().deleteGroup(sg);
1778 ap.av.setSelectionGroup(null);
1788 protected void outline_actionPerformed()
1790 SequenceGroup sg = getGroup();
1791 Color col = JColorChooser.showDialog(this, "Select Outline Colour",
1796 sg.setOutlineColour(col);
1808 public void showBoxes_actionPerformed()
1810 getGroup().setDisplayBoxes(showBoxes.isSelected());
1820 public void showText_actionPerformed()
1822 getGroup().setDisplayText(showText.isSelected());
1832 public void showColourText_actionPerformed()
1834 getGroup().setColourText(showColourText.isSelected());
1838 public void showLink(String url)
1842 jalview.util.BrowserLauncher.openURL(url);
1843 } catch (Exception ex)
1846 .showInternalMessageDialog(
1848 "Unixers: Couldn't find default web browser."
1849 + "\nAdd the full path to your browser in Preferences.",
1850 "Web browser not found", JOptionPane.WARNING_MESSAGE);
1852 ex.printStackTrace();
1856 void hideSequences(boolean representGroup)
1858 SequenceGroup sg = ap.av.getSelectionGroup();
1859 if (sg == null || sg.getSize() < 1)
1861 ap.av.hideSequence(new SequenceI[]
1866 ap.av.setSelectionGroup(null);
1870 ap.av.hideRepSequences(sequence, sg);
1875 int gsize = sg.getSize();
1878 hseqs = new SequenceI[gsize];
1881 for (int i = 0; i < gsize; i++)
1883 hseqs[index++] = sg.getSequenceAt(i);
1886 ap.av.hideSequence(hseqs);
1887 // refresh(); TODO: ? needed ?
1888 ap.av.sendSelection();
1891 public void copy_actionPerformed()
1893 ap.alignFrame.copy_actionPerformed(null);
1896 public void cut_actionPerformed()
1898 ap.alignFrame.cut_actionPerformed(null);
1901 void changeCase(ActionEvent e)
1903 Object source = e.getSource();
1904 SequenceGroup sg = ap.av.getSelectionGroup();
1908 int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
1909 sg.getEndRes() + 1);
1914 if (source == toggle)
1916 description = "Toggle Case";
1917 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1919 else if (source == upperCase)
1921 description = "To Upper Case";
1922 caseChange = ChangeCaseCommand.TO_UPPER;
1926 description = "To Lower Case";
1927 caseChange = ChangeCaseCommand.TO_LOWER;
1930 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1931 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1932 startEnd, caseChange);
1934 ap.alignFrame.addHistoryItem(caseCommand);
1936 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1942 public void outputText_actionPerformed(ActionEvent e)
1944 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1945 cap.setForInput(null);
1946 Desktop.addInternalFrame(cap,
1947 "Alignment output - " + e.getActionCommand(), 600, 500);
1949 String[] omitHidden = null;
1951 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1952 // or we simply trust the user wants
1953 // wysiwig behaviour
1954 SequenceGroup sg = ap.av.getSelectionGroup();
1955 ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection());
1956 omitHidden = ap.av.getViewAsString(true);
1957 Alignment oal = new Alignment(ap.av.getSequenceSelection());
1958 AlignmentAnnotation[] nala = ap.av.getAlignment()
1959 .getAlignmentAnnotation();
1962 for (int i = 0; i < nala.length; i++)
1964 AlignmentAnnotation na = nala[i];
1965 oal.addAnnotation(na);
1968 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
1969 oal, omitHidden, csel, sg));
1973 public void pdbFromFile_actionPerformed() throws IOException
1975 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
1976 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
1977 chooser.setFileView(new jalview.io.JalviewFileView());
1978 chooser.setDialogTitle("Select a PDB file for "
1979 + sequence.getDisplayId(false));
1980 chooser.setToolTipText("Load a PDB file and associate it with sequence '"
1981 + sequence.getDisplayId(false) + "'");
1983 int value = chooser.showOpenDialog(null);
1985 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
1987 String choice = chooser.getSelectedFile().getPath();
1988 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
1989 new AssociatePdbFileWithSeq().associatePdbWithSeq(choice,
1990 jalview.io.AppletFormatAdapter.FILE, sequence, true);
1995 public void enterPDB_actionPerformed()
1997 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
1998 "Enter PDB Id", "Enter PDB Id", JOptionPane.QUESTION_MESSAGE);
2000 if (id != null && id.length() > 0)
2002 PDBEntry entry = new PDBEntry();
2003 entry.setId(id.toUpperCase());
2004 sequence.getDatasetSequence().addPDBId(entry);
2008 public void discoverPDB_actionPerformed()
2011 final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
2013 : ap.av.getSequenceSelection());
2014 Thread discpdb = new Thread(new Runnable()
2019 new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
2020 .fetchDBRefs(false);
2027 public void sequenceFeature_actionPerformed()
2029 SequenceGroup sg = ap.av.getSelectionGroup();
2035 int rsize = 0, gSize = sg.getSize();
2036 SequenceI[] rseqs, seqs = new SequenceI[gSize];
2037 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
2039 for (int i = 0; i < gSize; i++)
2041 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
2042 int end = sg.findEndRes(sg.getSequenceAt(i));
2045 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
2046 features[rsize] = new SequenceFeature(null, null, null, start, end,
2051 rseqs = new SequenceI[rsize];
2052 tfeatures = new SequenceFeature[rsize];
2053 System.arraycopy(seqs, 0, rseqs, 0, rsize);
2054 System.arraycopy(features, 0, tfeatures, 0, rsize);
2055 features = tfeatures;
2057 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
2058 features, true, ap))
2060 ap.alignFrame.setShowSeqFeatures(true);
2061 ap.highlightSearchResults(null);
2065 public void textColour_actionPerformed()
2067 SequenceGroup sg = getGroup();
2070 new TextColourChooser().chooseColour(ap, sg);
2074 public void colourByStructure(String pdbid)
2076 Annotation[] anots = ap.av.getStructureSelectionManager()
2077 .colourSequenceFromStructure(sequence, pdbid);
2079 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
2080 "Coloured by " + pdbid, anots);
2082 ap.av.getAlignment().addAnnotation(an);
2083 an.createSequenceMapping(sequence, 0, true);
2084 // an.adjustForAlignment();
2085 ap.av.getAlignment().setAnnotationIndex(an, 0);
2087 ap.adjustAnnotationHeight();
2089 sequence.addAlignmentAnnotation(an);
2093 public void editSequence_actionPerformed(ActionEvent actionEvent)
2095 SequenceGroup sg = ap.av.getSelectionGroup();
2099 if (sequence == null)
2100 sequence = (Sequence) sg.getSequenceAt(0);
2102 EditNameDialog dialog = new EditNameDialog(
2103 sequence.getSequenceAsString(sg.getStartRes(),
2104 sg.getEndRes() + 1), null, "Edit Sequence ", null,
2105 "Edit Sequence", ap.alignFrame);
2109 EditCommand editCommand = new EditCommand("Edit Sequences",
2110 EditCommand.REPLACE, dialog.getName().replace(' ',
2111 ap.av.getGapCharacter()),
2112 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2113 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
2115 ap.alignFrame.addHistoryItem(editCommand);
2117 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()