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/>.
18 package jalview.appletgui;
22 import java.awt.event.*;
24 import jalview.analysis.*;
25 import jalview.commands.*;
26 import jalview.datamodel.*;
27 import jalview.schemes.*;
28 import jalview.util.UrlLink;
29 import jalview.io.AppletFormatAdapter;
30 import jalview.io.SequenceAnnotationReport;
32 public class APopupMenu extends java.awt.PopupMenu implements
33 ActionListener, ItemListener
35 Menu groupMenu = new Menu();
37 MenuItem editGroupName = new MenuItem();
39 protected MenuItem clustalColour = new MenuItem();
41 protected MenuItem zappoColour = new MenuItem();
43 protected MenuItem taylorColour = new MenuItem();
45 protected MenuItem hydrophobicityColour = new MenuItem();
47 protected MenuItem helixColour = new MenuItem();
49 protected MenuItem strandColour = new MenuItem();
51 protected MenuItem turnColour = new MenuItem();
53 protected MenuItem buriedColour = new MenuItem();
55 protected CheckboxMenuItem abovePIDColour = new CheckboxMenuItem();
57 protected MenuItem userDefinedColour = new MenuItem();
59 protected MenuItem PIDColour = new MenuItem();
61 protected MenuItem BLOSUM62Colour = new MenuItem();
63 MenuItem noColourmenuItem = new MenuItem();
65 protected CheckboxMenuItem conservationMenuItem = new CheckboxMenuItem();
67 final AlignmentPanel ap;
69 MenuItem unGroupMenuItem = new MenuItem();
71 MenuItem nucleotideMenuItem = new MenuItem();
73 Menu colourMenu = new Menu();
75 CheckboxMenuItem showBoxes = new CheckboxMenuItem();
77 CheckboxMenuItem showText = new CheckboxMenuItem();
79 CheckboxMenuItem showColourText = new CheckboxMenuItem();
81 CheckboxMenuItem displayNonconserved = new CheckboxMenuItem();
83 Menu editMenu = new Menu("Edit");
85 MenuItem copy = new MenuItem("Copy (Jalview Only)");
87 MenuItem cut = new MenuItem("Cut (Jalview Only)");
89 MenuItem toUpper = new MenuItem("To Upper Case");
91 MenuItem toLower = new MenuItem("To Lower Case");
93 MenuItem toggleCase = new MenuItem("Toggle Case");
95 Menu outputmenu = new Menu();
97 Menu seqMenu = new Menu();
99 MenuItem pdb = new MenuItem();
101 MenuItem hideSeqs = new MenuItem();
103 MenuItem repGroup = new MenuItem();
105 MenuItem sequenceName = new MenuItem("Edit Name/Description");
107 MenuItem sequenceFeature = new MenuItem("Create Sequence Feature");
109 MenuItem editSequence = new MenuItem("Edit Sequence");
111 MenuItem sequenceDetails = new MenuItem("Sequence Details ...");
113 MenuItem selSeqDetails = new MenuItem("Sequence Details ...");
115 MenuItem makeReferenceSeq = new MenuItem();
119 MenuItem revealAll = new MenuItem();
121 MenuItem revealSeq = new MenuItem();
124 * index of sequence to be revealed
126 int revealSeq_index = -1;
128 Menu menu1 = new Menu();
130 public APopupMenu(AlignmentPanel apanel, final Sequence seq, Vector links)
132 // /////////////////////////////////////////////////////////
133 // If this is activated from the sequence panel, the user may want to
134 // edit or annotate a particular residue. Therefore display the residue menu
136 // If from the IDPanel, we must display the sequence menu
137 // ////////////////////////////////////////////////////////
145 } catch (Exception e)
150 for (int i = 0; i < jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS.length; i++)
152 MenuItem item = new MenuItem(
153 jalview.io.AppletFormatAdapter.WRITEABLE_FORMATS[i]);
155 item.addActionListener(this);
156 outputmenu.add(item);
159 SequenceGroup sg = ap.av.getSelectionGroup();
161 if (sg != null && sg.getSize() > 0)
163 editGroupName.setLabel("Name: " + sg.getName());
164 showText.setState(sg.getDisplayText());
165 showColourText.setState(sg.getColourText());
166 showBoxes.setState(sg.getDisplayBoxes());
167 displayNonconserved.setState(sg.getShowNonconserved());
168 if (!ap.av.getAlignment().getGroups().contains(sg))
170 groupMenu.remove(unGroupMenuItem);
180 if (links != null && links.size() > 0)
182 Menu linkMenu = new Menu("Link");
184 for (int i = 0; i < links.size(); i++)
186 link = links.elementAt(i).toString();
187 UrlLink urlLink = new UrlLink(link);
188 if (!urlLink.isValid())
190 System.err.println(urlLink.getInvalidMessage());
193 final String target = urlLink.getTarget(); // link.substring(0,
194 // link.indexOf("|"));
195 final String label = urlLink.getLabel();
196 if (seq != null && urlLink.isDynamic())
199 // collect matching db-refs
200 DBRefEntry[] dbr = jalview.util.DBRefUtils.selectRefs(
201 seq.getDBRef(), new String[]
203 // collect id string too
204 String id = seq.getName();
205 String descr = seq.getDescription();
206 if (descr != null && descr.length() < 1)
212 for (int r = 0; r < dbr.length; r++)
214 if (id != null && dbr[r].getAccessionId().equals(id))
216 // suppress duplicate link creation for the bare sequence ID
217 // string with this link
220 // create Bare ID link for this RUL
221 String[] urls = urlLink.makeUrls(dbr[r].getAccessionId(),
225 for (int u = 0; u < urls.length; u += 2)
227 addshowLink(linkMenu, label + "|" + urls[u], urls[u + 1]);
234 // create Bare ID link for this RUL
235 String[] urls = urlLink.makeUrls(id, true);
238 for (int u = 0; u < urls.length; u += 2)
240 addshowLink(linkMenu, label, urls[u + 1]);
243 // addshowLink(linkMenu, target, url_pref + id + url_suff);
245 // Now construct URLs from description but only try to do it for regex
247 if (descr != null && urlLink.getRegexReplace() != null)
249 // create link for this URL from description only if regex matches
250 String[] urls = urlLink.makeUrls(descr, true);
253 for (int u = 0; u < urls.length; u += 2)
255 addshowLink(linkMenu, label, urls[u + 1]);
262 addshowLink(linkMenu, target, urlLink.getUrl_prefix()); // link.substring(link.lastIndexOf("|")+1));
267 * if (link.indexOf("$SEQUENCE_ID$") > -1) { // Substitute SEQUENCE_ID
268 * string and any matching database reference accessions String url_pref
269 * = link.substring(link.indexOf("|") + 1,
270 * link.indexOf("$SEQUENCE_ID$"));
272 * String url_suff = link.substring(link.indexOf("$SEQUENCE_ID$") + 13);
273 * // collect matching db-refs DBRefEntry[] dbr =
274 * jalview.util.DBRefUtils.selectRefs(seq.getDBRef(), new
275 * String[]{target}); // collect id string too String id =
276 * seq.getName(); if (id.indexOf("|") > -1) { id =
277 * id.substring(id.lastIndexOf("|") + 1); } if (dbr!=null) { for (int
278 * r=0;r<dbr.length; r++) { if (dbr[r].getAccessionId().equals(id)) { //
279 * suppress duplicate link creation for the bare sequence ID string with
280 * this link id = null; } addshowLink(linkMenu,
281 * dbr[r].getSource()+"|"+dbr[r].getAccessionId(), target,
282 * url_pref+dbr[r].getAccessionId()+url_suff); } } if (id!=null) { //
283 * create Bare ID link for this RUL addshowLink(linkMenu, target,
284 * url_pref + id + url_suff); } } else { addshowLink(linkMenu, target,
285 * link.substring(link.lastIndexOf("|")+1)); }
288 if (linkMenu.getItemCount() > 0)
292 seqMenu.add(linkMenu);
300 // TODO: add group link menu entry here
303 seqMenu.setLabel(seq.getName());
304 if (seq == ap.av.getAlignment().getSeqrep())
306 makeReferenceSeq.setLabel("Unmark representative");
308 makeReferenceSeq.setLabel("Mark as representative");
310 repGroup.setLabel("Represent Group with " + seq.getName());
317 if (!ap.av.hasHiddenRows())
324 final int index = ap.av.getAlignment().findIndex(seq);
326 if (ap.av.adjustForHiddenSeqs(index)
327 - ap.av.adjustForHiddenSeqs(index - 1) > 1)
329 revealSeq_index = index;
339 * add a show URL menu item to the given linkMenu
343 * - menu label string
347 private void addshowLink(Menu linkMenu, final String target,
350 addshowLink(linkMenu, target, target, url);
354 * add a show URL menu item to the given linkMenu
358 * - URL target window
360 * - menu label string
364 private void addshowLink(Menu linkMenu, final String target,
365 final String label, final String url)
367 MenuItem item = new MenuItem(label);
368 item.addActionListener(new java.awt.event.ActionListener()
370 public void actionPerformed(ActionEvent e)
372 ap.alignFrame.showURL(url, target);
378 public void itemStateChanged(ItemEvent evt)
380 if (evt.getSource() == abovePIDColour)
382 abovePIDColour_itemStateChanged();
384 else if (evt.getSource() == showColourText)
386 showColourText_itemStateChanged();
388 else if (evt.getSource() == showText)
390 showText_itemStateChanged();
392 else if (evt.getSource() == showBoxes)
394 showBoxes_itemStateChanged();
396 else if (evt.getSource() == displayNonconserved)
398 this.showNonconserved_itemStateChanged();
402 public void actionPerformed(ActionEvent evt)
404 Object source = evt.getSource();
405 if (source == clustalColour)
407 clustalColour_actionPerformed();
409 else if (source == zappoColour)
411 zappoColour_actionPerformed();
413 else if (source == taylorColour)
415 taylorColour_actionPerformed();
417 else if (source == hydrophobicityColour)
419 hydrophobicityColour_actionPerformed();
421 else if (source == helixColour)
423 helixColour_actionPerformed();
425 else if (source == strandColour)
427 strandColour_actionPerformed();
429 else if (source == turnColour)
431 turnColour_actionPerformed();
433 else if (source == buriedColour)
435 buriedColour_actionPerformed();
437 else if (source == nucleotideMenuItem)
439 nucleotideMenuItem_actionPerformed();
442 else if (source == userDefinedColour)
444 userDefinedColour_actionPerformed();
446 else if (source == PIDColour)
448 PIDColour_actionPerformed();
450 else if (source == BLOSUM62Colour)
452 BLOSUM62Colour_actionPerformed();
454 else if (source == noColourmenuItem)
456 noColourmenuItem_actionPerformed();
458 else if (source == conservationMenuItem)
460 conservationMenuItem_itemStateChanged();
462 else if (source == unGroupMenuItem)
464 unGroupMenuItem_actionPerformed();
467 else if (source == sequenceName)
471 else if (source == makeReferenceSeq)
473 makeReferenceSeq_actionPerformed();
475 else if (source == sequenceDetails)
477 showSequenceDetails();
479 else if (source == selSeqDetails)
481 showSequenceSelectionDetails();
483 else if (source == pdb)
487 else if (source == hideSeqs)
489 hideSequences(false);
491 else if (source == repGroup)
495 else if (source == revealSeq)
497 ap.av.showSequence(revealSeq_index);
499 else if (source == revealAll)
501 ap.av.showAllHiddenSeqs();
504 else if (source == editGroupName)
506 EditNameDialog dialog = new EditNameDialog(getGroup().getName(),
507 getGroup().getDescription(), " Group Name",
508 "Group Description", ap.alignFrame,
509 "Edit Group Name / Description", 500, 100, true);
513 getGroup().setName(dialog.getName().replace(' ', '_'));
514 getGroup().setDescription(dialog.getDescription());
518 else if (source == copy)
520 ap.alignFrame.copy_actionPerformed();
522 else if (source == cut)
524 ap.alignFrame.cut_actionPerformed();
526 else if (source == editSequence)
528 SequenceGroup sg = ap.av.getSelectionGroup();
533 seq = (Sequence) sg.getSequenceAt(0);
535 EditNameDialog dialog = new EditNameDialog(seq.getSequenceAsString(
536 sg.getStartRes(), sg.getEndRes() + 1), null,
537 "Edit Sequence ", null,
539 ap.alignFrame, "Edit Sequence", 500, 100, true);
543 EditCommand editCommand = new EditCommand("Edit Sequences",
544 EditCommand.REPLACE, dialog.getName().replace(' ',
545 ap.av.getGapCharacter()),
546 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
547 sg.getStartRes(), sg.getEndRes() + 1,
548 ap.av.getAlignment());
550 ap.alignFrame.addHistoryItem(editCommand);
552 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
557 else if (source == toUpper || source == toLower || source == toggleCase)
559 SequenceGroup sg = ap.av.getSelectionGroup();
560 Vector regions = new Vector();
563 int[][] startEnd = ap.av.getVisibleRegionBoundaries(
564 sg.getStartRes(), sg.getEndRes() + 1);
569 if (source == toggleCase)
571 description = "Toggle Case";
572 caseChange = ChangeCaseCommand.TOGGLE_CASE;
574 else if (source == toUpper)
576 description = "To Upper Case";
577 caseChange = ChangeCaseCommand.TO_UPPER;
581 description = "To Lower Case";
582 caseChange = ChangeCaseCommand.TO_LOWER;
585 ChangeCaseCommand caseCommand = new ChangeCaseCommand(description,
586 sg.getSequencesAsArray(ap.av.getHiddenRepSequences()),
587 startEnd, caseChange);
589 ap.alignFrame.addHistoryItem(caseCommand);
591 ap.av.firePropertyChange("alignment", null, ap.av.getAlignment()
596 else if (source == sequenceFeature)
598 SequenceGroup sg = ap.av.getSelectionGroup();
604 int rsize = 0, gSize = sg.getSize();
605 SequenceI[] rseqs, seqs = new SequenceI[gSize];
606 SequenceFeature[] tfeatures, features = new SequenceFeature[gSize];
608 for (int i = 0; i < gSize; i++)
610 int start = sg.getSequenceAt(i).findPosition(sg.getStartRes());
611 int end = sg.findEndRes(sg.getSequenceAt(i));
614 seqs[rsize] = sg.getSequenceAt(i);
615 features[rsize] = new SequenceFeature(null, null, null, start,
620 rseqs = new SequenceI[rsize];
621 tfeatures = new SequenceFeature[rsize];
622 System.arraycopy(seqs, 0, rseqs, 0, rsize);
623 System.arraycopy(features, 0, tfeatures, 0, rsize);
624 features = tfeatures;
627 if (ap.seqPanel.seqCanvas.getFeatureRenderer().amendFeatures(seqs,
630 ap.alignFrame.sequenceFeatures.setState(true);
631 ap.av.showSequenceFeatures(true);
632 ap.highlightSearchResults(null);
642 void outputText(ActionEvent e)
644 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, ap.alignFrame);
646 Frame frame = new Frame();
648 jalview.bin.JalviewLite.addFrame(frame,
649 "Selection output - " + e.getActionCommand(), 600, 500);
650 // JBPNote: getSelectionAsNewSequence behaviour has changed - this method
651 // now returns a full copy of sequence data
652 // TODO consider using getSequenceSelection instead here
654 cap.setText(new jalview.io.AppletFormatAdapter().formatSequences(
655 e.getActionCommand(),
656 new Alignment(ap.av.getSelectionAsNewSequence()),
657 ap.av.showJVSuffix));
661 protected void showSequenceSelectionDetails()
663 createSequenceDetailsReport(ap.av.getSequenceSelection());
666 protected void showSequenceDetails()
668 createSequenceDetailsReport(new SequenceI[]
672 public void createSequenceDetailsReport(SequenceI[] sequences)
675 CutAndPasteTransfer cap = new CutAndPasteTransfer(false, ap.alignFrame);
677 StringBuffer contents = new StringBuffer();
678 for (SequenceI seq : sequences)
680 contents.append("<p><h2>Annotation for " + seq.getDisplayId(true)
682 new SequenceAnnotationReport(null)
683 .createSequenceAnnotationReport(
689 (ap.seqPanel.seqCanvas.fr != null) ? ap.seqPanel.seqCanvas.fr.minmax
691 contents.append("</p>");
693 Frame frame = new Frame();
695 jalview.bin.JalviewLite.addFrame(frame, "Sequence Details for "
696 + (sequences.length == 1 ? sequences[0].getDisplayId(true)
697 : "Selection"), 600, 500);
698 cap.setText("<html>" + contents.toString() + "</html>");
703 EditNameDialog dialog = new EditNameDialog(seq.getName(),
704 seq.getDescription(), " Sequence Name",
705 "Sequence Description", ap.alignFrame,
706 "Edit Sequence Name / Description", 500, 100, true);
710 seq.setName(dialog.getName());
711 seq.setDescription(dialog.getDescription());
712 ap.paintAlignment(false);
718 if (seq.getPDBId() != null)
720 PDBEntry entry = (PDBEntry) seq.getPDBId().firstElement();
722 if (ap.av.applet.jmolAvailable)
723 new jalview.appletgui.AppletJmol(entry, new Sequence[]
724 { seq }, null, ap, AppletFormatAdapter.URL);
726 new MCview.AppletPDBViewer(entry, new Sequence[]
727 { seq }, null, ap, AppletFormatAdapter.URL);
732 CutAndPasteTransfer cap = new CutAndPasteTransfer(true, ap.alignFrame);
733 cap.setText("Paste your PDB file here.");
734 cap.setPDBImport(seq);
735 Frame frame = new Frame();
737 jalview.bin.JalviewLite.addFrame(frame,
738 "Paste PDB file for sequence " + seq.getName(), 400, 300);
742 private void jbInit() throws Exception
744 groupMenu.setLabel("Group");
745 groupMenu.setLabel("Selection");
746 sequenceFeature.addActionListener(this);
748 editGroupName.addActionListener(this);
749 unGroupMenuItem.setLabel("Remove Group");
750 unGroupMenuItem.addActionListener(this);
752 nucleotideMenuItem.setLabel("Nucleotide");
753 nucleotideMenuItem.addActionListener(this);
754 conservationMenuItem.addItemListener(this);
755 abovePIDColour.addItemListener(this);
756 colourMenu.setLabel("Group Colour");
757 showBoxes.setLabel("Boxes");
758 showBoxes.setState(true);
759 showBoxes.addItemListener(this);
760 sequenceName.addActionListener(this);
761 sequenceDetails.addActionListener(this);
762 selSeqDetails.addActionListener(this);
763 displayNonconserved.setLabel("Show Nonconserved");
764 displayNonconserved.setState(false);
765 displayNonconserved.addItemListener(this);
766 showText.setLabel("Text");
767 showText.addItemListener(this);
768 showColourText.setLabel("Colour Text");
769 showColourText.addItemListener(this);
770 outputmenu.setLabel("Output to Textbox...");
771 seqMenu.setLabel("Sequence");
772 pdb.setLabel("View PDB Structure");
773 hideSeqs.setLabel("Hide Sequences");
774 repGroup.setLabel("Represent Group with");
775 revealAll.setLabel("Reveal All");
776 revealSeq.setLabel("Reveal Sequences");
777 menu1.setLabel("Group");
783 // groupMenu.add(selSeqDetails);
784 groupMenu.add(editGroupName);
785 groupMenu.add(editMenu);
786 groupMenu.add(outputmenu);
787 groupMenu.add(sequenceFeature);
788 groupMenu.add(menu1);
790 colourMenu.add(noColourmenuItem);
791 colourMenu.add(clustalColour);
792 colourMenu.add(BLOSUM62Colour);
793 colourMenu.add(PIDColour);
794 colourMenu.add(zappoColour);
795 colourMenu.add(taylorColour);
796 colourMenu.add(hydrophobicityColour);
797 colourMenu.add(helixColour);
798 colourMenu.add(strandColour);
799 colourMenu.add(turnColour);
800 colourMenu.add(buriedColour);
801 colourMenu.add(nucleotideMenuItem);
802 colourMenu.add(userDefinedColour);
803 colourMenu.addSeparator();
804 colourMenu.add(abovePIDColour);
805 colourMenu.add(conservationMenuItem);
807 noColourmenuItem.setLabel("None");
808 noColourmenuItem.addActionListener(this);
810 clustalColour.setLabel("Clustalx colours");
811 clustalColour.addActionListener(this);
812 zappoColour.setLabel("Zappo");
813 zappoColour.addActionListener(this);
814 taylorColour.setLabel("Taylor");
815 taylorColour.addActionListener(this);
816 hydrophobicityColour.setLabel("Hydrophobicity");
817 hydrophobicityColour.addActionListener(this);
818 helixColour.setLabel("Helix propensity");
819 helixColour.addActionListener(this);
820 strandColour.setLabel("Strand propensity");
821 strandColour.addActionListener(this);
822 turnColour.setLabel("Turn propensity");
823 turnColour.addActionListener(this);
824 buriedColour.setLabel("Buried Index");
825 buriedColour.addActionListener(this);
826 abovePIDColour.setLabel("Above % Identity");
828 userDefinedColour.setLabel("User Defined");
829 userDefinedColour.addActionListener(this);
830 PIDColour.setLabel("Percentage Identity");
831 PIDColour.addActionListener(this);
832 BLOSUM62Colour.setLabel("BLOSUM62");
833 BLOSUM62Colour.addActionListener(this);
834 conservationMenuItem.setLabel("Conservation");
837 copy.addActionListener(this);
839 cut.addActionListener(this);
841 editMenu.add(editSequence);
842 editSequence.addActionListener(this);
844 editMenu.add(toUpper);
845 toUpper.addActionListener(this);
846 editMenu.add(toLower);
847 toLower.addActionListener(this);
848 editMenu.add(toggleCase);
849 seqMenu.add(sequenceName);
850 seqMenu.add(makeReferenceSeq);
851 // seqMenu.add(sequenceDetails);
853 if (!ap.av.applet.useXtrnalSviewer)
857 seqMenu.add(repGroup);
858 menu1.add(unGroupMenuItem);
859 menu1.add(colourMenu);
860 menu1.add(showBoxes);
862 menu1.add(showColourText);
863 menu1.add(displayNonconserved);
864 toggleCase.addActionListener(this);
865 pdb.addActionListener(this);
866 hideSeqs.addActionListener(this);
867 repGroup.addActionListener(this);
868 revealAll.addActionListener(this);
869 revealSeq.addActionListener(this);
870 makeReferenceSeq.addActionListener(this);
875 ap.paintAlignment(true);
878 protected void clustalColour_actionPerformed()
880 SequenceGroup sg = getGroup();
881 sg.cs = new ClustalxColourScheme(sg, ap.av.getHiddenRepSequences());
885 protected void zappoColour_actionPerformed()
887 getGroup().cs = new ZappoColourScheme();
891 protected void taylorColour_actionPerformed()
893 getGroup().cs = new TaylorColourScheme();
897 protected void hydrophobicityColour_actionPerformed()
899 getGroup().cs = new HydrophobicColourScheme();
903 protected void helixColour_actionPerformed()
905 getGroup().cs = new HelixColourScheme();
909 protected void strandColour_actionPerformed()
911 getGroup().cs = new StrandColourScheme();
915 protected void turnColour_actionPerformed()
917 getGroup().cs = new TurnColourScheme();
921 protected void buriedColour_actionPerformed()
923 getGroup().cs = new BuriedColourScheme();
927 public void nucleotideMenuItem_actionPerformed()
929 getGroup().cs = new NucleotideColourScheme();
933 protected void abovePIDColour_itemStateChanged()
935 SequenceGroup sg = getGroup();
941 if (abovePIDColour.getState())
943 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av
944 .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth()));
945 int threshold = SliderPanel.setPIDSliderSource(ap, sg.cs, getGroup()
948 sg.cs.setThreshold(threshold, ap.av.getIgnoreGapsConsensus());
950 SliderPanel.showPIDSlider();
954 // remove PIDColouring
956 sg.cs.setThreshold(0, ap.av.getIgnoreGapsConsensus());
963 protected void userDefinedColour_actionPerformed()
965 new UserDefinedColours(ap, getGroup());
968 protected void PIDColour_actionPerformed()
970 SequenceGroup sg = getGroup();
971 sg.cs = new PIDColourScheme();
972 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av
973 .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth()));
977 protected void BLOSUM62Colour_actionPerformed()
979 SequenceGroup sg = getGroup();
981 sg.cs = new Blosum62ColourScheme();
983 sg.cs.setConsensus(AAFrequency.calculate(sg.getSequences(ap.av
984 .getHiddenRepSequences()), 0, ap.av.getAlignment().getWidth()));
989 protected void noColourmenuItem_actionPerformed()
991 getGroup().cs = null;
995 protected void conservationMenuItem_itemStateChanged()
997 SequenceGroup sg = getGroup();
1003 if (conservationMenuItem.getState())
1006 sg.cs.setConservation(Conservation.calculateConservation("Group",
1007 ResidueProperties.propHash, 3, sg.getSequences(ap.av
1008 .getHiddenRepSequences()), 0, ap.av.getAlignment()
1009 .getWidth(), false, ap.av.getConsPercGaps(), false));
1010 SliderPanel.setConservationSlider(ap, sg.cs, sg.getName());
1011 SliderPanel.showConservationSlider();
1014 // remove ConservationColouring
1016 sg.cs.setConservation(null);
1022 SequenceGroup getGroup()
1024 SequenceGroup sg = ap.av.getSelectionGroup();
1026 // this method won't add a new group if it already exists
1029 ap.av.getAlignment().addGroup(sg);
1035 void unGroupMenuItem_actionPerformed()
1037 SequenceGroup sg = ap.av.getSelectionGroup();
1038 ap.av.getAlignment().deleteGroup(sg);
1039 ap.av.setSelectionGroup(null);
1040 ap.paintAlignment(true);
1043 public void showColourText_itemStateChanged()
1045 getGroup().setColourText(showColourText.getState());
1049 public void showText_itemStateChanged()
1051 getGroup().setDisplayText(showText.getState());
1054 public void makeReferenceSeq_actionPerformed()
1056 if (!ap.av.getAlignment().hasSeqrep())
1058 // initialise the display flags so the user sees something happen
1059 ap.av.setDisplayReferenceSeq(true);
1060 ap.av.setColourByReferenceSeq(true);
1061 ap.av.getAlignment().setSeqrep(seq);
1065 if (ap.av.getAlignment().getSeqrep() == seq)
1067 ap.av.getAlignment().setSeqrep(null);
1071 ap.av.getAlignment().setSeqrep(seq);
1077 public void showNonconserved_itemStateChanged()
1079 getGroup().setShowNonconserved(this.displayNonconserved.getState());
1083 public void showBoxes_itemStateChanged()
1085 getGroup().setDisplayBoxes(showBoxes.getState());
1089 void hideSequences(boolean representGroup)
1091 SequenceGroup sg = ap.av.getSelectionGroup();
1092 if (sg == null || sg.getSize() < 1)
1094 ap.av.hideSequence(new SequenceI[]
1099 ap.av.setSelectionGroup(null);
1103 ap.av.hideRepSequences(seq, sg);
1108 int gsize = sg.getSize();
1111 hseqs = new SequenceI[gsize];
1114 for (int i = 0; i < gsize; i++)
1116 hseqs[index++] = sg.getSequenceAt(i);
1119 ap.av.hideSequence(hseqs);
1120 ap.av.sendSelection();