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();
133 // JBPNote: Commented these out - Should add these services via the web services menu system.
134 // JMenuItem ContraFold = new JMenuItem();
136 // JMenuItem RNAFold = new JMenuItem();
138 JMenuItem enterPDB = new JMenuItem();
140 JMenuItem discoverPDB = new JMenuItem();
142 JMenu outputMenu = new JMenu();
144 JMenuItem sequenceFeature = new JMenuItem();
146 JMenuItem textColour = new JMenuItem();
148 JMenu jMenu1 = new JMenu();
150 JMenu structureMenu = new JMenu();
152 JMenu viewStructureMenu = new JMenu();
154 // JMenu colStructureMenu = new JMenu();
155 JMenuItem editSequence = new JMenuItem();
157 // JMenuItem annotationMenuItem = new JMenuItem();
159 JMenu groupLinksMenu;
162 * Creates a new PopupMenu object.
169 public PopupMenu(final AlignmentPanel ap, Sequence seq, Vector links)
171 this(ap, seq, links, null);
181 public PopupMenu(final AlignmentPanel ap, final SequenceI seq,
182 Vector links, Vector groupLinks)
184 // /////////////////////////////////////////////////////////
185 // If this is activated from the sequence panel, the user may want to
186 // edit or annotate a particular residue. Therefore display the residue menu
188 // If from the IDPanel, we must display the sequence menu
189 // ////////////////////////////////////////////////////////
193 ButtonGroup colours = new ButtonGroup();
194 colours.add(noColourmenuItem);
195 colours.add(clustalColour);
196 colours.add(zappoColour);
197 colours.add(taylorColour);
198 colours.add(hydrophobicityColour);
199 colours.add(helixColour);
200 colours.add(strandColour);
201 colours.add(turnColour);
202 colours.add(buriedColour);
203 colours.add(abovePIDColour);
204 colours.add(userDefinedColour);
205 colours.add(PIDColour);
206 colours.add(BLOSUM62Colour);
207 colours.add(purinePyrimidineColour);
208 colours.add(RNAInteractionColour);
209 // colours.add(covariationColour);
211 for (int i = 0; i < jalview.io.FormatAdapter.WRITEABLE_FORMATS.length; i++)
213 JMenuItem item = new JMenuItem(
214 jalview.io.FormatAdapter.WRITEABLE_FORMATS[i]);
216 item.addActionListener(new java.awt.event.ActionListener()
218 public void actionPerformed(ActionEvent e)
220 outputText_actionPerformed(e);
224 outputMenu.add(item);
230 } catch (Exception e)
238 sequenceMenu.setText(sequence.getName());
240 if (seq.getDatasetSequence().getPDBId() != null
241 && seq.getDatasetSequence().getPDBId().size() > 0)
243 java.util.Enumeration e = seq.getDatasetSequence().getPDBId()
246 while (e.hasMoreElements())
248 final PDBEntry pdb = (PDBEntry) e.nextElement();
250 menuItem = new JMenuItem();
251 menuItem.setText(pdb.getId());
252 menuItem.addActionListener(new java.awt.event.ActionListener()
254 public void actionPerformed(ActionEvent e)
256 // TODO re JAL-860: optionally open dialog or provide a menu entry
257 // allowing user to open just one structure per sequence
258 new AppJmol(pdb, ap.av.collateForPDB(new PDBEntry[]
259 { pdb })[0], null, ap);
260 // new PDBViewer(pdb, seqs2, null, ap, AppletFormatAdapter.FILE);
264 viewStructureMenu.add(menuItem);
267 * menuItem = new JMenuItem(); menuItem.setText(pdb.getId());
268 * menuItem.addActionListener(new java.awt.event.ActionListener() {
269 * public void actionPerformed(ActionEvent e) {
270 * colourByStructure(pdb.getId()); } });
271 * colStructureMenu.add(menuItem);
277 if (ap.av.getAlignment().isNucleotide() == false)
279 structureMenu.remove(viewStructureMenu);
281 // structureMenu.remove(colStructureMenu);
284 if (ap.av.getAlignment().isNucleotide() == true)
286 AlignmentAnnotation[] aa = ap.av.getAlignment()
287 .getAlignmentAnnotation();
288 for (int i = 0; i < aa.length; i++)
290 if (aa[i].getRNAStruc() != null)
292 final String rnastruc = aa[i].getRNAStruc();
293 final String structureLine = aa[i].label;
294 menuItem = new JMenuItem();
295 menuItem.setText("2D RNA " + structureLine);
296 menuItem.addActionListener(new java.awt.event.ActionListener()
299 public void actionPerformed(ActionEvent e)
301 //System.out.println("1:"+structureLine);
302 System.out.println("1:sname"+seq.getName());
303 System.out.println("2:seq"+seq);
305 //System.out.println("3:"+seq.getSequenceAsString());
306 System.out.println("3:strucseq"+rnastruc);
307 //System.out.println("4:struc"+seq.getRNA());
308 System.out.println("5:name"+seq.getName());
309 System.out.println("6:ap"+ap);
310 new AppVarna(structureLine, seq, seq.getSequenceAsString(), rnastruc, seq
312 //new AppVarna(seq.getName(),seq,rnastruc,seq.getRNA(), seq.getName(), ap);
313 System.out.println("end");
316 viewStructureMenu.add(menuItem);
320 // SequenceFeatures[] test = seq.getSequenceFeatures();
322 if (seq.getAnnotation() != null)
324 AlignmentAnnotation seqAnno[] = seq.getAnnotation();
325 for (int i = 0; i < seqAnno.length; i++)
327 if (seqAnno[i].getRNAStruc() != null)
329 final String rnastruc = seqAnno[i].getRNAStruc();
331 // TODO: make rnastrucF a bit more nice
332 menuItem = new JMenuItem();
333 menuItem.setText("2D RNA - " + seq.getName());
334 menuItem.addActionListener(new java.awt.event.ActionListener()
336 public void actionPerformed(ActionEvent e)
338 // TODO: VARNA does'nt print gaps in the sequence
340 new AppVarna(seq.getName() + " structure", seq, seq
341 .getSequenceAsString(), rnastruc, seq.getName(),
345 viewStructureMenu.add(menuItem);
352 menuItem = new JMenuItem("Hide Sequences");
353 menuItem.addActionListener(new java.awt.event.ActionListener()
355 public void actionPerformed(ActionEvent e)
357 hideSequences(false);
362 if (ap.av.getSelectionGroup() != null
363 && ap.av.getSelectionGroup().getSize() > 1)
365 menuItem = new JMenuItem("Represent Group with " + seq.getName());
366 menuItem.addActionListener(new java.awt.event.ActionListener()
368 public void actionPerformed(ActionEvent e)
373 sequenceMenu.add(menuItem);
376 if (ap.av.hasHiddenRows())
378 final int index = ap.av.getAlignment().findIndex(seq);
380 if (ap.av.adjustForHiddenSeqs(index)
381 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
383 menuItem = new JMenuItem("Reveal Sequences");
384 menuItem.addActionListener(new ActionListener()
386 public void actionPerformed(ActionEvent e)
388 ap.av.showSequence(index);
389 if (ap.overviewPanel != null)
391 ap.overviewPanel.updateOverviewImage();
399 // for the case when no sequences are even visible
400 if (ap.av.hasHiddenRows())
403 menuItem = new JMenuItem("Reveal All");
404 menuItem.addActionListener(new ActionListener()
406 public void actionPerformed(ActionEvent e)
408 ap.av.showAllHiddenSeqs();
409 if (ap.overviewPanel != null)
411 ap.overviewPanel.updateOverviewImage();
421 SequenceGroup sg = ap.av.getSelectionGroup();
423 if (sg != null && sg.getSize() > 0)
425 groupName.setText("Name: " + sg.getName());
426 groupName.setText("Edit name and description of current group.");
428 if (sg.cs instanceof ZappoColourScheme)
430 zappoColour.setSelected(true);
432 else if (sg.cs instanceof TaylorColourScheme)
434 taylorColour.setSelected(true);
436 else if (sg.cs instanceof PIDColourScheme)
438 PIDColour.setSelected(true);
440 else if (sg.cs instanceof Blosum62ColourScheme)
442 BLOSUM62Colour.setSelected(true);
444 else if (sg.cs instanceof UserColourScheme)
446 userDefinedColour.setSelected(true);
448 else if (sg.cs instanceof HydrophobicColourScheme)
450 hydrophobicityColour.setSelected(true);
452 else if (sg.cs instanceof HelixColourScheme)
454 helixColour.setSelected(true);
456 else if (sg.cs instanceof StrandColourScheme)
458 strandColour.setSelected(true);
460 else if (sg.cs instanceof TurnColourScheme)
462 turnColour.setSelected(true);
464 else if (sg.cs instanceof BuriedColourScheme)
466 buriedColour.setSelected(true);
468 else if (sg.cs instanceof ClustalxColourScheme)
470 clustalColour.setSelected(true);
472 else if (sg.cs instanceof PurinePyrimidineColourScheme)
474 purinePyrimidineColour.setSelected(true);
479 * else if (sg.cs instanceof CovariationColourScheme) {
480 * covariationColour.setSelected(true); }
484 noColourmenuItem.setSelected(true);
487 if (sg.cs != null && sg.cs.conservationApplied())
489 conservationMenuItem.setSelected(true);
491 displayNonconserved.setSelected(sg.getShowNonconserved());
492 showText.setSelected(sg.getDisplayText());
493 showColourText.setSelected(sg.getColourText());
494 showBoxes.setSelected(sg.getDisplayBoxes());
495 // add any groupURLs to the groupURL submenu and make it visible
496 if (groupLinks != null && groupLinks.size() > 0)
498 buildGroupURLMenu(sg, groupLinks);
500 // Add a 'show all structures' for the current selection
501 Hashtable<String, PDBEntry> pdbe = new Hashtable<String, PDBEntry>();
502 SequenceI sqass = null;
503 for (SequenceI sq : ap.av.getSequenceSelection())
505 Vector<PDBEntry> pes = (Vector<PDBEntry>) sq.getDatasetSequence()
509 for (PDBEntry pe : pes)
511 pdbe.put(pe.getId(), pe);
521 final PDBEntry[] pe = pdbe.values().toArray(
522 new PDBEntry[pdbe.size()]);
523 final JMenuItem gpdbview;
524 if (pdbe.size() == 1)
526 structureMenu.add(gpdbview = new JMenuItem("View structure for "
527 + sqass.getDisplayId(false)));
531 structureMenu.add(gpdbview = new JMenuItem("View all "
532 + pdbe.size() + " structures."));
534 gpdbview.setToolTipText("Open a new Jmol view with all structures associated with the current selection and superimpose them using the alignment.");
535 gpdbview.addActionListener(new ActionListener()
539 public void actionPerformed(ActionEvent e)
541 new AppJmol(ap, pe, ap.av.collateForPDB(pe));
548 groupMenu.setVisible(false);
549 editMenu.setVisible(false);
552 if (!ap.av.getAlignment().getGroups().contains(sg))
554 unGroupMenuItem.setVisible(false);
559 sequenceMenu.setVisible(false);
560 structureMenu.setVisible(false);
563 if (links != null && links.size() > 0)
566 JMenu linkMenu = new JMenu("Link");
567 Vector linkset = new Vector();
568 for (int i = 0; i < links.size(); i++)
570 String link = links.elementAt(i).toString();
571 UrlLink urlLink = null;
574 urlLink = new UrlLink(link);
575 } catch (Exception foo)
577 jalview.bin.Cache.log.error("Exception for URLLink '" + link
582 if (!urlLink.isValid())
584 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
587 final String label = urlLink.getLabel();
588 if (seq != null && urlLink.isDynamic())
591 // collect matching db-refs
592 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
593 seq.getDBRef(), new String[]
594 { urlLink.getTarget() });
595 // collect id string too
596 String id = seq.getName();
597 String descr = seq.getDescription();
598 if (descr != null && descr.length() < 1)
605 for (int r = 0; r < dbr.length; r++)
607 if (id != null && dbr[r].getAccessionId().equals(id))
609 // suppress duplicate link creation for the bare sequence ID
610 // string with this link
613 // create Bare ID link for this RUL
614 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
618 for (int u = 0; u < urls.length; u += 2)
620 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
622 linkset.addElement(urls[u] + "|" + urls[u + 1]);
623 addshowLink(linkMenu, label + "|" + urls[u],
632 // create Bare ID link for this RUL
633 String[] urls = urlLink.makeUrls(id, true);
636 for (int u = 0; u < urls.length; u += 2)
638 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
640 linkset.addElement(urls[u] + "|" + urls[u + 1]);
641 addshowLink(linkMenu, label, urls[u + 1]);
646 // Create urls from description but only for URL links which are regex
648 if (descr != null && urlLink.getRegexReplace() != null)
650 // create link for this URL from description where regex matches
651 String[] urls = urlLink.makeUrls(descr, true);
654 for (int u = 0; u < urls.length; u += 2)
656 if (!linkset.contains(urls[u] + "|" + urls[u + 1]))
658 linkset.addElement(urls[u] + "|" + urls[u + 1]);
659 addshowLink(linkMenu, label, urls[u + 1]);
667 if (!linkset.contains(label + "|" + urlLink.getUrl_prefix()))
669 linkset.addElement(label + "|" + urlLink.getUrl_prefix());
670 // Add a non-dynamic link
671 addshowLink(linkMenu, label, urlLink.getUrl_prefix());
675 if (sequence != null)
677 sequenceMenu.add(linkMenu);
686 private void buildGroupURLMenu(SequenceGroup sg, Vector groupLinks)
689 // TODO: usability: thread off the generation of group url content so root
691 // sequence only URLs
692 // ID/regex match URLs
693 groupLinksMenu = new JMenu("Group Link");
694 JMenu[] linkMenus = new JMenu[]
695 { null, new JMenu("IDS"), new JMenu("Sequences"),
696 new JMenu("IDS and Sequences") }; // three types of url that might be
698 SequenceI[] seqs = ap.av.getSelectionAsNewSequence();
699 String[][] idandseqs = GroupUrlLink.formStrings(seqs);
700 Hashtable commonDbrefs = new Hashtable();
701 for (int sq = 0; sq < seqs.length; sq++)
704 int start = seqs[sq].findPosition(sg.getStartRes()), end = seqs[sq]
705 .findPosition(sg.getEndRes());
706 // just collect ids from dataset sequence
707 // TODO: check if IDs collected from selecton group intersects with the
708 // current selection, too
709 SequenceI sqi = seqs[sq];
710 while (sqi.getDatasetSequence() != null)
712 sqi = sqi.getDatasetSequence();
714 DBRefEntry[] dbr = sqi.getDBRef();
715 if (dbr != null && dbr.length > 0)
717 for (int d = 0; d < dbr.length; d++)
719 String src = dbr[d].getSource(); // jalview.util.DBRefUtils.getCanonicalName(dbr[d].getSource()).toUpperCase();
720 Object[] sarray = (Object[]) commonDbrefs.get(src);
723 sarray = new Object[2];
724 sarray[0] = new int[]
726 sarray[1] = new String[seqs.length];
728 commonDbrefs.put(src, sarray);
731 if (((String[]) sarray[1])[sq] == null)
734 || (dbr[d].getMap().locateMappedRange(start, end) != null))
736 ((String[]) sarray[1])[sq] = dbr[d].getAccessionId();
737 ((int[]) sarray[0])[0]++;
743 // now create group links for all distinct ID/sequence sets.
744 boolean addMenu = false; // indicates if there are any group links to give
746 for (int i = 0; i < groupLinks.size(); i++)
748 String link = groupLinks.elementAt(i).toString();
749 GroupUrlLink urlLink = null;
752 urlLink = new GroupUrlLink(link);
753 } catch (Exception foo)
755 jalview.bin.Cache.log.error("Exception for GroupURLLink '" + link
760 if (!urlLink.isValid())
762 jalview.bin.Cache.log.error(urlLink.getInvalidMessage());
765 final String label = urlLink.getLabel();
766 boolean usingNames = false;
767 // Now see which parts of the group apply for this URL
768 String ltarget = urlLink.getTarget(); // jalview.util.DBRefUtils.getCanonicalName(urlLink.getTarget());
769 Object[] idset = (Object[]) commonDbrefs.get(ltarget.toUpperCase());
770 String[] seqstr, ids; // input to makeUrl
773 int numinput = ((int[]) idset[0])[0];
774 String[] allids = ((String[]) idset[1]);
775 seqstr = new String[numinput];
776 ids = new String[numinput];
777 for (int sq = 0, idcount = 0; sq < seqs.length; sq++)
779 if (allids[sq] != null)
781 ids[idcount] = allids[sq];
782 seqstr[idcount++] = idandseqs[1][sq];
788 // just use the id/seq set
789 seqstr = idandseqs[1];
793 // and try and make the groupURL!
795 Object[] urlset = null;
798 urlset = urlLink.makeUrlStubs(ids, seqstr,
799 "FromJalview" + System.currentTimeMillis(), false);
800 } catch (UrlStringTooLongException e)
805 int type = urlLink.getGroupURLType() & 3;
806 // System.out.println(urlLink.getGroupURLType()
807 // +" "+((String[])urlset[3])[0]);
808 // first two bits ofurlLink type bitfield are sequenceids and sequences
809 // TODO: FUTURE: ensure the groupURL menu structure can be generalised
810 addshowLink(linkMenus[type], label
811 + (((type & 1) == 1) ? ("("
812 + (usingNames ? "Names" : ltarget) + ")") : ""),
819 groupLinksMenu = new JMenu("Group Links");
820 for (int m = 0; m < linkMenus.length; m++)
822 if (linkMenus[m] != null
823 && linkMenus[m].getMenuComponentCount() > 0)
825 groupLinksMenu.add(linkMenus[m]);
829 groupMenu.add(groupLinksMenu);
834 * add a show URL menu item to the given linkMenu
838 * - menu label string
842 private void addshowLink(JMenu linkMenu, String label, final String url)
844 JMenuItem item = new JMenuItem(label);
845 item.setToolTipText("open URL: " + url);
846 item.addActionListener(new java.awt.event.ActionListener()
848 public void actionPerformed(ActionEvent e)
850 new Thread(new Runnable()
866 * add a late bound groupURL item to the given linkMenu
870 * - menu label string
871 * @param urlgenerator
872 * GroupURLLink used to generate URL
874 * Object array returned from the makeUrlStubs function.
876 private void addshowLink(JMenu linkMenu, String label,
877 final GroupUrlLink urlgenerator, final Object[] urlstub)
879 JMenuItem item = new JMenuItem(label);
880 item.setToolTipText("open URL (" + urlgenerator.getUrl_prefix()
881 + "..) (" + urlgenerator.getNumberInvolved(urlstub) + " seqs)"); // TODO:
890 item.addActionListener(new java.awt.event.ActionListener()
892 public void actionPerformed(ActionEvent e)
894 new Thread(new Runnable()
901 showLink(urlgenerator.constructFrom(urlstub));
902 } catch (UrlStringTooLongException e)
920 private void jbInit() throws Exception
922 groupMenu.setText("Group");
923 groupMenu.setText("Selection");
924 groupName.setText("Name");
925 groupName.addActionListener(new java.awt.event.ActionListener()
927 public void actionPerformed(ActionEvent e)
929 groupName_actionPerformed();
932 sequenceMenu.setText("Sequence");
933 sequenceName.setText("Edit Name/Description");
934 sequenceName.addActionListener(new java.awt.event.ActionListener()
936 public void actionPerformed(ActionEvent e)
938 sequenceName_actionPerformed();
941 sequenceDetails.setText("Sequence Details ...");
942 sequenceDetails.addActionListener(new java.awt.event.ActionListener()
944 public void actionPerformed(ActionEvent e)
946 sequenceDetails_actionPerformed();
949 sequenceSelDetails.setText("Sequence Details ...");
951 .addActionListener(new java.awt.event.ActionListener()
953 public void actionPerformed(ActionEvent e)
955 sequenceSelectionDetails_actionPerformed();
958 PIDColour.setFocusPainted(false);
959 unGroupMenuItem.setText("Remove Group");
960 unGroupMenuItem.addActionListener(new java.awt.event.ActionListener()
962 public void actionPerformed(ActionEvent e)
964 unGroupMenuItem_actionPerformed();
968 outline.setText("Border colour");
969 outline.addActionListener(new java.awt.event.ActionListener()
971 public void actionPerformed(ActionEvent e)
973 outline_actionPerformed();
976 nucleotideMenuItem.setText("Nucleotide");
977 nucleotideMenuItem.addActionListener(new ActionListener()
979 public void actionPerformed(ActionEvent e)
981 nucleotideMenuItem_actionPerformed();
984 colourMenu.setText("Group Colour");
985 showBoxes.setText("Boxes");
986 showBoxes.setState(true);
987 showBoxes.addActionListener(new ActionListener()
989 public void actionPerformed(ActionEvent e)
991 showBoxes_actionPerformed();
994 showText.setText("Text");
995 showText.setState(true);
996 showText.addActionListener(new ActionListener()
998 public void actionPerformed(ActionEvent e)
1000 showText_actionPerformed();
1003 showColourText.setText("Colour Text");
1004 showColourText.addActionListener(new ActionListener()
1006 public void actionPerformed(ActionEvent e)
1008 showColourText_actionPerformed();
1011 displayNonconserved.setText("Show Nonconserved");
1012 displayNonconserved.setState(true);
1013 displayNonconserved.addActionListener(new ActionListener()
1015 public void actionPerformed(ActionEvent e)
1017 showNonconserved_actionPerformed();
1020 editMenu.setText("Edit");
1022 cut.addActionListener(new ActionListener()
1024 public void actionPerformed(ActionEvent e)
1026 cut_actionPerformed();
1029 upperCase.setText("To Upper Case");
1030 upperCase.addActionListener(new ActionListener()
1032 public void actionPerformed(ActionEvent e)
1037 copy.setText("Copy");
1038 copy.addActionListener(new ActionListener()
1040 public void actionPerformed(ActionEvent e)
1042 copy_actionPerformed();
1045 lowerCase.setText("To Lower Case");
1046 lowerCase.addActionListener(new ActionListener()
1048 public void actionPerformed(ActionEvent e)
1053 toggle.setText("Toggle Case");
1054 toggle.addActionListener(new ActionListener()
1056 public void actionPerformed(ActionEvent e)
1061 pdbMenu.setText("Associate Structure with Sequence");
1062 pdbFromFile.setText("From File");
1063 pdbFromFile.addActionListener(new ActionListener()
1065 public void actionPerformed(ActionEvent e)
1068 pdbFromFile_actionPerformed();
1069 } catch (Exception e1) {
1070 // TODO Auto-generated catch block
1071 e1.printStackTrace();
1075 // RNAFold.setText("From RNA Fold with predict2D");
1076 // RNAFold.addActionListener(new ActionListener()
1078 // public void actionPerformed(ActionEvent e)
1081 // RNAFold_actionPerformed();
1082 // } catch (Exception e1) {
1083 // // TODO Auto-generated catch block
1084 // e1.printStackTrace();
1088 // ContraFold.setText("From Contra Fold with predict2D");
1089 // ContraFold.addActionListener(new ActionListener()
1091 // public void actionPerformed(ActionEvent e)
1094 // ContraFold_actionPerformed();
1095 // } catch (Exception e1) {
1096 // // TODO Auto-generated catch block
1097 // e1.printStackTrace();
1101 enterPDB.setText("Enter PDB Id");
1102 enterPDB.addActionListener(new ActionListener()
1104 public void actionPerformed(ActionEvent e)
1106 enterPDB_actionPerformed();
1109 discoverPDB.setText("Discover PDB ids");
1110 discoverPDB.addActionListener(new ActionListener()
1112 public void actionPerformed(ActionEvent e)
1114 discoverPDB_actionPerformed();
1117 outputMenu.setText("Output to Textbox...");
1118 sequenceFeature.setText("Create Sequence Feature");
1119 sequenceFeature.addActionListener(new ActionListener()
1121 public void actionPerformed(ActionEvent e)
1123 sequenceFeature_actionPerformed();
1126 textColour.setText("Text Colour");
1127 textColour.addActionListener(new ActionListener()
1129 public void actionPerformed(ActionEvent e)
1131 textColour_actionPerformed();
1134 jMenu1.setText("Group");
1135 structureMenu.setText("Structure");
1136 viewStructureMenu.setText("View Structure");
1137 // colStructureMenu.setText("Colour By Structure");
1138 editSequence.setText("Edit Sequence...");
1139 editSequence.addActionListener(new ActionListener()
1141 public void actionPerformed(ActionEvent actionEvent)
1143 editSequence_actionPerformed(actionEvent);
1148 * annotationMenuItem.setText("By Annotation");
1149 * annotationMenuItem.addActionListener(new ActionListener() { public void
1150 * actionPerformed(ActionEvent actionEvent) {
1151 * annotationMenuItem_actionPerformed(actionEvent); } });
1153 groupMenu.add(sequenceSelDetails);
1156 this.add(structureMenu);
1157 groupMenu.add(editMenu);
1158 groupMenu.add(outputMenu);
1159 groupMenu.add(sequenceFeature);
1160 groupMenu.add(jMenu1);
1161 sequenceMenu.add(sequenceName);
1162 sequenceMenu.add(sequenceDetails);
1163 colourMenu.add(textColour);
1164 colourMenu.add(noColourmenuItem);
1165 colourMenu.add(clustalColour);
1166 colourMenu.add(BLOSUM62Colour);
1167 colourMenu.add(PIDColour);
1168 colourMenu.add(zappoColour);
1169 colourMenu.add(taylorColour);
1170 colourMenu.add(hydrophobicityColour);
1171 colourMenu.add(helixColour);
1172 colourMenu.add(strandColour);
1173 colourMenu.add(turnColour);
1174 colourMenu.add(buriedColour);
1175 colourMenu.add(nucleotideMenuItem);
1176 if (ap.getAlignment().isNucleotide()) {
1177 // JBPNote - commented since the colourscheme isn't functional
1178 // colourMenu.add(RNAInteractionColour);
1179 colourMenu.add(purinePyrimidineColour);
1181 // colourMenu.add(covariationColour);
1182 colourMenu.add(userDefinedColour);
1184 if (jalview.gui.UserDefinedColours.getUserColourSchemes() != null)
1186 java.util.Enumeration userColours = jalview.gui.UserDefinedColours
1187 .getUserColourSchemes().keys();
1189 while (userColours.hasMoreElements())
1191 JMenuItem item = new JMenuItem(userColours.nextElement().toString());
1192 item.addActionListener(new ActionListener()
1194 public void actionPerformed(ActionEvent evt)
1196 userDefinedColour_actionPerformed(evt);
1199 colourMenu.add(item);
1203 colourMenu.addSeparator();
1204 colourMenu.add(abovePIDColour);
1205 colourMenu.add(conservationMenuItem);
1206 // colourMenu.add(annotationMenuItem);
1209 editMenu.add(editSequence);
1210 editMenu.add(upperCase);
1211 editMenu.add(lowerCase);
1212 editMenu.add(toggle);
1213 pdbMenu.add(pdbFromFile);
1214 // JBPNote: These shouldn't be added here - should appear in a generic 'apply web service to this sequence menu'
1215 // pdbMenu.add(RNAFold);
1216 // pdbMenu.add(ContraFold);
1217 pdbMenu.add(enterPDB);
1218 pdbMenu.add(discoverPDB);
1219 jMenu1.add(groupName);
1220 jMenu1.add(unGroupMenuItem);
1221 jMenu1.add(colourMenu);
1222 jMenu1.add(showBoxes);
1223 jMenu1.add(showText);
1224 jMenu1.add(showColourText);
1225 jMenu1.add(outline);
1226 jMenu1.add(displayNonconserved);
1227 structureMenu.add(pdbMenu);
1228 structureMenu.add(viewStructureMenu);
1229 // structureMenu.add(colStructureMenu);
1230 noColourmenuItem.setText("None");
1231 noColourmenuItem.addActionListener(new java.awt.event.ActionListener()
1233 public void actionPerformed(ActionEvent e)
1235 noColourmenuItem_actionPerformed();
1239 clustalColour.setText("Clustalx colours");
1240 clustalColour.addActionListener(new java.awt.event.ActionListener()
1242 public void actionPerformed(ActionEvent e)
1244 clustalColour_actionPerformed();
1247 zappoColour.setText("Zappo");
1248 zappoColour.addActionListener(new java.awt.event.ActionListener()
1250 public void actionPerformed(ActionEvent e)
1252 zappoColour_actionPerformed();
1255 taylorColour.setText("Taylor");
1256 taylorColour.addActionListener(new java.awt.event.ActionListener()
1258 public void actionPerformed(ActionEvent e)
1260 taylorColour_actionPerformed();
1263 hydrophobicityColour.setText("Hydrophobicity");
1264 hydrophobicityColour
1265 .addActionListener(new java.awt.event.ActionListener()
1267 public void actionPerformed(ActionEvent e)
1269 hydrophobicityColour_actionPerformed();
1272 helixColour.setText("Helix propensity");
1273 helixColour.addActionListener(new java.awt.event.ActionListener()
1275 public void actionPerformed(ActionEvent e)
1277 helixColour_actionPerformed();
1280 strandColour.setText("Strand propensity");
1281 strandColour.addActionListener(new java.awt.event.ActionListener()
1283 public void actionPerformed(ActionEvent e)
1285 strandColour_actionPerformed();
1288 turnColour.setText("Turn propensity");
1289 turnColour.addActionListener(new java.awt.event.ActionListener()
1291 public void actionPerformed(ActionEvent e)
1293 turnColour_actionPerformed();
1296 buriedColour.setText("Buried Index");
1297 buriedColour.addActionListener(new java.awt.event.ActionListener()
1299 public void actionPerformed(ActionEvent e)
1301 buriedColour_actionPerformed();
1304 abovePIDColour.setText("Above % Identity");
1305 abovePIDColour.addActionListener(new java.awt.event.ActionListener()
1307 public void actionPerformed(ActionEvent e)
1309 abovePIDColour_actionPerformed();
1312 userDefinedColour.setText("User Defined...");
1313 userDefinedColour.addActionListener(new java.awt.event.ActionListener()
1315 public void actionPerformed(ActionEvent e)
1317 userDefinedColour_actionPerformed(e);
1320 PIDColour.setText("Percentage Identity");
1321 PIDColour.addActionListener(new java.awt.event.ActionListener()
1323 public void actionPerformed(ActionEvent e)
1325 PIDColour_actionPerformed();
1328 BLOSUM62Colour.setText("BLOSUM62");
1329 BLOSUM62Colour.addActionListener(new java.awt.event.ActionListener()
1331 public void actionPerformed(ActionEvent e)
1333 BLOSUM62Colour_actionPerformed();
1336 purinePyrimidineColour.setText("Purine/Pyrimidine");
1337 purinePyrimidineColour
1338 .addActionListener(new java.awt.event.ActionListener()
1340 public void actionPerformed(ActionEvent e)
1342 purinePyrimidineColour_actionPerformed();
1348 * covariationColour.addActionListener(new java.awt.event.ActionListener() {
1349 * public void actionPerformed(ActionEvent e) {
1350 * covariationColour_actionPerformed(); } });
1353 conservationMenuItem.setText("Conservation");
1354 conservationMenuItem
1355 .addActionListener(new java.awt.event.ActionListener()
1357 public void actionPerformed(ActionEvent e)
1359 conservationMenuItem_actionPerformed();
1364 protected void sequenceSelectionDetails_actionPerformed()
1366 createSequenceDetailsReport(ap.av.getSequenceSelection());
1369 protected void sequenceDetails_actionPerformed()
1371 createSequenceDetailsReport(new SequenceI[]
1375 public void createSequenceDetailsReport(SequenceI[] sequences)
1377 CutAndPasteHtmlTransfer cap = new CutAndPasteHtmlTransfer();
1378 StringBuffer contents = new StringBuffer();
1379 for (SequenceI seq : sequences)
1381 contents.append("<p><h2>Annotation for " + seq.getDisplayId(true)
1383 new SequenceAnnotationReport(null)
1384 .createSequenceAnnotationReport(
1390 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
1392 contents.append("</p>");
1394 cap.setText("<html>" + contents.toString() + "</html>");
1396 Desktop.instance.addInternalFrame(cap, "Sequence Details for "
1397 + (sequences.length == 1 ? sequences[0].getDisplayId(true)
1398 : "Selection"), 500, 400);
1402 protected void showNonconserved_actionPerformed()
1404 getGroup().setShowNonconserved(displayNonconserved.isSelected());
1409 * call to refresh view after settings change
1413 ap.updateAnnotation();
1414 ap.paintAlignment(true);
1416 PaintRefresher.Refresh(this, ap.av.getSequenceSetId());
1425 protected void clustalColour_actionPerformed()
1427 SequenceGroup sg = getGroup();
1428 sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
1438 protected void zappoColour_actionPerformed()
1440 getGroup().cs = new ZappoColourScheme();
1450 protected void taylorColour_actionPerformed()
1452 getGroup().cs = new TaylorColourScheme();
1462 protected void hydrophobicityColour_actionPerformed()
1464 getGroup().cs = new HydrophobicColourScheme();
1474 protected void helixColour_actionPerformed()
1476 getGroup().cs = new HelixColourScheme();
1486 protected void strandColour_actionPerformed()
1488 getGroup().cs = new StrandColourScheme();
1498 protected void turnColour_actionPerformed()
1500 getGroup().cs = new TurnColourScheme();
1510 protected void buriedColour_actionPerformed()
1512 getGroup().cs = new BuriedColourScheme();
1522 public void nucleotideMenuItem_actionPerformed()
1524 getGroup().cs = new NucleotideColourScheme();
1528 protected void purinePyrimidineColour_actionPerformed()
1530 getGroup().cs = new PurinePyrimidineColourScheme();
1536 * protected void covariationColour_actionPerformed() { getGroup().cs = new
1537 * CovariationColourScheme(sequence.getAnnotation()[0]); refresh(); }
1545 protected void abovePIDColour_actionPerformed()
1547 SequenceGroup sg = getGroup();
1553 if (abovePIDColour.isSelected())
1555 sg.cs.setConsensus(AAFrequency.calculate(
1556 sg.getSequences(ap.av.getHiddenRepSequences()),
1557 sg.getStartRes(), sg.getEndRes() + 1));
1559 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
1562 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
1564 SliderPanel.showPIDSlider();
1567 // remove PIDColouring
1569 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
1581 protected void userDefinedColour_actionPerformed(ActionEvent e)
1583 SequenceGroup sg = getGroup();
1585 if (e.getActionCommand().equals("User Defined..."))
1587 new UserDefinedColours(ap, sg);
1591 UserColourScheme udc = (UserColourScheme) UserDefinedColours
1592 .getUserColourSchemes().get(e.getActionCommand());
1605 protected void PIDColour_actionPerformed()
1607 SequenceGroup sg = getGroup();
1608 sg.cs = new PIDColourScheme();
1609 sg.cs.setConsensus(AAFrequency.calculate(
1610 sg.getSequences(ap.av.getHiddenRepSequences()),
1611 sg.getStartRes(), sg.getEndRes() + 1));
1621 protected void BLOSUM62Colour_actionPerformed()
1623 SequenceGroup sg = getGroup();
1625 sg.cs = new Blosum62ColourScheme();
1627 sg.cs.setConsensus(AAFrequency.calculate(
1628 sg.getSequences(ap.av.getHiddenRepSequences()),
1629 sg.getStartRes(), sg.getEndRes() + 1));
1640 protected void noColourmenuItem_actionPerformed()
1642 getGroup().cs = null;
1652 protected void conservationMenuItem_actionPerformed()
1654 SequenceGroup sg = getGroup();
1660 if (conservationMenuItem.isSelected())
1662 Conservation c = new Conservation("Group",
1663 ResidueProperties.propHash, 3, sg.getSequences(ap.av
1664 .getHiddenRepSequences()), sg.getStartRes(),
1665 sg.getEndRes() + 1);
1668 c.verdict(false, ap.av.getConsPercGaps());
1670 sg.cs.setConservation(c);
1672 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1673 SliderPanel.showConservationSlider();
1676 // remove ConservationColouring
1678 sg.cs.setConservation(null);
1684 public void annotationMenuItem_actionPerformed(ActionEvent actionEvent)
1686 SequenceGroup sg = getGroup();
1692 AnnotationColourGradient acg = new AnnotationColourGradient(
1693 sequence.getAnnotation()[0], null,
1694 AnnotationColourGradient.NO_THRESHOLD);
1696 acg.predefinedColours = true;
1708 protected void groupName_actionPerformed()
1711 SequenceGroup sg = getGroup();
1712 EditNameDialog dialog = new EditNameDialog(sg.getName(),
1713 sg.getDescription(), " Group Name ",
1714 "Group Description ", "Edit Group Name/Description",
1722 sg.setName(dialog.getName());
1723 sg.setDescription(dialog.getDescription());
1728 * Get selection group - adding it to the alignment if necessary.
1730 * @return sequence group to operate on
1732 SequenceGroup getGroup()
1734 SequenceGroup sg = ap.av.getSelectionGroup();
1735 // this method won't add a new group if it already exists
1738 ap.av.getAlignment().addGroup(sg);
1750 void sequenceName_actionPerformed()
1752 EditNameDialog dialog = new EditNameDialog(sequence.getName(),
1753 sequence.getDescription(), " Sequence Name ",
1754 "Sequence Description ", "Edit Sequence Name/Description",
1762 if (dialog.getName() != null)
1764 if (dialog.getName().indexOf(" ") > -1)
1766 JOptionPane.showMessageDialog(ap,
1767 "Spaces have been converted to \"_\"",
1768 "No spaces allowed in Sequence Name",
1769 JOptionPane.WARNING_MESSAGE);
1772 sequence.setName(dialog.getName().replace(' ', '_'));
1773 ap.paintAlignment(false);
1776 sequence.setDescription(dialog.getDescription());
1778 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1789 void unGroupMenuItem_actionPerformed()
1791 SequenceGroup sg = ap.av.getSelectionGroup();
1792 ap.av.getAlignment().deleteGroup(sg);
1793 ap.av.setSelectionGroup(null);
1803 protected void outline_actionPerformed()
1805 SequenceGroup sg = getGroup();
1806 Color col = JColorChooser.showDialog(this, "Select Outline Colour",
1811 sg.setOutlineColour(col);
1823 public void showBoxes_actionPerformed()
1825 getGroup().setDisplayBoxes(showBoxes.isSelected());
1835 public void showText_actionPerformed()
1837 getGroup().setDisplayText(showText.isSelected());
1847 public void showColourText_actionPerformed()
1849 getGroup().setColourText(showColourText.isSelected());
1853 public void showLink(String url)
1857 jalview.util.BrowserLauncher.openURL(url);
1858 } catch (Exception ex)
1861 .showInternalMessageDialog(
1863 "Unixers: Couldn't find default web browser."
1864 + "\nAdd the full path to your browser in Preferences.",
1865 "Web browser not found", JOptionPane.WARNING_MESSAGE);
1867 ex.printStackTrace();
1871 void hideSequences(boolean representGroup)
1873 SequenceGroup sg = ap.av.getSelectionGroup();
1874 if (sg == null || sg.getSize() < 1)
1876 ap.av.hideSequence(new SequenceI[]
1881 ap.av.setSelectionGroup(null);
1885 ap.av.hideRepSequences(sequence, sg);
1890 int gsize = sg.getSize();
1893 hseqs = new SequenceI[gsize];
1896 for (int i = 0; i < gsize; i++)
1898 hseqs[index++] = sg.getSequenceAt(i);
1901 ap.av.hideSequence(hseqs);
1902 // refresh(); TODO: ? needed ?
1903 ap.av.sendSelection();
1906 public void copy_actionPerformed()
1908 ap.alignFrame.copy_actionPerformed(null);
1911 public void cut_actionPerformed()
1913 ap.alignFrame.cut_actionPerformed(null);
1916 void changeCase(ActionEvent e)
1918 Object source = e.getSource();
1919 SequenceGroup sg = ap.av.getSelectionGroup();
1923 int[][] startEnd = ap.av.getVisibleRegionBoundaries(sg.getStartRes(),
1924 sg.getEndRes() + 1);
1929 if (source == toggle)
1931 description = "Toggle Case";
1932 caseChange = ChangeCaseCommand.TOGGLE_CASE;
1934 else if (source == upperCase)
1936 description = "To Upper Case";
1937 caseChange = ChangeCaseCommand.TO_UPPER;
1941 description = "To Lower Case";
1942 caseChange = ChangeCaseCommand.TO_LOWER;
1945 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
1946 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
1947 startEnd, caseChange);
1949 ap.alignFrame.addHistoryItem(caseCommand);
1951 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
1957 public void outputText_actionPerformed(ActionEvent e)
1959 CutAndPasteTransfer cap = new CutAndPasteTransfer();
1960 cap.setForInput(null);
1961 Desktop.addInternalFrame(cap,
1962 "Alignment output - " + e.getActionCommand(), 600, 500);
1964 String[] omitHidden = null;
1966 System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens
1967 // or we simply trust the user wants
1968 // wysiwig behaviour
1969 SequenceGroup sg = ap.av.getSelectionGroup();
1970 ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection());
1971 omitHidden = ap.av.getViewAsString(true);
1972 Alignment oal = new Alignment(ap.av.getSequenceSelection());
1973 AlignmentAnnotation[] nala = ap.av.getAlignment()
1974 .getAlignmentAnnotation();
1977 for (int i = 0; i < nala.length; i++)
1979 AlignmentAnnotation na = nala[i];
1980 oal.addAnnotation(na);
1983 cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(),
1984 oal, omitHidden, csel, sg));
1988 public void pdbFromFile_actionPerformed() throws Exception
1990 jalview.io.JalviewFileChooser chooser = new jalview.io.JalviewFileChooser(
1991 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
1992 chooser.setFileView(new jalview.io.JalviewFileView());
1993 chooser.setDialogTitle("Select a PDB file for "
1994 + sequence.getDisplayId(false));
1995 chooser.setToolTipText("Load a PDB file and associate it with sequence '"
1996 + sequence.getDisplayId(false) + "'");
1998 int value = chooser.showOpenDialog(null);
2000 if (value == jalview.io.JalviewFileChooser.APPROVE_OPTION)
2002 String choice = chooser.getSelectedFile().getPath();
2003 jalview.bin.Cache.setProperty("LAST_DIRECTORY", choice);
2004 new AssociatePdbFileWithSeq().associatePdbWithSeq(choice,
2005 jalview.io.AppletFormatAdapter.FILE, sequence, true);
2009 // JBNote: commented out - these won't be instantiated here...!
2010 // public void RNAFold_actionPerformed() throws Exception
2012 // Predict2D P2D = new Predict2D();
2013 // P2D.getStructure2DFromRNAFold("toto");
2016 // public void ContraFold_actionPerformed() throws Exception
2018 // Predict2D P2D = new Predict2D();
2019 // P2D.getStructure2DFromContraFold("toto");
2021 public void enterPDB_actionPerformed()
2023 String id = JOptionPane.showInternalInputDialog(Desktop.desktop,
2024 "Enter PDB Id", "Enter PDB Id", JOptionPane.QUESTION_MESSAGE);
2026 if (id != null && id.length() > 0)
2028 PDBEntry entry = new PDBEntry();
2029 entry.setId(id.toUpperCase());
2030 sequence.getDatasetSequence().addPDBId(entry);
2034 public void discoverPDB_actionPerformed()
2037 final SequenceI[] sequences = ((ap.av.getSelectionGroup() == null) ? new SequenceI[]
2039 : ap.av.getSequenceSelection());
2040 Thread discpdb = new Thread(new Runnable()
2045 new jalview.ws.DBRefFetcher(sequences, ap.alignFrame)
2046 .fetchDBRefs(false);
2053 public void sequenceFeature_actionPerformed()
2055 SequenceGroup sg = ap.av.getSelectionGroup();
2061 int rsize = 0, gSize = sg.getSize();
2062 SequenceI[] rseqs, seqs = new SequenceI[gSize];
2063 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
2065 for (int i = 0; i < gSize; i++)
2067 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
2068 int end = sg.findEndRes(sg.getSequenceAt(i));
2071 seqs[rsize] = sg.getSequenceAt(i).getDatasetSequence();
2072 features[rsize] = new SequenceFeature(null, null, null, start, end,
2077 rseqs = new SequenceI[rsize];
2078 tfeatures = new SequenceFeature[rsize];
2079 System.arraycopy(seqs, 0, rseqs, 0, rsize);
2080 System.arraycopy(features, 0, tfeatures, 0, rsize);
2081 features = tfeatures;
2083 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
2084 features, true, ap))
2086 ap.alignFrame.setShowSeqFeatures(true);
2087 ap.highlightSearchResults(null);
2091 public void textColour_actionPerformed()
2093 SequenceGroup sg = getGroup();
2096 new TextColourChooser().chooseColour(ap, sg);
2100 public void colourByStructure(String pdbid)
2102 Annotation[] anots = ap.av.getStructureSelectionManager()
2103 .colourSequenceFromStructure(sequence, pdbid);
2105 AlignmentAnnotation an = new AlignmentAnnotation("Structure",
2106 "Coloured by " + pdbid, anots);
2108 ap.av.getAlignment().addAnnotation(an);
2109 an.createSequenceMapping(sequence, 0, true);
2110 // an.adjustForAlignment();
2111 ap.av.getAlignment().setAnnotationIndex(an, 0);
2113 ap.adjustAnnotationHeight();
2115 sequence.addAlignmentAnnotation(an);
2119 public void editSequence_actionPerformed(ActionEvent actionEvent)
2121 SequenceGroup sg = ap.av.getSelectionGroup();
2125 if (sequence == null)
2126 sequence = (Sequence) sg.getSequenceAt(0);
2128 EditNameDialog dialog = new EditNameDialog(
2129 sequence.getSequenceAsString(sg.getStartRes(),
2130 sg.getEndRes() + 1), null, "Edit Sequence ", null,
2131 "Edit Sequence", ap.alignFrame);
2135 EditCommand editCommand = new EditCommand("Edit Sequences",
2136 EditCommand.REPLACE, dialog.getName().replace(' ',
2137 ap.av.getGapCharacter()),
2138 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
2139 sg.getStartRes(), sg.getEndRes() + 1, ap.av.getAlignment());
2141 ap.alignFrame.addHistoryItem(editCommand);
2143 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()