2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)
3 * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 * Jalview is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty
13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 * PURPOSE. See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 package jalview.appletgui;
24 import jalview.analysis.*;
26 import jalview.datamodel.*;
27 import jalview.schemes.*;
29 public class AlignViewport
39 boolean cursorMode = false;
41 boolean showJVSuffix = true;
43 boolean showText = true;
45 boolean showColourText = false;
47 boolean showBoxes = true;
49 boolean wrapAlignment = false;
51 boolean renderGaps = true;
53 boolean showSequenceFeatures = false;
55 boolean showAnnotation = true;
57 boolean showConservation = true;
59 boolean showQuality = true;
61 boolean showConsensus = true;
63 boolean upperCasebold = false;
65 boolean colourAppliesToAllGroups = true;
67 ColourSchemeI globalColourScheme = null;
69 boolean conservationColourSelected = false;
71 boolean abovePIDThreshold = false;
73 SequenceGroup selectionGroup;
81 Font font = new Font("SansSerif", Font.PLAIN, 10);
83 boolean validCharWidth = true;
87 ColumnSelection colSel = new ColumnSelection();
93 NJTree currentTree = null;
95 boolean scaleAboveWrapped = true;
97 boolean scaleLeftWrapped = true;
99 boolean scaleRightWrapped = true;
101 // The following vector holds the features which are
102 // currently visible, in the correct order or rendering
103 public Hashtable featuresDisplayed;
105 boolean hasHiddenColumns = false;
107 boolean hasHiddenRows = false;
109 boolean showHiddenMarkers = true;
111 public Hashtable[] hconsensus;
113 AlignmentAnnotation consensus;
115 AlignmentAnnotation conservation;
117 AlignmentAnnotation quality;
119 AlignmentAnnotation[] groupConsensus;
121 AlignmentAnnotation[] groupConservation;
123 boolean autocalculateConsensus = true;
125 public int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
127 private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
130 boolean ignoreGapsInConsensusCalculation = false;
132 jalview.bin.JalviewLite applet;
134 Hashtable sequenceColours;
138 Stack historyList = new Stack();
140 Stack redoList = new Stack();
142 String sequenceSetID;
144 Hashtable hiddenRepSequences;
146 public AlignViewport(AlignmentI al, JalviewLite applet)
148 this.applet = applet;
151 this.endRes = al.getWidth() - 1;
153 this.endSeq = al.getHeight() - 1;
156 // get the width and height scaling factors if they were specified
157 String param = applet.getParameter("widthScale");
162 widthScale = new Float(param).floatValue();
163 } catch (Exception e)
166 if (widthScale <= 1.0)
169 .println("Invalid alignment character width scaling factor ("
170 + widthScale + "). Ignoring.");
176 .println("Alignment character width scaling factor is now "
180 param = applet.getParameter("heightScale");
185 heightScale = new Float(param).floatValue();
186 } catch (Exception e)
189 if (heightScale <= 1.0)
192 .println("Invalid alignment character height scaling factor ("
193 + heightScale + "). Ignoring.");
199 .println("Alignment character height scaling factor is now "
206 MAC = new jalview.util.Platform().isAMac();
210 String param = applet.getParameter("showFullId");
213 showJVSuffix = Boolean.valueOf(param).booleanValue();
216 param = applet.getParameter("showAnnotation");
219 showAnnotation = Boolean.valueOf(param).booleanValue();
222 param = applet.getParameter("showConservation");
225 showConservation = Boolean.valueOf(param).booleanValue();
228 param = applet.getParameter("showQuality");
231 showQuality = Boolean.valueOf(param).booleanValue();
234 param = applet.getParameter("showConsensus");
237 showConsensus = Boolean.valueOf(param).booleanValue();
240 param = applet.getParameter("showUnconserved");
243 this.showUnconserved = Boolean.valueOf(param).booleanValue();
246 param = applet.getParameter("upperCase");
249 if (param.equalsIgnoreCase("bold"))
251 upperCasebold = true;
254 param = applet.getParameter("sortByTree");
257 sortByTree = Boolean.valueOf(param).booleanValue();
264 String colour = applet.getParameter("defaultColour");
268 colour = applet.getParameter("userDefinedColour");
271 colour = "User Defined";
277 globalColourScheme = ColourSchemeProperty.getColour(alignment,
279 if (globalColourScheme != null)
281 globalColourScheme.setConsensus(hconsensus);
285 if (applet.getParameter("userDefinedColour") != null)
287 ((UserColourScheme) globalColourScheme).parseAppletParameter(applet
288 .getParameter("userDefinedColour"));
291 if (hconsensus == null)
293 if (!alignment.isNucleotide())
295 conservation = new AlignmentAnnotation("Conservation",
296 "Conservation of total alignment less than " + ConsPercGaps
297 + "% gaps", new Annotation[1], 0f, 11f,
298 AlignmentAnnotation.BAR_GRAPH);
299 conservation.hasText = true;
300 conservation.autoCalculated = true;
302 if (showConservation)
304 alignment.addAnnotation(conservation);
309 quality = new AlignmentAnnotation("Quality",
310 "Alignment Quality based on Blosum62 scores",
311 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
312 quality.hasText = true;
313 quality.autoCalculated = true;
315 alignment.addAnnotation(quality);
319 consensus = new AlignmentAnnotation("Consensus", "PID",
320 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
321 consensus.hasText = true;
322 consensus.autoCalculated = true;
326 alignment.addAnnotation(consensus);
332 public void showSequenceFeatures(boolean b)
334 showSequenceFeatures = b;
337 public boolean getShowSequenceFeatures()
339 return showSequenceFeatures;
342 class ConservationThread extends Thread
346 public ConservationThread(AlignmentPanel ap)
355 updatingConservation = true;
357 while (UPDATING_CONSERVATION)
363 ap.paintAlignment(false);
366 } catch (Exception ex)
368 ex.printStackTrace();
372 UPDATING_CONSERVATION = true;
374 int alWidth = alignment.getWidth();
380 Conservation cons = new jalview.analysis.Conservation("All",
381 jalview.schemes.ResidueProperties.propHash, 3,
382 alignment.getSequences(), 0, alWidth - 1);
385 cons.verdict(false, ConsPercGaps);
392 char[] sequence = cons.getConsSequence().getSequence();
404 maxB = 0f - minB; // scalable range for colouring both Conservation and
414 conservation.annotations = new Annotation[alWidth];
418 quality.graphMax = cons.qualityRange[1].floatValue();
419 quality.annotations = new Annotation[alWidth];
420 qmin = cons.qualityRange[0].floatValue();
421 qmax = cons.qualityRange[1].floatValue();
424 for (int i = 0; i < alWidth; i++)
430 if (Character.isDigit(c))
432 value = (int) (c - '0');
442 // TODO - refactor to use a graduatedColorScheme to calculate the
444 float vprop = value - min;
446 conservation.annotations[i] = new Annotation(String.valueOf(c),
447 String.valueOf(value), ' ', value, new Color(minR
448 + (maxR * vprop), minG + (maxG * vprop), minB
454 value = ((Double) cons.quality.elementAt(i)).floatValue();
455 vprop = value - qmin;
457 quality.annotations[i] = new Annotation(" ",
458 String.valueOf(value), ' ', value, new Color(minR
459 + (maxR * vprop), minG + (maxG * vprop), minB
463 } catch (OutOfMemoryError error)
465 System.out.println("Out of memory calculating conservation!!");
471 UPDATING_CONSERVATION = false;
472 updatingConservation = false;
476 ap.paintAlignment(true);
482 ConservationThread conservationThread;
484 ConsensusThread consensusThread;
486 boolean consUpdateNeeded = false;
488 static boolean UPDATING_CONSENSUS = false;
490 static boolean UPDATING_CONSERVATION = false;
492 boolean updatingConsensus = false;
494 boolean updatingConservation = false;
499 public void updateConservation(final AlignmentPanel ap)
501 if (alignment.isNucleotide() || conservation == null)
506 conservationThread = new ConservationThread(ap);
507 conservationThread.start();
513 public void updateConsensus(final AlignmentPanel ap)
515 consensusThread = new ConsensusThread(ap);
516 consensusThread.start();
519 class ConsensusThread extends Thread
523 public ConsensusThread(AlignmentPanel ap)
530 updatingConsensus = true;
531 while (UPDATING_CONSENSUS)
537 ap.paintAlignment(false);
541 } catch (Exception ex)
543 ex.printStackTrace();
547 UPDATING_CONSENSUS = true;
551 int aWidth = alignment.getWidth();
557 consensus.annotations = null;
558 consensus.annotations = new Annotation[aWidth];
560 hconsensus = new Hashtable[aWidth];
561 AAFrequency.calculate(alignment.getSequencesArray(), 0,
562 alignment.getWidth(), hconsensus, true); // always calculate the
564 AAFrequency.completeConsensus(consensus, hconsensus, 0, aWidth,
565 ignoreGapsInConsensusCalculation,
566 includeAllConsensusSymbols);
568 if (globalColourScheme != null)
570 globalColourScheme.setConsensus(hconsensus);
573 } catch (OutOfMemoryError error)
575 alignment.deleteAnnotation(consensus);
579 System.out.println("Out of memory calculating consensus!!");
582 UPDATING_CONSENSUS = false;
583 updatingConsensus = false;
587 ap.paintAlignment(true);
593 * get the consensus sequence as displayed under the PID consensus annotation
596 * @return consensus sequence as a new sequence object
598 public SequenceI getConsensusSeq()
600 if (consensus == null)
604 StringBuffer seqs = new StringBuffer();
605 for (int i = 0; i < consensus.annotations.length; i++)
607 if (consensus.annotations[i] != null)
609 if (consensus.annotations[i].description.charAt(0) == '[')
611 seqs.append(consensus.annotations[i].description.charAt(1));
615 seqs.append(consensus.annotations[i].displayCharacter);
619 SequenceI sq = new Sequence("Consensus", seqs.toString());
620 sq.setDescription("Percentage Identity Consensus "
621 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
625 public SequenceGroup getSelectionGroup()
627 return selectionGroup;
630 public void setSelectionGroup(SequenceGroup sg)
635 public boolean getConservationSelected()
637 return conservationColourSelected;
640 public void setConservationSelected(boolean b)
642 conservationColourSelected = b;
645 public boolean getAbovePIDThreshold()
647 return abovePIDThreshold;
650 public void setAbovePIDThreshold(boolean b)
652 abovePIDThreshold = b;
655 public int getStartRes()
660 public int getEndRes()
665 public int getStartSeq()
670 public void setGlobalColourScheme(ColourSchemeI cs)
672 globalColourScheme = cs;
675 public ColourSchemeI getGlobalColourScheme()
677 return globalColourScheme;
680 public void setStartRes(int res)
685 public void setStartSeq(int seq)
690 public void setEndRes(int res)
692 if (res > alignment.getWidth() - 1)
694 // log.System.out.println(" Corrected res from " + res + " to maximum " +
695 // (alignment.getWidth()-1));
696 res = alignment.getWidth() - 1;
705 public void setEndSeq(int seq)
707 if (seq > alignment.getHeight())
709 seq = alignment.getHeight();
718 public int getEndSeq()
723 java.awt.Frame nullFrame;
725 protected FeatureSettings featureSettings = null;
727 private float heightScale = 1, widthScale = 1;
729 public void setFont(Font f)
732 if (nullFrame == null)
734 nullFrame = new java.awt.Frame();
735 nullFrame.addNotify();
738 java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font);
739 setCharHeight((int) (heightScale * fm.getHeight()));
740 charWidth = (int) (widthScale * fm.charWidth('M'));
744 Font f2 = new Font(f.getName(), Font.BOLD, f.getSize());
745 fm = nullFrame.getGraphics().getFontMetrics(f2);
746 charWidth = (int) (widthScale * (fm.stringWidth("MMMMMMMMMMM") / 10));
750 public Font getFont()
755 public int getCharWidth()
760 public void setCharHeight(int h)
765 public int getCharHeight()
770 public void setWrappedWidth(int w)
772 this.wrappedWidth = w;
775 public int getwrappedWidth()
780 public AlignmentI getAlignment()
785 public void setAlignment(AlignmentI align)
787 this.alignment = align;
790 public void setWrapAlignment(boolean state)
792 wrapAlignment = state;
795 public void setShowText(boolean state)
800 public void setRenderGaps(boolean state)
805 public boolean getColourText()
807 return showColourText;
810 public void setColourText(boolean state)
812 showColourText = state;
815 public void setShowBoxes(boolean state)
820 public boolean getWrapAlignment()
822 return wrapAlignment;
825 public boolean getShowText()
830 public boolean getShowBoxes()
835 public char getGapCharacter()
837 return getAlignment().getGapCharacter();
840 public void setGapCharacter(char gap)
842 if (getAlignment() != null)
844 getAlignment().setGapCharacter(gap);
848 public void setThreshold(int thresh)
853 public int getThreshold()
858 public void setIncrement(int inc)
863 public int getIncrement()
868 public void setHiddenColumns(ColumnSelection colsel)
870 this.colSel = colsel;
871 if (colSel.getHiddenColumns() != null)
873 hasHiddenColumns = true;
877 public ColumnSelection getColumnSelection()
882 public void resetSeqLimits(int height)
884 setEndSeq(height / getCharHeight());
887 public void setCurrentTree(NJTree tree)
892 public NJTree getCurrentTree()
897 public void setColourAppliesToAllGroups(boolean b)
899 colourAppliesToAllGroups = b;
902 public boolean getColourAppliesToAllGroups()
904 return colourAppliesToAllGroups;
907 public boolean getShowJVSuffix()
912 public void setShowJVSuffix(boolean b)
917 public boolean getShowAnnotation()
919 return showAnnotation;
922 public void setShowAnnotation(boolean b)
927 public boolean getScaleAboveWrapped()
929 return scaleAboveWrapped;
932 public boolean getScaleLeftWrapped()
934 return scaleLeftWrapped;
937 public boolean getScaleRightWrapped()
939 return scaleRightWrapped;
942 public void setScaleAboveWrapped(boolean b)
944 scaleAboveWrapped = b;
947 public void setScaleLeftWrapped(boolean b)
949 scaleLeftWrapped = b;
952 public void setScaleRightWrapped(boolean b)
954 scaleRightWrapped = b;
957 public void setIgnoreGapsConsensus(boolean b)
959 ignoreGapsInConsensusCalculation = b;
960 updateConsensus(null);
961 if (globalColourScheme != null)
963 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
964 ignoreGapsInConsensusCalculation);
970 * Property change listener for changes in alignment
975 public void addPropertyChangeListener(
976 java.beans.PropertyChangeListener listener)
978 changeSupport.addPropertyChangeListener(listener);
987 public void removePropertyChangeListener(
988 java.beans.PropertyChangeListener listener)
990 changeSupport.removePropertyChangeListener(listener);
994 * Property change listener for changes in alignment
1003 public void firePropertyChange(String prop, Object oldvalue,
1006 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
1009 public boolean getIgnoreGapsConsensus()
1011 return ignoreGapsInConsensusCalculation;
1014 public void hideSelectedColumns()
1016 if (colSel.size() < 1)
1021 colSel.hideSelectedColumns();
1022 setSelectionGroup(null);
1024 hasHiddenColumns = true;
1027 public void invertColumnSelection()
1029 for (int i = 0; i < alignment.getWidth(); i++)
1031 if (colSel.contains(i))
1033 colSel.removeElement(i);
1037 if (!hasHiddenColumns || colSel.isVisible(i))
1039 colSel.addElement(i);
1045 public void hideColumns(int start, int end)
1049 colSel.hideColumns(start);
1053 colSel.hideColumns(start, end);
1056 hasHiddenColumns = true;
1059 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1061 int sSize = sg.getSize();
1067 if (hiddenRepSequences == null)
1069 hiddenRepSequences = new Hashtable();
1072 hiddenRepSequences.put(repSequence, sg);
1074 // Hide all sequences except the repSequence
1075 SequenceI[] seqs = new SequenceI[sSize - 1];
1077 for (int i = 0; i < sSize; i++)
1079 if (sg.getSequenceAt(i) != repSequence)
1081 if (index == sSize - 1)
1086 seqs[index++] = sg.getSequenceAt(i);
1094 public void hideAllSelectedSeqs()
1096 if (selectionGroup == null || selectionGroup.getSize() < 1)
1101 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1105 setSelectionGroup(null);
1108 public void hideSequence(SequenceI[] seq)
1112 for (int i = 0; i < seq.length; i++)
1114 alignment.getHiddenSequences().hideSequence(seq[i]);
1117 hasHiddenRows = true;
1118 firePropertyChange("alignment", null, alignment.getSequences());
1122 public void showColumn(int col)
1124 colSel.revealHiddenColumns(col);
1125 if (colSel.getHiddenColumns() == null)
1127 hasHiddenColumns = false;
1131 public void showAllHiddenColumns()
1133 colSel.revealAllHiddenColumns();
1134 hasHiddenColumns = false;
1137 public void showAllHiddenSeqs()
1139 if (alignment.getHiddenSequences().getSize() > 0)
1141 if (selectionGroup == null)
1143 selectionGroup = new SequenceGroup();
1144 selectionGroup.setEndRes(alignment.getWidth() - 1);
1146 Vector tmp = alignment.getHiddenSequences().showAll(
1147 hiddenRepSequences);
1148 for (int t = 0; t < tmp.size(); t++)
1150 selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
1152 firePropertyChange("alignment", null, alignment.getSequences());
1153 hasHiddenRows = false;
1154 hiddenRepSequences = null;
1158 public int adjustForHiddenSeqs(int alignmentIndex)
1160 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1165 * This method returns the a new SequenceI [] with the selection sequence and
1166 * start and end points adjusted
1170 public SequenceI[] getSelectionAsNewSequence()
1172 SequenceI[] sequences;
1174 if (selectionGroup == null)
1176 sequences = alignment.getSequencesArray();
1180 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1187 * get the currently selected sequence objects or all the sequences in the
1190 * @return array of references to sequence objects
1192 public SequenceI[] getSequenceSelection()
1194 SequenceI[] sequences = null;
1195 if (selectionGroup != null)
1197 sequences = selectionGroup.getSequencesInOrder(alignment);
1199 if (sequences == null)
1201 sequences = alignment.getSequencesArray();
1207 * This method returns the visible alignment as text, as seen on the GUI, ie
1208 * if columns are hidden they will not be returned in the result. Use this for
1209 * calculating trees, PCA, redundancy etc on views which contain hidden
1214 public jalview.datamodel.CigarArray getViewAsCigars(
1215 boolean selectedRegionOnly)
1217 CigarArray selection = null;
1218 SequenceI[] seqs = null;
1220 int start = 0, end = 0;
1221 if (selectedRegionOnly && selectionGroup != null)
1223 iSize = selectionGroup.getSize();
1224 seqs = selectionGroup.getSequencesInOrder(alignment);
1225 start = selectionGroup.getStartRes();
1226 end = selectionGroup.getEndRes(); // inclusive for start and end in
1227 // SeqCigar constructor
1231 iSize = alignment.getHeight();
1232 seqs = alignment.getSequencesArray();
1233 end = alignment.getWidth() - 1;
1235 SeqCigar[] selseqs = new SeqCigar[iSize];
1236 for (i = 0; i < iSize; i++)
1238 selseqs[i] = new SeqCigar(seqs[i], start, end);
1240 selection = new CigarArray(selseqs);
1241 // now construct the CigarArray operations
1242 if (hasHiddenColumns)
1244 Vector regions = colSel.getHiddenColumns();
1246 int hideStart, hideEnd;
1248 for (int j = 0; last < end & j < regions.size(); j++)
1250 region = (int[]) regions.elementAt(j);
1251 hideStart = region[0];
1252 hideEnd = region[1];
1253 // edit hidden regions to selection range
1254 if (hideStart < last)
1266 if (hideStart > end)
1276 if (hideStart > hideEnd)
1281 * form operations...
1283 if (last < hideStart)
1285 selection.addOperation(CigarArray.M, hideStart - last);
1287 selection.addOperation(CigarArray.D, 1 + hideEnd - hideStart);
1290 // Final match if necessary.
1293 selection.addOperation(CigarArray.M, end - last + 1);
1298 selection.addOperation(CigarArray.M, end - start + 1);
1304 * return a compact representation of the current alignment selection to pass
1305 * to an analysis function
1307 * @param selectedOnly
1308 * boolean true to just return the selected view
1309 * @return AlignmentView
1311 jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly)
1314 // this is here because the AlignmentView constructor modifies the
1316 // object. Refactoring of Cigar and alignment view representation should
1317 // be done to remove redundancy.
1318 CigarArray aligview = getViewAsCigars(selectedOnly);
1319 if (aligview != null)
1321 return new AlignmentView(aligview,
1322 (selectedOnly && selectionGroup != null) ? selectionGroup
1323 .getStartRes() : 0);
1329 * This method returns the visible alignment as text, as seen on the GUI, ie
1330 * if columns are hidden they will not be returned in the result. Use this for
1331 * calculating trees, PCA, redundancy etc on views which contain hidden
1336 public String[] getViewAsString(boolean selectedRegionOnly)
1338 String[] selection = null;
1339 SequenceI[] seqs = null;
1341 int start = 0, end = 0;
1342 if (selectedRegionOnly && selectionGroup != null)
1344 iSize = selectionGroup.getSize();
1345 seqs = selectionGroup.getSequencesInOrder(alignment);
1346 start = selectionGroup.getStartRes();
1347 end = selectionGroup.getEndRes() + 1;
1351 iSize = alignment.getHeight();
1352 seqs = alignment.getSequencesArray();
1353 end = alignment.getWidth();
1356 selection = new String[iSize];
1358 for (i = 0; i < iSize; i++)
1360 if (hasHiddenColumns)
1362 StringBuffer visibleSeq = new StringBuffer();
1363 Vector regions = colSel.getHiddenColumns();
1365 int blockStart = start, blockEnd = end;
1367 int hideStart, hideEnd;
1369 for (int j = 0; j < regions.size(); j++)
1371 region = (int[]) regions.elementAt(j);
1372 hideStart = region[0];
1373 hideEnd = region[1];
1375 if (hideStart < start)
1380 blockStart = Math.min(blockStart, hideEnd + 1);
1381 blockEnd = Math.min(blockEnd, hideStart);
1383 if (blockStart > blockEnd)
1388 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
1390 blockStart = hideEnd + 1;
1394 if (end > blockStart)
1396 visibleSeq.append(seqs[i].getSequence(blockStart, end));
1399 selection[i] = visibleSeq.toString();
1403 selection[i] = seqs[i].getSequenceAsString(start, end);
1410 public boolean getShowHiddenMarkers()
1412 return showHiddenMarkers;
1415 public void setShowHiddenMarkers(boolean show)
1417 showHiddenMarkers = show;
1420 public Color getSequenceColour(SequenceI seq)
1422 if (sequenceColours == null || !sequenceColours.containsKey(seq))
1428 return (Color) sequenceColours.get(seq);
1432 public void setSequenceColour(SequenceI seq, Color col)
1434 if (sequenceColours == null)
1436 sequenceColours = new Hashtable();
1441 sequenceColours.remove(seq);
1445 sequenceColours.put(seq, col);
1449 public String getSequenceSetId()
1451 if (sequenceSetID == null)
1453 sequenceSetID = alignment.hashCode() + "";
1456 return sequenceSetID;
1459 public void alignmentChanged(AlignmentPanel ap)
1461 alignment.padGaps();
1463 if (hconsensus != null && autocalculateConsensus)
1465 updateConsensus(ap);
1466 updateConservation(ap);
1469 // Reset endRes of groups if beyond alignment width
1470 int alWidth = alignment.getWidth();
1471 Vector groups = alignment.getGroups();
1474 for (int i = 0; i < groups.size(); i++)
1476 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
1477 if (sg.getEndRes() > alWidth)
1479 sg.setEndRes(alWidth - 1);
1484 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1486 selectionGroup.setEndRes(alWidth - 1);
1489 resetAllColourSchemes();
1491 // AW alignment.adjustSequenceAnnotations();
1494 void resetAllColourSchemes()
1496 ColourSchemeI cs = globalColourScheme;
1499 if (cs instanceof ClustalxColourScheme)
1501 ((ClustalxColourScheme) cs).resetClustalX(alignment.getSequences(),
1502 alignment.getWidth());
1505 cs.setConsensus(hconsensus);
1506 if (cs.conservationApplied())
1508 Alignment al = (Alignment) alignment;
1509 Conservation c = new Conservation("All",
1510 ResidueProperties.propHash, 3, al.getSequences(), 0,
1513 c.verdict(false, ConsPercGaps);
1515 cs.setConservation(c);
1519 int s, sSize = alignment.getGroups().size();
1520 for (s = 0; s < sSize; s++)
1522 SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
1523 if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
1525 ((ClustalxColourScheme) sg.cs).resetClustalX(
1526 sg.getSequences(hiddenRepSequences), sg.getWidth());
1528 sg.recalcConservation();
1532 boolean centreColumnLabels;
1534 public boolean getCentreColumnLabels()
1536 return centreColumnLabels;
1539 public void updateSequenceIdColours()
1541 Vector groups = alignment.getGroups();
1542 for (int ig = 0, igSize = groups.size(); ig < igSize; ig++)
1544 SequenceGroup sg = (SequenceGroup) groups.elementAt(ig);
1545 if (sg.idColour != null)
1547 Vector sqs = sg.getSequences(hiddenRepSequences);
1548 for (int s = 0, sSize = sqs.size(); s < sSize; s++)
1550 this.setSequenceColour((SequenceI) sqs.elementAt(s), sg.idColour);
1556 public boolean followHighlight = false;
1558 public boolean getFollowHighlight()
1560 return followHighlight;
1564 * show non-conserved residues only
1566 public boolean showUnconserved = false;
1569 * when set, alignment should be reordered according to a newly opened tree
1571 public boolean sortByTree = false;
1574 * @return the showUnconserved
1576 public boolean getShowunconserved()
1578 return showUnconserved;
1582 * @param showNonconserved
1583 * the showUnconserved to set
1585 public void setShowunconserved(boolean displayNonconserved)
1587 this.showUnconserved = displayNonconserved;
1591 * consensus annotation includes all percentage for all symbols in column
1592 * DISABLED FOR 2.5 RELEASE (bug #60064 logo rendering is not AWT 1.1
1595 private boolean includeAllConsensusSymbols = false;
1598 * should conservation rows be shown for groups DISABLED FOR 2.5 RELEASE (bug
1601 boolean showGroupConservation = false;
1604 * should consensus rows be shown for groups DISABLED FOR 2.5 RELEASE (bug
1607 boolean showGroupConsensus = false;
1610 * should consensus profile be rendered by default DISABLED FOR 2.5 RELEASE
1611 * (bug #60064 logo rendering is not AWT 1.1 compatible)
1613 public boolean showSequenceLogo = false;
1616 * should consensus histograms be rendered by default
1618 public boolean showConsensusHistogram = true;
1621 * @return the showConsensusProfile
1623 public boolean isShowSequenceLogo()
1625 return showSequenceLogo;
1629 * @param showSequenceLogo
1630 * the new value public void setShowSequenceLogo(boolean
1631 * showSequenceLogo) { this.showSequenceLogo = showSequenceLogo; }
1634 * @param showGroupConsensus
1635 * the showGroupConsensus to set
1637 public void setShowGroupConsensus(boolean showGroupConsensus)
1639 this.showGroupConsensus = showGroupConsensus;
1643 * @return the includeAllConsensusSymbols
1645 public boolean isIncludeAllConsensusSymbols()
1652 * @return flag to indicate if the consensus histogram should be rendered by
1655 public boolean isShowConsensusHistogram()
1657 return this.showConsensusHistogram;
1661 * synthesize a column selection if none exists so it covers the given
1662 * selection group. if wholewidth is false, no column selection is made if the
1663 * selection group covers the whole alignment width.
1668 public void expandColSelection(SequenceGroup sg, boolean wholewidth)
1672 && (sgs = sg.getStartRes()) >= 0
1673 && sg.getStartRes() <= (sge = sg.getEndRes())
1674 && (colSel == null || colSel.getSelected() == null || colSel
1675 .getSelected().size() == 0))
1677 if (!wholewidth && alignment.getWidth() == (1 + sge - sgs))
1684 colSel = new ColumnSelection();
1686 for (int cspos = sg.getStartRes(); cspos <= sg.getEndRes(); cspos++)
1688 colSel.addElement(cspos);