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;
120 boolean autocalculateConsensus = true;
122 public int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
124 private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
127 boolean ignoreGapsInConsensusCalculation = false;
129 jalview.bin.JalviewLite applet;
131 Hashtable sequenceColours;
135 Stack historyList = new Stack();
137 Stack redoList = new Stack();
139 String sequenceSetID;
141 Hashtable hiddenRepSequences;
143 public AlignViewport(AlignmentI al, JalviewLite applet)
145 this.applet = applet;
148 this.endRes = al.getWidth() - 1;
150 this.endSeq = al.getHeight() - 1;
153 MAC = new jalview.util.Platform().isAMac();
157 String param = applet.getParameter("showFullId");
160 showJVSuffix = Boolean.valueOf(param).booleanValue();
163 param = applet.getParameter("showAnnotation");
166 showAnnotation = Boolean.valueOf(param).booleanValue();
169 param = applet.getParameter("showConservation");
172 showConservation = Boolean.valueOf(param).booleanValue();
175 param = applet.getParameter("showQuality");
178 showQuality = Boolean.valueOf(param).booleanValue();
181 param = applet.getParameter("showConsensus");
184 showConsensus = Boolean.valueOf(param).booleanValue();
187 param = applet.getParameter("showUnconserved");
190 this.showUnconserved = Boolean.valueOf(param).booleanValue();
193 param = applet.getParameter("upperCase");
196 if (param.equalsIgnoreCase("bold"))
198 upperCasebold = true;
201 param = applet.getParameter("sortByTree");
204 sortByTree=Boolean.valueOf(param).booleanValue();
211 String colour = applet.getParameter("defaultColour");
215 colour = applet.getParameter("userDefinedColour");
218 colour = "User Defined";
224 globalColourScheme = ColourSchemeProperty.getColour(alignment,
226 if (globalColourScheme != null)
228 globalColourScheme.setConsensus(hconsensus);
232 if (applet.getParameter("userDefinedColour") != null)
234 ((UserColourScheme) globalColourScheme).parseAppletParameter(applet
235 .getParameter("userDefinedColour"));
238 if (hconsensus == null)
240 if (!alignment.isNucleotide())
242 conservation = new AlignmentAnnotation("Conservation",
243 "Conservation of total alignment less than " + ConsPercGaps
244 + "% gaps", new Annotation[1], 0f, 11f,
245 AlignmentAnnotation.BAR_GRAPH);
246 conservation.hasText = true;
247 conservation.autoCalculated = true;
249 if (showConservation)
251 alignment.addAnnotation(conservation);
256 quality = new AlignmentAnnotation("Quality",
257 "Alignment Quality based on Blosum62 scores",
258 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
259 quality.hasText = true;
260 quality.autoCalculated = true;
262 alignment.addAnnotation(quality);
266 consensus = new AlignmentAnnotation("Consensus", "PID",
267 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
268 consensus.hasText = true;
269 consensus.autoCalculated = true;
273 alignment.addAnnotation(consensus);
279 public void showSequenceFeatures(boolean b)
281 showSequenceFeatures = b;
284 public boolean getShowSequenceFeatures()
286 return showSequenceFeatures;
289 class ConservationThread extends Thread
293 public ConservationThread(AlignmentPanel ap)
302 updatingConservation = true;
304 while (UPDATING_CONSERVATION)
310 ap.paintAlignment(false);
313 } catch (Exception ex)
315 ex.printStackTrace();
319 UPDATING_CONSERVATION = true;
321 int alWidth = alignment.getWidth();
327 Conservation cons = new jalview.analysis.Conservation("All",
328 jalview.schemes.ResidueProperties.propHash, 3, alignment
329 .getSequences(), 0, alWidth - 1);
332 cons.verdict(false, ConsPercGaps);
339 char[] sequence = cons.getConsSequence().getSequence();
351 maxB = 0f - minB; // scalable range for colouring both Conservation and
361 conservation.annotations = new Annotation[alWidth];
365 quality.graphMax = cons.qualityRange[1].floatValue();
366 quality.annotations = new Annotation[alWidth];
367 qmin = cons.qualityRange[0].floatValue();
368 qmax = cons.qualityRange[1].floatValue();
371 for (int i = 0; i < alWidth; i++)
377 if (Character.isDigit(c))
379 value = (int) (c - '0');
390 float vprop = value - min;
392 conservation.annotations[i] = new Annotation(String.valueOf(c),
393 String.valueOf(value), ' ', value, new Color(minR
394 + (maxR * vprop), minG + (maxG * vprop), minB
400 value = ((Double) cons.quality.elementAt(i)).floatValue();
401 vprop = value - qmin;
403 quality.annotations[i] = new Annotation(" ", String
404 .valueOf(value), ' ', value, new Color(minR
405 + (maxR * vprop), minG + (maxG * vprop), minB
409 } catch (OutOfMemoryError error)
411 System.out.println("Out of memory calculating conservation!!");
417 UPDATING_CONSERVATION = false;
418 updatingConservation = false;
422 ap.paintAlignment(true);
428 ConservationThread conservationThread;
430 ConsensusThread consensusThread;
432 boolean consUpdateNeeded = false;
434 static boolean UPDATING_CONSENSUS = false;
436 static boolean UPDATING_CONSERVATION = false;
438 boolean updatingConsensus = false;
440 boolean updatingConservation = false;
445 public void updateConservation(final AlignmentPanel ap)
447 if (alignment.isNucleotide() || conservation == null)
452 conservationThread = new ConservationThread(ap);
453 conservationThread.start();
459 public void updateConsensus(final AlignmentPanel ap)
461 consensusThread = new ConsensusThread(ap);
462 consensusThread.start();
465 class ConsensusThread extends Thread
469 public ConsensusThread(AlignmentPanel ap)
476 updatingConsensus = true;
477 while (UPDATING_CONSENSUS)
483 ap.paintAlignment(false);
487 } catch (Exception ex)
489 ex.printStackTrace();
493 UPDATING_CONSENSUS = true;
497 int aWidth = alignment.getWidth();
503 consensus.annotations = null;
504 consensus.annotations = new Annotation[aWidth];
506 hconsensus = new Hashtable[aWidth];
507 AAFrequency.calculate(alignment.getSequencesArray(), 0, alignment
508 .getWidth(), hconsensus);
510 for (int i = 0; i < aWidth; i++)
513 if (ignoreGapsInConsensusCalculation)
515 value = ((Float) hconsensus[i].get(AAFrequency.PID_NOGAPS))
520 value = ((Float) hconsensus[i].get(AAFrequency.PID_GAPS))
524 String maxRes = hconsensus[i].get(AAFrequency.MAXRESIDUE)
526 String mouseOver = hconsensus[i].get(AAFrequency.MAXRESIDUE)
529 if (maxRes.length() > 1)
531 mouseOver = "[" + maxRes + "] ";
535 mouseOver += ((int) value + "%");
536 consensus.annotations[i] = new Annotation(maxRes, mouseOver, ' ',
540 if (globalColourScheme != null)
542 globalColourScheme.setConsensus(hconsensus);
545 } catch (OutOfMemoryError error)
547 alignment.deleteAnnotation(consensus);
551 System.out.println("Out of memory calculating consensus!!");
554 UPDATING_CONSENSUS = false;
555 updatingConsensus = false;
559 ap.paintAlignment(true);
565 * get the consensus sequence as displayed under the PID consensus annotation
568 * @return consensus sequence as a new sequence object
571 * get the consensus sequence as displayed under the PID consensus annotation
574 * @return consensus sequence as a new sequence object
576 public SequenceI getConsensusSeq()
578 if (consensus == null)
582 StringBuffer seqs = new StringBuffer();
583 for (int i = 0; i < consensus.annotations.length; i++)
585 if (consensus.annotations[i] != null)
587 if (consensus.annotations[i].description.charAt(0) == '[')
589 seqs.append(consensus.annotations[i].description.charAt(1));
593 seqs.append(consensus.annotations[i].displayCharacter);
597 SequenceI sq = new Sequence("Consensus", seqs.toString());
598 sq.setDescription("Percentage Identity Consensus "
599 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
603 public SequenceGroup getSelectionGroup()
605 return selectionGroup;
608 public void setSelectionGroup(SequenceGroup sg)
613 public boolean getConservationSelected()
615 return conservationColourSelected;
618 public void setConservationSelected(boolean b)
620 conservationColourSelected = b;
623 public boolean getAbovePIDThreshold()
625 return abovePIDThreshold;
628 public void setAbovePIDThreshold(boolean b)
630 abovePIDThreshold = b;
633 public int getStartRes()
638 public int getEndRes()
643 public int getStartSeq()
648 public void setGlobalColourScheme(ColourSchemeI cs)
650 globalColourScheme = cs;
653 public ColourSchemeI getGlobalColourScheme()
655 return globalColourScheme;
658 public void setStartRes(int res)
663 public void setStartSeq(int seq)
668 public void setEndRes(int res)
670 if (res > alignment.getWidth() - 1)
672 // log.System.out.println(" Corrected res from " + res + " to maximum " +
673 // (alignment.getWidth()-1));
674 res = alignment.getWidth() - 1;
683 public void setEndSeq(int seq)
685 if (seq > alignment.getHeight())
687 seq = alignment.getHeight();
696 public int getEndSeq()
701 java.awt.Frame nullFrame;
703 protected FeatureSettings featureSettings = null;
705 public void setFont(Font f)
708 if (nullFrame == null)
710 nullFrame = new java.awt.Frame();
711 nullFrame.addNotify();
714 java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font);
715 setCharHeight(fm.getHeight());
716 charWidth = fm.charWidth('M');
720 Font f2 = new Font(f.getName(), Font.BOLD, f.getSize());
721 fm = nullFrame.getGraphics().getFontMetrics(f2);
722 charWidth = fm.stringWidth("MMMMMMMMMMM") / 10;
726 public Font getFont()
731 public int getCharWidth()
736 public void setCharHeight(int h)
741 public int getCharHeight()
746 public void setWrappedWidth(int w)
748 this.wrappedWidth = w;
751 public int getwrappedWidth()
756 public AlignmentI getAlignment()
761 public void setAlignment(AlignmentI align)
763 this.alignment = align;
766 public void setWrapAlignment(boolean state)
768 wrapAlignment = state;
771 public void setShowText(boolean state)
776 public void setRenderGaps(boolean state)
781 public boolean getColourText()
783 return showColourText;
786 public void setColourText(boolean state)
788 showColourText = state;
791 public void setShowBoxes(boolean state)
796 public boolean getWrapAlignment()
798 return wrapAlignment;
801 public boolean getShowText()
806 public boolean getShowBoxes()
811 public char getGapCharacter()
813 return getAlignment().getGapCharacter();
816 public void setGapCharacter(char gap)
818 if (getAlignment() != null)
820 getAlignment().setGapCharacter(gap);
824 public void setThreshold(int thresh)
829 public int getThreshold()
834 public void setIncrement(int inc)
839 public int getIncrement()
844 public void setHiddenColumns(ColumnSelection colsel)
846 this.colSel = colsel;
847 if (colSel.getHiddenColumns() != null)
849 hasHiddenColumns = true;
853 public ColumnSelection getColumnSelection()
858 public void resetSeqLimits(int height)
860 setEndSeq(height / getCharHeight());
863 public void setCurrentTree(NJTree tree)
868 public NJTree getCurrentTree()
873 public void setColourAppliesToAllGroups(boolean b)
875 colourAppliesToAllGroups = b;
878 public boolean getColourAppliesToAllGroups()
880 return colourAppliesToAllGroups;
883 public boolean getShowJVSuffix()
888 public void setShowJVSuffix(boolean b)
893 public boolean getShowAnnotation()
895 return showAnnotation;
898 public void setShowAnnotation(boolean b)
903 public boolean getScaleAboveWrapped()
905 return scaleAboveWrapped;
908 public boolean getScaleLeftWrapped()
910 return scaleLeftWrapped;
913 public boolean getScaleRightWrapped()
915 return scaleRightWrapped;
918 public void setScaleAboveWrapped(boolean b)
920 scaleAboveWrapped = b;
923 public void setScaleLeftWrapped(boolean b)
925 scaleLeftWrapped = b;
928 public void setScaleRightWrapped(boolean b)
930 scaleRightWrapped = b;
933 public void setIgnoreGapsConsensus(boolean b)
935 ignoreGapsInConsensusCalculation = b;
936 updateConsensus(null);
937 if (globalColourScheme != null)
939 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
940 ignoreGapsInConsensusCalculation);
946 * Property change listener for changes in alignment
951 public void addPropertyChangeListener(
952 java.beans.PropertyChangeListener listener)
954 changeSupport.addPropertyChangeListener(listener);
963 public void removePropertyChangeListener(
964 java.beans.PropertyChangeListener listener)
966 changeSupport.removePropertyChangeListener(listener);
970 * Property change listener for changes in alignment
979 public void firePropertyChange(String prop, Object oldvalue,
982 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
985 public boolean getIgnoreGapsConsensus()
987 return ignoreGapsInConsensusCalculation;
990 public void hideSelectedColumns()
992 if (colSel.size() < 1)
997 colSel.hideSelectedColumns();
998 setSelectionGroup(null);
1000 hasHiddenColumns = true;
1003 public void invertColumnSelection()
1005 for (int i = 0; i < alignment.getWidth(); i++)
1007 if (colSel.contains(i))
1009 colSel.removeElement(i);
1013 if (!hasHiddenColumns || colSel.isVisible(i))
1015 colSel.addElement(i);
1021 public void hideColumns(int start, int end)
1025 colSel.hideColumns(start);
1029 colSel.hideColumns(start, end);
1032 hasHiddenColumns = true;
1035 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1037 int sSize = sg.getSize();
1043 if (hiddenRepSequences == null)
1045 hiddenRepSequences = new Hashtable();
1048 hiddenRepSequences.put(repSequence, sg);
1050 // Hide all sequences except the repSequence
1051 SequenceI[] seqs = new SequenceI[sSize - 1];
1053 for (int i = 0; i < sSize; i++)
1055 if (sg.getSequenceAt(i) != repSequence)
1057 if (index == sSize - 1)
1062 seqs[index++] = sg.getSequenceAt(i);
1070 public void hideAllSelectedSeqs()
1072 if (selectionGroup == null || selectionGroup.getSize() < 1)
1077 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1081 setSelectionGroup(null);
1084 public void hideSequence(SequenceI[] seq)
1088 for (int i = 0; i < seq.length; i++)
1090 alignment.getHiddenSequences().hideSequence(seq[i]);
1093 hasHiddenRows = true;
1094 firePropertyChange("alignment", null, alignment.getSequences());
1098 public void showColumn(int col)
1100 colSel.revealHiddenColumns(col);
1101 if (colSel.getHiddenColumns() == null)
1103 hasHiddenColumns = false;
1107 public void showAllHiddenColumns()
1109 colSel.revealAllHiddenColumns();
1110 hasHiddenColumns = false;
1113 public void showAllHiddenSeqs()
1115 if (alignment.getHiddenSequences().getSize() > 0)
1117 if (selectionGroup == null)
1119 selectionGroup = new SequenceGroup();
1120 selectionGroup.setEndRes(alignment.getWidth() - 1);
1122 Vector tmp = alignment.getHiddenSequences().showAll(
1123 hiddenRepSequences);
1124 for (int t = 0; t < tmp.size(); t++)
1126 selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
1128 firePropertyChange("alignment", null, alignment.getSequences());
1129 hasHiddenRows = false;
1130 hiddenRepSequences = null;
1134 public int adjustForHiddenSeqs(int alignmentIndex)
1136 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1141 * This method returns the a new SequenceI [] with the selection sequence and
1142 * start and end points adjusted
1146 public SequenceI[] getSelectionAsNewSequence()
1148 SequenceI[] sequences;
1150 if (selectionGroup == null)
1152 sequences = alignment.getSequencesArray();
1156 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1163 * This method returns the visible alignment as text, as seen on the GUI, ie
1164 * if columns are hidden they will not be returned in the result. Use this for
1165 * calculating trees, PCA, redundancy etc on views which contain hidden
1170 public jalview.datamodel.CigarArray getViewAsCigars(
1171 boolean selectedRegionOnly)
1173 CigarArray selection = null;
1174 SequenceI[] seqs = null;
1176 int start = 0, end = 0;
1177 if (selectedRegionOnly && selectionGroup != null)
1179 iSize = selectionGroup.getSize();
1180 seqs = selectionGroup.getSequencesInOrder(alignment);
1181 start = selectionGroup.getStartRes();
1182 end = selectionGroup.getEndRes(); // inclusive for start and end in
1183 // SeqCigar constructor
1187 iSize = alignment.getHeight();
1188 seqs = alignment.getSequencesArray();
1189 end = alignment.getWidth() - 1;
1191 SeqCigar[] selseqs = new SeqCigar[iSize];
1192 for (i = 0; i < iSize; i++)
1194 selseqs[i] = new SeqCigar(seqs[i], start, end);
1196 selection = new CigarArray(selseqs);
1197 // now construct the CigarArray operations
1198 if (hasHiddenColumns)
1200 Vector regions = colSel.getHiddenColumns();
1202 int hideStart, hideEnd;
1204 for (int j = 0; last < end & j < regions.size(); j++)
1206 region = (int[]) regions.elementAt(j);
1207 hideStart = region[0];
1208 hideEnd = region[1];
1209 // edit hidden regions to selection range
1210 if (hideStart < last)
1222 if (hideStart > end)
1232 if (hideStart > hideEnd)
1237 * form operations...
1239 if (last < hideStart)
1241 selection.addOperation(CigarArray.M, hideStart - last);
1243 selection.addOperation(CigarArray.D, 1 + hideEnd - hideStart);
1246 // Final match if necessary.
1249 selection.addOperation(CigarArray.M, end - last + 1);
1254 selection.addOperation(CigarArray.M, end - start + 1);
1260 * return a compact representation of the current alignment selection to pass
1261 * to an analysis function
1263 * @param selectedOnly
1264 * boolean true to just return the selected view
1265 * @return AlignmentView
1267 jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly)
1270 // this is here because the AlignmentView constructor modifies the
1272 // object. Refactoring of Cigar and alignment view representation should
1273 // be done to remove redundancy.
1274 CigarArray aligview = getViewAsCigars(selectedOnly);
1275 if (aligview != null)
1277 return new AlignmentView(aligview,
1278 (selectedOnly && selectionGroup != null) ? selectionGroup
1279 .getStartRes() : 0);
1285 * This method returns the visible alignment as text, as seen on the GUI, ie
1286 * if columns are hidden they will not be returned in the result. Use this for
1287 * calculating trees, PCA, redundancy etc on views which contain hidden
1292 public String[] getViewAsString(boolean selectedRegionOnly)
1294 String[] selection = null;
1295 SequenceI[] seqs = null;
1297 int start = 0, end = 0;
1298 if (selectedRegionOnly && selectionGroup != null)
1300 iSize = selectionGroup.getSize();
1301 seqs = selectionGroup.getSequencesInOrder(alignment);
1302 start = selectionGroup.getStartRes();
1303 end = selectionGroup.getEndRes() + 1;
1307 iSize = alignment.getHeight();
1308 seqs = alignment.getSequencesArray();
1309 end = alignment.getWidth();
1312 selection = new String[iSize];
1314 for (i = 0; i < iSize; i++)
1316 if (hasHiddenColumns)
1318 StringBuffer visibleSeq = new StringBuffer();
1319 Vector regions = colSel.getHiddenColumns();
1321 int blockStart = start, blockEnd = end;
1323 int hideStart, hideEnd;
1325 for (int j = 0; j < regions.size(); j++)
1327 region = (int[]) regions.elementAt(j);
1328 hideStart = region[0];
1329 hideEnd = region[1];
1331 if (hideStart < start)
1336 blockStart = Math.min(blockStart, hideEnd + 1);
1337 blockEnd = Math.min(blockEnd, hideStart);
1339 if (blockStart > blockEnd)
1344 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
1346 blockStart = hideEnd + 1;
1350 if (end > blockStart)
1352 visibleSeq.append(seqs[i].getSequence(blockStart, end));
1355 selection[i] = visibleSeq.toString();
1359 selection[i] = seqs[i].getSequenceAsString(start, end);
1366 public boolean getShowHiddenMarkers()
1368 return showHiddenMarkers;
1371 public void setShowHiddenMarkers(boolean show)
1373 showHiddenMarkers = show;
1376 public Color getSequenceColour(SequenceI seq)
1378 if (sequenceColours == null || !sequenceColours.containsKey(seq))
1384 return (Color) sequenceColours.get(seq);
1388 public void setSequenceColour(SequenceI seq, Color col)
1390 if (sequenceColours == null)
1392 sequenceColours = new Hashtable();
1397 sequenceColours.remove(seq);
1401 sequenceColours.put(seq, col);
1405 public String getSequenceSetId()
1407 if (sequenceSetID == null)
1409 sequenceSetID = alignment.hashCode() + "";
1412 return sequenceSetID;
1415 public void alignmentChanged(AlignmentPanel ap)
1417 alignment.padGaps();
1419 if (hconsensus != null && autocalculateConsensus)
1421 updateConsensus(ap);
1422 updateConservation(ap);
1425 // Reset endRes of groups if beyond alignment width
1426 int alWidth = alignment.getWidth();
1427 Vector groups = alignment.getGroups();
1430 for (int i = 0; i < groups.size(); i++)
1432 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
1433 if (sg.getEndRes() > alWidth)
1435 sg.setEndRes(alWidth - 1);
1440 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1442 selectionGroup.setEndRes(alWidth - 1);
1445 resetAllColourSchemes();
1447 // AW alignment.adjustSequenceAnnotations();
1450 void resetAllColourSchemes()
1452 ColourSchemeI cs = globalColourScheme;
1455 if (cs instanceof ClustalxColourScheme)
1457 ((ClustalxColourScheme) cs).resetClustalX(alignment.getSequences(),
1458 alignment.getWidth());
1461 cs.setConsensus(hconsensus);
1462 if (cs.conservationApplied())
1464 Alignment al = (Alignment) alignment;
1465 Conservation c = new Conservation("All",
1466 ResidueProperties.propHash, 3, al.getSequences(), 0, al
1469 c.verdict(false, ConsPercGaps);
1471 cs.setConservation(c);
1475 int s, sSize = alignment.getGroups().size();
1476 for (s = 0; s < sSize; s++)
1478 SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
1479 if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
1481 ((ClustalxColourScheme) sg.cs).resetClustalX(sg
1482 .getSequences(hiddenRepSequences), sg.getWidth());
1484 sg.recalcConservation();
1488 boolean centreColumnLabels;
1491 public boolean getCentreColumnLabels()
1493 return centreColumnLabels;
1496 public void updateSequenceIdColours()
1498 Vector groups = alignment.getGroups();
1499 for (int ig = 0, igSize = groups.size(); ig < igSize; ig++)
1501 SequenceGroup sg = (SequenceGroup) groups.elementAt(ig);
1502 if (sg.idColour != null)
1504 Vector sqs = sg.getSequences(hiddenRepSequences);
1505 for (int s = 0, sSize = sqs.size(); s < sSize; s++)
1507 this.setSequenceColour((SequenceI) sqs.elementAt(s), sg.idColour);
1512 public boolean followHighlight=false;
1513 public boolean getFollowHighlight() {
1514 return followHighlight;
1517 * show non-conserved residues only
1519 public boolean showUnconserved=false;
1522 * when set, alignment should be reordered according to a newly opened tree
1524 public boolean sortByTree=false;
1527 * @return the showUnconserved
1529 public boolean getShowunconserved()
1531 return showUnconserved;
1535 * @param showUnconserved the showUnconserved to set
1537 public void setShowunconserved(boolean displayNonconserved)
1539 this.showUnconserved = displayNonconserved;