2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.appletgui;
25 import jalview.analysis.*;
27 import jalview.datamodel.*;
28 import jalview.schemes.*;
30 public class AlignViewport
40 boolean cursorMode = false;
42 boolean showJVSuffix = true;
44 boolean showText = true;
46 boolean showColourText = false;
48 boolean showBoxes = true;
50 boolean wrapAlignment = false;
52 boolean renderGaps = true;
54 boolean showSequenceFeatures = false;
56 boolean showAnnotation = true;
58 boolean showConservation = true;
60 boolean showQuality = true;
62 boolean showConsensus = true;
64 boolean upperCasebold = false;
66 boolean colourAppliesToAllGroups = true;
68 ColourSchemeI globalColourScheme = null;
70 boolean conservationColourSelected = false;
72 boolean abovePIDThreshold = false;
74 SequenceGroup selectionGroup;
82 Font font = new Font("SansSerif", Font.PLAIN, 10);
84 boolean validCharWidth = true;
88 ColumnSelection colSel = new ColumnSelection();
94 NJTree currentTree = null;
96 boolean scaleAboveWrapped = true;
98 boolean scaleLeftWrapped = true;
100 boolean scaleRightWrapped = true;
102 // The following vector holds the features which are
103 // currently visible, in the correct order or rendering
104 public Hashtable featuresDisplayed;
106 boolean hasHiddenColumns = false;
108 boolean hasHiddenRows = false;
110 boolean showHiddenMarkers = true;
112 public Hashtable[] hconsensus;
114 AlignmentAnnotation consensus;
116 AlignmentAnnotation conservation;
118 AlignmentAnnotation quality;
119 AlignmentAnnotation[] groupConsensus;
120 AlignmentAnnotation[] groupConservation;
122 boolean autocalculateConsensus = true;
124 public int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
126 private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
129 boolean ignoreGapsInConsensusCalculation = false;
131 jalview.bin.JalviewLite applet;
133 Hashtable sequenceColours;
137 Stack historyList = new Stack();
139 Stack redoList = new Stack();
141 String sequenceSetID;
143 Hashtable hiddenRepSequences;
145 public AlignViewport(AlignmentI al, JalviewLite applet)
147 this.applet = applet;
150 this.endRes = al.getWidth() - 1;
152 this.endSeq = al.getHeight() - 1;
155 // get the width and height scaling factors if they were specified
156 String param = applet.getParameter("widthScale");
160 widthScale = new Float(param).floatValue();
161 } catch (Exception e)
166 System.err.println("Invalid alignment character width scaling factor ("+widthScale+"). Ignoring.");
171 System.err.println("Alignment character width scaling factor is now "+widthScale);
174 param = applet.getParameter("heightScale");
178 heightScale = new Float(param).floatValue();
179 } catch (Exception e)
182 if (heightScale<=1.0)
184 System.err.println("Invalid alignment character height scaling factor ("+heightScale+"). Ignoring.");
189 System.err.println("Alignment character height scaling factor is now "+heightScale);
195 MAC = new jalview.util.Platform().isAMac();
199 String param = applet.getParameter("showFullId");
202 showJVSuffix = Boolean.valueOf(param).booleanValue();
205 param = applet.getParameter("showAnnotation");
208 showAnnotation = Boolean.valueOf(param).booleanValue();
211 param = applet.getParameter("showConservation");
214 showConservation = Boolean.valueOf(param).booleanValue();
217 param = applet.getParameter("showQuality");
220 showQuality = Boolean.valueOf(param).booleanValue();
223 param = applet.getParameter("showConsensus");
226 showConsensus = Boolean.valueOf(param).booleanValue();
229 param = applet.getParameter("showUnconserved");
232 this.showUnconserved = Boolean.valueOf(param).booleanValue();
235 param = applet.getParameter("upperCase");
238 if (param.equalsIgnoreCase("bold"))
240 upperCasebold = true;
243 param = applet.getParameter("sortByTree");
246 sortByTree=Boolean.valueOf(param).booleanValue();
253 String colour = applet.getParameter("defaultColour");
257 colour = applet.getParameter("userDefinedColour");
260 colour = "User Defined";
266 globalColourScheme = ColourSchemeProperty.getColour(alignment,
268 if (globalColourScheme != null)
270 globalColourScheme.setConsensus(hconsensus);
274 if (applet.getParameter("userDefinedColour") != null)
276 ((UserColourScheme) globalColourScheme).parseAppletParameter(applet
277 .getParameter("userDefinedColour"));
280 if (hconsensus == null)
282 if (!alignment.isNucleotide())
284 conservation = new AlignmentAnnotation("Conservation",
285 "Conservation of total alignment less than " + ConsPercGaps
286 + "% gaps", new Annotation[1], 0f, 11f,
287 AlignmentAnnotation.BAR_GRAPH);
288 conservation.hasText = true;
289 conservation.autoCalculated = true;
291 if (showConservation)
293 alignment.addAnnotation(conservation);
298 quality = new AlignmentAnnotation("Quality",
299 "Alignment Quality based on Blosum62 scores",
300 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
301 quality.hasText = true;
302 quality.autoCalculated = true;
304 alignment.addAnnotation(quality);
308 consensus = new AlignmentAnnotation("Consensus", "PID",
309 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
310 consensus.hasText = true;
311 consensus.autoCalculated = true;
315 alignment.addAnnotation(consensus);
321 public void showSequenceFeatures(boolean b)
323 showSequenceFeatures = b;
326 public boolean getShowSequenceFeatures()
328 return showSequenceFeatures;
331 class ConservationThread extends Thread
335 public ConservationThread(AlignmentPanel ap)
344 updatingConservation = true;
346 while (UPDATING_CONSERVATION)
352 ap.paintAlignment(false);
355 } catch (Exception ex)
357 ex.printStackTrace();
361 UPDATING_CONSERVATION = true;
363 int alWidth = alignment.getWidth();
369 Conservation cons = new jalview.analysis.Conservation("All",
370 jalview.schemes.ResidueProperties.propHash, 3, alignment
371 .getSequences(), 0, alWidth - 1);
374 cons.verdict(false, ConsPercGaps);
381 char[] sequence = cons.getConsSequence().getSequence();
393 maxB = 0f - minB; // scalable range for colouring both Conservation and
403 conservation.annotations = new Annotation[alWidth];
407 quality.graphMax = cons.qualityRange[1].floatValue();
408 quality.annotations = new Annotation[alWidth];
409 qmin = cons.qualityRange[0].floatValue();
410 qmax = cons.qualityRange[1].floatValue();
413 for (int i = 0; i < alWidth; i++)
419 if (Character.isDigit(c))
421 value = (int) (c - '0');
431 // TODO - refactor to use a graduatedColorScheme to calculate the histogram colors.
432 float vprop = value - min;
434 conservation.annotations[i] = new Annotation(String.valueOf(c),
435 String.valueOf(value), ' ', value, new Color(minR
436 + (maxR * vprop), minG + (maxG * vprop), minB
442 value = ((Double) cons.quality.elementAt(i)).floatValue();
443 vprop = value - qmin;
445 quality.annotations[i] = new Annotation(" ", String
446 .valueOf(value), ' ', value, new Color(minR
447 + (maxR * vprop), minG + (maxG * vprop), minB
451 } catch (OutOfMemoryError error)
453 System.out.println("Out of memory calculating conservation!!");
459 UPDATING_CONSERVATION = false;
460 updatingConservation = false;
464 ap.paintAlignment(true);
470 ConservationThread conservationThread;
472 ConsensusThread consensusThread;
474 boolean consUpdateNeeded = false;
476 static boolean UPDATING_CONSENSUS = false;
478 static boolean UPDATING_CONSERVATION = false;
480 boolean updatingConsensus = false;
482 boolean updatingConservation = false;
487 public void updateConservation(final AlignmentPanel ap)
489 if (alignment.isNucleotide() || conservation == null)
494 conservationThread = new ConservationThread(ap);
495 conservationThread.start();
501 public void updateConsensus(final AlignmentPanel ap)
503 consensusThread = new ConsensusThread(ap);
504 consensusThread.start();
507 class ConsensusThread extends Thread
511 public ConsensusThread(AlignmentPanel ap)
518 updatingConsensus = true;
519 while (UPDATING_CONSENSUS)
525 ap.paintAlignment(false);
529 } catch (Exception ex)
531 ex.printStackTrace();
535 UPDATING_CONSENSUS = true;
539 int aWidth = alignment.getWidth();
545 consensus.annotations = null;
546 consensus.annotations = new Annotation[aWidth];
548 hconsensus = new Hashtable[aWidth];
549 AAFrequency.calculate(alignment.getSequencesArray(), 0, alignment
550 .getWidth(), hconsensus, includeAllConsensusSymbols);
551 AAFrequency.completeConsensus(consensus,hconsensus,0,aWidth,ignoreGapsInConsensusCalculation, includeAllConsensusSymbols);
553 if (globalColourScheme != null)
555 globalColourScheme.setConsensus(hconsensus);
558 } catch (OutOfMemoryError error)
560 alignment.deleteAnnotation(consensus);
564 System.out.println("Out of memory calculating consensus!!");
567 UPDATING_CONSENSUS = false;
568 updatingConsensus = false;
572 ap.paintAlignment(true);
578 * get the consensus sequence as displayed under the PID consensus annotation
581 * @return consensus sequence as a new sequence object
583 public SequenceI getConsensusSeq()
585 if (consensus == null)
589 StringBuffer seqs = new StringBuffer();
590 for (int i = 0; i < consensus.annotations.length; i++)
592 if (consensus.annotations[i] != null)
594 if (consensus.annotations[i].description.charAt(0) == '[')
596 seqs.append(consensus.annotations[i].description.charAt(1));
600 seqs.append(consensus.annotations[i].displayCharacter);
604 SequenceI sq = new Sequence("Consensus", seqs.toString());
605 sq.setDescription("Percentage Identity Consensus "
606 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
610 public SequenceGroup getSelectionGroup()
612 return selectionGroup;
615 public void setSelectionGroup(SequenceGroup sg)
620 public boolean getConservationSelected()
622 return conservationColourSelected;
625 public void setConservationSelected(boolean b)
627 conservationColourSelected = b;
630 public boolean getAbovePIDThreshold()
632 return abovePIDThreshold;
635 public void setAbovePIDThreshold(boolean b)
637 abovePIDThreshold = b;
640 public int getStartRes()
645 public int getEndRes()
650 public int getStartSeq()
655 public void setGlobalColourScheme(ColourSchemeI cs)
657 globalColourScheme = cs;
660 public ColourSchemeI getGlobalColourScheme()
662 return globalColourScheme;
665 public void setStartRes(int res)
670 public void setStartSeq(int seq)
675 public void setEndRes(int res)
677 if (res > alignment.getWidth() - 1)
679 // log.System.out.println(" Corrected res from " + res + " to maximum " +
680 // (alignment.getWidth()-1));
681 res = alignment.getWidth() - 1;
690 public void setEndSeq(int seq)
692 if (seq > alignment.getHeight())
694 seq = alignment.getHeight();
703 public int getEndSeq()
708 java.awt.Frame nullFrame;
710 protected FeatureSettings featureSettings = null;
712 private float heightScale=1,widthScale=1;
714 public void setFont(Font f)
717 if (nullFrame == null)
719 nullFrame = new java.awt.Frame();
720 nullFrame.addNotify();
723 java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font);
724 setCharHeight((int)(heightScale*fm.getHeight()));
725 charWidth = (int)(widthScale*fm.charWidth('M'));
729 Font f2 = new Font(f.getName(), Font.BOLD, f.getSize());
730 fm = nullFrame.getGraphics().getFontMetrics(f2);
731 charWidth = (int)(widthScale*(fm.stringWidth("MMMMMMMMMMM") / 10));
735 public Font getFont()
740 public int getCharWidth()
745 public void setCharHeight(int h)
750 public int getCharHeight()
755 public void setWrappedWidth(int w)
757 this.wrappedWidth = w;
760 public int getwrappedWidth()
765 public AlignmentI getAlignment()
770 public void setAlignment(AlignmentI align)
772 this.alignment = align;
775 public void setWrapAlignment(boolean state)
777 wrapAlignment = state;
780 public void setShowText(boolean state)
785 public void setRenderGaps(boolean state)
790 public boolean getColourText()
792 return showColourText;
795 public void setColourText(boolean state)
797 showColourText = state;
800 public void setShowBoxes(boolean state)
805 public boolean getWrapAlignment()
807 return wrapAlignment;
810 public boolean getShowText()
815 public boolean getShowBoxes()
820 public char getGapCharacter()
822 return getAlignment().getGapCharacter();
825 public void setGapCharacter(char gap)
827 if (getAlignment() != null)
829 getAlignment().setGapCharacter(gap);
833 public void setThreshold(int thresh)
838 public int getThreshold()
843 public void setIncrement(int inc)
848 public int getIncrement()
853 public void setHiddenColumns(ColumnSelection colsel)
855 this.colSel = colsel;
856 if (colSel.getHiddenColumns() != null)
858 hasHiddenColumns = true;
862 public ColumnSelection getColumnSelection()
867 public void resetSeqLimits(int height)
869 setEndSeq(height / getCharHeight());
872 public void setCurrentTree(NJTree tree)
877 public NJTree getCurrentTree()
882 public void setColourAppliesToAllGroups(boolean b)
884 colourAppliesToAllGroups = b;
887 public boolean getColourAppliesToAllGroups()
889 return colourAppliesToAllGroups;
892 public boolean getShowJVSuffix()
897 public void setShowJVSuffix(boolean b)
902 public boolean getShowAnnotation()
904 return showAnnotation;
907 public void setShowAnnotation(boolean b)
912 public boolean getScaleAboveWrapped()
914 return scaleAboveWrapped;
917 public boolean getScaleLeftWrapped()
919 return scaleLeftWrapped;
922 public boolean getScaleRightWrapped()
924 return scaleRightWrapped;
927 public void setScaleAboveWrapped(boolean b)
929 scaleAboveWrapped = b;
932 public void setScaleLeftWrapped(boolean b)
934 scaleLeftWrapped = b;
937 public void setScaleRightWrapped(boolean b)
939 scaleRightWrapped = b;
942 public void setIgnoreGapsConsensus(boolean b)
944 ignoreGapsInConsensusCalculation = b;
945 updateConsensus(null);
946 if (globalColourScheme != null)
948 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
949 ignoreGapsInConsensusCalculation);
955 * Property change listener for changes in alignment
960 public void addPropertyChangeListener(
961 java.beans.PropertyChangeListener listener)
963 changeSupport.addPropertyChangeListener(listener);
972 public void removePropertyChangeListener(
973 java.beans.PropertyChangeListener listener)
975 changeSupport.removePropertyChangeListener(listener);
979 * Property change listener for changes in alignment
988 public void firePropertyChange(String prop, Object oldvalue,
991 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
994 public boolean getIgnoreGapsConsensus()
996 return ignoreGapsInConsensusCalculation;
999 public void hideSelectedColumns()
1001 if (colSel.size() < 1)
1006 colSel.hideSelectedColumns();
1007 setSelectionGroup(null);
1009 hasHiddenColumns = true;
1012 public void invertColumnSelection()
1014 for (int i = 0; i < alignment.getWidth(); i++)
1016 if (colSel.contains(i))
1018 colSel.removeElement(i);
1022 if (!hasHiddenColumns || colSel.isVisible(i))
1024 colSel.addElement(i);
1030 public void hideColumns(int start, int end)
1034 colSel.hideColumns(start);
1038 colSel.hideColumns(start, end);
1041 hasHiddenColumns = true;
1044 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1046 int sSize = sg.getSize();
1052 if (hiddenRepSequences == null)
1054 hiddenRepSequences = new Hashtable();
1057 hiddenRepSequences.put(repSequence, sg);
1059 // Hide all sequences except the repSequence
1060 SequenceI[] seqs = new SequenceI[sSize - 1];
1062 for (int i = 0; i < sSize; i++)
1064 if (sg.getSequenceAt(i) != repSequence)
1066 if (index == sSize - 1)
1071 seqs[index++] = sg.getSequenceAt(i);
1079 public void hideAllSelectedSeqs()
1081 if (selectionGroup == null || selectionGroup.getSize() < 1)
1086 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1090 setSelectionGroup(null);
1093 public void hideSequence(SequenceI[] seq)
1097 for (int i = 0; i < seq.length; i++)
1099 alignment.getHiddenSequences().hideSequence(seq[i]);
1102 hasHiddenRows = true;
1103 firePropertyChange("alignment", null, alignment.getSequences());
1107 public void showColumn(int col)
1109 colSel.revealHiddenColumns(col);
1110 if (colSel.getHiddenColumns() == null)
1112 hasHiddenColumns = false;
1116 public void showAllHiddenColumns()
1118 colSel.revealAllHiddenColumns();
1119 hasHiddenColumns = false;
1122 public void showAllHiddenSeqs()
1124 if (alignment.getHiddenSequences().getSize() > 0)
1126 if (selectionGroup == null)
1128 selectionGroup = new SequenceGroup();
1129 selectionGroup.setEndRes(alignment.getWidth() - 1);
1131 Vector tmp = alignment.getHiddenSequences().showAll(
1132 hiddenRepSequences);
1133 for (int t = 0; t < tmp.size(); t++)
1135 selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
1137 firePropertyChange("alignment", null, alignment.getSequences());
1138 hasHiddenRows = false;
1139 hiddenRepSequences = null;
1143 public int adjustForHiddenSeqs(int alignmentIndex)
1145 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1150 * This method returns the a new SequenceI [] with the selection sequence and
1151 * start and end points adjusted
1155 public SequenceI[] getSelectionAsNewSequence()
1157 SequenceI[] sequences;
1159 if (selectionGroup == null)
1161 sequences = alignment.getSequencesArray();
1165 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1172 * This method returns the visible alignment as text, as seen on the GUI, ie
1173 * if columns are hidden they will not be returned in the result. Use this for
1174 * calculating trees, PCA, redundancy etc on views which contain hidden
1179 public jalview.datamodel.CigarArray getViewAsCigars(
1180 boolean selectedRegionOnly)
1182 CigarArray selection = null;
1183 SequenceI[] seqs = null;
1185 int start = 0, end = 0;
1186 if (selectedRegionOnly && selectionGroup != null)
1188 iSize = selectionGroup.getSize();
1189 seqs = selectionGroup.getSequencesInOrder(alignment);
1190 start = selectionGroup.getStartRes();
1191 end = selectionGroup.getEndRes(); // inclusive for start and end in
1192 // SeqCigar constructor
1196 iSize = alignment.getHeight();
1197 seqs = alignment.getSequencesArray();
1198 end = alignment.getWidth() - 1;
1200 SeqCigar[] selseqs = new SeqCigar[iSize];
1201 for (i = 0; i < iSize; i++)
1203 selseqs[i] = new SeqCigar(seqs[i], start, end);
1205 selection = new CigarArray(selseqs);
1206 // now construct the CigarArray operations
1207 if (hasHiddenColumns)
1209 Vector regions = colSel.getHiddenColumns();
1211 int hideStart, hideEnd;
1213 for (int j = 0; last < end & j < regions.size(); j++)
1215 region = (int[]) regions.elementAt(j);
1216 hideStart = region[0];
1217 hideEnd = region[1];
1218 // edit hidden regions to selection range
1219 if (hideStart < last)
1231 if (hideStart > end)
1241 if (hideStart > hideEnd)
1246 * form operations...
1248 if (last < hideStart)
1250 selection.addOperation(CigarArray.M, hideStart - last);
1252 selection.addOperation(CigarArray.D, 1 + hideEnd - hideStart);
1255 // Final match if necessary.
1258 selection.addOperation(CigarArray.M, end - last + 1);
1263 selection.addOperation(CigarArray.M, end - start + 1);
1269 * return a compact representation of the current alignment selection to pass
1270 * to an analysis function
1272 * @param selectedOnly
1273 * boolean true to just return the selected view
1274 * @return AlignmentView
1276 jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly)
1279 // this is here because the AlignmentView constructor modifies the
1281 // object. Refactoring of Cigar and alignment view representation should
1282 // be done to remove redundancy.
1283 CigarArray aligview = getViewAsCigars(selectedOnly);
1284 if (aligview != null)
1286 return new AlignmentView(aligview,
1287 (selectedOnly && selectionGroup != null) ? selectionGroup
1288 .getStartRes() : 0);
1294 * This method returns the visible alignment as text, as seen on the GUI, ie
1295 * if columns are hidden they will not be returned in the result. Use this for
1296 * calculating trees, PCA, redundancy etc on views which contain hidden
1301 public String[] getViewAsString(boolean selectedRegionOnly)
1303 String[] selection = null;
1304 SequenceI[] seqs = null;
1306 int start = 0, end = 0;
1307 if (selectedRegionOnly && selectionGroup != null)
1309 iSize = selectionGroup.getSize();
1310 seqs = selectionGroup.getSequencesInOrder(alignment);
1311 start = selectionGroup.getStartRes();
1312 end = selectionGroup.getEndRes() + 1;
1316 iSize = alignment.getHeight();
1317 seqs = alignment.getSequencesArray();
1318 end = alignment.getWidth();
1321 selection = new String[iSize];
1323 for (i = 0; i < iSize; i++)
1325 if (hasHiddenColumns)
1327 StringBuffer visibleSeq = new StringBuffer();
1328 Vector regions = colSel.getHiddenColumns();
1330 int blockStart = start, blockEnd = end;
1332 int hideStart, hideEnd;
1334 for (int j = 0; j < regions.size(); j++)
1336 region = (int[]) regions.elementAt(j);
1337 hideStart = region[0];
1338 hideEnd = region[1];
1340 if (hideStart < start)
1345 blockStart = Math.min(blockStart, hideEnd + 1);
1346 blockEnd = Math.min(blockEnd, hideStart);
1348 if (blockStart > blockEnd)
1353 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
1355 blockStart = hideEnd + 1;
1359 if (end > blockStart)
1361 visibleSeq.append(seqs[i].getSequence(blockStart, end));
1364 selection[i] = visibleSeq.toString();
1368 selection[i] = seqs[i].getSequenceAsString(start, end);
1375 public boolean getShowHiddenMarkers()
1377 return showHiddenMarkers;
1380 public void setShowHiddenMarkers(boolean show)
1382 showHiddenMarkers = show;
1385 public Color getSequenceColour(SequenceI seq)
1387 if (sequenceColours == null || !sequenceColours.containsKey(seq))
1393 return (Color) sequenceColours.get(seq);
1397 public void setSequenceColour(SequenceI seq, Color col)
1399 if (sequenceColours == null)
1401 sequenceColours = new Hashtable();
1406 sequenceColours.remove(seq);
1410 sequenceColours.put(seq, col);
1414 public String getSequenceSetId()
1416 if (sequenceSetID == null)
1418 sequenceSetID = alignment.hashCode() + "";
1421 return sequenceSetID;
1424 public void alignmentChanged(AlignmentPanel ap)
1426 alignment.padGaps();
1428 if (hconsensus != null && autocalculateConsensus)
1430 updateConsensus(ap);
1431 updateConservation(ap);
1434 // Reset endRes of groups if beyond alignment width
1435 int alWidth = alignment.getWidth();
1436 Vector groups = alignment.getGroups();
1439 for (int i = 0; i < groups.size(); i++)
1441 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
1442 if (sg.getEndRes() > alWidth)
1444 sg.setEndRes(alWidth - 1);
1449 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1451 selectionGroup.setEndRes(alWidth - 1);
1454 resetAllColourSchemes();
1456 // AW alignment.adjustSequenceAnnotations();
1459 void resetAllColourSchemes()
1461 ColourSchemeI cs = globalColourScheme;
1464 if (cs instanceof ClustalxColourScheme)
1466 ((ClustalxColourScheme) cs).resetClustalX(alignment.getSequences(),
1467 alignment.getWidth());
1470 cs.setConsensus(hconsensus);
1471 if (cs.conservationApplied())
1473 Alignment al = (Alignment) alignment;
1474 Conservation c = new Conservation("All",
1475 ResidueProperties.propHash, 3, al.getSequences(), 0, al
1478 c.verdict(false, ConsPercGaps);
1480 cs.setConservation(c);
1484 int s, sSize = alignment.getGroups().size();
1485 for (s = 0; s < sSize; s++)
1487 SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
1488 if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
1490 ((ClustalxColourScheme) sg.cs).resetClustalX(sg
1491 .getSequences(hiddenRepSequences), sg.getWidth());
1493 sg.recalcConservation();
1497 boolean centreColumnLabels;
1500 public boolean getCentreColumnLabels()
1502 return centreColumnLabels;
1505 public void updateSequenceIdColours()
1507 Vector groups = alignment.getGroups();
1508 for (int ig = 0, igSize = groups.size(); ig < igSize; ig++)
1510 SequenceGroup sg = (SequenceGroup) groups.elementAt(ig);
1511 if (sg.idColour != null)
1513 Vector sqs = sg.getSequences(hiddenRepSequences);
1514 for (int s = 0, sSize = sqs.size(); s < sSize; s++)
1516 this.setSequenceColour((SequenceI) sqs.elementAt(s), sg.idColour);
1521 public boolean followHighlight=false;
1522 public boolean getFollowHighlight() {
1523 return followHighlight;
1526 * show non-conserved residues only
1528 public boolean showUnconserved=false;
1531 * when set, alignment should be reordered according to a newly opened tree
1533 public boolean sortByTree=false;
1536 * @return the showUnconserved
1538 public boolean getShowunconserved()
1540 return showUnconserved;
1544 * @param showUnconserved the showUnconserved to set
1546 public void setShowunconserved(boolean displayNonconserved)
1548 this.showUnconserved = displayNonconserved;
1552 * consensus annotation includes all percentage for all symbols in column
1553 * DISABLED FOR 2.5 RELEASE (bug #60064 logo rendering is not AWT 1.1 compatible)
1555 private boolean includeAllConsensusSymbols=false;
1558 * should conservation rows be shown for groups
1559 * DISABLED FOR 2.5 RELEASE (bug 62446)
1561 boolean showGroupConservation = false;
1563 * should consensus rows be shown for groups
1564 * DISABLED FOR 2.5 RELEASE (bug 62446)
1566 boolean showGroupConsensus = false;
1568 * should consensus profile be rendered by default
1569 * DISABLED FOR 2.5 RELEASE (bug #60064 logo rendering is not AWT 1.1 compatible)
1571 public boolean showSequenceLogo = false;
1573 * should consensus histograms be rendered by default
1575 public boolean showConsensusHistogram = true;
1577 * @return the showConsensusProfile
1579 public boolean isShowSequenceLogo()
1581 return showSequenceLogo;
1584 * @param showSequenceLogo the new value
1585 public void setShowSequenceLogo(boolean showSequenceLogo)
1587 this.showSequenceLogo = showSequenceLogo;
1591 * @param showGroupConsensus the showGroupConsensus to set
1593 public void setShowGroupConsensus(boolean showGroupConsensus)
1595 this.showGroupConsensus = showGroupConsensus;
1598 * @return the includeAllConsensusSymbols
1600 public boolean isIncludeAllConsensusSymbols()
1607 * @return flag to indicate if the consensus histogram should be rendered by default
1609 public boolean isShowConsensusHistogram()
1611 return this.showConsensusHistogram;