2 * Jalview - A Sequence Alignment Editor and Viewer (Development Version 2.4.1)
3 * Copyright (C) 2009 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
19 package jalview.appletgui;
25 import jalview.analysis.*;
27 import jalview.datamodel.*;
28 import jalview.schemes.*;
30 public class AlignViewport
40 boolean cursorMode = false;
42 boolean showJVSuffix = true;
44 boolean showText = true;
46 boolean showColourText = false;
48 boolean showBoxes = true;
50 boolean wrapAlignment = false;
52 boolean renderGaps = true;
54 boolean showSequenceFeatures = false;
56 boolean showAnnotation = true;
58 boolean showConservation = true;
60 boolean showQuality = true;
62 boolean showConsensus = true;
64 boolean upperCasebold = false;
66 boolean colourAppliesToAllGroups = true;
68 ColourSchemeI globalColourScheme = null;
70 boolean conservationColourSelected = false;
72 boolean abovePIDThreshold = false;
74 SequenceGroup selectionGroup;
82 Font font = new Font("SansSerif", Font.PLAIN, 10);
84 boolean validCharWidth = true;
88 ColumnSelection colSel = new ColumnSelection();
94 NJTree currentTree = null;
96 boolean scaleAboveWrapped = true;
98 boolean scaleLeftWrapped = true;
100 boolean scaleRightWrapped = true;
102 // The following vector holds the features which are
103 // currently visible, in the correct order or rendering
104 public Hashtable featuresDisplayed;
106 boolean hasHiddenColumns = false;
108 boolean hasHiddenRows = false;
110 boolean showHiddenMarkers = true;
112 public Hashtable[] hconsensus;
114 AlignmentAnnotation consensus;
116 AlignmentAnnotation conservation;
118 AlignmentAnnotation quality;
119 AlignmentAnnotation[] groupConsensus;
120 AlignmentAnnotation[] groupConservation;
122 boolean autocalculateConsensus = true;
124 public int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
126 private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
129 boolean ignoreGapsInConsensusCalculation = false;
131 jalview.bin.JalviewLite applet;
133 Hashtable sequenceColours;
137 Stack historyList = new Stack();
139 Stack redoList = new Stack();
141 String sequenceSetID;
143 Hashtable hiddenRepSequences;
145 public AlignViewport(AlignmentI al, JalviewLite applet)
147 this.applet = applet;
150 this.endRes = al.getWidth() - 1;
152 this.endSeq = al.getHeight() - 1;
155 // get the width and height scaling factors if they were specified
156 String param = applet.getParameter("widthScale");
160 widthScale = new Float(param).floatValue();
161 } catch (Exception e)
166 System.err.println("Invalid alignment character width scaling factor ("+widthScale+"). Ignoring.");
171 System.err.println("Alignment character width scaling factor is now "+widthScale);
174 param = applet.getParameter("heightScale");
178 heightScale = new Float(param).floatValue();
179 } catch (Exception e)
182 if (heightScale<=1.0)
184 System.err.println("Invalid alignment character height scaling factor ("+heightScale+"). Ignoring.");
189 System.err.println("Alignment character height scaling factor is now "+heightScale);
195 MAC = new jalview.util.Platform().isAMac();
199 String param = applet.getParameter("showFullId");
202 showJVSuffix = Boolean.valueOf(param).booleanValue();
205 param = applet.getParameter("showAnnotation");
208 showAnnotation = Boolean.valueOf(param).booleanValue();
211 param = applet.getParameter("showConservation");
214 showConservation = Boolean.valueOf(param).booleanValue();
217 param = applet.getParameter("showQuality");
220 showQuality = Boolean.valueOf(param).booleanValue();
223 param = applet.getParameter("showConsensus");
226 showConsensus = Boolean.valueOf(param).booleanValue();
229 param = applet.getParameter("showUnconserved");
232 this.showUnconserved = Boolean.valueOf(param).booleanValue();
235 param = applet.getParameter("upperCase");
238 if (param.equalsIgnoreCase("bold"))
240 upperCasebold = true;
243 param = applet.getParameter("sortByTree");
246 sortByTree=Boolean.valueOf(param).booleanValue();
253 String colour = applet.getParameter("defaultColour");
257 colour = applet.getParameter("userDefinedColour");
260 colour = "User Defined";
266 globalColourScheme = ColourSchemeProperty.getColour(alignment,
268 if (globalColourScheme != null)
270 globalColourScheme.setConsensus(hconsensus);
274 if (applet.getParameter("userDefinedColour") != null)
276 ((UserColourScheme) globalColourScheme).parseAppletParameter(applet
277 .getParameter("userDefinedColour"));
280 if (hconsensus == null)
282 if (!alignment.isNucleotide())
284 conservation = new AlignmentAnnotation("Conservation",
285 "Conservation of total alignment less than " + ConsPercGaps
286 + "% gaps", new Annotation[1], 0f, 11f,
287 AlignmentAnnotation.BAR_GRAPH);
288 conservation.hasText = true;
289 conservation.autoCalculated = true;
291 if (showConservation)
293 alignment.addAnnotation(conservation);
298 quality = new AlignmentAnnotation("Quality",
299 "Alignment Quality based on Blosum62 scores",
300 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
301 quality.hasText = true;
302 quality.autoCalculated = true;
304 alignment.addAnnotation(quality);
308 consensus = new AlignmentAnnotation("Consensus", "PID",
309 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
310 consensus.hasText = true;
311 consensus.autoCalculated = true;
315 alignment.addAnnotation(consensus);
321 public void showSequenceFeatures(boolean b)
323 showSequenceFeatures = b;
326 public boolean getShowSequenceFeatures()
328 return showSequenceFeatures;
331 class ConservationThread extends Thread
335 public ConservationThread(AlignmentPanel ap)
344 updatingConservation = true;
346 while (UPDATING_CONSERVATION)
352 ap.paintAlignment(false);
355 } catch (Exception ex)
357 ex.printStackTrace();
361 UPDATING_CONSERVATION = true;
363 int alWidth = alignment.getWidth();
369 Conservation cons = new jalview.analysis.Conservation("All",
370 jalview.schemes.ResidueProperties.propHash, 3, alignment
371 .getSequences(), 0, alWidth - 1);
374 cons.verdict(false, ConsPercGaps);
381 char[] sequence = cons.getConsSequence().getSequence();
393 maxB = 0f - minB; // scalable range for colouring both Conservation and
403 conservation.annotations = new Annotation[alWidth];
407 quality.graphMax = cons.qualityRange[1].floatValue();
408 quality.annotations = new Annotation[alWidth];
409 qmin = cons.qualityRange[0].floatValue();
410 qmax = cons.qualityRange[1].floatValue();
413 for (int i = 0; i < alWidth; i++)
419 if (Character.isDigit(c))
421 value = (int) (c - '0');
431 // TODO - refactor to use a graduatedColorScheme to calculate the histogram colors.
432 float vprop = value - min;
434 conservation.annotations[i] = new Annotation(String.valueOf(c),
435 String.valueOf(value), ' ', value, new Color(minR
436 + (maxR * vprop), minG + (maxG * vprop), minB
442 value = ((Double) cons.quality.elementAt(i)).floatValue();
443 vprop = value - qmin;
445 quality.annotations[i] = new Annotation(" ", String
446 .valueOf(value), ' ', value, new Color(minR
447 + (maxR * vprop), minG + (maxG * vprop), minB
451 } catch (OutOfMemoryError error)
453 System.out.println("Out of memory calculating conservation!!");
459 UPDATING_CONSERVATION = false;
460 updatingConservation = false;
464 ap.paintAlignment(true);
470 ConservationThread conservationThread;
472 ConsensusThread consensusThread;
474 boolean consUpdateNeeded = false;
476 static boolean UPDATING_CONSENSUS = false;
478 static boolean UPDATING_CONSERVATION = false;
480 boolean updatingConsensus = false;
482 boolean updatingConservation = false;
487 public void updateConservation(final AlignmentPanel ap)
489 if (alignment.isNucleotide() || conservation == null)
494 conservationThread = new ConservationThread(ap);
495 conservationThread.start();
501 public void updateConsensus(final AlignmentPanel ap)
503 consensusThread = new ConsensusThread(ap);
504 consensusThread.start();
507 class ConsensusThread extends Thread
511 public ConsensusThread(AlignmentPanel ap)
518 updatingConsensus = true;
519 while (UPDATING_CONSENSUS)
525 ap.paintAlignment(false);
529 } catch (Exception ex)
531 ex.printStackTrace();
535 UPDATING_CONSENSUS = true;
539 int aWidth = alignment.getWidth();
545 consensus.annotations = null;
546 consensus.annotations = new Annotation[aWidth];
548 hconsensus = new Hashtable[aWidth];
549 AAFrequency.calculate(alignment.getSequencesArray(), 0, alignment
550 .getWidth(), hconsensus, includeAllConsensusSymbols);
551 AAFrequency.completeConsensus(consensus,hconsensus,0,aWidth,ignoreGapsInConsensusCalculation, includeAllConsensusSymbols);
553 if (globalColourScheme != null)
555 globalColourScheme.setConsensus(hconsensus);
558 } catch (OutOfMemoryError error)
560 alignment.deleteAnnotation(consensus);
564 System.out.println("Out of memory calculating consensus!!");
567 UPDATING_CONSENSUS = false;
568 updatingConsensus = false;
572 ap.paintAlignment(true);
578 * get the consensus sequence as displayed under the PID consensus annotation
581 * @return consensus sequence as a new sequence object
583 public SequenceI getConsensusSeq()
585 if (consensus == null)
589 StringBuffer seqs = new StringBuffer();
590 for (int i = 0; i < consensus.annotations.length; i++)
592 if (consensus.annotations[i] != null)
594 if (consensus.annotations[i].description.charAt(0) == '[')
596 seqs.append(consensus.annotations[i].description.charAt(1));
600 seqs.append(consensus.annotations[i].displayCharacter);
604 SequenceI sq = new Sequence("Consensus", seqs.toString());
605 sq.setDescription("Percentage Identity Consensus "
606 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
610 public SequenceGroup getSelectionGroup()
612 return selectionGroup;
615 public void setSelectionGroup(SequenceGroup sg)
620 public boolean getConservationSelected()
622 return conservationColourSelected;
625 public void setConservationSelected(boolean b)
627 conservationColourSelected = b;
630 public boolean getAbovePIDThreshold()
632 return abovePIDThreshold;
635 public void setAbovePIDThreshold(boolean b)
637 abovePIDThreshold = b;
640 public int getStartRes()
645 public int getEndRes()
650 public int getStartSeq()
655 public void setGlobalColourScheme(ColourSchemeI cs)
657 globalColourScheme = cs;
660 public ColourSchemeI getGlobalColourScheme()
662 return globalColourScheme;
665 public void setStartRes(int res)
670 public void setStartSeq(int seq)
675 public void setEndRes(int res)
677 if (res > alignment.getWidth() - 1)
679 // log.System.out.println(" Corrected res from " + res + " to maximum " +
680 // (alignment.getWidth()-1));
681 res = alignment.getWidth() - 1;
690 public void setEndSeq(int seq)
692 if (seq > alignment.getHeight())
694 seq = alignment.getHeight();
703 public int getEndSeq()
708 java.awt.Frame nullFrame;
710 protected FeatureSettings featureSettings = null;
712 private float heightScale=1,widthScale=1;
714 public void setFont(Font f)
717 if (nullFrame == null)
719 nullFrame = new java.awt.Frame();
720 nullFrame.addNotify();
723 java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font);
724 setCharHeight((int)(heightScale*fm.getHeight()));
725 charWidth = (int)(widthScale*fm.charWidth('M'));
729 Font f2 = new Font(f.getName(), Font.BOLD, f.getSize());
730 fm = nullFrame.getGraphics().getFontMetrics(f2);
731 charWidth = (int)(widthScale*(fm.stringWidth("MMMMMMMMMMM") / 10));
735 public Font getFont()
740 public int getCharWidth()
745 public void setCharHeight(int h)
750 public int getCharHeight()
755 public void setWrappedWidth(int w)
757 this.wrappedWidth = w;
760 public int getwrappedWidth()
765 public AlignmentI getAlignment()
770 public void setAlignment(AlignmentI align)
772 this.alignment = align;
775 public void setWrapAlignment(boolean state)
777 wrapAlignment = state;
780 public void setShowText(boolean state)
785 public void setRenderGaps(boolean state)
790 public boolean getColourText()
792 return showColourText;
795 public void setColourText(boolean state)
797 showColourText = state;
800 public void setShowBoxes(boolean state)
805 public boolean getWrapAlignment()
807 return wrapAlignment;
810 public boolean getShowText()
815 public boolean getShowBoxes()
820 public char getGapCharacter()
822 return getAlignment().getGapCharacter();
825 public void setGapCharacter(char gap)
827 if (getAlignment() != null)
829 getAlignment().setGapCharacter(gap);
833 public void setThreshold(int thresh)
838 public int getThreshold()
843 public void setIncrement(int inc)
848 public int getIncrement()
853 public void setHiddenColumns(ColumnSelection colsel)
855 this.colSel = colsel;
856 if (colSel.getHiddenColumns() != null)
858 hasHiddenColumns = true;
862 public ColumnSelection getColumnSelection()
867 public void resetSeqLimits(int height)
869 setEndSeq(height / getCharHeight());
872 public void setCurrentTree(NJTree tree)
877 public NJTree getCurrentTree()
882 public void setColourAppliesToAllGroups(boolean b)
884 colourAppliesToAllGroups = b;
887 public boolean getColourAppliesToAllGroups()
889 return colourAppliesToAllGroups;
892 public boolean getShowJVSuffix()
897 public void setShowJVSuffix(boolean b)
902 public boolean getShowAnnotation()
904 return showAnnotation;
907 public void setShowAnnotation(boolean b)
912 public boolean getScaleAboveWrapped()
914 return scaleAboveWrapped;
917 public boolean getScaleLeftWrapped()
919 return scaleLeftWrapped;
922 public boolean getScaleRightWrapped()
924 return scaleRightWrapped;
927 public void setScaleAboveWrapped(boolean b)
929 scaleAboveWrapped = b;
932 public void setScaleLeftWrapped(boolean b)
934 scaleLeftWrapped = b;
937 public void setScaleRightWrapped(boolean b)
939 scaleRightWrapped = b;
942 public void setIgnoreGapsConsensus(boolean b)
944 ignoreGapsInConsensusCalculation = b;
945 updateConsensus(null);
946 if (globalColourScheme != null)
948 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
949 ignoreGapsInConsensusCalculation);
955 * Property change listener for changes in alignment
960 public void addPropertyChangeListener(
961 java.beans.PropertyChangeListener listener)
963 changeSupport.addPropertyChangeListener(listener);
972 public void removePropertyChangeListener(
973 java.beans.PropertyChangeListener listener)
975 changeSupport.removePropertyChangeListener(listener);
979 * Property change listener for changes in alignment
988 public void firePropertyChange(String prop, Object oldvalue,
991 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
994 public boolean getIgnoreGapsConsensus()
996 return ignoreGapsInConsensusCalculation;
999 public void hideSelectedColumns()
1001 if (colSel.size() < 1)
1006 colSel.hideSelectedColumns();
1007 setSelectionGroup(null);
1009 hasHiddenColumns = true;
1012 public void invertColumnSelection()
1014 for (int i = 0; i < alignment.getWidth(); i++)
1016 if (colSel.contains(i))
1018 colSel.removeElement(i);
1022 if (!hasHiddenColumns || colSel.isVisible(i))
1024 colSel.addElement(i);
1030 public void hideColumns(int start, int end)
1034 colSel.hideColumns(start);
1038 colSel.hideColumns(start, end);
1041 hasHiddenColumns = true;
1044 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1046 int sSize = sg.getSize();
1052 if (hiddenRepSequences == null)
1054 hiddenRepSequences = new Hashtable();
1057 hiddenRepSequences.put(repSequence, sg);
1059 // Hide all sequences except the repSequence
1060 SequenceI[] seqs = new SequenceI[sSize - 1];
1062 for (int i = 0; i < sSize; i++)
1064 if (sg.getSequenceAt(i) != repSequence)
1066 if (index == sSize - 1)
1071 seqs[index++] = sg.getSequenceAt(i);
1079 public void hideAllSelectedSeqs()
1081 if (selectionGroup == null || selectionGroup.getSize() < 1)
1086 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1090 setSelectionGroup(null);
1093 public void hideSequence(SequenceI[] seq)
1097 for (int i = 0; i < seq.length; i++)
1099 alignment.getHiddenSequences().hideSequence(seq[i]);
1102 hasHiddenRows = true;
1103 firePropertyChange("alignment", null, alignment.getSequences());
1107 public void showColumn(int col)
1109 colSel.revealHiddenColumns(col);
1110 if (colSel.getHiddenColumns() == null)
1112 hasHiddenColumns = false;
1116 public void showAllHiddenColumns()
1118 colSel.revealAllHiddenColumns();
1119 hasHiddenColumns = false;
1122 public void showAllHiddenSeqs()
1124 if (alignment.getHiddenSequences().getSize() > 0)
1126 if (selectionGroup == null)
1128 selectionGroup = new SequenceGroup();
1129 selectionGroup.setEndRes(alignment.getWidth() - 1);
1131 Vector tmp = alignment.getHiddenSequences().showAll(
1132 hiddenRepSequences);
1133 for (int t = 0; t < tmp.size(); t++)
1135 selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
1137 firePropertyChange("alignment", null, alignment.getSequences());
1138 hasHiddenRows = false;
1139 hiddenRepSequences = null;
1143 public int adjustForHiddenSeqs(int alignmentIndex)
1145 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1150 * This method returns the a new SequenceI [] with the selection sequence and
1151 * start and end points adjusted
1155 public SequenceI[] getSelectionAsNewSequence()
1157 SequenceI[] sequences;
1159 if (selectionGroup == null)
1161 sequences = alignment.getSequencesArray();
1165 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1171 * get the currently selected sequence objects or all the sequences in the
1174 * @return array of references to sequence objects
1176 public SequenceI[] getSequenceSelection()
1178 SequenceI[] sequences=null;
1179 if (selectionGroup!=null)
1181 sequences = selectionGroup.getSequencesInOrder(alignment);
1183 if (sequences == null)
1185 sequences = alignment.getSequencesArray();
1190 * This method returns the visible alignment as text, as seen on the GUI, ie
1191 * if columns are hidden they will not be returned in the result. Use this for
1192 * calculating trees, PCA, redundancy etc on views which contain hidden
1197 public jalview.datamodel.CigarArray getViewAsCigars(
1198 boolean selectedRegionOnly)
1200 CigarArray selection = null;
1201 SequenceI[] seqs = null;
1203 int start = 0, end = 0;
1204 if (selectedRegionOnly && selectionGroup != null)
1206 iSize = selectionGroup.getSize();
1207 seqs = selectionGroup.getSequencesInOrder(alignment);
1208 start = selectionGroup.getStartRes();
1209 end = selectionGroup.getEndRes(); // inclusive for start and end in
1210 // SeqCigar constructor
1214 iSize = alignment.getHeight();
1215 seqs = alignment.getSequencesArray();
1216 end = alignment.getWidth() - 1;
1218 SeqCigar[] selseqs = new SeqCigar[iSize];
1219 for (i = 0; i < iSize; i++)
1221 selseqs[i] = new SeqCigar(seqs[i], start, end);
1223 selection = new CigarArray(selseqs);
1224 // now construct the CigarArray operations
1225 if (hasHiddenColumns)
1227 Vector regions = colSel.getHiddenColumns();
1229 int hideStart, hideEnd;
1231 for (int j = 0; last < end & j < regions.size(); j++)
1233 region = (int[]) regions.elementAt(j);
1234 hideStart = region[0];
1235 hideEnd = region[1];
1236 // edit hidden regions to selection range
1237 if (hideStart < last)
1249 if (hideStart > end)
1259 if (hideStart > hideEnd)
1264 * form operations...
1266 if (last < hideStart)
1268 selection.addOperation(CigarArray.M, hideStart - last);
1270 selection.addOperation(CigarArray.D, 1 + hideEnd - hideStart);
1273 // Final match if necessary.
1276 selection.addOperation(CigarArray.M, end - last + 1);
1281 selection.addOperation(CigarArray.M, end - start + 1);
1287 * return a compact representation of the current alignment selection to pass
1288 * to an analysis function
1290 * @param selectedOnly
1291 * boolean true to just return the selected view
1292 * @return AlignmentView
1294 jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly)
1297 // this is here because the AlignmentView constructor modifies the
1299 // object. Refactoring of Cigar and alignment view representation should
1300 // be done to remove redundancy.
1301 CigarArray aligview = getViewAsCigars(selectedOnly);
1302 if (aligview != null)
1304 return new AlignmentView(aligview,
1305 (selectedOnly && selectionGroup != null) ? selectionGroup
1306 .getStartRes() : 0);
1312 * This method returns the visible alignment as text, as seen on the GUI, ie
1313 * if columns are hidden they will not be returned in the result. Use this for
1314 * calculating trees, PCA, redundancy etc on views which contain hidden
1319 public String[] getViewAsString(boolean selectedRegionOnly)
1321 String[] selection = null;
1322 SequenceI[] seqs = null;
1324 int start = 0, end = 0;
1325 if (selectedRegionOnly && selectionGroup != null)
1327 iSize = selectionGroup.getSize();
1328 seqs = selectionGroup.getSequencesInOrder(alignment);
1329 start = selectionGroup.getStartRes();
1330 end = selectionGroup.getEndRes() + 1;
1334 iSize = alignment.getHeight();
1335 seqs = alignment.getSequencesArray();
1336 end = alignment.getWidth();
1339 selection = new String[iSize];
1341 for (i = 0; i < iSize; i++)
1343 if (hasHiddenColumns)
1345 StringBuffer visibleSeq = new StringBuffer();
1346 Vector regions = colSel.getHiddenColumns();
1348 int blockStart = start, blockEnd = end;
1350 int hideStart, hideEnd;
1352 for (int j = 0; j < regions.size(); j++)
1354 region = (int[]) regions.elementAt(j);
1355 hideStart = region[0];
1356 hideEnd = region[1];
1358 if (hideStart < start)
1363 blockStart = Math.min(blockStart, hideEnd + 1);
1364 blockEnd = Math.min(blockEnd, hideStart);
1366 if (blockStart > blockEnd)
1371 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
1373 blockStart = hideEnd + 1;
1377 if (end > blockStart)
1379 visibleSeq.append(seqs[i].getSequence(blockStart, end));
1382 selection[i] = visibleSeq.toString();
1386 selection[i] = seqs[i].getSequenceAsString(start, end);
1393 public boolean getShowHiddenMarkers()
1395 return showHiddenMarkers;
1398 public void setShowHiddenMarkers(boolean show)
1400 showHiddenMarkers = show;
1403 public Color getSequenceColour(SequenceI seq)
1405 if (sequenceColours == null || !sequenceColours.containsKey(seq))
1411 return (Color) sequenceColours.get(seq);
1415 public void setSequenceColour(SequenceI seq, Color col)
1417 if (sequenceColours == null)
1419 sequenceColours = new Hashtable();
1424 sequenceColours.remove(seq);
1428 sequenceColours.put(seq, col);
1432 public String getSequenceSetId()
1434 if (sequenceSetID == null)
1436 sequenceSetID = alignment.hashCode() + "";
1439 return sequenceSetID;
1442 public void alignmentChanged(AlignmentPanel ap)
1444 alignment.padGaps();
1446 if (hconsensus != null && autocalculateConsensus)
1448 updateConsensus(ap);
1449 updateConservation(ap);
1452 // Reset endRes of groups if beyond alignment width
1453 int alWidth = alignment.getWidth();
1454 Vector groups = alignment.getGroups();
1457 for (int i = 0; i < groups.size(); i++)
1459 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
1460 if (sg.getEndRes() > alWidth)
1462 sg.setEndRes(alWidth - 1);
1467 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1469 selectionGroup.setEndRes(alWidth - 1);
1472 resetAllColourSchemes();
1474 // AW alignment.adjustSequenceAnnotations();
1477 void resetAllColourSchemes()
1479 ColourSchemeI cs = globalColourScheme;
1482 if (cs instanceof ClustalxColourScheme)
1484 ((ClustalxColourScheme) cs).resetClustalX(alignment.getSequences(),
1485 alignment.getWidth());
1488 cs.setConsensus(hconsensus);
1489 if (cs.conservationApplied())
1491 Alignment al = (Alignment) alignment;
1492 Conservation c = new Conservation("All",
1493 ResidueProperties.propHash, 3, al.getSequences(), 0, al
1496 c.verdict(false, ConsPercGaps);
1498 cs.setConservation(c);
1502 int s, sSize = alignment.getGroups().size();
1503 for (s = 0; s < sSize; s++)
1505 SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
1506 if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
1508 ((ClustalxColourScheme) sg.cs).resetClustalX(sg
1509 .getSequences(hiddenRepSequences), sg.getWidth());
1511 sg.recalcConservation();
1515 boolean centreColumnLabels;
1518 public boolean getCentreColumnLabels()
1520 return centreColumnLabels;
1523 public void updateSequenceIdColours()
1525 Vector groups = alignment.getGroups();
1526 for (int ig = 0, igSize = groups.size(); ig < igSize; ig++)
1528 SequenceGroup sg = (SequenceGroup) groups.elementAt(ig);
1529 if (sg.idColour != null)
1531 Vector sqs = sg.getSequences(hiddenRepSequences);
1532 for (int s = 0, sSize = sqs.size(); s < sSize; s++)
1534 this.setSequenceColour((SequenceI) sqs.elementAt(s), sg.idColour);
1539 public boolean followHighlight=false;
1540 public boolean getFollowHighlight() {
1541 return followHighlight;
1544 * show non-conserved residues only
1546 public boolean showUnconserved=false;
1549 * when set, alignment should be reordered according to a newly opened tree
1551 public boolean sortByTree=false;
1554 * @return the showUnconserved
1556 public boolean getShowunconserved()
1558 return showUnconserved;
1562 * @param showUnconserved the showUnconserved to set
1564 public void setShowunconserved(boolean displayNonconserved)
1566 this.showUnconserved = displayNonconserved;
1570 * consensus annotation includes all percentage for all symbols in column
1571 * DISABLED FOR 2.5 RELEASE (bug #60064 logo rendering is not AWT 1.1 compatible)
1573 private boolean includeAllConsensusSymbols=false;
1576 * should conservation rows be shown for groups
1577 * DISABLED FOR 2.5 RELEASE (bug 62446)
1579 boolean showGroupConservation = false;
1581 * should consensus rows be shown for groups
1582 * DISABLED FOR 2.5 RELEASE (bug 62446)
1584 boolean showGroupConsensus = false;
1586 * should consensus profile be rendered by default
1587 * DISABLED FOR 2.5 RELEASE (bug #60064 logo rendering is not AWT 1.1 compatible)
1589 public boolean showSequenceLogo = false;
1591 * should consensus histograms be rendered by default
1593 public boolean showConsensusHistogram = true;
1595 * @return the showConsensusProfile
1597 public boolean isShowSequenceLogo()
1599 return showSequenceLogo;
1602 * @param showSequenceLogo the new value
1603 public void setShowSequenceLogo(boolean showSequenceLogo)
1605 this.showSequenceLogo = showSequenceLogo;
1609 * @param showGroupConsensus the showGroupConsensus to set
1611 public void setShowGroupConsensus(boolean showGroupConsensus)
1613 this.showGroupConsensus = showGroupConsensus;
1616 * @return the includeAllConsensusSymbols
1618 public boolean isIncludeAllConsensusSymbols()
1625 * @return flag to indicate if the consensus histogram should be rendered by default
1627 public boolean isShowConsensusHistogram()
1629 return this.showConsensusHistogram;
1632 * synthesize a column selection if none exists so it covers the given selection group.
1633 * if wholewidth is false, no column selection is made if the selection group covers the whole alignment width.
1637 public void expandColSelection(SequenceGroup sg, boolean wholewidth)
1640 if (sg!=null && (sgs=sg.getStartRes())>=0 && sg.getStartRes()<=(sge=sg.getEndRes())&& (colSel==null || colSel.getSelected()==null || colSel.getSelected().size()==0))
1642 if (!wholewidth && alignment.getWidth()==(1+sge-sgs))
1649 colSel = new ColumnSelection();
1651 for (int cspos = sg.getStartRes(); cspos<=sg.getEndRes(); cspos++) {
1652 colSel.addElement(cspos);