2 * Jalview - A Sequence Alignment Editor and Viewer
3 * Copyright (C) 2007 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
20 package jalview.appletgui;
26 import jalview.analysis.*;
28 import jalview.datamodel.*;
29 import jalview.schemes.*;
31 public class AlignViewport
39 boolean cursorMode = false;
41 boolean showJVSuffix = true;
42 boolean showText = true;
43 boolean showColourText = false;
44 boolean showBoxes = true;
45 boolean wrapAlignment = false;
46 boolean renderGaps = true;
47 boolean showSequenceFeatures = false;
48 boolean showAnnotation = true;
49 boolean showConservation = true;
50 boolean showQuality = true;
51 boolean showConsensus = true;
52 boolean upperCasebold = false;
54 boolean colourAppliesToAllGroups = true;
55 ColourSchemeI globalColourScheme = null;
56 boolean conservationColourSelected = false;
57 boolean abovePIDThreshold = false;
59 SequenceGroup selectionGroup;
65 Font font = new Font("SansSerif", Font.PLAIN, 10);
66 boolean validCharWidth = true;
69 ColumnSelection colSel = new ColumnSelection();
74 NJTree currentTree = null;
76 boolean scaleAboveWrapped = true;
77 boolean scaleLeftWrapped = true;
78 boolean scaleRightWrapped = true;
80 // The following vector holds the features which are
81 // currently visible, in the correct order or rendering
82 public Hashtable featuresDisplayed;
84 boolean hasHiddenColumns = false;
85 boolean hasHiddenRows = false;
86 boolean showHiddenMarkers = true;
88 public Hashtable[] hconsensus;
89 AlignmentAnnotation consensus;
90 AlignmentAnnotation conservation;
91 AlignmentAnnotation quality;
93 boolean autocalculateConsensus = true;
95 public int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
97 private java.beans.PropertyChangeSupport changeSupport = new java.beans.
98 PropertyChangeSupport(this);
100 boolean ignoreGapsInConsensusCalculation = false;
102 jalview.bin.JalviewLite applet;
104 Hashtable sequenceColours;
108 Stack historyList = new Stack();
109 Stack redoList = new Stack();
111 String sequenceSetID;
113 Hashtable hiddenRepSequences;
115 public AlignViewport(AlignmentI al, JalviewLite applet)
117 this.applet = applet;
120 this.endRes = al.getWidth() - 1;
122 this.endSeq = al.getHeight() - 1;
125 if (System.getProperty("os.name").startsWith("Mac"))
132 String param = applet.getParameter("showFullId");
135 showJVSuffix = Boolean.valueOf(param).booleanValue();
138 param = applet.getParameter("showAnnotation");
141 showAnnotation = Boolean.valueOf(param).booleanValue();
144 param = applet.getParameter("showConservation");
147 showConservation = Boolean.valueOf(param).booleanValue();
150 param = applet.getParameter("showQuality");
153 showQuality = Boolean.valueOf(param).booleanValue();
156 param = applet.getParameter("showConsensus");
159 showConsensus = Boolean.valueOf(param).booleanValue();
162 param = applet.getParameter("upperCase");
165 if (param.equalsIgnoreCase("bold"))
167 upperCasebold = true;
175 String colour = applet.getParameter("defaultColour");
179 colour = applet.getParameter("userDefinedColour");
182 colour = "User Defined";
188 globalColourScheme = ColourSchemeProperty.getColour(alignment, colour);
189 if (globalColourScheme != null)
191 globalColourScheme.setConsensus(hconsensus);
195 if (applet.getParameter("userDefinedColour") != null)
197 ( (UserColourScheme) globalColourScheme).parseAppletParameter(
198 applet.getParameter("userDefinedColour"));
201 if (hconsensus == null)
203 if (!alignment.isNucleotide())
205 conservation = new AlignmentAnnotation("Conservation",
206 "Conservation of total alignment less than " +
207 ConsPercGaps + "% gaps",
208 new Annotation[1], 0f,
210 AlignmentAnnotation.BAR_GRAPH);
211 conservation.hasText = true;
212 conservation.autoCalculated = true;
214 if (showConservation)
216 alignment.addAnnotation(conservation);
221 quality = new AlignmentAnnotation("Quality",
222 "Alignment Quality based on Blosum62 scores",
226 AlignmentAnnotation.BAR_GRAPH);
227 quality.hasText = true;
228 quality.autoCalculated = true;
230 alignment.addAnnotation(quality);
234 consensus = new AlignmentAnnotation("Consensus", "PID",
235 new Annotation[1], 0f, 100f,
236 AlignmentAnnotation.BAR_GRAPH);
237 consensus.hasText = true;
238 consensus.autoCalculated = true;
242 alignment.addAnnotation(consensus);
248 public void showSequenceFeatures(boolean b)
250 showSequenceFeatures = b;
253 public boolean getShowSequenceFeatures()
255 return showSequenceFeatures;
258 class ConservationThread
262 public ConservationThread(AlignmentPanel ap)
271 updatingConservation = true;
273 while (UPDATING_CONSERVATION)
279 ap.paintAlignment(false);
285 ex.printStackTrace();
289 UPDATING_CONSERVATION = true;
291 int alWidth = alignment.getWidth();
297 Conservation cons = new jalview.analysis.Conservation("All",
298 jalview.schemes.ResidueProperties.propHash, 3,
299 alignment.getSequences(), 0, alWidth - 1);
302 cons.verdict(false, ConsPercGaps);
309 char[] sequence = cons.getConsSequence().getSequence();
321 maxB = 0f - minB; // scalable range for colouring both Conservation and Quality
330 conservation.annotations = new Annotation[alWidth];
334 quality.graphMax = cons.qualityRange[1].floatValue();
335 quality.annotations = new Annotation[alWidth];
336 qmin = cons.qualityRange[0].floatValue();
337 qmax = cons.qualityRange[1].floatValue();
340 for (int i = 0; i < alWidth; i++)
346 if (Character.isDigit(c))
348 value = (int) (c - '0');
359 float vprop = value - min;
361 conservation.annotations[i] =
362 new Annotation(String.valueOf(c),
363 String.valueOf(value), ' ', value,
364 new Color(minR + (maxR * vprop),
365 minG + (maxG * vprop),
366 minB + (maxB * vprop)));
371 value = ( (Double) cons.quality.elementAt(i)).floatValue();
372 vprop = value - qmin;
374 quality.annotations[i] = new Annotation(" ", String.valueOf(value),
377 new Color(minR + (maxR * vprop),
378 minG + (maxG * vprop),
379 minB + (maxB * vprop)));
383 catch (OutOfMemoryError error)
385 System.out.println("Out of memory calculating conservation!!");
391 UPDATING_CONSERVATION = false;
392 updatingConservation = false;
396 ap.paintAlignment(true);
402 ConservationThread conservationThread;
404 ConsensusThread consensusThread;
406 boolean consUpdateNeeded = false;
408 static boolean UPDATING_CONSENSUS = false;
410 static boolean UPDATING_CONSERVATION = false;
412 boolean updatingConsensus = false;
414 boolean updatingConservation = false;
419 public void updateConservation(final AlignmentPanel ap)
421 if (alignment.isNucleotide() || conservation == null)
426 conservationThread = new ConservationThread(ap);
427 conservationThread.start();
433 public void updateConsensus(final AlignmentPanel ap)
435 consensusThread = new ConsensusThread(ap);
436 consensusThread.start();
439 class ConsensusThread
443 public ConsensusThread(AlignmentPanel ap)
450 updatingConsensus = true;
451 while (UPDATING_CONSENSUS)
457 ap.paintAlignment(false);
464 ex.printStackTrace();
468 UPDATING_CONSENSUS = true;
472 int aWidth = alignment.getWidth();
478 consensus.annotations = null;
479 consensus.annotations = new Annotation[aWidth];
481 hconsensus = new Hashtable[aWidth];
482 AAFrequency.calculate(alignment.getSequencesArray(),
484 alignment.getWidth(),
487 for (int i = 0; i < aWidth; i++)
490 if (ignoreGapsInConsensusCalculation)
492 value = ( (Float) hconsensus[i].get(AAFrequency.PID_NOGAPS)).
497 value = ( (Float) hconsensus[i].get(AAFrequency.PID_GAPS)).
501 String maxRes = hconsensus[i].get(AAFrequency.MAXRESIDUE).toString();
502 String mouseOver = hconsensus[i].get(AAFrequency.MAXRESIDUE) + " ";
504 if (maxRes.length() > 1)
506 mouseOver = "[" + maxRes + "] ";
510 mouseOver += ( (int) value + "%");
511 consensus.annotations[i] = new Annotation(maxRes, mouseOver, ' ',
515 if (globalColourScheme != null)
517 globalColourScheme.setConsensus(hconsensus);
521 catch (OutOfMemoryError error)
523 alignment.deleteAnnotation(consensus);
527 System.out.println("Out of memory calculating consensus!!");
530 UPDATING_CONSENSUS = false;
531 updatingConsensus = false;
535 ap.paintAlignment(true);
541 * get the consensus sequence as displayed under the PID consensus annotation row.
542 * @return consensus sequence as a new sequence object
545 * get the consensus sequence as displayed under the PID consensus annotation row.
546 * @return consensus sequence as a new sequence object
548 public SequenceI getConsensusSeq()
550 if (consensus == null)
554 StringBuffer seqs = new StringBuffer();
555 for (int i = 0; i < consensus.annotations.length; i++)
557 if (consensus.annotations[i] != null)
559 if (consensus.annotations[i].description.charAt(0) == '[')
561 seqs.append(consensus.annotations[i].description.charAt(1));
565 seqs.append(consensus.annotations[i].displayCharacter);
569 SequenceI sq = new Sequence("Consensus", seqs.toString());
570 sq.setDescription("Percentage Identity Consensus " +
571 ( (ignoreGapsInConsensusCalculation) ? " without gaps" :
576 public SequenceGroup getSelectionGroup()
578 return selectionGroup;
581 public void setSelectionGroup(SequenceGroup sg)
586 public boolean getConservationSelected()
588 return conservationColourSelected;
591 public void setConservationSelected(boolean b)
593 conservationColourSelected = b;
596 public boolean getAbovePIDThreshold()
598 return abovePIDThreshold;
601 public void setAbovePIDThreshold(boolean b)
603 abovePIDThreshold = b;
606 public int getStartRes()
611 public int getEndRes()
616 public int getStartSeq()
621 public void setGlobalColourScheme(ColourSchemeI cs)
623 globalColourScheme = cs;
626 public ColourSchemeI getGlobalColourScheme()
628 return globalColourScheme;
631 public void setStartRes(int res)
636 public void setStartSeq(int seq)
641 public void setEndRes(int res)
643 if (res > alignment.getWidth() - 1)
645 // log.System.out.println(" Corrected res from " + res + " to maximum " + (alignment.getWidth()-1));
646 res = alignment.getWidth() - 1;
655 public void setEndSeq(int seq)
657 if (seq > alignment.getHeight())
659 seq = alignment.getHeight();
668 public int getEndSeq()
673 java.awt.Frame nullFrame;
674 public void setFont(Font f)
677 if (nullFrame == null)
679 nullFrame = new java.awt.Frame();
680 nullFrame.addNotify();
683 java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font);
684 setCharHeight(fm.getHeight());
685 charWidth = fm.charWidth('M');
689 Font f2 = new Font(f.getName(), Font.BOLD, f.getSize());
690 fm = nullFrame.getGraphics().getFontMetrics(f2);
691 charWidth = fm.stringWidth("MMMMMMMMMMM") / 10;
695 public Font getFont()
700 public int getCharWidth()
705 public void setCharHeight(int h)
710 public int getCharHeight()
715 public void setWrappedWidth(int w)
717 this.wrappedWidth = w;
720 public int getwrappedWidth()
725 public AlignmentI getAlignment()
730 public void setAlignment(AlignmentI align)
732 this.alignment = align;
735 public void setWrapAlignment(boolean state)
737 wrapAlignment = state;
740 public void setShowText(boolean state)
745 public void setRenderGaps(boolean state)
750 public boolean getColourText()
752 return showColourText;
755 public void setColourText(boolean state)
757 showColourText = state;
760 public void setShowBoxes(boolean state)
765 public boolean getWrapAlignment()
767 return wrapAlignment;
770 public boolean getShowText()
775 public boolean getShowBoxes()
780 public char getGapCharacter()
782 return getAlignment().getGapCharacter();
785 public void setGapCharacter(char gap)
787 if (getAlignment() != null)
789 getAlignment().setGapCharacter(gap);
793 public void setThreshold(int thresh)
798 public int getThreshold()
803 public void setIncrement(int inc)
808 public int getIncrement()
813 public void setHiddenColumns(ColumnSelection colsel)
815 this.colSel = colsel;
816 if (colSel.getHiddenColumns() != null)
818 hasHiddenColumns = true;
822 public ColumnSelection getColumnSelection()
827 public void resetSeqLimits(int height)
829 setEndSeq(height / getCharHeight());
832 public void setCurrentTree(NJTree tree)
837 public NJTree getCurrentTree()
842 public void setColourAppliesToAllGroups(boolean b)
844 colourAppliesToAllGroups = b;
847 public boolean getColourAppliesToAllGroups()
849 return colourAppliesToAllGroups;
852 public boolean getShowJVSuffix()
857 public void setShowJVSuffix(boolean b)
862 public boolean getShowAnnotation()
864 return showAnnotation;
867 public void setShowAnnotation(boolean b)
872 public boolean getScaleAboveWrapped()
874 return scaleAboveWrapped;
877 public boolean getScaleLeftWrapped()
879 return scaleLeftWrapped;
882 public boolean getScaleRightWrapped()
884 return scaleRightWrapped;
887 public void setScaleAboveWrapped(boolean b)
889 scaleAboveWrapped = b;
892 public void setScaleLeftWrapped(boolean b)
894 scaleLeftWrapped = b;
897 public void setScaleRightWrapped(boolean b)
899 scaleRightWrapped = b;
902 public void setIgnoreGapsConsensus(boolean b)
904 ignoreGapsInConsensusCalculation = b;
905 updateConsensus(null);
906 if (globalColourScheme != null)
908 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
909 ignoreGapsInConsensusCalculation);
915 * Property change listener for changes in alignment
917 * @param listener DOCUMENT ME!
919 public void addPropertyChangeListener(
920 java.beans.PropertyChangeListener listener)
922 changeSupport.addPropertyChangeListener(listener);
928 * @param listener DOCUMENT ME!
930 public void removePropertyChangeListener(
931 java.beans.PropertyChangeListener listener)
933 changeSupport.removePropertyChangeListener(listener);
937 * Property change listener for changes in alignment
939 * @param prop DOCUMENT ME!
940 * @param oldvalue DOCUMENT ME!
941 * @param newvalue DOCUMENT ME!
943 public void firePropertyChange(String prop, Object oldvalue, Object newvalue)
945 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
948 public boolean getIgnoreGapsConsensus()
950 return ignoreGapsInConsensusCalculation;
953 public void hideSelectedColumns()
955 if (colSel.size() < 1)
960 colSel.hideSelectedColumns();
961 setSelectionGroup(null);
963 hasHiddenColumns = true;
966 public void invertColumnSelection()
968 for (int i = 0; i < alignment.getWidth(); i++)
970 if (colSel.contains(i))
972 colSel.removeElement(i);
976 if (!hasHiddenColumns || colSel.isVisible(i))
978 colSel.addElement(i);
984 public void hideColumns(int start, int end)
988 colSel.hideColumns(start);
992 colSel.hideColumns(start, end);
995 hasHiddenColumns = true;
998 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1000 int sSize = sg.getSize();
1006 if (hiddenRepSequences == null)
1008 hiddenRepSequences = new Hashtable();
1011 hiddenRepSequences.put(repSequence, sg);
1013 //Hide all sequences except the repSequence
1014 SequenceI[] seqs = new SequenceI[sSize - 1];
1016 for (int i = 0; i < sSize; i++)
1018 if (sg.getSequenceAt(i) != repSequence)
1020 if (index == sSize - 1)
1025 seqs[index++] = sg.getSequenceAt(i);
1033 public void hideAllSelectedSeqs()
1035 if (selectionGroup == null || selectionGroup.getSize()<1)
1040 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1044 setSelectionGroup(null);
1047 public void hideSequence(SequenceI[] seq)
1051 for (int i = 0; i < seq.length; i++)
1053 alignment.getHiddenSequences().hideSequence(seq[i]);
1056 hasHiddenRows = true;
1057 firePropertyChange("alignment", null, alignment.getSequences());
1061 public void showColumn(int col)
1063 colSel.revealHiddenColumns(col);
1064 if (colSel.getHiddenColumns() == null)
1066 hasHiddenColumns = false;
1070 public void showAllHiddenColumns()
1072 colSel.revealAllHiddenColumns();
1073 hasHiddenColumns = false;
1076 public void showAllHiddenSeqs()
1078 if (alignment.getHiddenSequences().getSize() > 0)
1080 if (selectionGroup == null)
1082 selectionGroup = new SequenceGroup();
1083 selectionGroup.setEndRes(alignment.getWidth() - 1);
1085 Vector tmp = alignment.getHiddenSequences().showAll(hiddenRepSequences);
1086 for (int t = 0; t < tmp.size(); t++)
1088 selectionGroup.addSequence(
1089 (SequenceI) tmp.elementAt(t), false
1092 firePropertyChange("alignment", null, alignment.getSequences());
1093 hasHiddenRows = false;
1094 hiddenRepSequences = null;
1098 public int adjustForHiddenSeqs(int alignmentIndex)
1100 return alignment.getHiddenSequences().adjustForHiddenSeqs(alignmentIndex);
1104 * This method returns the a new SequenceI [] with
1105 * the selection sequence and start and end points adjusted
1108 public SequenceI[] getSelectionAsNewSequence()
1110 SequenceI[] sequences;
1112 if (selectionGroup == null)
1114 sequences = alignment.getSequencesArray();
1118 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1125 * This method returns the visible alignment as text, as
1126 * seen on the GUI, ie if columns are hidden they will not
1127 * be returned in the result.
1128 * Use this for calculating trees, PCA, redundancy etc on views
1129 * which contain hidden columns.
1132 public jalview.datamodel.CigarArray getViewAsCigars(boolean
1135 CigarArray selection = null;
1136 SequenceI[] seqs = null;
1138 int start = 0, end = 0;
1139 if (selectedRegionOnly && selectionGroup != null)
1141 iSize = selectionGroup.getSize();
1142 seqs = selectionGroup.getSequencesInOrder(alignment);
1143 start = selectionGroup.getStartRes();
1144 end = selectionGroup.getEndRes(); // inclusive for start and end in SeqCigar constructor
1148 iSize = alignment.getHeight();
1149 seqs = alignment.getSequencesArray();
1150 end = alignment.getWidth() - 1;
1152 SeqCigar[] selseqs = new SeqCigar[iSize];
1153 for (i = 0; i < iSize; i++)
1155 selseqs[i] = new SeqCigar(seqs[i], start, end);
1157 selection = new CigarArray(selseqs);
1158 // now construct the CigarArray operations
1159 if (hasHiddenColumns)
1161 Vector regions = colSel.getHiddenColumns();
1163 int hideStart, hideEnd;
1165 for (int j = 0; last < end & j < regions.size(); j++)
1167 region = (int[]) regions.elementAt(j);
1168 hideStart = region[0];
1169 hideEnd = region[1];
1170 // edit hidden regions to selection range
1171 if (hideStart < last)
1183 if (hideStart > end)
1193 if (hideStart > hideEnd)
1198 * form operations...
1200 if (last < hideStart)
1202 selection.addOperation(CigarArray.M, hideStart - last);
1204 selection.addOperation(CigarArray.D, 1 + hideEnd - hideStart);
1207 // Final match if necessary.
1210 selection.addOperation(CigarArray.M, end - last + 1);
1215 selection.addOperation(CigarArray.M, end - start + 1);
1221 * return a compact representation of the current alignment selection to
1222 * pass to an analysis function
1223 * @param selectedOnly boolean true to just return the selected view
1224 * @return AlignmentView
1226 jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly)
1229 // this is here because the AlignmentView constructor modifies the CigarArray
1230 // object. Refactoring of Cigar and alignment view representation should
1231 // be done to remove redundancy.
1232 CigarArray aligview = getViewAsCigars(selectedOnly);
1233 if (aligview != null)
1235 return new AlignmentView(aligview,
1236 (selectedOnly && selectionGroup != null) ?
1237 selectionGroup.getStartRes() : 0);
1243 * This method returns the visible alignment as text, as
1244 * seen on the GUI, ie if columns are hidden they will not
1245 * be returned in the result.
1246 * Use this for calculating trees, PCA, redundancy etc on views
1247 * which contain hidden columns.
1250 public String[] getViewAsString(boolean selectedRegionOnly)
1252 String[] selection = null;
1253 SequenceI[] seqs = null;
1255 int start = 0, end = 0;
1256 if (selectedRegionOnly && selectionGroup != null)
1258 iSize = selectionGroup.getSize();
1259 seqs = selectionGroup.getSequencesInOrder(alignment);
1260 start = selectionGroup.getStartRes();
1261 end = selectionGroup.getEndRes() + 1;
1265 iSize = alignment.getHeight();
1266 seqs = alignment.getSequencesArray();
1267 end = alignment.getWidth();
1270 selection = new String[iSize];
1272 for (i = 0; i < iSize; i++)
1274 if (hasHiddenColumns)
1276 StringBuffer visibleSeq = new StringBuffer();
1277 Vector regions = colSel.getHiddenColumns();
1279 int blockStart = start, blockEnd = end;
1281 int hideStart, hideEnd;
1283 for (int j = 0; j < regions.size(); j++)
1285 region = (int[]) regions.elementAt(j);
1286 hideStart = region[0];
1287 hideEnd = region[1];
1289 if (hideStart < start)
1294 blockStart = Math.min(blockStart, hideEnd + 1);
1295 blockEnd = Math.min(blockEnd, hideStart);
1297 if (blockStart > blockEnd)
1302 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
1304 blockStart = hideEnd + 1;
1308 if (end > blockStart)
1310 visibleSeq.append(seqs[i].getSequence(blockStart, end));
1313 selection[i] = visibleSeq.toString();
1317 selection[i] = seqs[i].getSequenceAsString(start, end);
1324 public boolean getShowHiddenMarkers()
1326 return showHiddenMarkers;
1329 public void setShowHiddenMarkers(boolean show)
1331 showHiddenMarkers = show;
1334 public Color getSequenceColour(SequenceI seq)
1336 if (sequenceColours == null || !sequenceColours.containsKey(seq))
1342 return (Color) sequenceColours.get(seq);
1346 public void setSequenceColour(SequenceI seq, Color col)
1348 if (sequenceColours == null)
1350 sequenceColours = new Hashtable();
1355 sequenceColours.remove(seq);
1359 sequenceColours.put(seq, col);
1363 public String getSequenceSetId()
1365 if (sequenceSetID == null)
1367 sequenceSetID = alignment.hashCode() + "";
1370 return sequenceSetID;
1373 public void alignmentChanged(AlignmentPanel ap)
1375 alignment.padGaps();
1377 if (hconsensus != null && autocalculateConsensus)
1379 updateConsensus(ap);
1380 updateConservation(ap);
1383 //Reset endRes of groups if beyond alignment width
1384 int alWidth = alignment.getWidth();
1385 Vector groups = alignment.getGroups();
1388 for (int i = 0; i < groups.size(); i++)
1390 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
1391 if (sg.getEndRes() > alWidth)
1393 sg.setEndRes(alWidth - 1);
1398 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1400 selectionGroup.setEndRes(alWidth - 1);
1403 resetAllColourSchemes();
1405 //AW alignment.adjustSequenceAnnotations();
1408 void resetAllColourSchemes()
1410 ColourSchemeI cs = globalColourScheme;
1413 if (cs instanceof ClustalxColourScheme)
1415 ( (ClustalxColourScheme) cs).
1416 resetClustalX(alignment.getSequences(),
1417 alignment.getWidth());
1420 cs.setConsensus(hconsensus);
1421 if (cs.conservationApplied())
1423 Alignment al = (Alignment) alignment;
1424 Conservation c = new Conservation("All",
1425 ResidueProperties.propHash, 3,
1426 al.getSequences(), 0,
1429 c.verdict(false, ConsPercGaps);
1431 cs.setConservation(c);
1435 int s, sSize = alignment.getGroups().size();
1436 for (s = 0; s < sSize; s++)
1438 SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
1439 if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
1441 ( (ClustalxColourScheme) sg.cs).resetClustalX(
1442 sg.getSequences(hiddenRepSequences), sg.getWidth());
1444 sg.recalcConservation();