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;
173 String colour = applet.getParameter("defaultColour");
177 colour = applet.getParameter("userDefinedColour");
180 colour = "User Defined";
186 globalColourScheme = ColourSchemeProperty.getColour(alignment, colour);
187 if (globalColourScheme != null)
189 globalColourScheme.setConsensus(hconsensus);
193 if (applet.getParameter("userDefinedColour") != null)
195 ( (UserColourScheme) globalColourScheme).parseAppletParameter(
196 applet.getParameter("userDefinedColour"));
199 if (hconsensus == null)
201 if (!alignment.isNucleotide())
203 conservation = new AlignmentAnnotation("Conservation",
204 "Conservation of total alignment less than " +
205 ConsPercGaps + "% gaps",
206 new Annotation[1], 0f,
208 AlignmentAnnotation.BAR_GRAPH);
209 conservation.hasText = true;
210 conservation.autoCalculated = true;
212 if (showConservation)
214 alignment.addAnnotation(conservation);
219 quality = new AlignmentAnnotation("Quality",
220 "Alignment Quality based on Blosum62 scores",
224 AlignmentAnnotation.BAR_GRAPH);
225 quality.hasText = true;
226 quality.autoCalculated = true;
228 alignment.addAnnotation(quality);
232 consensus = new AlignmentAnnotation("Consensus", "PID",
233 new Annotation[1], 0f, 100f,
234 AlignmentAnnotation.BAR_GRAPH);
235 consensus.hasText = true;
236 consensus.autoCalculated = true;
240 alignment.addAnnotation(consensus);
246 public void showSequenceFeatures(boolean b)
248 showSequenceFeatures = b;
251 public boolean getShowSequenceFeatures()
253 return showSequenceFeatures;
256 class ConservationThread
260 public ConservationThread(AlignmentPanel ap)
269 updatingConservation = true;
271 while (UPDATING_CONSERVATION)
277 ap.paintAlignment(false);
283 ex.printStackTrace();
287 UPDATING_CONSERVATION = true;
289 int alWidth = alignment.getWidth();
295 Conservation cons = new jalview.analysis.Conservation("All",
296 jalview.schemes.ResidueProperties.propHash, 3,
297 alignment.getSequences(), 0, alWidth - 1);
300 cons.verdict(false, ConsPercGaps);
307 char[] sequence = cons.getConsSequence().getSequence();
319 maxB = 0f - minB; // scalable range for colouring both Conservation and Quality
328 conservation.annotations = new Annotation[alWidth];
332 quality.graphMax = cons.qualityRange[1].floatValue();
333 quality.annotations = new Annotation[alWidth];
334 qmin = cons.qualityRange[0].floatValue();
335 qmax = cons.qualityRange[1].floatValue();
338 for (int i = 0; i < alWidth; i++)
344 if (Character.isDigit(c))
346 value = (int) (c - '0');
357 float vprop = value - min;
359 conservation.annotations[i] =
360 new Annotation(String.valueOf(c),
361 String.valueOf(value), ' ', value,
362 new Color(minR + (maxR * vprop),
363 minG + (maxG * vprop),
364 minB + (maxB * vprop)));
369 value = ( (Double) cons.quality.elementAt(i)).floatValue();
370 vprop = value - qmin;
372 quality.annotations[i] = new Annotation(" ", String.valueOf(value),
375 new Color(minR + (maxR * vprop),
376 minG + (maxG * vprop),
377 minB + (maxB * vprop)));
381 catch (OutOfMemoryError error)
383 System.out.println("Out of memory calculating conservation!!");
389 UPDATING_CONSERVATION = false;
390 updatingConservation = false;
394 ap.paintAlignment(true);
400 ConservationThread conservationThread;
402 ConsensusThread consensusThread;
404 boolean consUpdateNeeded = false;
406 static boolean UPDATING_CONSENSUS = false;
408 static boolean UPDATING_CONSERVATION = false;
410 boolean updatingConsensus = false;
412 boolean updatingConservation = false;
417 public void updateConservation(final AlignmentPanel ap)
419 if (alignment.isNucleotide() || conservation == null)
424 conservationThread = new ConservationThread(ap);
425 conservationThread.start();
431 public void updateConsensus(final AlignmentPanel ap)
433 consensusThread = new ConsensusThread(ap);
434 consensusThread.start();
437 class ConsensusThread
441 public ConsensusThread(AlignmentPanel ap)
448 updatingConsensus = true;
449 while (UPDATING_CONSENSUS)
455 ap.paintAlignment(false);
462 ex.printStackTrace();
466 UPDATING_CONSENSUS = true;
470 int aWidth = alignment.getWidth();
476 consensus.annotations = null;
477 consensus.annotations = new Annotation[aWidth];
479 hconsensus = new Hashtable[aWidth];
480 AAFrequency.calculate(alignment.getSequencesArray(),
482 alignment.getWidth(),
485 for (int i = 0; i < aWidth; i++)
488 if (ignoreGapsInConsensusCalculation)
490 value = ( (Float) hconsensus[i].get(AAFrequency.PID_NOGAPS)).
495 value = ( (Float) hconsensus[i].get(AAFrequency.PID_GAPS)).
499 String maxRes = hconsensus[i].get(AAFrequency.MAXRESIDUE).toString();
500 String mouseOver = hconsensus[i].get(AAFrequency.MAXRESIDUE) + " ";
502 if (maxRes.length() > 1)
504 mouseOver = "[" + maxRes + "] ";
508 mouseOver += ( (int) value + "%");
509 consensus.annotations[i] = new Annotation(maxRes, mouseOver, ' ',
513 if (globalColourScheme != null)
515 globalColourScheme.setConsensus(hconsensus);
519 catch (OutOfMemoryError error)
521 alignment.deleteAnnotation(consensus);
525 System.out.println("Out of memory calculating consensus!!");
528 UPDATING_CONSENSUS = false;
529 updatingConsensus = false;
533 ap.paintAlignment(true);
539 * get the consensus sequence as displayed under the PID consensus annotation row.
540 * @return consensus sequence as a new sequence object
543 * get the consensus sequence as displayed under the PID consensus annotation row.
544 * @return consensus sequence as a new sequence object
546 public SequenceI getConsensusSeq()
548 if (consensus == null)
552 StringBuffer seqs = new StringBuffer();
553 for (int i = 0; i < consensus.annotations.length; i++)
555 if (consensus.annotations[i] != null)
557 if (consensus.annotations[i].description.charAt(0) == '[')
559 seqs.append(consensus.annotations[i].description.charAt(1));
563 seqs.append(consensus.annotations[i].displayCharacter);
567 SequenceI sq = new Sequence("Consensus", seqs.toString());
568 sq.setDescription("Percentage Identity Consensus " +
569 ( (ignoreGapsInConsensusCalculation) ? " without gaps" :
574 public SequenceGroup getSelectionGroup()
576 return selectionGroup;
579 public void setSelectionGroup(SequenceGroup sg)
584 public boolean getConservationSelected()
586 return conservationColourSelected;
589 public void setConservationSelected(boolean b)
591 conservationColourSelected = b;
594 public boolean getAbovePIDThreshold()
596 return abovePIDThreshold;
599 public void setAbovePIDThreshold(boolean b)
601 abovePIDThreshold = b;
604 public int getStartRes()
609 public int getEndRes()
614 public int getStartSeq()
619 public void setGlobalColourScheme(ColourSchemeI cs)
621 globalColourScheme = cs;
624 public ColourSchemeI getGlobalColourScheme()
626 return globalColourScheme;
629 public void setStartRes(int res)
634 public void setStartSeq(int seq)
639 public void setEndRes(int res)
641 if (res > alignment.getWidth() - 1)
643 // log.System.out.println(" Corrected res from " + res + " to maximum " + (alignment.getWidth()-1));
644 res = alignment.getWidth() - 1;
653 public void setEndSeq(int seq)
655 if (seq > alignment.getHeight())
657 seq = alignment.getHeight();
666 public int getEndSeq()
671 java.awt.Frame nullFrame;
672 protected FeatureSettings featureSettings=null;
673 public void setFont(Font f)
676 if (nullFrame == null)
678 nullFrame = new java.awt.Frame();
679 nullFrame.addNotify();
682 java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font);
683 setCharHeight(fm.getHeight());
684 charWidth = fm.charWidth('M');
688 Font f2 = new Font(f.getName(), Font.BOLD, f.getSize());
689 fm = nullFrame.getGraphics().getFontMetrics(f2);
690 charWidth = fm.stringWidth("MMMMMMMMMMM") / 10;
694 public Font getFont()
699 public int getCharWidth()
704 public void setCharHeight(int h)
709 public int getCharHeight()
714 public void setWrappedWidth(int w)
716 this.wrappedWidth = w;
719 public int getwrappedWidth()
724 public AlignmentI getAlignment()
729 public void setAlignment(AlignmentI align)
731 this.alignment = align;
734 public void setWrapAlignment(boolean state)
736 wrapAlignment = state;
739 public void setShowText(boolean state)
744 public void setRenderGaps(boolean state)
749 public boolean getColourText()
751 return showColourText;
754 public void setColourText(boolean state)
756 showColourText = state;
759 public void setShowBoxes(boolean state)
764 public boolean getWrapAlignment()
766 return wrapAlignment;
769 public boolean getShowText()
774 public boolean getShowBoxes()
779 public char getGapCharacter()
781 return getAlignment().getGapCharacter();
784 public void setGapCharacter(char gap)
786 if (getAlignment() != null)
788 getAlignment().setGapCharacter(gap);
792 public void setThreshold(int thresh)
797 public int getThreshold()
802 public void setIncrement(int inc)
807 public int getIncrement()
812 public void setHiddenColumns(ColumnSelection colsel)
814 this.colSel = colsel;
815 if (colSel.getHiddenColumns() != null)
817 hasHiddenColumns = true;
821 public ColumnSelection getColumnSelection()
826 public void resetSeqLimits(int height)
828 setEndSeq(height / getCharHeight());
831 public void setCurrentTree(NJTree tree)
836 public NJTree getCurrentTree()
841 public void setColourAppliesToAllGroups(boolean b)
843 colourAppliesToAllGroups = b;
846 public boolean getColourAppliesToAllGroups()
848 return colourAppliesToAllGroups;
851 public boolean getShowJVSuffix()
856 public void setShowJVSuffix(boolean b)
861 public boolean getShowAnnotation()
863 return showAnnotation;
866 public void setShowAnnotation(boolean b)
871 public boolean getScaleAboveWrapped()
873 return scaleAboveWrapped;
876 public boolean getScaleLeftWrapped()
878 return scaleLeftWrapped;
881 public boolean getScaleRightWrapped()
883 return scaleRightWrapped;
886 public void setScaleAboveWrapped(boolean b)
888 scaleAboveWrapped = b;
891 public void setScaleLeftWrapped(boolean b)
893 scaleLeftWrapped = b;
896 public void setScaleRightWrapped(boolean b)
898 scaleRightWrapped = b;
901 public void setIgnoreGapsConsensus(boolean b)
903 ignoreGapsInConsensusCalculation = b;
904 updateConsensus(null);
905 if (globalColourScheme != null)
907 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
908 ignoreGapsInConsensusCalculation);
914 * Property change listener for changes in alignment
916 * @param listener DOCUMENT ME!
918 public void addPropertyChangeListener(
919 java.beans.PropertyChangeListener listener)
921 changeSupport.addPropertyChangeListener(listener);
927 * @param listener DOCUMENT ME!
929 public void removePropertyChangeListener(
930 java.beans.PropertyChangeListener listener)
932 changeSupport.removePropertyChangeListener(listener);
936 * Property change listener for changes in alignment
938 * @param prop DOCUMENT ME!
939 * @param oldvalue DOCUMENT ME!
940 * @param newvalue DOCUMENT ME!
942 public void firePropertyChange(String prop, Object oldvalue, Object newvalue)
944 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
947 public boolean getIgnoreGapsConsensus()
949 return ignoreGapsInConsensusCalculation;
952 public void hideSelectedColumns()
954 if (colSel.size() < 1)
959 colSel.hideSelectedColumns();
960 setSelectionGroup(null);
962 hasHiddenColumns = true;
965 public void invertColumnSelection()
967 for (int i = 0; i < alignment.getWidth(); i++)
969 if (colSel.contains(i))
971 colSel.removeElement(i);
975 if (!hasHiddenColumns || colSel.isVisible(i))
977 colSel.addElement(i);
983 public void hideColumns(int start, int end)
987 colSel.hideColumns(start);
991 colSel.hideColumns(start, end);
994 hasHiddenColumns = true;
997 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
999 int sSize = sg.getSize();
1005 if (hiddenRepSequences == null)
1007 hiddenRepSequences = new Hashtable();
1010 hiddenRepSequences.put(repSequence, sg);
1012 //Hide all sequences except the repSequence
1013 SequenceI[] seqs = new SequenceI[sSize - 1];
1015 for (int i = 0; i < sSize; i++)
1017 if (sg.getSequenceAt(i) != repSequence)
1019 if (index == sSize - 1)
1024 seqs[index++] = sg.getSequenceAt(i);
1032 public void hideAllSelectedSeqs()
1034 if (selectionGroup == null || selectionGroup.getSize()<1)
1039 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1043 setSelectionGroup(null);
1046 public void hideSequence(SequenceI[] seq)
1050 for (int i = 0; i < seq.length; i++)
1052 alignment.getHiddenSequences().hideSequence(seq[i]);
1055 hasHiddenRows = true;
1056 firePropertyChange("alignment", null, alignment.getSequences());
1060 public void showColumn(int col)
1062 colSel.revealHiddenColumns(col);
1063 if (colSel.getHiddenColumns() == null)
1065 hasHiddenColumns = false;
1069 public void showAllHiddenColumns()
1071 colSel.revealAllHiddenColumns();
1072 hasHiddenColumns = false;
1075 public void showAllHiddenSeqs()
1077 if (alignment.getHiddenSequences().getSize() > 0)
1079 if (selectionGroup == null)
1081 selectionGroup = new SequenceGroup();
1082 selectionGroup.setEndRes(alignment.getWidth() - 1);
1084 Vector tmp = alignment.getHiddenSequences().showAll(hiddenRepSequences);
1085 for (int t = 0; t < tmp.size(); t++)
1087 selectionGroup.addSequence(
1088 (SequenceI) tmp.elementAt(t), false
1091 firePropertyChange("alignment", null, alignment.getSequences());
1092 hasHiddenRows = false;
1093 hiddenRepSequences = null;
1097 public int adjustForHiddenSeqs(int alignmentIndex)
1099 return alignment.getHiddenSequences().adjustForHiddenSeqs(alignmentIndex);
1103 * This method returns the a new SequenceI [] with
1104 * the selection sequence and start and end points adjusted
1107 public SequenceI[] getSelectionAsNewSequence()
1109 SequenceI[] sequences;
1111 if (selectionGroup == null)
1113 sequences = alignment.getSequencesArray();
1117 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1124 * This method returns the visible alignment as text, as
1125 * seen on the GUI, ie if columns are hidden they will not
1126 * be returned in the result.
1127 * Use this for calculating trees, PCA, redundancy etc on views
1128 * which contain hidden columns.
1131 public jalview.datamodel.CigarArray getViewAsCigars(boolean
1134 CigarArray selection = null;
1135 SequenceI[] seqs = null;
1137 int start = 0, end = 0;
1138 if (selectedRegionOnly && selectionGroup != null)
1140 iSize = selectionGroup.getSize();
1141 seqs = selectionGroup.getSequencesInOrder(alignment);
1142 start = selectionGroup.getStartRes();
1143 end = selectionGroup.getEndRes(); // inclusive for start and end in SeqCigar constructor
1147 iSize = alignment.getHeight();
1148 seqs = alignment.getSequencesArray();
1149 end = alignment.getWidth() - 1;
1151 SeqCigar[] selseqs = new SeqCigar[iSize];
1152 for (i = 0; i < iSize; i++)
1154 selseqs[i] = new SeqCigar(seqs[i], start, end);
1156 selection = new CigarArray(selseqs);
1157 // now construct the CigarArray operations
1158 if (hasHiddenColumns)
1160 Vector regions = colSel.getHiddenColumns();
1162 int hideStart, hideEnd;
1164 for (int j = 0; last < end & j < regions.size(); j++)
1166 region = (int[]) regions.elementAt(j);
1167 hideStart = region[0];
1168 hideEnd = region[1];
1169 // edit hidden regions to selection range
1170 if (hideStart < last)
1182 if (hideStart > end)
1192 if (hideStart > hideEnd)
1197 * form operations...
1199 if (last < hideStart)
1201 selection.addOperation(CigarArray.M, hideStart - last);
1203 selection.addOperation(CigarArray.D, 1 + hideEnd - hideStart);
1206 // Final match if necessary.
1209 selection.addOperation(CigarArray.M, end - last + 1);
1214 selection.addOperation(CigarArray.M, end - start + 1);
1220 * return a compact representation of the current alignment selection to
1221 * pass to an analysis function
1222 * @param selectedOnly boolean true to just return the selected view
1223 * @return AlignmentView
1225 jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly)
1228 // this is here because the AlignmentView constructor modifies the CigarArray
1229 // object. Refactoring of Cigar and alignment view representation should
1230 // be done to remove redundancy.
1231 CigarArray aligview = getViewAsCigars(selectedOnly);
1232 if (aligview != null)
1234 return new AlignmentView(aligview,
1235 (selectedOnly && selectionGroup != null) ?
1236 selectionGroup.getStartRes() : 0);
1242 * This method returns the visible alignment as text, as
1243 * seen on the GUI, ie if columns are hidden they will not
1244 * be returned in the result.
1245 * Use this for calculating trees, PCA, redundancy etc on views
1246 * which contain hidden columns.
1249 public String[] getViewAsString(boolean selectedRegionOnly)
1251 String[] selection = null;
1252 SequenceI[] seqs = null;
1254 int start = 0, end = 0;
1255 if (selectedRegionOnly && selectionGroup != null)
1257 iSize = selectionGroup.getSize();
1258 seqs = selectionGroup.getSequencesInOrder(alignment);
1259 start = selectionGroup.getStartRes();
1260 end = selectionGroup.getEndRes() + 1;
1264 iSize = alignment.getHeight();
1265 seqs = alignment.getSequencesArray();
1266 end = alignment.getWidth();
1269 selection = new String[iSize];
1271 for (i = 0; i < iSize; i++)
1273 if (hasHiddenColumns)
1275 StringBuffer visibleSeq = new StringBuffer();
1276 Vector regions = colSel.getHiddenColumns();
1278 int blockStart = start, blockEnd = end;
1280 int hideStart, hideEnd;
1282 for (int j = 0; j < regions.size(); j++)
1284 region = (int[]) regions.elementAt(j);
1285 hideStart = region[0];
1286 hideEnd = region[1];
1288 if (hideStart < start)
1293 blockStart = Math.min(blockStart, hideEnd + 1);
1294 blockEnd = Math.min(blockEnd, hideStart);
1296 if (blockStart > blockEnd)
1301 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
1303 blockStart = hideEnd + 1;
1307 if (end > blockStart)
1309 visibleSeq.append(seqs[i].getSequence(blockStart, end));
1312 selection[i] = visibleSeq.toString();
1316 selection[i] = seqs[i].getSequenceAsString(start, end);
1323 public boolean getShowHiddenMarkers()
1325 return showHiddenMarkers;
1328 public void setShowHiddenMarkers(boolean show)
1330 showHiddenMarkers = show;
1333 public Color getSequenceColour(SequenceI seq)
1335 if (sequenceColours == null || !sequenceColours.containsKey(seq))
1341 return (Color) sequenceColours.get(seq);
1345 public void setSequenceColour(SequenceI seq, Color col)
1347 if (sequenceColours == null)
1349 sequenceColours = new Hashtable();
1354 sequenceColours.remove(seq);
1358 sequenceColours.put(seq, col);
1362 public String getSequenceSetId()
1364 if (sequenceSetID == null)
1366 sequenceSetID = alignment.hashCode() + "";
1369 return sequenceSetID;
1372 public void alignmentChanged(AlignmentPanel ap)
1374 alignment.padGaps();
1376 if (hconsensus != null && autocalculateConsensus)
1378 updateConsensus(ap);
1379 updateConservation(ap);
1382 //Reset endRes of groups if beyond alignment width
1383 int alWidth = alignment.getWidth();
1384 Vector groups = alignment.getGroups();
1387 for (int i = 0; i < groups.size(); i++)
1389 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
1390 if (sg.getEndRes() > alWidth)
1392 sg.setEndRes(alWidth - 1);
1397 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1399 selectionGroup.setEndRes(alWidth - 1);
1402 resetAllColourSchemes();
1404 //AW alignment.adjustSequenceAnnotations();
1407 void resetAllColourSchemes()
1409 ColourSchemeI cs = globalColourScheme;
1412 if (cs instanceof ClustalxColourScheme)
1414 ( (ClustalxColourScheme) cs).
1415 resetClustalX(alignment.getSequences(),
1416 alignment.getWidth());
1419 cs.setConsensus(hconsensus);
1420 if (cs.conservationApplied())
1422 Alignment al = (Alignment) alignment;
1423 Conservation c = new Conservation("All",
1424 ResidueProperties.propHash, 3,
1425 al.getSequences(), 0,
1428 c.verdict(false, ConsPercGaps);
1430 cs.setConservation(c);
1434 int s, sSize = alignment.getGroups().size();
1435 for (s = 0; s < sSize; s++)
1437 SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
1438 if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
1440 ( (ClustalxColourScheme) sg.cs).resetClustalX(
1441 sg.getSequences(hiddenRepSequences), sg.getWidth());
1443 sg.recalcConservation();
1446 boolean centreColumnLabels;
1447 public boolean getCentreColumnLabels()
1449 return centreColumnLabels;
1452 public void updateSequenceIdColours()
1454 Vector groups = alignment.getGroups();
1455 for (int ig=0,igSize=groups.size(); ig<igSize; ig++)
1457 SequenceGroup sg = (SequenceGroup) groups.elementAt(ig);
1458 if (sg.idColour!=null)
1460 Vector sqs = sg.getSequences(hiddenRepSequences);
1461 for (int s=0,sSize=sqs.size();s<sSize;s++)
1463 this.setSequenceColour((SequenceI) sqs.elementAt(s), sg.idColour);