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);
473 else if (sg.cs instanceof RNAInteractionColourScheme)
475 RNAInteractionColour.setSelected(true);
478 * else if (sg.cs instanceof CovariationColourScheme) {
479 * covariationColour.setSelected(true); }
483 noColourmenuItem.setSelected(true);
486 if (sg.cs != null && sg.cs.conservationApplied())
488 conservationMenuItem.setSelected(true);
490 displayNonconserved.setSelected(sg.getShowNonconserved());
491 showText.setSelected(sg.getDisplayText());
492 showColourText.setSelected(sg.getColourText());
493 showBoxes.setSelected(sg.getDisplayBoxes());
494 // add any groupURLs to the groupURL submenu and make it visible
495 if (groupLinks != null && groupLinks.size() > 0)
497 buildGroupURLMenu(sg, groupLinks);
499 // Add a 'show all structures' for the current selection
500 Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>();
501 SequenceI sqass = null;
502 for (SequenceI sq : ap.av.getSequenceSelection())
504 Vector<PDBEntry> pes = (Vector<PDBEntry>) sq.getDatasetSequence()
508 for (PDBEntry pe : pes)
510 pdbe.put(pe.getId(), pe);
520 final PDBEntry[] pe = pdbe.values().toArray(
521 new PDBEntry[pdbe.size()]);
522 final JMenuItem gpdbview;
523 if (pdbe.size() == 1)
525 structureMenu.add(gpdbview = new JMenuItem("View structure for "
526 + sqass.getDisplayId(false)));
530 structureMenu.add(gpdbview = new JMenuItem("View all "
531 + pdbe.size() + " structures."));
533 gpdbview.setToolTipText("Open a new Jmol view with all structures associated with the current selection and superimpose them using the alignment.");
534 gpdbview.addActionListener(new ActionListener()
538 public void actionPerformed(ActionEvent e)
540 new AppJmol(ap, pe, ap.av.collateForPDB(pe));
547 groupMenu.setVisible(false);
548 editMenu.setVisible(false);
551 if (!ap.av.getAlignment().getGroups().contains(sg))
553 unGroupMenuItem.setVisible(false);
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();
967 outline.setText("Border colour");
968 outline.addActionListener(new java.awt.event.ActionListener()
970 public void actionPerformed(ActionEvent e)
972 outline_actionPerformed();
975 nucleotideMenuItem.setText("Nucleotide");
976 nucleotideMenuItem.addActionListener(new ActionListener()
978 public void actionPerformed(ActionEvent e)
980 nucleotideMenuItem_actionPerformed();
983 colourMenu.setText("Group Colour");
984 showBoxes.setText("Boxes");
985 showBoxes.setState(true);
986 showBoxes.addActionListener(new ActionListener()
988 public void actionPerformed(ActionEvent e)
990 showBoxes_actionPerformed();
993 showText.setText("Text");
994 showText.setState(true);
995 showText.addActionListener(new ActionListener()
997 public void actionPerformed(ActionEvent e)
999 showText_actionPerformed();
1002 showColourText.setText("Colour Text");
1003 showColourText.addActionListener(new ActionListener()
1005 public void actionPerformed(ActionEvent e)
1007 showColourText_actionPerformed();
1010 displayNonconserved.setText("Show Nonconserved");
1011 displayNonconserved.setState(true);
1012 displayNonconserved.addActionListener(new ActionListener()
1014 public void actionPerformed(ActionEvent e)
1016 showNonconserved_actionPerformed();
1019 editMenu.setText("Edit");
1021 cut.addActionListener(new ActionListener()
1023 public void actionPerformed(ActionEvent e)
1025 cut_actionPerformed();
1028 upperCase.setText("To Upper Case");
1029 upperCase.addActionListener(new ActionListener()
1031 public void actionPerformed(ActionEvent e)
1036 copy.setText("Copy");
1037 copy.addActionListener(new ActionListener()
1039 public void actionPerformed(ActionEvent e)
1041 copy_actionPerformed();
1044 lowerCase.setText("To Lower Case");
1045 lowerCase.addActionListener(new ActionListener()
1047 public void actionPerformed(ActionEvent e)
1052 toggle.setText("Toggle Case");
1053 toggle.addActionListener(new ActionListener()
1055 public void actionPerformed(ActionEvent e)
1060 pdbMenu.setText("Associate Structure with Sequence");
1061 pdbFromFile.setText("From File");
1062 pdbFromFile.addActionListener(new ActionListener()
1064 public void actionPerformed(ActionEvent e)
1067 pdbFromFile_actionPerformed();
1068 } catch (ExceptionFileFormatOrSyntax e1) {
1069 // TODO Auto-generated catch block
1070 e1.printStackTrace();
1071 } catch (ParserConfigurationException e1) {
1072 // TODO Auto-generated catch block
1073 e1.printStackTrace();
1074 } catch (SAXException e1) {
1075 // TODO Auto-generated catch block
1076 e1.printStackTrace();
1077 } catch (ExceptionPermissionDenied e1) {
1078 // TODO Auto-generated catch block
1079 e1.printStackTrace();
1080 } catch (ExceptionLoadingFailed e1) {
1081 // TODO Auto-generated catch block
1082 e1.printStackTrace();
1083 } catch (InterruptedException e1) {
1084 // TODO Auto-generated catch block
1085 e1.printStackTrace();
1086 } catch (ExceptionUnmatchedClosingParentheses e1) {
1087 // TODO Auto-generated catch block
1088 e1.printStackTrace();
1092 enterPDB.setText("Enter PDB Id");
1093 enterPDB.addActionListener(new ActionListener()
1095 public void actionPerformed(ActionEvent e)
1097 enterPDB_actionPerformed();
1100 discoverPDB.setText("Discover PDB ids");
1101 discoverPDB.addActionListener(new ActionListener()
1103 public void actionPerformed(ActionEvent e)
1105 discoverPDB_actionPerformed();
1108 outputMenu.setText("Output to Textbox...");
1109 sequenceFeature.setText("Create Sequence Feature");
1110 sequenceFeature.addActionListener(new ActionListener()
1112 public void actionPerformed(ActionEvent e)
1114 sequenceFeature_actionPerformed();
1117 textColour.setText("Text Colour");
1118 textColour.addActionListener(new ActionListener()
1120 public void actionPerformed(ActionEvent e)
1122 textColour_actionPerformed();
1125 jMenu1.setText("Group");
1126 structureMenu.setText("Structure");
1127 viewStructureMenu.setText("View Structure");
1128 // colStructureMenu.setText("Colour By Structure");
1129 editSequence.setText("Edit Sequence...");
1130 editSequence.addActionListener(new ActionListener()
1132 public void actionPerformed(ActionEvent actionEvent)
1134 editSequence_actionPerformed(actionEvent);
1139 * annotationMenuItem.setText("By Annotation");
1140 * annotationMenuItem.addActionListener(new ActionListener() { public void
1141 * actionPerformed(ActionEvent actionEvent) {
1142 * annotationMenuItem_actionPerformed(actionEvent); } });
1144 groupMenu.add(sequenceSelDetails);
1147 this.add(structureMenu);
1148 groupMenu.add(editMenu);
1149 groupMenu.add(outputMenu);
1150 groupMenu.add(sequenceFeature);
1151 groupMenu.add(jMenu1);
1152 sequenceMenu.add(sequenceName);
1153 sequenceMenu.add(sequenceDetails);
1154 colourMenu.add(textColour);
1155 colourMenu.add(noColourmenuItem);
1156 colourMenu.add(clustalColour);
1157 colourMenu.add(BLOSUM62Colour);
1158 colourMenu.add(PIDColour);
1159 colourMenu.add(zappoColour);
1160 colourMenu.add(taylorColour);
1161 colourMenu.add(hydrophobicityColour);
1162 colourMenu.add(helixColour);
1163 colourMenu.add(strandColour);
1164 colourMenu.add(turnColour);
1165 colourMenu.add(buriedColour);
1166 colourMenu.add(nucleotideMenuItem);
1167 if (ap.getAlignment().isNucleotide()) {
1168 colourMenu.add(RNAInteractionColour);
1169 colourMenu.add(purinePyrimidineColour);
1171 // colourMenu.add(covariationColour);
1172 colourMenu.add(userDefinedColour);
1174 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
1176 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
1177 .getUserColourSchemes().keys();
1179 while (userColours.hasMoreElements())
1181 JMenuItem item = new JMenuItem(userColours.nextElement().toString());
1182 item.addActionListener(new ActionListener()
1184 public void actionPerformed(ActionEvent evt)
1186 userDefinedColour_actionPerformed(evt);
1189 colourMenu.add(item);
1193 colourMenu.addSeparator();
1194 colourMenu.add(abovePIDColour);
1195 colourMenu.add(conservationMenuItem);
1196 // colourMenu.add(annotationMenuItem);
1199 editMenu.add(editSequence);
1200 editMenu.add(upperCase);
1201 editMenu.add(lowerCase);
1202 editMenu.add(toggle);
1203 pdbMenu.add(pdbFromFile);
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();
1333 RNAInteractionColour.setText("RNA Interaction type");
1334 RNAInteractionColour
1335 .addActionListener(new java.awt.event.ActionListener()
1337 public void actionPerformed(ActionEvent e)
1339 RNAInteractionColour_actionPerformed();
1343 * covariationColour.addActionListener(new java.awt.event.ActionListener() {
1344 * public void actionPerformed(ActionEvent e) {
1345 * covariationColour_actionPerformed(); } });
1348 conservationMenuItem.setText("Conservation");
1349 conservationMenuItem
1350 .addActionListener(new java.awt.event.ActionListener()
1352 public void actionPerformed(ActionEvent e)
1354 conservationMenuItem_actionPerformed();
1359 protected void sequenceSelectionDetails_actionPerformed()
1361 createSequenceDetailsReport(ap.av.getSequenceSelection());
1364 protected void sequenceDetails_actionPerformed()
1366 createSequenceDetailsReport(new SequenceI[]
1370 public void createSequenceDetailsReport(SequenceI[] sequences)
1372 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1373 StringBuffer contents = new StringBuffer();
1374 for (SequenceI seq : sequences)
1376 contents.append("<p><h2>Annotation for " + seq.getDisplayId(true)
1378 new SequenceAnnotationReport(null)
1379 .createSequenceAnnotationReport(
1385 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
1387 contents.append("</p>");
1389 cap.setText("<html>" + contents.toString() + "</html>");
1391 Desktop.instance.addInternalFrame(cap, "Sequence Details for "
1392 + (sequences.length == 1 ? sequences[0].getDisplayId(true)
1393 : "Selection"), 500, 400);
1397 protected void showNonconserved_actionPerformed()
1399 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1404 * call to refresh view after settings change
1408 ap.updateAnnotation();
1409 ap.paintAlignment(true);
1411 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1420 protected void clustalColour_actionPerformed()
1422 SequenceGroup sg = getGroup();
1423 sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
1433 protected void zappoColour_actionPerformed()
1435 getGroup().cs = new ZappoColourScheme();
1445 protected void taylorColour_actionPerformed()
1447 getGroup().cs = new TaylorColourScheme();
1457 protected void hydrophobicityColour_actionPerformed()
1459 getGroup().cs = new HydrophobicColourScheme();
1469 protected void helixColour_actionPerformed()
1471 getGroup().cs = new HelixColourScheme();
1481 protected void strandColour_actionPerformed()
1483 getGroup().cs = new StrandColourScheme();
1493 protected void turnColour_actionPerformed()
1495 getGroup().cs = new TurnColourScheme();
1505 protected void buriedColour_actionPerformed()
1507 getGroup().cs = new BuriedColourScheme();
1517 public void nucleotideMenuItem_actionPerformed()
1519 getGroup().cs = new NucleotideColourScheme();
1523 protected void purinePyrimidineColour_actionPerformed()
1525 getGroup().cs = new PurinePyrimidineColourScheme();
1529 protected void RNAInteractionColour_actionPerformed()
1531 getGroup().cs = new RNAInteractionColourScheme();
1535 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1536 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1544 protected void abovePIDColour_actionPerformed()
1546 SequenceGroup sg = getGroup();
1552 if (abovePIDColour.isSelected())
1554 sg.cs.setConsensus(AAFrequency.calculate(
1555 sg.getSequences(ap.av.getHiddenRepSequences()),
1556 sg.getStartRes(), sg.getEndRes() + 1));
1558 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1561 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
1563 SliderPanel.showPIDSlider();
1566 // remove PIDColouring
1568 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
1580 protected void userDefinedColour_actionPerformed(ActionEvent e)
1582 SequenceGroup sg = getGroup();
1584 if (e.getActionCommand().equals("User Defined..."))
1586 new UserDefinedColours(ap, sg);
1590 UserColourScheme udc = (UserColourScheme) UserDefinedColours
1591 .getUserColourSchemes().get(e.getActionCommand());
1604 protected void PIDColour_actionPerformed()
1606 SequenceGroup sg = getGroup();
1607 sg.cs = new PIDColourScheme();
1608 sg.cs.setConsensus(AAFrequency.calculate(
1609 sg.getSequences(ap.av.getHiddenRepSequences()),
1610 sg.getStartRes(), sg.getEndRes() + 1));
1620 protected void BLOSUM62Colour_actionPerformed()
1622 SequenceGroup sg = getGroup();
1624 sg.cs = new Blosum62ColourScheme();
1626 sg.cs.setConsensus(AAFrequency.calculate(
1627 sg.getSequences(ap.av.getHiddenRepSequences()),
1628 sg.getStartRes(), sg.getEndRes() + 1));
1639 protected void noColourmenuItem_actionPerformed()
1641 getGroup().cs = null;
1651 protected void conservationMenuItem_actionPerformed()
1653 SequenceGroup sg = getGroup();
1659 if (conservationMenuItem.isSelected())
1661 Conservation c = new Conservation("Group",
1662 ResidueProperties.propHash, 3, sg.getSequences(ap.av
1663 .getHiddenRepSequences()), sg.getStartRes(),
1664 sg.getEndRes() + 1);
1667 c.verdict(false, ap.av.getConsPercGaps());
1669 sg.cs.setConservation(c);
1671 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1672 SliderPanel.showConservationSlider();
1675 // remove ConservationColouring
1677 sg.cs.setConservation(null);
1683 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1685 SequenceGroup sg = getGroup();
1691 AnnotationColourGradient acg = new AnnotationColourGradient(
1692 sequence.getAnnotation()[0], null,
1693 AnnotationColourGradient.NO_THRESHOLD);
1695 acg.predefinedColours = true;
1707 protected void groupName_actionPerformed()
1710 SequenceGroup sg = getGroup();
1711 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1712 sg.getDescription(), " Group Name ",
1713 "Group Description ", "Edit Group Name/Description",
1721 sg.setName(dialog.getName());
1722 sg.setDescription(dialog.getDescription());
1727 * Get selection group - adding it to the alignment if necessary.
1729 * @return sequence group to operate on
1731 SequenceGroup getGroup()
1733 SequenceGroup sg = ap.av.getSelectionGroup();
1734 // this method won't add a new group if it already exists
1737 ap.av.getAlignment().addGroup(sg);
1749 void sequenceName_actionPerformed()
1751 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1752 sequence.getDescription(), " Sequence Name ",
1753 "Sequence Description ", "Edit Sequence Name/Description",
1761 if (dialog.getName() != null)
1763 if (dialog.getName().indexOf(" ") > -1)
1765 JOptionPane.showMessageDialog(ap,
1766 "Spaces have been converted to \"_\"",
1767 "No spaces allowed in Sequence Name",
1768 JOptionPane.WARNING_MESSAGE);
1771 sequence.setName(dialog.getName().replace(' ', '_'));
1772 ap.paintAlignment(false);
1775 sequence.setDescription(dialog.getDescription());
1777 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1788 void unGroupMenuItem_actionPerformed()
1790 SequenceGroup sg = ap.av.getSelectionGroup();
1791 ap.av.getAlignment().deleteGroup(sg);
1792 ap.av.setSelectionGroup(null);
1802 protected void outline_actionPerformed()
1804 SequenceGroup sg = getGroup();
1805 Color col = JColorChooser.showDialog(this, "Select Outline Colour",
1810 sg.setOutlineColour(col);
1822 public void showBoxes_actionPerformed()
1824 getGroup().setDisplayBoxes(showBoxes.isSelected());
1834 public void showText_actionPerformed()
1836 getGroup().setDisplayText(showText.isSelected());
1846 public void showColourText_actionPerformed()
1848 getGroup().setColourText(showColourText.isSelected());
1852 public void showLink(String url)
1856 jalview.util.BrowserLauncher.openURL(url);
1857 } catch (Exception ex)
1860 .showInternalMessageDialog(
1862 "Unixers: Couldn't find default web browser."
1863 + "\nAdd the full path to your browser in Preferences.",
1864 "Web browser not found", JOptionPane.WARNING_MESSAGE);
1866 ex.printStackTrace();
1870 void hideSequences(boolean representGroup)
1872 SequenceGroup sg = ap.av.getSelectionGroup();
1873 if (sg == null || sg.getSize() < 1)
1875 ap.av.hideSequence(new SequenceI[]
1880 ap.av.setSelectionGroup(null);
1884 ap.av.hideRepSequences(sequence, sg);
1889 int gsize = sg.getSize();
1892 hseqs = new SequenceI[gsize];
1895 for (int i = 0; i < gsize; i++)
1897 hseqs[index++] = sg.getSequenceAt(i);
1900 ap.av.hideSequence(hseqs);
1901 // refresh(); TODO: ? needed ?
1902 ap.av.sendSelection();
1905 public void copy_actionPerformed()
1907 ap.alignFrame.copy_actionPerformed(null);
1910 public void cut_actionPerformed()
1912 ap.alignFrame.cut_actionPerformed(null);
1915 void changeCase(ActionEvent e)
1917 Object source = e.getSource();
1918 SequenceGroup sg = ap.av.getSelectionGroup();
1922 int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
1923 sg.getEndRes() + 1);
1928 if (source == toggle)
1930 description = "Toggle Case";
1931 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1933 else if (source == upperCase)
1935 description = "To Upper Case";
1936 caseChange = ChangeCaseCommand.TO_UPPER;
1940 description = "To Lower Case";
1941 caseChange = ChangeCaseCommand.TO_LOWER;
1944 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1945 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1946 startEnd, caseChange);
1948 ap.alignFrame.addHistoryItem(caseCommand);
1950 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1956 public void outputText_actionPerformed(ActionEvent e)
1958 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1959 cap.setForInput(null);
1960 Desktop.addInternalFrame(cap,
1961 "Alignment output - " + e.getActionCommand(), 600, 500);
1963 String[] omitHidden = null;
1965 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1966 // or we simply trust the user wants
1967 // wysiwig behaviour
1968 SequenceGroup sg = ap.av.getSelectionGroup();
1969 ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection());
1970 omitHidden = ap.av.getViewAsString(true);
1971 Alignment oal = new Alignment(ap.av.getSequenceSelection());
1972 AlignmentAnnotation[] nala = ap.av.getAlignment()
1973 .getAlignmentAnnotation();
1976 for (int i = 0; i < nala.length; i++)
1978 AlignmentAnnotation na = nala[i];
1979 oal.addAnnotation(na);
1982 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
1983 oal, omitHidden, csel, sg));
1987 public void pdbFromFile_actionPerformed() throws IOException
1989 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
1990 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
1991 chooser.setFileView(new jalview.io.JalviewFileView());
1992 chooser.setDialogTitle("Select a PDB file for "
1993 + sequence.getDisplayId(false));
1994 chooser.setToolTipText("Load a PDB file and associate it with sequence '"
1995 + sequence.getDisplayId(false) + "'");
1997 int value = chooser.showOpenDialog(null);
1999 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
2001 String choice = chooser.getSelectedFile().getPath();
2002 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
2003 new AssociatePdbFileWithSeq().associatePdbWithSeq(choice,
2004 jalview.io.AppletFormatAdapter.FILE, sequence, true);
2009 public void enterPDB_actionPerformed()
2011 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
2012 "Enter PDB Id", "Enter PDB Id", JOptionPane.QUESTION_MESSAGE);
2014 if (id != null && id.length() > 0)
2016 PDBEntry entry = new PDBEntry();
2017 entry.setId(id.toUpperCase());
2018 sequence.getDatasetSequence().addPDBId(entry);
2022 public void discoverPDB_actionPerformed()
2025 final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
2027 : ap.av.getSequenceSelection());
2028 Thread discpdb = new Thread(new Runnable()
2033 new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
2034 .fetchDBRefs(false);
2041 public void sequenceFeature_actionPerformed()
2043 SequenceGroup sg = ap.av.getSelectionGroup();
2049 int rsize = 0, gSize = sg.getSize();
2050 SequenceI[] rseqs, seqs = new SequenceI[gSize];
2051 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
2053 for (int i = 0; i < gSize; i++)
2055 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
2056 int end = sg.findEndRes(sg.getSequenceAt(i));
2059 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
2060 features[rsize] = new SequenceFeature(null, null, null, start, end,
2065 rseqs = new SequenceI[rsize];
2066 tfeatures = new SequenceFeature[rsize];
2067 System.arraycopy(seqs, 0, rseqs, 0, rsize);
2068 System.arraycopy(features, 0, tfeatures, 0, rsize);
2069 features = tfeatures;
2071 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
2072 features, true, ap))
2074 ap.alignFrame.setShowSeqFeatures(true);
2075 ap.highlightSearchResults(null);
2079 public void textColour_actionPerformed()
2081 SequenceGroup sg = getGroup();
2084 new TextColourChooser().chooseColour(ap, sg);
2088 public void colourByStructure(String pdbid)
2090 Annotation[] anots = ap.av.getStructureSelectionManager()
2091 .colourSequenceFromStructure(sequence, pdbid);
2093 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
2094 "Coloured by " + pdbid, anots);
2096 ap.av.getAlignment().addAnnotation(an);
2097 an.createSequenceMapping(sequence, 0, true);
2098 // an.adjustForAlignment();
2099 ap.av.getAlignment().setAnnotationIndex(an, 0);
2101 ap.adjustAnnotationHeight();
2103 sequence.addAlignmentAnnotation(an);
2107 public void editSequence_actionPerformed(ActionEvent actionEvent)
2109 SequenceGroup sg = ap.av.getSelectionGroup();
2113 if (sequence == null)
2114 sequence = (Sequence) sg.getSequenceAt(0);
2116 EditNameDialog dialog = new EditNameDialog(
2117 sequence.getSequenceAsString(sg.getStartRes(),
2118 sg.getEndRes() + 1), null, "Edit Sequence ", null,
2119 "Edit Sequence", ap.alignFrame);
2123 EditCommand editCommand = new EditCommand("Edit Sequences",
2124 EditCommand.REPLACE, dialog.getName().replace(' ',
2125 ap.av.getGapCharacter()),
2126 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2127 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
2129 ap.alignFrame.addHistoryItem(editCommand);
2131 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()