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 protected FeatureSettings featureSettings=null;
675 public void setFont(Font f)
678 if (nullFrame == null)
680 nullFrame = new java.awt.Frame();
681 nullFrame.addNotify();
684 java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font);
685 setCharHeight(fm.getHeight());
686 charWidth = fm.charWidth('M');
690 Font f2 = new Font(f.getName(), Font.BOLD, f.getSize());
691 fm = nullFrame.getGraphics().getFontMetrics(f2);
692 charWidth = fm.stringWidth("MMMMMMMMMMM") / 10;
696 public Font getFont()
701 public int getCharWidth()
706 public void setCharHeight(int h)
711 public int getCharHeight()
716 public void setWrappedWidth(int w)
718 this.wrappedWidth = w;
721 public int getwrappedWidth()
726 public AlignmentI getAlignment()
731 public void setAlignment(AlignmentI align)
733 this.alignment = align;
736 public void setWrapAlignment(boolean state)
738 wrapAlignment = state;
741 public void setShowText(boolean state)
746 public void setRenderGaps(boolean state)
751 public boolean getColourText()
753 return showColourText;
756 public void setColourText(boolean state)
758 showColourText = state;
761 public void setShowBoxes(boolean state)
766 public boolean getWrapAlignment()
768 return wrapAlignment;
771 public boolean getShowText()
776 public boolean getShowBoxes()
781 public char getGapCharacter()
783 return getAlignment().getGapCharacter();
786 public void setGapCharacter(char gap)
788 if (getAlignment() != null)
790 getAlignment().setGapCharacter(gap);
794 public void setThreshold(int thresh)
799 public int getThreshold()
804 public void setIncrement(int inc)
809 public int getIncrement()
814 public void setHiddenColumns(ColumnSelection colsel)
816 this.colSel = colsel;
817 if (colSel.getHiddenColumns() != null)
819 hasHiddenColumns = true;
823 public ColumnSelection getColumnSelection()
828 public void resetSeqLimits(int height)
830 setEndSeq(height / getCharHeight());
833 public void setCurrentTree(NJTree tree)
838 public NJTree getCurrentTree()
843 public void setColourAppliesToAllGroups(boolean b)
845 colourAppliesToAllGroups = b;
848 public boolean getColourAppliesToAllGroups()
850 return colourAppliesToAllGroups;
853 public boolean getShowJVSuffix()
858 public void setShowJVSuffix(boolean b)
863 public boolean getShowAnnotation()
865 return showAnnotation;
868 public void setShowAnnotation(boolean b)
873 public boolean getScaleAboveWrapped()
875 return scaleAboveWrapped;
878 public boolean getScaleLeftWrapped()
880 return scaleLeftWrapped;
883 public boolean getScaleRightWrapped()
885 return scaleRightWrapped;
888 public void setScaleAboveWrapped(boolean b)
890 scaleAboveWrapped = b;
893 public void setScaleLeftWrapped(boolean b)
895 scaleLeftWrapped = b;
898 public void setScaleRightWrapped(boolean b)
900 scaleRightWrapped = b;
903 public void setIgnoreGapsConsensus(boolean b)
905 ignoreGapsInConsensusCalculation = b;
906 updateConsensus(null);
907 if (globalColourScheme != null)
909 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
910 ignoreGapsInConsensusCalculation);
916 * Property change listener for changes in alignment
918 * @param listener DOCUMENT ME!
920 public void addPropertyChangeListener(
921 java.beans.PropertyChangeListener listener)
923 changeSupport.addPropertyChangeListener(listener);
929 * @param listener DOCUMENT ME!
931 public void removePropertyChangeListener(
932 java.beans.PropertyChangeListener listener)
934 changeSupport.removePropertyChangeListener(listener);
938 * Property change listener for changes in alignment
940 * @param prop DOCUMENT ME!
941 * @param oldvalue DOCUMENT ME!
942 * @param newvalue DOCUMENT ME!
944 public void firePropertyChange(String prop, Object oldvalue, Object newvalue)
946 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
949 public boolean getIgnoreGapsConsensus()
951 return ignoreGapsInConsensusCalculation;
954 public void hideSelectedColumns()
956 if (colSel.size() < 1)
961 colSel.hideSelectedColumns();
962 setSelectionGroup(null);
964 hasHiddenColumns = true;
967 public void invertColumnSelection()
969 for (int i = 0; i < alignment.getWidth(); i++)
971 if (colSel.contains(i))
973 colSel.removeElement(i);
977 if (!hasHiddenColumns || colSel.isVisible(i))
979 colSel.addElement(i);
985 public void hideColumns(int start, int end)
989 colSel.hideColumns(start);
993 colSel.hideColumns(start, end);
996 hasHiddenColumns = true;
999 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1001 int sSize = sg.getSize();
1007 if (hiddenRepSequences == null)
1009 hiddenRepSequences = new Hashtable();
1012 hiddenRepSequences.put(repSequence, sg);
1014 //Hide all sequences except the repSequence
1015 SequenceI[] seqs = new SequenceI[sSize - 1];
1017 for (int i = 0; i < sSize; i++)
1019 if (sg.getSequenceAt(i) != repSequence)
1021 if (index == sSize - 1)
1026 seqs[index++] = sg.getSequenceAt(i);
1034 public void hideAllSelectedSeqs()
1036 if (selectionGroup == null || selectionGroup.getSize()<1)
1041 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1045 setSelectionGroup(null);
1048 public void hideSequence(SequenceI[] seq)
1052 for (int i = 0; i < seq.length; i++)
1054 alignment.getHiddenSequences().hideSequence(seq[i]);
1057 hasHiddenRows = true;
1058 firePropertyChange("alignment", null, alignment.getSequences());
1062 public void showColumn(int col)
1064 colSel.revealHiddenColumns(col);
1065 if (colSel.getHiddenColumns() == null)
1067 hasHiddenColumns = false;
1071 public void showAllHiddenColumns()
1073 colSel.revealAllHiddenColumns();
1074 hasHiddenColumns = false;
1077 public void showAllHiddenSeqs()
1079 if (alignment.getHiddenSequences().getSize() > 0)
1081 if (selectionGroup == null)
1083 selectionGroup = new SequenceGroup();
1084 selectionGroup.setEndRes(alignment.getWidth() - 1);
1086 Vector tmp = alignment.getHiddenSequences().showAll(hiddenRepSequences);
1087 for (int t = 0; t < tmp.size(); t++)
1089 selectionGroup.addSequence(
1090 (SequenceI) tmp.elementAt(t), false
1093 firePropertyChange("alignment", null, alignment.getSequences());
1094 hasHiddenRows = false;
1095 hiddenRepSequences = null;
1099 public int adjustForHiddenSeqs(int alignmentIndex)
1101 return alignment.getHiddenSequences().adjustForHiddenSeqs(alignmentIndex);
1105 * This method returns the a new SequenceI [] with
1106 * the selection sequence and start and end points adjusted
1109 public SequenceI[] getSelectionAsNewSequence()
1111 SequenceI[] sequences;
1113 if (selectionGroup == null)
1115 sequences = alignment.getSequencesArray();
1119 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1126 * This method returns the visible alignment as text, as
1127 * seen on the GUI, ie if columns are hidden they will not
1128 * be returned in the result.
1129 * Use this for calculating trees, PCA, redundancy etc on views
1130 * which contain hidden columns.
1133 public jalview.datamodel.CigarArray getViewAsCigars(boolean
1136 CigarArray selection = null;
1137 SequenceI[] seqs = null;
1139 int start = 0, end = 0;
1140 if (selectedRegionOnly && selectionGroup != null)
1142 iSize = selectionGroup.getSize();
1143 seqs = selectionGroup.getSequencesInOrder(alignment);
1144 start = selectionGroup.getStartRes();
1145 end = selectionGroup.getEndRes(); // inclusive for start and end in SeqCigar constructor
1149 iSize = alignment.getHeight();
1150 seqs = alignment.getSequencesArray();
1151 end = alignment.getWidth() - 1;
1153 SeqCigar[] selseqs = new SeqCigar[iSize];
1154 for (i = 0; i < iSize; i++)
1156 selseqs[i] = new SeqCigar(seqs[i], start, end);
1158 selection = new CigarArray(selseqs);
1159 // now construct the CigarArray operations
1160 if (hasHiddenColumns)
1162 Vector regions = colSel.getHiddenColumns();
1164 int hideStart, hideEnd;
1166 for (int j = 0; last < end & j < regions.size(); j++)
1168 region = (int[]) regions.elementAt(j);
1169 hideStart = region[0];
1170 hideEnd = region[1];
1171 // edit hidden regions to selection range
1172 if (hideStart < last)
1184 if (hideStart > end)
1194 if (hideStart > hideEnd)
1199 * form operations...
1201 if (last < hideStart)
1203 selection.addOperation(CigarArray.M, hideStart - last);
1205 selection.addOperation(CigarArray.D, 1 + hideEnd - hideStart);
1208 // Final match if necessary.
1211 selection.addOperation(CigarArray.M, end - last + 1);
1216 selection.addOperation(CigarArray.M, end - start + 1);
1222 * return a compact representation of the current alignment selection to
1223 * pass to an analysis function
1224 * @param selectedOnly boolean true to just return the selected view
1225 * @return AlignmentView
1227 jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly)
1230 // this is here because the AlignmentView constructor modifies the CigarArray
1231 // object. Refactoring of Cigar and alignment view representation should
1232 // be done to remove redundancy.
1233 CigarArray aligview = getViewAsCigars(selectedOnly);
1234 if (aligview != null)
1236 return new AlignmentView(aligview,
1237 (selectedOnly && selectionGroup != null) ?
1238 selectionGroup.getStartRes() : 0);
1244 * This method returns the visible alignment as text, as
1245 * seen on the GUI, ie if columns are hidden they will not
1246 * be returned in the result.
1247 * Use this for calculating trees, PCA, redundancy etc on views
1248 * which contain hidden columns.
1251 public String[] getViewAsString(boolean selectedRegionOnly)
1253 String[] selection = null;
1254 SequenceI[] seqs = null;
1256 int start = 0, end = 0;
1257 if (selectedRegionOnly && selectionGroup != null)
1259 iSize = selectionGroup.getSize();
1260 seqs = selectionGroup.getSequencesInOrder(alignment);
1261 start = selectionGroup.getStartRes();
1262 end = selectionGroup.getEndRes() + 1;
1266 iSize = alignment.getHeight();
1267 seqs = alignment.getSequencesArray();
1268 end = alignment.getWidth();
1271 selection = new String[iSize];
1273 for (i = 0; i < iSize; i++)
1275 if (hasHiddenColumns)
1277 StringBuffer visibleSeq = new StringBuffer();
1278 Vector regions = colSel.getHiddenColumns();
1280 int blockStart = start, blockEnd = end;
1282 int hideStart, hideEnd;
1284 for (int j = 0; j < regions.size(); j++)
1286 region = (int[]) regions.elementAt(j);
1287 hideStart = region[0];
1288 hideEnd = region[1];
1290 if (hideStart < start)
1295 blockStart = Math.min(blockStart, hideEnd + 1);
1296 blockEnd = Math.min(blockEnd, hideStart);
1298 if (blockStart > blockEnd)
1303 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
1305 blockStart = hideEnd + 1;
1309 if (end > blockStart)
1311 visibleSeq.append(seqs[i].getSequence(blockStart, end));
1314 selection[i] = visibleSeq.toString();
1318 selection[i] = seqs[i].getSequenceAsString(start, end);
1325 public boolean getShowHiddenMarkers()
1327 return showHiddenMarkers;
1330 public void setShowHiddenMarkers(boolean show)
1332 showHiddenMarkers = show;
1335 public Color getSequenceColour(SequenceI seq)
1337 if (sequenceColours == null || !sequenceColours.containsKey(seq))
1343 return (Color) sequenceColours.get(seq);
1347 public void setSequenceColour(SequenceI seq, Color col)
1349 if (sequenceColours == null)
1351 sequenceColours = new Hashtable();
1356 sequenceColours.remove(seq);
1360 sequenceColours.put(seq, col);
1364 public String getSequenceSetId()
1366 if (sequenceSetID == null)
1368 sequenceSetID = alignment.hashCode() + "";
1371 return sequenceSetID;
1374 public void alignmentChanged(AlignmentPanel ap)
1376 alignment.padGaps();
1378 if (hconsensus != null && autocalculateConsensus)
1380 updateConsensus(ap);
1381 updateConservation(ap);
1384 //Reset endRes of groups if beyond alignment width
1385 int alWidth = alignment.getWidth();
1386 Vector groups = alignment.getGroups();
1389 for (int i = 0; i < groups.size(); i++)
1391 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
1392 if (sg.getEndRes() > alWidth)
1394 sg.setEndRes(alWidth - 1);
1399 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1401 selectionGroup.setEndRes(alWidth - 1);
1404 resetAllColourSchemes();
1406 //AW alignment.adjustSequenceAnnotations();
1409 void resetAllColourSchemes()
1411 ColourSchemeI cs = globalColourScheme;
1414 if (cs instanceof ClustalxColourScheme)
1416 ( (ClustalxColourScheme) cs).
1417 resetClustalX(alignment.getSequences(),
1418 alignment.getWidth());
1421 cs.setConsensus(hconsensus);
1422 if (cs.conservationApplied())
1424 Alignment al = (Alignment) alignment;
1425 Conservation c = new Conservation("All",
1426 ResidueProperties.propHash, 3,
1427 al.getSequences(), 0,
1430 c.verdict(false, ConsPercGaps);
1432 cs.setConservation(c);
1436 int s, sSize = alignment.getGroups().size();
1437 for (s = 0; s < sSize; s++)
1439 SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
1440 if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
1442 ( (ClustalxColourScheme) sg.cs).resetClustalX(
1443 sg.getSequences(hiddenRepSequences), sg.getWidth());
1445 sg.recalcConservation();