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 MAC = new jalview.util.Platform().isAMac();
129 String param = applet.getParameter("showFullId");
132 showJVSuffix = Boolean.valueOf(param).booleanValue();
135 param = applet.getParameter("showAnnotation");
138 showAnnotation = Boolean.valueOf(param).booleanValue();
141 param = applet.getParameter("showConservation");
144 showConservation = Boolean.valueOf(param).booleanValue();
147 param = applet.getParameter("showQuality");
150 showQuality = Boolean.valueOf(param).booleanValue();
153 param = applet.getParameter("showConsensus");
156 showConsensus = Boolean.valueOf(param).booleanValue();
159 param = applet.getParameter("upperCase");
162 if (param.equalsIgnoreCase("bold"))
164 upperCasebold = true;
172 String colour = applet.getParameter("defaultColour");
176 colour = applet.getParameter("userDefinedColour");
179 colour = "User Defined";
185 globalColourScheme = ColourSchemeProperty.getColour(alignment, colour);
186 if (globalColourScheme != null)
188 globalColourScheme.setConsensus(hconsensus);
192 if (applet.getParameter("userDefinedColour") != null)
194 ( (UserColourScheme) globalColourScheme).parseAppletParameter(
195 applet.getParameter("userDefinedColour"));
198 if (hconsensus == null)
200 if (!alignment.isNucleotide())
202 conservation = new AlignmentAnnotation("Conservation",
203 "Conservation of total alignment less than " +
204 ConsPercGaps + "% gaps",
205 new Annotation[1], 0f,
207 AlignmentAnnotation.BAR_GRAPH);
208 conservation.hasText = true;
209 conservation.autoCalculated = true;
211 if (showConservation)
213 alignment.addAnnotation(conservation);
218 quality = new AlignmentAnnotation("Quality",
219 "Alignment Quality based on Blosum62 scores",
223 AlignmentAnnotation.BAR_GRAPH);
224 quality.hasText = true;
225 quality.autoCalculated = true;
227 alignment.addAnnotation(quality);
231 consensus = new AlignmentAnnotation("Consensus", "PID",
232 new Annotation[1], 0f, 100f,
233 AlignmentAnnotation.BAR_GRAPH);
234 consensus.hasText = true;
235 consensus.autoCalculated = true;
239 alignment.addAnnotation(consensus);
245 public void showSequenceFeatures(boolean b)
247 showSequenceFeatures = b;
250 public boolean getShowSequenceFeatures()
252 return showSequenceFeatures;
255 class ConservationThread
259 public ConservationThread(AlignmentPanel ap)
268 updatingConservation = true;
270 while (UPDATING_CONSERVATION)
276 ap.paintAlignment(false);
282 ex.printStackTrace();
286 UPDATING_CONSERVATION = true;
288 int alWidth = alignment.getWidth();
294 Conservation cons = new jalview.analysis.Conservation("All",
295 jalview.schemes.ResidueProperties.propHash, 3,
296 alignment.getSequences(), 0, alWidth - 1);
299 cons.verdict(false, ConsPercGaps);
306 char[] sequence = cons.getConsSequence().getSequence();
318 maxB = 0f - minB; // scalable range for colouring both Conservation and Quality
327 conservation.annotations = new Annotation[alWidth];
331 quality.graphMax = cons.qualityRange[1].floatValue();
332 quality.annotations = new Annotation[alWidth];
333 qmin = cons.qualityRange[0].floatValue();
334 qmax = cons.qualityRange[1].floatValue();
337 for (int i = 0; i < alWidth; i++)
343 if (Character.isDigit(c))
345 value = (int) (c - '0');
356 float vprop = value - min;
358 conservation.annotations[i] =
359 new Annotation(String.valueOf(c),
360 String.valueOf(value), ' ', value,
361 new Color(minR + (maxR * vprop),
362 minG + (maxG * vprop),
363 minB + (maxB * vprop)));
368 value = ( (Double) cons.quality.elementAt(i)).floatValue();
369 vprop = value - qmin;
371 quality.annotations[i] = new Annotation(" ", String.valueOf(value),
374 new Color(minR + (maxR * vprop),
375 minG + (maxG * vprop),
376 minB + (maxB * vprop)));
380 catch (OutOfMemoryError error)
382 System.out.println("Out of memory calculating conservation!!");
388 UPDATING_CONSERVATION = false;
389 updatingConservation = false;
393 ap.paintAlignment(true);
399 ConservationThread conservationThread;
401 ConsensusThread consensusThread;
403 boolean consUpdateNeeded = false;
405 static boolean UPDATING_CONSENSUS = false;
407 static boolean UPDATING_CONSERVATION = false;
409 boolean updatingConsensus = false;
411 boolean updatingConservation = false;
416 public void updateConservation(final AlignmentPanel ap)
418 if (alignment.isNucleotide() || conservation == null)
423 conservationThread = new ConservationThread(ap);
424 conservationThread.start();
430 public void updateConsensus(final AlignmentPanel ap)
432 consensusThread = new ConsensusThread(ap);
433 consensusThread.start();
436 class ConsensusThread
440 public ConsensusThread(AlignmentPanel ap)
447 updatingConsensus = true;
448 while (UPDATING_CONSENSUS)
454 ap.paintAlignment(false);
461 ex.printStackTrace();
465 UPDATING_CONSENSUS = true;
469 int aWidth = alignment.getWidth();
475 consensus.annotations = null;
476 consensus.annotations = new Annotation[aWidth];
478 hconsensus = new Hashtable[aWidth];
479 AAFrequency.calculate(alignment.getSequencesArray(),
481 alignment.getWidth(),
484 for (int i = 0; i < aWidth; i++)
487 if (ignoreGapsInConsensusCalculation)
489 value = ( (Float) hconsensus[i].get(AAFrequency.PID_NOGAPS)).
494 value = ( (Float) hconsensus[i].get(AAFrequency.PID_GAPS)).
498 String maxRes = hconsensus[i].get(AAFrequency.MAXRESIDUE).toString();
499 String mouseOver = hconsensus[i].get(AAFrequency.MAXRESIDUE) + " ";
501 if (maxRes.length() > 1)
503 mouseOver = "[" + maxRes + "] ";
507 mouseOver += ( (int) value + "%");
508 consensus.annotations[i] = new Annotation(maxRes, mouseOver, ' ',
512 if (globalColourScheme != null)
514 globalColourScheme.setConsensus(hconsensus);
518 catch (OutOfMemoryError error)
520 alignment.deleteAnnotation(consensus);
524 System.out.println("Out of memory calculating consensus!!");
527 UPDATING_CONSENSUS = false;
528 updatingConsensus = false;
532 ap.paintAlignment(true);
538 * get the consensus sequence as displayed under the PID consensus annotation row.
539 * @return consensus sequence as a new sequence object
542 * get the consensus sequence as displayed under the PID consensus annotation row.
543 * @return consensus sequence as a new sequence object
545 public SequenceI getConsensusSeq()
547 if (consensus == null)
551 StringBuffer seqs = new StringBuffer();
552 for (int i = 0; i < consensus.annotations.length; i++)
554 if (consensus.annotations[i] != null)
556 if (consensus.annotations[i].description.charAt(0) == '[')
558 seqs.append(consensus.annotations[i].description.charAt(1));
562 seqs.append(consensus.annotations[i].displayCharacter);
566 SequenceI sq = new Sequence("Consensus", seqs.toString());
567 sq.setDescription("Percentage Identity Consensus " +
568 ( (ignoreGapsInConsensusCalculation) ? " without gaps" :
573 public SequenceGroup getSelectionGroup()
575 return selectionGroup;
578 public void setSelectionGroup(SequenceGroup sg)
583 public boolean getConservationSelected()
585 return conservationColourSelected;
588 public void setConservationSelected(boolean b)
590 conservationColourSelected = b;
593 public boolean getAbovePIDThreshold()
595 return abovePIDThreshold;
598 public void setAbovePIDThreshold(boolean b)
600 abovePIDThreshold = b;
603 public int getStartRes()
608 public int getEndRes()
613 public int getStartSeq()
618 public void setGlobalColourScheme(ColourSchemeI cs)
620 globalColourScheme = cs;
623 public ColourSchemeI getGlobalColourScheme()
625 return globalColourScheme;
628 public void setStartRes(int res)
633 public void setStartSeq(int seq)
638 public void setEndRes(int res)
640 if (res > alignment.getWidth() - 1)
642 // log.System.out.println(" Corrected res from " + res + " to maximum " + (alignment.getWidth()-1));
643 res = alignment.getWidth() - 1;
652 public void setEndSeq(int seq)
654 if (seq > alignment.getHeight())
656 seq = alignment.getHeight();
665 public int getEndSeq()
670 java.awt.Frame nullFrame;
671 protected FeatureSettings featureSettings=null;
672 public void setFont(Font f)
675 if (nullFrame == null)
677 nullFrame = new java.awt.Frame();
678 nullFrame.addNotify();
681 java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font);
682 setCharHeight(fm.getHeight());
683 charWidth = fm.charWidth('M');
687 Font f2 = new Font(f.getName(), Font.BOLD, f.getSize());
688 fm = nullFrame.getGraphics().getFontMetrics(f2);
689 charWidth = fm.stringWidth("MMMMMMMMMMM") / 10;
693 public Font getFont()
698 public int getCharWidth()
703 public void setCharHeight(int h)
708 public int getCharHeight()
713 public void setWrappedWidth(int w)
715 this.wrappedWidth = w;
718 public int getwrappedWidth()
723 public AlignmentI getAlignment()
728 public void setAlignment(AlignmentI align)
730 this.alignment = align;
733 public void setWrapAlignment(boolean state)
735 wrapAlignment = state;
738 public void setShowText(boolean state)
743 public void setRenderGaps(boolean state)
748 public boolean getColourText()
750 return showColourText;
753 public void setColourText(boolean state)
755 showColourText = state;
758 public void setShowBoxes(boolean state)
763 public boolean getWrapAlignment()
765 return wrapAlignment;
768 public boolean getShowText()
773 public boolean getShowBoxes()
778 public char getGapCharacter()
780 return getAlignment().getGapCharacter();
783 public void setGapCharacter(char gap)
785 if (getAlignment() != null)
787 getAlignment().setGapCharacter(gap);
791 public void setThreshold(int thresh)
796 public int getThreshold()
801 public void setIncrement(int inc)
806 public int getIncrement()
811 public void setHiddenColumns(ColumnSelection colsel)
813 this.colSel = colsel;
814 if (colSel.getHiddenColumns() != null)
816 hasHiddenColumns = true;
820 public ColumnSelection getColumnSelection()
825 public void resetSeqLimits(int height)
827 setEndSeq(height / getCharHeight());
830 public void setCurrentTree(NJTree tree)
835 public NJTree getCurrentTree()
840 public void setColourAppliesToAllGroups(boolean b)
842 colourAppliesToAllGroups = b;
845 public boolean getColourAppliesToAllGroups()
847 return colourAppliesToAllGroups;
850 public boolean getShowJVSuffix()
855 public void setShowJVSuffix(boolean b)
860 public boolean getShowAnnotation()
862 return showAnnotation;
865 public void setShowAnnotation(boolean b)
870 public boolean getScaleAboveWrapped()
872 return scaleAboveWrapped;
875 public boolean getScaleLeftWrapped()
877 return scaleLeftWrapped;
880 public boolean getScaleRightWrapped()
882 return scaleRightWrapped;
885 public void setScaleAboveWrapped(boolean b)
887 scaleAboveWrapped = b;
890 public void setScaleLeftWrapped(boolean b)
892 scaleLeftWrapped = b;
895 public void setScaleRightWrapped(boolean b)
897 scaleRightWrapped = b;
900 public void setIgnoreGapsConsensus(boolean b)
902 ignoreGapsInConsensusCalculation = b;
903 updateConsensus(null);
904 if (globalColourScheme != null)
906 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
907 ignoreGapsInConsensusCalculation);
913 * Property change listener for changes in alignment
915 * @param listener DOCUMENT ME!
917 public void addPropertyChangeListener(
918 java.beans.PropertyChangeListener listener)
920 changeSupport.addPropertyChangeListener(listener);
926 * @param listener DOCUMENT ME!
928 public void removePropertyChangeListener(
929 java.beans.PropertyChangeListener listener)
931 changeSupport.removePropertyChangeListener(listener);
935 * Property change listener for changes in alignment
937 * @param prop DOCUMENT ME!
938 * @param oldvalue DOCUMENT ME!
939 * @param newvalue DOCUMENT ME!
941 public void firePropertyChange(String prop, Object oldvalue, Object newvalue)
943 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
946 public boolean getIgnoreGapsConsensus()
948 return ignoreGapsInConsensusCalculation;
951 public void hideSelectedColumns()
953 if (colSel.size() < 1)
958 colSel.hideSelectedColumns();
959 setSelectionGroup(null);
961 hasHiddenColumns = true;
964 public void invertColumnSelection()
966 for (int i = 0; i < alignment.getWidth(); i++)
968 if (colSel.contains(i))
970 colSel.removeElement(i);
974 if (!hasHiddenColumns || colSel.isVisible(i))
976 colSel.addElement(i);
982 public void hideColumns(int start, int end)
986 colSel.hideColumns(start);
990 colSel.hideColumns(start, end);
993 hasHiddenColumns = true;
996 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
998 int sSize = sg.getSize();
1004 if (hiddenRepSequences == null)
1006 hiddenRepSequences = new Hashtable();
1009 hiddenRepSequences.put(repSequence, sg);
1011 //Hide all sequences except the repSequence
1012 SequenceI[] seqs = new SequenceI[sSize - 1];
1014 for (int i = 0; i < sSize; i++)
1016 if (sg.getSequenceAt(i) != repSequence)
1018 if (index == sSize - 1)
1023 seqs[index++] = sg.getSequenceAt(i);
1031 public void hideAllSelectedSeqs()
1033 if (selectionGroup == null || selectionGroup.getSize()<1)
1038 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1042 setSelectionGroup(null);
1045 public void hideSequence(SequenceI[] seq)
1049 for (int i = 0; i < seq.length; i++)
1051 alignment.getHiddenSequences().hideSequence(seq[i]);
1054 hasHiddenRows = true;
1055 firePropertyChange("alignment", null, alignment.getSequences());
1059 public void showColumn(int col)
1061 colSel.revealHiddenColumns(col);
1062 if (colSel.getHiddenColumns() == null)
1064 hasHiddenColumns = false;
1068 public void showAllHiddenColumns()
1070 colSel.revealAllHiddenColumns();
1071 hasHiddenColumns = false;
1074 public void showAllHiddenSeqs()
1076 if (alignment.getHiddenSequences().getSize() > 0)
1078 if (selectionGroup == null)
1080 selectionGroup = new SequenceGroup();
1081 selectionGroup.setEndRes(alignment.getWidth() - 1);
1083 Vector tmp = alignment.getHiddenSequences().showAll(hiddenRepSequences);
1084 for (int t = 0; t < tmp.size(); t++)
1086 selectionGroup.addSequence(
1087 (SequenceI) tmp.elementAt(t), false
1090 firePropertyChange("alignment", null, alignment.getSequences());
1091 hasHiddenRows = false;
1092 hiddenRepSequences = null;
1096 public int adjustForHiddenSeqs(int alignmentIndex)
1098 return alignment.getHiddenSequences().adjustForHiddenSeqs(alignmentIndex);
1102 * This method returns the a new SequenceI [] with
1103 * the selection sequence and start and end points adjusted
1106 public SequenceI[] getSelectionAsNewSequence()
1108 SequenceI[] sequences;
1110 if (selectionGroup == null)
1112 sequences = alignment.getSequencesArray();
1116 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1123 * This method returns the visible alignment as text, as
1124 * seen on the GUI, ie if columns are hidden they will not
1125 * be returned in the result.
1126 * Use this for calculating trees, PCA, redundancy etc on views
1127 * which contain hidden columns.
1130 public jalview.datamodel.CigarArray getViewAsCigars(boolean
1133 CigarArray selection = null;
1134 SequenceI[] seqs = null;
1136 int start = 0, end = 0;
1137 if (selectedRegionOnly && selectionGroup != null)
1139 iSize = selectionGroup.getSize();
1140 seqs = selectionGroup.getSequencesInOrder(alignment);
1141 start = selectionGroup.getStartRes();
1142 end = selectionGroup.getEndRes(); // inclusive for start and end in SeqCigar constructor
1146 iSize = alignment.getHeight();
1147 seqs = alignment.getSequencesArray();
1148 end = alignment.getWidth() - 1;
1150 SeqCigar[] selseqs = new SeqCigar[iSize];
1151 for (i = 0; i < iSize; i++)
1153 selseqs[i] = new SeqCigar(seqs[i], start, end);
1155 selection = new CigarArray(selseqs);
1156 // now construct the CigarArray operations
1157 if (hasHiddenColumns)
1159 Vector regions = colSel.getHiddenColumns();
1161 int hideStart, hideEnd;
1163 for (int j = 0; last < end & j < regions.size(); j++)
1165 region = (int[]) regions.elementAt(j);
1166 hideStart = region[0];
1167 hideEnd = region[1];
1168 // edit hidden regions to selection range
1169 if (hideStart < last)
1181 if (hideStart > end)
1191 if (hideStart > hideEnd)
1196 * form operations...
1198 if (last < hideStart)
1200 selection.addOperation(CigarArray.M, hideStart - last);
1202 selection.addOperation(CigarArray.D, 1 + hideEnd - hideStart);
1205 // Final match if necessary.
1208 selection.addOperation(CigarArray.M, end - last + 1);
1213 selection.addOperation(CigarArray.M, end - start + 1);
1219 * return a compact representation of the current alignment selection to
1220 * pass to an analysis function
1221 * @param selectedOnly boolean true to just return the selected view
1222 * @return AlignmentView
1224 jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly)
1227 // this is here because the AlignmentView constructor modifies the CigarArray
1228 // object. Refactoring of Cigar and alignment view representation should
1229 // be done to remove redundancy.
1230 CigarArray aligview = getViewAsCigars(selectedOnly);
1231 if (aligview != null)
1233 return new AlignmentView(aligview,
1234 (selectedOnly && selectionGroup != null) ?
1235 selectionGroup.getStartRes() : 0);
1241 * This method returns the visible alignment as text, as
1242 * seen on the GUI, ie if columns are hidden they will not
1243 * be returned in the result.
1244 * Use this for calculating trees, PCA, redundancy etc on views
1245 * which contain hidden columns.
1248 public String[] getViewAsString(boolean selectedRegionOnly)
1250 String[] selection = null;
1251 SequenceI[] seqs = null;
1253 int start = 0, end = 0;
1254 if (selectedRegionOnly && selectionGroup != null)
1256 iSize = selectionGroup.getSize();
1257 seqs = selectionGroup.getSequencesInOrder(alignment);
1258 start = selectionGroup.getStartRes();
1259 end = selectionGroup.getEndRes() + 1;
1263 iSize = alignment.getHeight();
1264 seqs = alignment.getSequencesArray();
1265 end = alignment.getWidth();
1268 selection = new String[iSize];
1270 for (i = 0; i < iSize; i++)
1272 if (hasHiddenColumns)
1274 StringBuffer visibleSeq = new StringBuffer();
1275 Vector regions = colSel.getHiddenColumns();
1277 int blockStart = start, blockEnd = end;
1279 int hideStart, hideEnd;
1281 for (int j = 0; j < regions.size(); j++)
1283 region = (int[]) regions.elementAt(j);
1284 hideStart = region[0];
1285 hideEnd = region[1];
1287 if (hideStart < start)
1292 blockStart = Math.min(blockStart, hideEnd + 1);
1293 blockEnd = Math.min(blockEnd, hideStart);
1295 if (blockStart > blockEnd)
1300 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
1302 blockStart = hideEnd + 1;
1306 if (end > blockStart)
1308 visibleSeq.append(seqs[i].getSequence(blockStart, end));
1311 selection[i] = visibleSeq.toString();
1315 selection[i] = seqs[i].getSequenceAsString(start, end);
1322 public boolean getShowHiddenMarkers()
1324 return showHiddenMarkers;
1327 public void setShowHiddenMarkers(boolean show)
1329 showHiddenMarkers = show;
1332 public Color getSequenceColour(SequenceI seq)
1334 if (sequenceColours == null || !sequenceColours.containsKey(seq))
1340 return (Color) sequenceColours.get(seq);
1344 public void setSequenceColour(SequenceI seq, Color col)
1346 if (sequenceColours == null)
1348 sequenceColours = new Hashtable();
1353 sequenceColours.remove(seq);
1357 sequenceColours.put(seq, col);
1361 public String getSequenceSetId()
1363 if (sequenceSetID == null)
1365 sequenceSetID = alignment.hashCode() + "";
1368 return sequenceSetID;
1371 public void alignmentChanged(AlignmentPanel ap)
1373 alignment.padGaps();
1375 if (hconsensus != null && autocalculateConsensus)
1377 updateConsensus(ap);
1378 updateConservation(ap);
1381 //Reset endRes of groups if beyond alignment width
1382 int alWidth = alignment.getWidth();
1383 Vector groups = alignment.getGroups();
1386 for (int i = 0; i < groups.size(); i++)
1388 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
1389 if (sg.getEndRes() > alWidth)
1391 sg.setEndRes(alWidth - 1);
1396 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1398 selectionGroup.setEndRes(alWidth - 1);
1401 resetAllColourSchemes();
1403 //AW alignment.adjustSequenceAnnotations();
1406 void resetAllColourSchemes()
1408 ColourSchemeI cs = globalColourScheme;
1411 if (cs instanceof ClustalxColourScheme)
1413 ( (ClustalxColourScheme) cs).
1414 resetClustalX(alignment.getSequences(),
1415 alignment.getWidth());
1418 cs.setConsensus(hconsensus);
1419 if (cs.conservationApplied())
1421 Alignment al = (Alignment) alignment;
1422 Conservation c = new Conservation("All",
1423 ResidueProperties.propHash, 3,
1424 al.getSequences(), 0,
1427 c.verdict(false, ConsPercGaps);
1429 cs.setConservation(c);
1433 int s, sSize = alignment.getGroups().size();
1434 for (s = 0; s < sSize; s++)
1436 SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
1437 if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
1439 ( (ClustalxColourScheme) sg.cs).resetClustalX(
1440 sg.getSequences(hiddenRepSequences), sg.getWidth());
1442 sg.recalcConservation();