2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
3 * Copyright (C) 2010 J Procter, AM Waterhouse, 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;
24 import jalview.analysis.*;
26 import jalview.datamodel.*;
27 import jalview.schemes.*;
29 public class AlignViewport
39 boolean cursorMode = false;
41 boolean showJVSuffix = true;
43 boolean showText = true;
45 boolean showColourText = false;
47 boolean showBoxes = true;
49 boolean wrapAlignment = false;
51 boolean renderGaps = true;
53 boolean showSequenceFeatures = false;
55 boolean showAnnotation = true;
57 boolean showConservation = true;
59 boolean showQuality = true;
61 boolean showConsensus = true;
63 boolean upperCasebold = false;
65 boolean colourAppliesToAllGroups = true;
67 ColourSchemeI globalColourScheme = null;
69 boolean conservationColourSelected = false;
71 boolean abovePIDThreshold = false;
73 SequenceGroup selectionGroup;
81 Font font = new Font("SansSerif", Font.PLAIN, 10);
83 boolean validCharWidth = true;
87 ColumnSelection colSel = new ColumnSelection();
93 NJTree currentTree = null;
95 boolean scaleAboveWrapped = true;
97 boolean scaleLeftWrapped = true;
99 boolean scaleRightWrapped = true;
101 // The following vector holds the features which are
102 // currently visible, in the correct order or rendering
103 public Hashtable featuresDisplayed;
105 boolean hasHiddenColumns = false;
107 boolean hasHiddenRows = false;
109 boolean showHiddenMarkers = true;
111 public Hashtable[] hconsensus;
113 AlignmentAnnotation consensus;
115 AlignmentAnnotation conservation;
117 AlignmentAnnotation quality;
119 AlignmentAnnotation[] groupConsensus;
121 AlignmentAnnotation[] groupConservation;
123 boolean autocalculateConsensus = true;
125 public int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
127 private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
130 boolean ignoreGapsInConsensusCalculation = false;
132 jalview.bin.JalviewLite applet;
134 Hashtable sequenceColours;
138 Stack historyList = new Stack();
140 Stack redoList = new Stack();
142 String sequenceSetID;
144 Hashtable hiddenRepSequences;
146 public AlignViewport(AlignmentI al, JalviewLite applet)
148 this.applet = applet;
151 this.endRes = al.getWidth() - 1;
153 this.endSeq = al.getHeight() - 1;
156 // get the width and height scaling factors if they were specified
157 String param = applet.getParameter("widthScale");
162 widthScale = new Float(param).floatValue();
163 } catch (Exception e)
166 if (widthScale <= 1.0)
169 .println("Invalid alignment character width scaling factor ("
170 + widthScale + "). Ignoring.");
176 .println("Alignment character width scaling factor is now "
180 param = applet.getParameter("heightScale");
185 heightScale = new Float(param).floatValue();
186 } catch (Exception e)
189 if (heightScale <= 1.0)
192 .println("Invalid alignment character height scaling factor ("
193 + heightScale + "). Ignoring.");
199 .println("Alignment character height scaling factor is now "
206 MAC = new jalview.util.Platform().isAMac();
210 String param = applet.getParameter("showFullId");
213 showJVSuffix = Boolean.valueOf(param).booleanValue();
216 param = applet.getParameter("showAnnotation");
219 showAnnotation = Boolean.valueOf(param).booleanValue();
222 param = applet.getParameter("showConservation");
225 showConservation = Boolean.valueOf(param).booleanValue();
228 param = applet.getParameter("showQuality");
231 showQuality = Boolean.valueOf(param).booleanValue();
234 param = applet.getParameter("showConsensus");
237 showConsensus = Boolean.valueOf(param).booleanValue();
240 param = applet.getParameter("showUnconserved");
243 this.showUnconserved = Boolean.valueOf(param).booleanValue();
246 param = applet.getParameter("upperCase");
249 if (param.equalsIgnoreCase("bold"))
251 upperCasebold = true;
254 param = applet.getParameter("sortByTree");
257 sortByTree = Boolean.valueOf(param).booleanValue();
264 String colour = applet.getParameter("defaultColour");
268 colour = applet.getParameter("userDefinedColour");
271 colour = "User Defined";
277 globalColourScheme = ColourSchemeProperty.getColour(alignment,
279 if (globalColourScheme != null)
281 globalColourScheme.setConsensus(hconsensus);
285 if (applet.getParameter("userDefinedColour") != null)
287 ((UserColourScheme) globalColourScheme).parseAppletParameter(applet
288 .getParameter("userDefinedColour"));
291 if (hconsensus == null)
293 if (!alignment.isNucleotide())
295 conservation = new AlignmentAnnotation("Conservation",
296 "Conservation of total alignment less than " + ConsPercGaps
297 + "% gaps", new Annotation[1], 0f, 11f,
298 AlignmentAnnotation.BAR_GRAPH);
299 conservation.hasText = true;
300 conservation.autoCalculated = true;
302 if (showConservation)
304 alignment.addAnnotation(conservation);
309 quality = new AlignmentAnnotation("Quality",
310 "Alignment Quality based on Blosum62 scores",
311 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
312 quality.hasText = true;
313 quality.autoCalculated = true;
315 alignment.addAnnotation(quality);
319 consensus = new AlignmentAnnotation("Consensus", "PID",
320 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
321 consensus.hasText = true;
322 consensus.autoCalculated = true;
326 alignment.addAnnotation(consensus);
332 public void showSequenceFeatures(boolean b)
334 showSequenceFeatures = b;
337 public boolean getShowSequenceFeatures()
339 return showSequenceFeatures;
342 class ConservationThread extends Thread
346 public ConservationThread(AlignmentPanel ap)
355 updatingConservation = true;
357 while (UPDATING_CONSERVATION)
363 ap.paintAlignment(false);
366 } catch (Exception ex)
368 ex.printStackTrace();
372 UPDATING_CONSERVATION = true;
374 int alWidth = alignment.getWidth();
380 Conservation cons = new jalview.analysis.Conservation("All",
381 jalview.schemes.ResidueProperties.propHash, 3, alignment
382 .getSequences(), 0, alWidth - 1);
385 cons.verdict(false, ConsPercGaps);
392 char[] sequence = cons.getConsSequence().getSequence();
404 maxB = 0f - minB; // scalable range for colouring both Conservation and
414 conservation.annotations = new Annotation[alWidth];
418 quality.graphMax = cons.qualityRange[1].floatValue();
419 quality.annotations = new Annotation[alWidth];
420 qmin = cons.qualityRange[0].floatValue();
421 qmax = cons.qualityRange[1].floatValue();
424 for (int i = 0; i < alWidth; i++)
430 if (Character.isDigit(c))
432 value = (int) (c - '0');
442 // TODO - refactor to use a graduatedColorScheme to calculate the
444 float vprop = value - min;
446 conservation.annotations[i] = new Annotation(String.valueOf(c),
447 String.valueOf(value), ' ', value, new Color(minR
448 + (maxR * vprop), minG + (maxG * vprop), minB
454 value = ((Double) cons.quality.elementAt(i)).floatValue();
455 vprop = value - qmin;
457 quality.annotations[i] = new Annotation(" ", String
458 .valueOf(value), ' ', value, new Color(minR
459 + (maxR * vprop), minG + (maxG * vprop), minB
463 } catch (OutOfMemoryError error)
465 System.out.println("Out of memory calculating conservation!!");
471 UPDATING_CONSERVATION = false;
472 updatingConservation = false;
476 ap.paintAlignment(true);
482 ConservationThread conservationThread;
484 ConsensusThread consensusThread;
486 boolean consUpdateNeeded = false;
488 static boolean UPDATING_CONSENSUS = false;
490 static boolean UPDATING_CONSERVATION = false;
492 boolean updatingConsensus = false;
494 boolean updatingConservation = false;
499 public void updateConservation(final AlignmentPanel ap)
501 if (alignment.isNucleotide() || conservation == null)
506 conservationThread = new ConservationThread(ap);
507 conservationThread.start();
513 public void updateConsensus(final AlignmentPanel ap)
515 consensusThread = new ConsensusThread(ap);
516 consensusThread.start();
519 class ConsensusThread extends Thread
523 public ConsensusThread(AlignmentPanel ap)
530 updatingConsensus = true;
531 while (UPDATING_CONSENSUS)
537 ap.paintAlignment(false);
541 } catch (Exception ex)
543 ex.printStackTrace();
547 UPDATING_CONSENSUS = true;
551 int aWidth = alignment.getWidth();
557 consensus.annotations = null;
558 consensus.annotations = new Annotation[aWidth];
560 hconsensus = new Hashtable[aWidth];
561 AAFrequency.calculate(alignment.getSequencesArray(), 0, alignment
562 .getWidth(), hconsensus, includeAllConsensusSymbols);
563 AAFrequency.completeConsensus(consensus, hconsensus, 0, aWidth,
564 ignoreGapsInConsensusCalculation,
565 includeAllConsensusSymbols);
567 if (globalColourScheme != null)
569 globalColourScheme.setConsensus(hconsensus);
572 } catch (OutOfMemoryError error)
574 alignment.deleteAnnotation(consensus);
578 System.out.println("Out of memory calculating consensus!!");
581 UPDATING_CONSENSUS = false;
582 updatingConsensus = false;
586 ap.paintAlignment(true);
592 * get the consensus sequence as displayed under the PID consensus annotation
595 * @return consensus sequence as a new sequence object
597 public SequenceI getConsensusSeq()
599 if (consensus == null)
603 StringBuffer seqs = new StringBuffer();
604 for (int i = 0; i < consensus.annotations.length; i++)
606 if (consensus.annotations[i] != null)
608 if (consensus.annotations[i].description.charAt(0) == '[')
610 seqs.append(consensus.annotations[i].description.charAt(1));
614 seqs.append(consensus.annotations[i].displayCharacter);
618 SequenceI sq = new Sequence("Consensus", seqs.toString());
619 sq.setDescription("Percentage Identity Consensus "
620 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
624 public SequenceGroup getSelectionGroup()
626 return selectionGroup;
629 public void setSelectionGroup(SequenceGroup sg)
634 public boolean getConservationSelected()
636 return conservationColourSelected;
639 public void setConservationSelected(boolean b)
641 conservationColourSelected = b;
644 public boolean getAbovePIDThreshold()
646 return abovePIDThreshold;
649 public void setAbovePIDThreshold(boolean b)
651 abovePIDThreshold = b;
654 public int getStartRes()
659 public int getEndRes()
664 public int getStartSeq()
669 public void setGlobalColourScheme(ColourSchemeI cs)
671 globalColourScheme = cs;
674 public ColourSchemeI getGlobalColourScheme()
676 return globalColourScheme;
679 public void setStartRes(int res)
684 public void setStartSeq(int seq)
689 public void setEndRes(int res)
691 if (res > alignment.getWidth() - 1)
693 // log.System.out.println(" Corrected res from " + res + " to maximum " +
694 // (alignment.getWidth()-1));
695 res = alignment.getWidth() - 1;
704 public void setEndSeq(int seq)
706 if (seq > alignment.getHeight())
708 seq = alignment.getHeight();
717 public int getEndSeq()
722 java.awt.Frame nullFrame;
724 protected FeatureSettings featureSettings = null;
726 private float heightScale = 1, widthScale = 1;
728 public void setFont(Font f)
731 if (nullFrame == null)
733 nullFrame = new java.awt.Frame();
734 nullFrame.addNotify();
737 java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font);
738 setCharHeight((int) (heightScale * fm.getHeight()));
739 charWidth = (int) (widthScale * fm.charWidth('M'));
743 Font f2 = new Font(f.getName(), Font.BOLD, f.getSize());
744 fm = nullFrame.getGraphics().getFontMetrics(f2);
745 charWidth = (int) (widthScale * (fm.stringWidth("MMMMMMMMMMM") / 10));
749 public Font getFont()
754 public int getCharWidth()
759 public void setCharHeight(int h)
764 public int getCharHeight()
769 public void setWrappedWidth(int w)
771 this.wrappedWidth = w;
774 public int getwrappedWidth()
779 public AlignmentI getAlignment()
784 public void setAlignment(AlignmentI align)
786 this.alignment = align;
789 public void setWrapAlignment(boolean state)
791 wrapAlignment = state;
794 public void setShowText(boolean state)
799 public void setRenderGaps(boolean state)
804 public boolean getColourText()
806 return showColourText;
809 public void setColourText(boolean state)
811 showColourText = state;
814 public void setShowBoxes(boolean state)
819 public boolean getWrapAlignment()
821 return wrapAlignment;
824 public boolean getShowText()
829 public boolean getShowBoxes()
834 public char getGapCharacter()
836 return getAlignment().getGapCharacter();
839 public void setGapCharacter(char gap)
841 if (getAlignment() != null)
843 getAlignment().setGapCharacter(gap);
847 public void setThreshold(int thresh)
852 public int getThreshold()
857 public void setIncrement(int inc)
862 public int getIncrement()
867 public void setHiddenColumns(ColumnSelection colsel)
869 this.colSel = colsel;
870 if (colSel.getHiddenColumns() != null)
872 hasHiddenColumns = true;
876 public ColumnSelection getColumnSelection()
881 public void resetSeqLimits(int height)
883 setEndSeq(height / getCharHeight());
886 public void setCurrentTree(NJTree tree)
891 public NJTree getCurrentTree()
896 public void setColourAppliesToAllGroups(boolean b)
898 colourAppliesToAllGroups = b;
901 public boolean getColourAppliesToAllGroups()
903 return colourAppliesToAllGroups;
906 public boolean getShowJVSuffix()
911 public void setShowJVSuffix(boolean b)
916 public boolean getShowAnnotation()
918 return showAnnotation;
921 public void setShowAnnotation(boolean b)
926 public boolean getScaleAboveWrapped()
928 return scaleAboveWrapped;
931 public boolean getScaleLeftWrapped()
933 return scaleLeftWrapped;
936 public boolean getScaleRightWrapped()
938 return scaleRightWrapped;
941 public void setScaleAboveWrapped(boolean b)
943 scaleAboveWrapped = b;
946 public void setScaleLeftWrapped(boolean b)
948 scaleLeftWrapped = b;
951 public void setScaleRightWrapped(boolean b)
953 scaleRightWrapped = b;
956 public void setIgnoreGapsConsensus(boolean b)
958 ignoreGapsInConsensusCalculation = b;
959 updateConsensus(null);
960 if (globalColourScheme != null)
962 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
963 ignoreGapsInConsensusCalculation);
969 * Property change listener for changes in alignment
974 public void addPropertyChangeListener(
975 java.beans.PropertyChangeListener listener)
977 changeSupport.addPropertyChangeListener(listener);
986 public void removePropertyChangeListener(
987 java.beans.PropertyChangeListener listener)
989 changeSupport.removePropertyChangeListener(listener);
993 * Property change listener for changes in alignment
1002 public void firePropertyChange(String prop, Object oldvalue,
1005 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
1008 public boolean getIgnoreGapsConsensus()
1010 return ignoreGapsInConsensusCalculation;
1013 public void hideSelectedColumns()
1015 if (colSel.size() < 1)
1020 colSel.hideSelectedColumns();
1021 setSelectionGroup(null);
1023 hasHiddenColumns = true;
1026 public void invertColumnSelection()
1028 for (int i = 0; i < alignment.getWidth(); i++)
1030 if (colSel.contains(i))
1032 colSel.removeElement(i);
1036 if (!hasHiddenColumns || colSel.isVisible(i))
1038 colSel.addElement(i);
1044 public void hideColumns(int start, int end)
1048 colSel.hideColumns(start);
1052 colSel.hideColumns(start, end);
1055 hasHiddenColumns = true;
1058 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1060 int sSize = sg.getSize();
1066 if (hiddenRepSequences == null)
1068 hiddenRepSequences = new Hashtable();
1071 hiddenRepSequences.put(repSequence, sg);
1073 // Hide all sequences except the repSequence
1074 SequenceI[] seqs = new SequenceI[sSize - 1];
1076 for (int i = 0; i < sSize; i++)
1078 if (sg.getSequenceAt(i) != repSequence)
1080 if (index == sSize - 1)
1085 seqs[index++] = sg.getSequenceAt(i);
1093 public void hideAllSelectedSeqs()
1095 if (selectionGroup == null || selectionGroup.getSize() < 1)
1100 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1104 setSelectionGroup(null);
1107 public void hideSequence(SequenceI[] seq)
1111 for (int i = 0; i < seq.length; i++)
1113 alignment.getHiddenSequences().hideSequence(seq[i]);
1116 hasHiddenRows = true;
1117 firePropertyChange("alignment", null, alignment.getSequences());
1121 public void showColumn(int col)
1123 colSel.revealHiddenColumns(col);
1124 if (colSel.getHiddenColumns() == null)
1126 hasHiddenColumns = false;
1130 public void showAllHiddenColumns()
1132 colSel.revealAllHiddenColumns();
1133 hasHiddenColumns = false;
1136 public void showAllHiddenSeqs()
1138 if (alignment.getHiddenSequences().getSize() > 0)
1140 if (selectionGroup == null)
1142 selectionGroup = new SequenceGroup();
1143 selectionGroup.setEndRes(alignment.getWidth() - 1);
1145 Vector tmp = alignment.getHiddenSequences().showAll(
1146 hiddenRepSequences);
1147 for (int t = 0; t < tmp.size(); t++)
1149 selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
1151 firePropertyChange("alignment", null, alignment.getSequences());
1152 hasHiddenRows = false;
1153 hiddenRepSequences = null;
1157 public int adjustForHiddenSeqs(int alignmentIndex)
1159 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1164 * This method returns the a new SequenceI [] with the selection sequence and
1165 * start and end points adjusted
1169 public SequenceI[] getSelectionAsNewSequence()
1171 SequenceI[] sequences;
1173 if (selectionGroup == null)
1175 sequences = alignment.getSequencesArray();
1179 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1186 * get the currently selected sequence objects or all the sequences in the
1189 * @return array of references to sequence objects
1191 public SequenceI[] getSequenceSelection()
1193 SequenceI[] sequences = null;
1194 if (selectionGroup != null)
1196 sequences = selectionGroup.getSequencesInOrder(alignment);
1198 if (sequences == null)
1200 sequences = alignment.getSequencesArray();
1206 * This method returns the visible alignment as text, as seen on the GUI, ie
1207 * if columns are hidden they will not be returned in the result. Use this for
1208 * calculating trees, PCA, redundancy etc on views which contain hidden
1213 public jalview.datamodel.CigarArray getViewAsCigars(
1214 boolean selectedRegionOnly)
1216 CigarArray selection = null;
1217 SequenceI[] seqs = null;
1219 int start = 0, end = 0;
1220 if (selectedRegionOnly && selectionGroup != null)
1222 iSize = selectionGroup.getSize();
1223 seqs = selectionGroup.getSequencesInOrder(alignment);
1224 start = selectionGroup.getStartRes();
1225 end = selectionGroup.getEndRes(); // inclusive for start and end in
1226 // SeqCigar constructor
1230 iSize = alignment.getHeight();
1231 seqs = alignment.getSequencesArray();
1232 end = alignment.getWidth() - 1;
1234 SeqCigar[] selseqs = new SeqCigar[iSize];
1235 for (i = 0; i < iSize; i++)
1237 selseqs[i] = new SeqCigar(seqs[i], start, end);
1239 selection = new CigarArray(selseqs);
1240 // now construct the CigarArray operations
1241 if (hasHiddenColumns)
1243 Vector regions = colSel.getHiddenColumns();
1245 int hideStart, hideEnd;
1247 for (int j = 0; last < end & j < regions.size(); j++)
1249 region = (int[]) regions.elementAt(j);
1250 hideStart = region[0];
1251 hideEnd = region[1];
1252 // edit hidden regions to selection range
1253 if (hideStart < last)
1265 if (hideStart > end)
1275 if (hideStart > hideEnd)
1280 * form operations...
1282 if (last < hideStart)
1284 selection.addOperation(CigarArray.M, hideStart - last);
1286 selection.addOperation(CigarArray.D, 1 + hideEnd - hideStart);
1289 // Final match if necessary.
1292 selection.addOperation(CigarArray.M, end - last + 1);
1297 selection.addOperation(CigarArray.M, end - start + 1);
1303 * return a compact representation of the current alignment selection to pass
1304 * to an analysis function
1306 * @param selectedOnly
1307 * boolean true to just return the selected view
1308 * @return AlignmentView
1310 jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly)
1313 // this is here because the AlignmentView constructor modifies the
1315 // object. Refactoring of Cigar and alignment view representation should
1316 // be done to remove redundancy.
1317 CigarArray aligview = getViewAsCigars(selectedOnly);
1318 if (aligview != null)
1320 return new AlignmentView(aligview,
1321 (selectedOnly && selectionGroup != null) ? selectionGroup
1322 .getStartRes() : 0);
1328 * This method returns the visible alignment as text, as seen on the GUI, ie
1329 * if columns are hidden they will not be returned in the result. Use this for
1330 * calculating trees, PCA, redundancy etc on views which contain hidden
1335 public String[] getViewAsString(boolean selectedRegionOnly)
1337 String[] selection = null;
1338 SequenceI[] seqs = null;
1340 int start = 0, end = 0;
1341 if (selectedRegionOnly && selectionGroup != null)
1343 iSize = selectionGroup.getSize();
1344 seqs = selectionGroup.getSequencesInOrder(alignment);
1345 start = selectionGroup.getStartRes();
1346 end = selectionGroup.getEndRes() + 1;
1350 iSize = alignment.getHeight();
1351 seqs = alignment.getSequencesArray();
1352 end = alignment.getWidth();
1355 selection = new String[iSize];
1357 for (i = 0; i < iSize; i++)
1359 if (hasHiddenColumns)
1361 StringBuffer visibleSeq = new StringBuffer();
1362 Vector regions = colSel.getHiddenColumns();
1364 int blockStart = start, blockEnd = end;
1366 int hideStart, hideEnd;
1368 for (int j = 0; j < regions.size(); j++)
1370 region = (int[]) regions.elementAt(j);
1371 hideStart = region[0];
1372 hideEnd = region[1];
1374 if (hideStart < start)
1379 blockStart = Math.min(blockStart, hideEnd + 1);
1380 blockEnd = Math.min(blockEnd, hideStart);
1382 if (blockStart > blockEnd)
1387 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
1389 blockStart = hideEnd + 1;
1393 if (end > blockStart)
1395 visibleSeq.append(seqs[i].getSequence(blockStart, end));
1398 selection[i] = visibleSeq.toString();
1402 selection[i] = seqs[i].getSequenceAsString(start, end);
1409 public boolean getShowHiddenMarkers()
1411 return showHiddenMarkers;
1414 public void setShowHiddenMarkers(boolean show)
1416 showHiddenMarkers = show;
1419 public Color getSequenceColour(SequenceI seq)
1421 if (sequenceColours == null || !sequenceColours.containsKey(seq))
1427 return (Color) sequenceColours.get(seq);
1431 public void setSequenceColour(SequenceI seq, Color col)
1433 if (sequenceColours == null)
1435 sequenceColours = new Hashtable();
1440 sequenceColours.remove(seq);
1444 sequenceColours.put(seq, col);
1448 public String getSequenceSetId()
1450 if (sequenceSetID == null)
1452 sequenceSetID = alignment.hashCode() + "";
1455 return sequenceSetID;
1458 public void alignmentChanged(AlignmentPanel ap)
1460 alignment.padGaps();
1462 if (hconsensus != null && autocalculateConsensus)
1464 updateConsensus(ap);
1465 updateConservation(ap);
1468 // Reset endRes of groups if beyond alignment width
1469 int alWidth = alignment.getWidth();
1470 Vector groups = alignment.getGroups();
1473 for (int i = 0; i < groups.size(); i++)
1475 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
1476 if (sg.getEndRes() > alWidth)
1478 sg.setEndRes(alWidth - 1);
1483 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1485 selectionGroup.setEndRes(alWidth - 1);
1488 resetAllColourSchemes();
1490 // AW alignment.adjustSequenceAnnotations();
1493 void resetAllColourSchemes()
1495 ColourSchemeI cs = globalColourScheme;
1498 if (cs instanceof ClustalxColourScheme)
1500 ((ClustalxColourScheme) cs).resetClustalX(alignment.getSequences(),
1501 alignment.getWidth());
1504 cs.setConsensus(hconsensus);
1505 if (cs.conservationApplied())
1507 Alignment al = (Alignment) alignment;
1508 Conservation c = new Conservation("All",
1509 ResidueProperties.propHash, 3, al.getSequences(), 0, al
1512 c.verdict(false, ConsPercGaps);
1514 cs.setConservation(c);
1518 int s, sSize = alignment.getGroups().size();
1519 for (s = 0; s < sSize; s++)
1521 SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
1522 if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
1524 ((ClustalxColourScheme) sg.cs).resetClustalX(sg
1525 .getSequences(hiddenRepSequences), sg.getWidth());
1527 sg.recalcConservation();
1531 boolean centreColumnLabels;
1533 public boolean getCentreColumnLabels()
1535 return centreColumnLabels;
1538 public void updateSequenceIdColours()
1540 Vector groups = alignment.getGroups();
1541 for (int ig = 0, igSize = groups.size(); ig < igSize; ig++)
1543 SequenceGroup sg = (SequenceGroup) groups.elementAt(ig);
1544 if (sg.idColour != null)
1546 Vector sqs = sg.getSequences(hiddenRepSequences);
1547 for (int s = 0, sSize = sqs.size(); s < sSize; s++)
1549 this.setSequenceColour((SequenceI) sqs.elementAt(s), sg.idColour);
1555 public boolean followHighlight = false;
1557 public boolean getFollowHighlight()
1559 return followHighlight;
1563 * show non-conserved residues only
1565 public boolean showUnconserved = false;
1568 * when set, alignment should be reordered according to a newly opened tree
1570 public boolean sortByTree = false;
1573 * @return the showUnconserved
1575 public boolean getShowunconserved()
1577 return showUnconserved;
1581 * @param showUnconserved
1582 * the showUnconserved to set
1584 public void setShowunconserved(boolean displayNonconserved)
1586 this.showUnconserved = displayNonconserved;
1590 * consensus annotation includes all percentage for all symbols in column
1591 * DISABLED FOR 2.5 RELEASE (bug #60064 logo rendering is not AWT 1.1
1594 private boolean includeAllConsensusSymbols = false;
1597 * should conservation rows be shown for groups DISABLED FOR 2.5 RELEASE (bug
1600 boolean showGroupConservation = false;
1603 * should consensus rows be shown for groups DISABLED FOR 2.5 RELEASE (bug
1606 boolean showGroupConsensus = false;
1609 * should consensus profile be rendered by default DISABLED FOR 2.5 RELEASE
1610 * (bug #60064 logo rendering is not AWT 1.1 compatible)
1612 public boolean showSequenceLogo = false;
1615 * should consensus histograms be rendered by default
1617 public boolean showConsensusHistogram = true;
1620 * @return the showConsensusProfile
1622 public boolean isShowSequenceLogo()
1624 return showSequenceLogo;
1628 * @param showSequenceLogo
1629 * the new value public void setShowSequenceLogo(boolean
1630 * showSequenceLogo) { this.showSequenceLogo = showSequenceLogo; }
1633 * @param showGroupConsensus
1634 * the showGroupConsensus to set
1636 public void setShowGroupConsensus(boolean showGroupConsensus)
1638 this.showGroupConsensus = showGroupConsensus;
1642 * @return the includeAllConsensusSymbols
1644 public boolean isIncludeAllConsensusSymbols()
1651 * @return flag to indicate if the consensus histogram should be rendered by
1654 public boolean isShowConsensusHistogram()
1656 return this.showConsensusHistogram;
1660 * synthesize a column selection if none exists so it covers the given
1661 * selection group. if wholewidth is false, no column selection is made if the
1662 * selection group covers the whole alignment width.
1667 public void expandColSelection(SequenceGroup sg, boolean wholewidth)
1671 && (sgs = sg.getStartRes()) >= 0
1672 && sg.getStartRes() <= (sge = sg.getEndRes())
1673 && (colSel == null || colSel.getSelected() == null || colSel
1674 .getSelected().size() == 0))
1676 if (!wholewidth && alignment.getWidth() == (1 + sge - sgs))
1683 colSel = new ColumnSelection();
1685 for (int cspos = sg.getStartRes(); cspos <= sg.getEndRes(); cspos++)
1687 colSel.addElement(cspos);