2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, 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.*;
25 import jalview.api.AlignCalcManagerI;
26 import jalview.api.AlignViewportI;
28 import jalview.datamodel.*;
29 import jalview.schemes.*;
30 import jalview.structure.SelectionSource;
31 import jalview.structure.VamsasSource;
32 import jalview.workers.ConservationThread;
34 public class AlignViewport extends AlignmentViewport implements AlignViewportI, SelectionSource, VamsasSource
44 boolean cursorMode = false;
46 boolean showJVSuffix = true;
48 boolean showText = true;
50 boolean showColourText = false;
52 boolean showBoxes = true;
54 boolean wrapAlignment = false;
56 boolean renderGaps = true;
58 boolean showSequenceFeatures = false;
60 boolean showAnnotation = true;
62 boolean showConservation = true;
64 boolean showQuality = true;
66 boolean showConsensus = true;
68 boolean upperCasebold = false;
70 boolean colourAppliesToAllGroups = true;
72 ColourSchemeI globalColourScheme = null;
74 boolean conservationColourSelected = false;
76 boolean abovePIDThreshold = false;
78 SequenceGroup selectionGroup;
86 Font font = new Font("SansSerif", Font.PLAIN, 10);
88 boolean validCharWidth = true;
92 ColumnSelection colSel = new ColumnSelection();
98 NJTree currentTree = null;
100 boolean scaleAboveWrapped = true;
102 boolean scaleLeftWrapped = true;
104 boolean scaleRightWrapped = true;
106 // The following vector holds the features which are
107 // currently visible, in the correct order or rendering
108 public Hashtable featuresDisplayed;
110 boolean hasHiddenColumns = false;
112 boolean hasHiddenRows = false;
114 boolean showHiddenMarkers = true;
116 public Hashtable[] hconsensus;
118 AlignmentAnnotation consensus;
120 AlignmentAnnotation conservation;
122 AlignmentAnnotation quality;
124 AlignmentAnnotation[] groupConsensus;
126 AlignmentAnnotation[] groupConservation;
128 boolean autocalculateConsensus = true;
130 private java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
133 boolean ignoreGapsInConsensusCalculation = false;
135 public jalview.bin.JalviewLite applet;
137 Hashtable sequenceColours;
141 Stack historyList = new Stack();
143 Stack redoList = new Stack();
145 String sequenceSetID;
147 Hashtable hiddenRepSequences;
149 AlignCalcManagerI calculator=new jalview.workers.AlignCalcManager();
151 public void finalize() {
158 public AlignViewport(AlignmentI al, JalviewLite applet)
160 this.applet = applet;
163 this.endRes = al.getWidth() - 1;
165 this.endSeq = al.getHeight() - 1;
168 // get the width and height scaling factors if they were specified
169 String param = applet.getParameter("widthScale");
174 widthScale = new Float(param).floatValue();
175 } catch (Exception e)
178 if (widthScale <= 1.0)
181 .println("Invalid alignment character width scaling factor ("
182 + widthScale + "). Ignoring.");
188 .println("Alignment character width scaling factor is now "
192 param = applet.getParameter("heightScale");
197 heightScale = new Float(param).floatValue();
198 } catch (Exception e)
201 if (heightScale <= 1.0)
204 .println("Invalid alignment character height scaling factor ("
205 + heightScale + "). Ignoring.");
211 .println("Alignment character height scaling factor is now "
218 MAC = new jalview.util.Platform().isAMac();
222 showJVSuffix = applet.getDefaultParameter("showFullId", showJVSuffix);
224 showAnnotation = applet.getDefaultParameter("showAnnotation", showAnnotation);
226 showConservation = applet.getDefaultParameter("showConservation", showConservation);
228 showQuality = applet.getDefaultParameter("showQuality", showQuality);
230 showConsensus = applet.getDefaultParameter("showConsensus", showConsensus);
232 showUnconserved = applet.getDefaultParameter("showUnconserved", showUnconserved);
234 String param = applet.getParameter("upperCase");
237 if (param.equalsIgnoreCase("bold"))
239 upperCasebold = true;
242 sortByTree = applet.getDefaultParameter("sortByTree", sortByTree);
244 followHighlight = applet.getDefaultParameter("automaticScrolling",followHighlight);
245 followSelection = followHighlight;
247 showSequenceLogo = applet.getDefaultParameter("showSequenceLogo", showSequenceLogo);
249 normaliseSequenceLogo = applet.getDefaultParameter("normaliseSequenceLogo", normaliseSequenceLogo);
251 showGroupConsensus = applet.getDefaultParameter("showGroupConsensus", showGroupConsensus);
253 showGroupConservation = applet.getDefaultParameter("showGroupConservation", showGroupConservation);
255 showConsensusHistogram = applet.getDefaultParameter("showConsensusHistogram", showConsensusHistogram);
261 String colour = applet.getParameter("defaultColour");
265 colour = applet.getParameter("userDefinedColour");
268 colour = "User Defined";
274 globalColourScheme = ColourSchemeProperty.getColour(alignment,
276 if (globalColourScheme != null)
278 globalColourScheme.setConsensus(hconsensus);
282 if (applet.getParameter("userDefinedColour") != null)
284 ((UserColourScheme) globalColourScheme).parseAppletParameter(applet
285 .getParameter("userDefinedColour"));
288 if (hconsensus == null)
290 if (!alignment.isNucleotide())
292 conservation = new AlignmentAnnotation("Conservation",
293 "Conservation of total alignment less than " + getConsPercGaps()
294 + "% gaps", new Annotation[1], 0f, 11f,
295 AlignmentAnnotation.BAR_GRAPH);
296 conservation.hasText = true;
297 conservation.autoCalculated = true;
299 if (showConservation)
301 alignment.addAnnotation(conservation);
306 quality = new AlignmentAnnotation("Quality",
307 "Alignment Quality based on Blosum62 scores",
308 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
309 quality.hasText = true;
310 quality.autoCalculated = true;
312 alignment.addAnnotation(quality);
316 consensus = new AlignmentAnnotation("Consensus", "PID",
317 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
318 consensus.hasText = true;
319 consensus.autoCalculated = true;
323 alignment.addAnnotation(consensus);
329 public void showSequenceFeatures(boolean b)
331 showSequenceFeatures = b;
334 public boolean getShowSequenceFeatures()
336 return showSequenceFeatures;
340 ConsensusThread consensusThread;
342 // StrucConsensusThread strucConsensusThread;
345 boolean consUpdateNeeded = false;
347 static boolean UPDATING_CONSENSUS = false;
349 static boolean UPDATING_STRUC_CONSENSUS = false;
351 static boolean UPDATING_CONSERVATION = false;
353 boolean updatingConsensus = false;
355 boolean updatingStrucConsensus = false;
357 boolean updatingConservation = false;
362 public void updateConservation(final AlignmentPanel ap)
364 if (alignment.isNucleotide() || conservation == null)
369 calculator.startWorker(new ConservationThread(this, ap));
375 public void updateConsensus(final AlignmentPanel ap)
377 consensusThread = new ConsensusThread(ap);
378 consensusThread.start();
381 class ConsensusThread extends Thread
385 public ConsensusThread(AlignmentPanel ap)
392 updatingConsensus = true;
393 while (UPDATING_CONSENSUS)
399 ap.paintAlignment(false);
403 } catch (Exception ex)
405 ex.printStackTrace();
409 UPDATING_CONSENSUS = true;
413 int aWidth = alignment==null ? -1 : alignment.getWidth();
416 UPDATING_CONSENSUS = false;
417 updatingConsensus = false;
421 consensus.annotations = null;
422 consensus.annotations = new Annotation[aWidth];
424 hconsensus = new Hashtable[aWidth];
425 AAFrequency.calculate(alignment.getSequencesArray(), 0,
426 alignment.getWidth(), hconsensus, true); // always calculate the
428 updateAnnotation(true);
429 //AAFrequency.completeConsensus(consensus, hconsensus, 0, aWidth,
430 // ignoreGapsInConsensusCalculation,
433 if (globalColourScheme != null)
435 globalColourScheme.setConsensus(hconsensus);
438 } catch (OutOfMemoryError error)
440 alignment.deleteAnnotation(consensus);
444 System.out.println("Out of memory calculating consensus!!");
447 UPDATING_CONSENSUS = false;
448 updatingConsensus = false;
452 ap.paintAlignment(true);
457 * update the consensus annotation from the sequence profile data using
458 * current visualization settings.
460 public void updateAnnotation()
462 updateAnnotation(false);
465 protected void updateAnnotation(boolean immediate)
467 // TODO: make calls thread-safe, so if another thread calls this method,
468 // it will either return or wait until one calculation is finished.
470 || (!updatingConsensus && consensus != null && hconsensus != null))
472 AAFrequency.completeConsensus(consensus, hconsensus, 0,
473 hconsensus.length, ignoreGapsInConsensusCalculation,
480 * get the consensus sequence as displayed under the PID consensus annotation
483 * @return consensus sequence as a new sequence object
485 public SequenceI getConsensusSeq()
487 if (consensus == null)
489 updateConsensus(null);
491 if (consensus == null)
495 StringBuffer seqs = new StringBuffer();
496 for (int i = 0; i < consensus.annotations.length; i++)
498 if (consensus.annotations[i] != null)
500 if (consensus.annotations[i].description.charAt(0) == '[')
502 seqs.append(consensus.annotations[i].description.charAt(1));
506 seqs.append(consensus.annotations[i].displayCharacter);
510 SequenceI sq = new Sequence("Consensus", seqs.toString());
511 sq.setDescription("Percentage Identity Consensus "
512 + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
516 public SequenceGroup getSelectionGroup()
518 return selectionGroup;
521 public void setSelectionGroup(SequenceGroup sg)
526 public boolean getConservationSelected()
528 return conservationColourSelected;
531 public void setConservationSelected(boolean b)
533 conservationColourSelected = b;
536 public boolean getAbovePIDThreshold()
538 return abovePIDThreshold;
541 public void setAbovePIDThreshold(boolean b)
543 abovePIDThreshold = b;
546 public int getStartRes()
551 public int getEndRes()
556 public int getStartSeq()
561 public void setGlobalColourScheme(ColourSchemeI cs)
563 globalColourScheme = cs;
566 public ColourSchemeI getGlobalColourScheme()
568 return globalColourScheme;
571 public void setStartRes(int res)
576 public void setStartSeq(int seq)
581 public void setEndRes(int res)
583 if (res > alignment.getWidth() - 1)
585 // log.System.out.println(" Corrected res from " + res + " to maximum " +
586 // (alignment.getWidth()-1));
587 res = alignment.getWidth() - 1;
596 public void setEndSeq(int seq)
598 if (seq > alignment.getHeight())
600 seq = alignment.getHeight();
609 public int getEndSeq()
614 java.awt.Frame nullFrame;
616 protected FeatureSettings featureSettings = null;
618 private float heightScale = 1, widthScale = 1;
620 public void setFont(Font f)
623 if (nullFrame == null)
625 nullFrame = new java.awt.Frame();
626 nullFrame.addNotify();
629 java.awt.FontMetrics fm = nullFrame.getGraphics().getFontMetrics(font);
630 setCharHeight((int) (heightScale * fm.getHeight()));
631 charWidth = (int) (widthScale * fm.charWidth('M'));
635 Font f2 = new Font(f.getName(), Font.BOLD, f.getSize());
636 fm = nullFrame.getGraphics().getFontMetrics(f2);
637 charWidth = (int) (widthScale * (fm.stringWidth("MMMMMMMMMMM") / 10));
641 public Font getFont()
646 public int getCharWidth()
651 public void setCharHeight(int h)
656 public int getCharHeight()
661 public void setWrappedWidth(int w)
663 this.wrappedWidth = w;
666 public int getwrappedWidth()
671 public AlignmentI getAlignment()
676 public void setAlignment(AlignmentI align)
678 this.alignment = align;
681 public void setWrapAlignment(boolean state)
683 wrapAlignment = state;
686 public void setShowText(boolean state)
691 public void setRenderGaps(boolean state)
696 public boolean getColourText()
698 return showColourText;
701 public void setColourText(boolean state)
703 showColourText = state;
706 public void setShowBoxes(boolean state)
711 public boolean getWrapAlignment()
713 return wrapAlignment;
716 public boolean getShowText()
721 public boolean getShowBoxes()
726 public char getGapCharacter()
728 return getAlignment().getGapCharacter();
731 public void setGapCharacter(char gap)
733 if (getAlignment() != null)
735 getAlignment().setGapCharacter(gap);
739 public void setThreshold(int thresh)
744 public int getThreshold()
749 public void setIncrement(int inc)
754 public int getIncrement()
759 public void setHiddenColumns(ColumnSelection colsel)
761 this.colSel = colsel;
762 if (colSel.getHiddenColumns() != null)
764 hasHiddenColumns = true;
768 public ColumnSelection getColumnSelection()
773 public void resetSeqLimits(int height)
775 setEndSeq(height / getCharHeight());
778 public void setCurrentTree(NJTree tree)
783 public NJTree getCurrentTree()
788 public void setColourAppliesToAllGroups(boolean b)
790 colourAppliesToAllGroups = b;
793 public boolean getColourAppliesToAllGroups()
795 return colourAppliesToAllGroups;
798 public boolean getShowJVSuffix()
803 public void setShowJVSuffix(boolean b)
808 public boolean getShowAnnotation()
810 return showAnnotation;
813 public void setShowAnnotation(boolean b)
818 public boolean getScaleAboveWrapped()
820 return scaleAboveWrapped;
823 public boolean getScaleLeftWrapped()
825 return scaleLeftWrapped;
828 public boolean getScaleRightWrapped()
830 return scaleRightWrapped;
833 public void setScaleAboveWrapped(boolean b)
835 scaleAboveWrapped = b;
838 public void setScaleLeftWrapped(boolean b)
840 scaleLeftWrapped = b;
843 public void setScaleRightWrapped(boolean b)
845 scaleRightWrapped = b;
848 public void setIgnoreGapsConsensus(boolean b)
850 ignoreGapsInConsensusCalculation = b;
851 updateConsensus(null);
852 if (globalColourScheme != null)
854 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
855 ignoreGapsInConsensusCalculation);
861 * Property change listener for changes in alignment
866 public void addPropertyChangeListener(
867 java.beans.PropertyChangeListener listener)
869 changeSupport.addPropertyChangeListener(listener);
878 public void removePropertyChangeListener(
879 java.beans.PropertyChangeListener listener)
881 changeSupport.removePropertyChangeListener(listener);
885 * Property change listener for changes in alignment
894 public void firePropertyChange(String prop, Object oldvalue,
897 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
900 public boolean getIgnoreGapsConsensus()
902 return ignoreGapsInConsensusCalculation;
905 public void hideSelectedColumns()
907 if (colSel.size() < 1)
912 colSel.hideSelectedColumns();
913 setSelectionGroup(null);
915 hasHiddenColumns = true;
918 public void invertColumnSelection()
920 for (int i = 0; i < alignment.getWidth(); i++)
922 if (colSel.contains(i))
924 colSel.removeElement(i);
928 if (!hasHiddenColumns || colSel.isVisible(i))
930 colSel.addElement(i);
936 public void hideColumns(int start, int end)
940 colSel.hideColumns(start);
944 colSel.hideColumns(start, end);
947 hasHiddenColumns = true;
950 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
952 int sSize = sg.getSize();
958 if (hiddenRepSequences == null)
960 hiddenRepSequences = new Hashtable();
963 hiddenRepSequences.put(repSequence, sg);
965 // Hide all sequences except the repSequence
966 SequenceI[] seqs = new SequenceI[sSize - 1];
968 for (int i = 0; i < sSize; i++)
970 if (sg.getSequenceAt(i) != repSequence)
972 if (index == sSize - 1)
977 seqs[index++] = sg.getSequenceAt(i);
985 public void hideAllSelectedSeqs()
987 if (selectionGroup == null || selectionGroup.getSize() < 1)
992 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
996 setSelectionGroup(null);
999 public void hideSequence(SequenceI[] seq)
1003 for (int i = 0; i < seq.length; i++)
1005 alignment.getHiddenSequences().hideSequence(seq[i]);
1008 hasHiddenRows = true;
1009 firePropertyChange("alignment", null, alignment.getSequences());
1012 public void showSequence(int index)
1014 Vector tmp = alignment.getHiddenSequences().showSequence(index,
1015 hiddenRepSequences);
1018 if (selectionGroup == null)
1020 selectionGroup = new SequenceGroup();
1021 selectionGroup.setEndRes(alignment.getWidth() - 1);
1024 for (int t = 0; t < tmp.size(); t++)
1026 selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
1028 firePropertyChange("alignment", null, alignment.getSequences());
1032 if (alignment.getHiddenSequences().getSize() < 1)
1034 hasHiddenRows = false;
1037 public void showColumn(int col)
1039 colSel.revealHiddenColumns(col);
1040 if (colSel.getHiddenColumns() == null)
1042 hasHiddenColumns = false;
1046 public void showAllHiddenColumns()
1048 colSel.revealAllHiddenColumns();
1049 hasHiddenColumns = false;
1052 public void showAllHiddenSeqs()
1054 if (alignment.getHiddenSequences().getSize() > 0)
1056 if (selectionGroup == null)
1058 selectionGroup = new SequenceGroup();
1059 selectionGroup.setEndRes(alignment.getWidth() - 1);
1061 Vector tmp = alignment.getHiddenSequences().showAll(
1062 hiddenRepSequences);
1063 for (int t = 0; t < tmp.size(); t++)
1065 selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
1067 firePropertyChange("alignment", null, alignment.getSequences());
1068 hasHiddenRows = false;
1069 hiddenRepSequences = null;
1074 public int adjustForHiddenSeqs(int alignmentIndex)
1076 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1081 * This method returns the a new SequenceI [] with the selection sequence and
1082 * start and end points adjusted
1086 public SequenceI[] getSelectionAsNewSequence()
1088 SequenceI[] sequences;
1090 if (selectionGroup == null)
1092 sequences = alignment.getSequencesArray();
1096 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1103 * get the currently selected sequence objects or all the sequences in the
1106 * @return array of references to sequence objects
1108 public SequenceI[] getSequenceSelection()
1110 SequenceI[] sequences = null;
1111 if (selectionGroup != null)
1113 sequences = selectionGroup.getSequencesInOrder(alignment);
1115 if (sequences == null)
1117 sequences = alignment.getSequencesArray();
1123 * This method returns the visible alignment as text, as seen on the GUI, ie
1124 * if columns are hidden they will not be returned in the result. Use this for
1125 * calculating trees, PCA, redundancy etc on views which contain hidden
1130 public jalview.datamodel.CigarArray getViewAsCigars(
1131 boolean selectedRegionOnly)
1133 return new jalview.datamodel.CigarArray(alignment, (hasHiddenColumns ? colSel : null), (selectedRegionOnly ? selectionGroup : null));
1137 * return a compact representation of the current alignment selection to pass
1138 * to an analysis function
1140 * @param selectedOnly
1141 * boolean true to just return the selected view
1142 * @return AlignmentView
1144 jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly)
1146 return getAlignmentView(selectedOnly, false);
1150 * return a compact representation of the current alignment selection to pass
1151 * to an analysis function
1153 * @param selectedOnly
1154 * boolean true to just return the selected view
1156 * boolean true to annotate the alignment view with groups on the alignment (and intersecting with selected region if selectedOnly is true)
1157 * @return AlignmentView
1159 public jalview.datamodel.AlignmentView getAlignmentView(boolean selectedOnly, boolean markGroups)
1161 return new AlignmentView(alignment, colSel, selectionGroup, hasHiddenColumns, selectedOnly, markGroups);
1164 * This method returns the visible alignment as text, as seen on the GUI, ie
1165 * if columns are hidden they will not be returned in the result. Use this for
1166 * calculating trees, PCA, redundancy etc on views which contain hidden
1171 public String[] getViewAsString(boolean selectedRegionOnly)
1173 String[] selection = null;
1174 SequenceI[] seqs = null;
1176 int start = 0, end = 0;
1177 if (selectedRegionOnly && selectionGroup != null)
1179 iSize = selectionGroup.getSize();
1180 seqs = selectionGroup.getSequencesInOrder(alignment);
1181 start = selectionGroup.getStartRes();
1182 end = selectionGroup.getEndRes() + 1;
1186 iSize = alignment.getHeight();
1187 seqs = alignment.getSequencesArray();
1188 end = alignment.getWidth();
1191 selection = new String[iSize];
1193 for (i = 0; i < iSize; i++)
1195 if (hasHiddenColumns)
1197 StringBuffer visibleSeq = new StringBuffer();
1198 Vector regions = colSel.getHiddenColumns();
1200 int blockStart = start, blockEnd = end;
1202 int hideStart, hideEnd;
1204 for (int j = 0; j < regions.size(); j++)
1206 region = (int[]) regions.elementAt(j);
1207 hideStart = region[0];
1208 hideEnd = region[1];
1210 if (hideStart < start)
1215 blockStart = Math.min(blockStart, hideEnd + 1);
1216 blockEnd = Math.min(blockEnd, hideStart);
1218 if (blockStart > blockEnd)
1223 visibleSeq.append(seqs[i].getSequence(blockStart, blockEnd));
1225 blockStart = hideEnd + 1;
1229 if (end > blockStart)
1231 visibleSeq.append(seqs[i].getSequence(blockStart, end));
1234 selection[i] = visibleSeq.toString();
1238 selection[i] = seqs[i].getSequenceAsString(start, end);
1245 public boolean getShowHiddenMarkers()
1247 return showHiddenMarkers;
1250 public void setShowHiddenMarkers(boolean show)
1252 showHiddenMarkers = show;
1255 public Color getSequenceColour(SequenceI seq)
1257 if (sequenceColours == null || !sequenceColours.containsKey(seq))
1263 return (Color) sequenceColours.get(seq);
1267 public void setSequenceColour(SequenceI seq, Color col)
1269 if (sequenceColours == null)
1271 sequenceColours = new Hashtable();
1276 sequenceColours.remove(seq);
1280 sequenceColours.put(seq, col);
1284 public String getSequenceSetId()
1286 if (sequenceSetID == null)
1288 sequenceSetID = alignment.hashCode() + "";
1291 return sequenceSetID;
1294 * unique viewId for synchronizing state (e.g. with stored Jalview Project)
1297 private String viewId = null;
1299 public String getViewId()
1303 viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
1308 public void alignmentChanged(AlignmentPanel ap)
1310 alignment.padGaps();
1312 if (hconsensus != null && autocalculateConsensus)
1314 updateConsensus(ap);
1315 updateConservation(ap);
1318 // Reset endRes of groups if beyond alignment width
1319 int alWidth = alignment.getWidth();
1320 Vector groups = alignment.getGroups();
1323 for (int i = 0; i < groups.size(); i++)
1325 SequenceGroup sg = (SequenceGroup) groups.elementAt(i);
1326 if (sg.getEndRes() > alWidth)
1328 sg.setEndRes(alWidth - 1);
1333 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1335 selectionGroup.setEndRes(alWidth - 1);
1338 resetAllColourSchemes();
1340 // AW alignment.adjustSequenceAnnotations();
1343 void resetAllColourSchemes()
1345 ColourSchemeI cs = globalColourScheme;
1348 if (cs instanceof ClustalxColourScheme)
1350 ((ClustalxColourScheme) cs).resetClustalX(alignment.getSequences(),
1351 alignment.getWidth());
1354 cs.setConsensus(hconsensus);
1355 if (cs.conservationApplied())
1357 cs.setConservation(Conservation.calculateConservation("All",
1358 ResidueProperties.propHash, 3, alignment.getSequences(), 0,
1359 alignment.getWidth(), false, getConsPercGaps(), false));
1363 int s, sSize = alignment.getGroups().size();
1364 for (s = 0; s < sSize; s++)
1366 SequenceGroup sg = (SequenceGroup) alignment.getGroups().elementAt(s);
1367 if (sg.cs != null && sg.cs instanceof ClustalxColourScheme)
1369 ((ClustalxColourScheme) sg.cs).resetClustalX(
1370 sg.getSequences(hiddenRepSequences), sg.getWidth());
1372 sg.recalcConservation();
1376 boolean centreColumnLabels;
1378 public boolean getCentreColumnLabels()
1380 return centreColumnLabels;
1383 public void updateSequenceIdColours()
1385 Vector groups = alignment.getGroups();
1386 for (int ig = 0, igSize = groups.size(); ig < igSize; ig++)
1388 SequenceGroup sg = (SequenceGroup) groups.elementAt(ig);
1389 if (sg.idColour != null)
1391 Vector sqs = sg.getSequences(hiddenRepSequences);
1392 for (int s = 0, sSize = sqs.size(); s < sSize; s++)
1394 this.setSequenceColour((SequenceI) sqs.elementAt(s), sg.idColour);
1400 public boolean followHighlight = true;
1402 public boolean getFollowHighlight()
1404 return followHighlight;
1407 public boolean followSelection = true;
1410 * @return true if view selection should always follow the selections
1411 * broadcast by other selection sources
1413 public boolean getFollowSelection()
1415 return followSelection;
1418 private long sgrouphash = -1, colselhash = -1;
1421 * checks current SelectionGroup against record of last hash value, and
1424 * @return true if SelectionGroup changed since last call
1426 boolean isSelectionGroupChanged()
1428 int hc = (selectionGroup == null) ? -1 : selectionGroup.hashCode();
1429 if (hc != sgrouphash)
1438 * checks current colsel against record of last hash value, and updates
1441 * @return true if colsel changed since last call
1443 boolean isColSelChanged()
1445 int hc = (colSel == null) ? -1 : colSel.hashCode();
1446 if (hc != colselhash)
1453 public void sendSelection()
1455 jalview.structure.StructureSelectionManager
1456 .getStructureSelectionManager(applet).sendSelection(
1457 new SequenceGroup(getSelectionGroup()),
1458 new ColumnSelection(getColumnSelection()), this);
1465 * show non-conserved residues only
1467 public boolean showUnconserved = false;
1470 * when set, alignment should be reordered according to a newly opened tree
1472 public boolean sortByTree = false;
1475 * @return the showUnconserved
1477 public boolean getShowunconserved()
1479 return showUnconserved;
1483 * @param showNonconserved
1484 * the showUnconserved to set
1486 public void setShowunconserved(boolean displayNonconserved)
1488 this.showUnconserved = displayNonconserved;
1492 * should conservation rows be shown for groups
1494 boolean showGroupConservation = false;
1497 * should consensus rows be shown for groups
1499 boolean showGroupConsensus = false;
1502 * should consensus profile be rendered by default
1504 public boolean showSequenceLogo = false;
1506 * should consensus profile be rendered normalised to row height
1508 public boolean normaliseSequenceLogo = false;
1511 * should consensus histograms be rendered by default
1513 public boolean showConsensusHistogram = true;
1516 * @return the showConsensusProfile
1518 public boolean isShowSequenceLogo()
1520 return showSequenceLogo;
1524 * @param showSequenceLogo
1527 public void setShowSequenceLogo(boolean showSequenceLogo)
1529 if (showSequenceLogo != this.showSequenceLogo)
1531 // TODO: decouple settings setting from calculation when refactoring
1532 // annotation update method from alignframe to viewport
1533 this.showSequenceLogo = showSequenceLogo;
1534 if (consensusThread != null)
1536 consensusThread.updateAnnotation();
1539 this.showSequenceLogo = showSequenceLogo;
1543 * @param showConsensusHistogram
1544 * the showConsensusHistogram to set
1546 public void setShowConsensusHistogram(boolean showConsensusHistogram)
1548 this.showConsensusHistogram = showConsensusHistogram;
1552 * @return the showGroupConservation
1554 public boolean isShowGroupConservation()
1556 return showGroupConservation;
1560 * @param showGroupConservation
1561 * the showGroupConservation to set
1563 public void setShowGroupConservation(boolean showGroupConservation)
1565 this.showGroupConservation = showGroupConservation;
1569 * @return the showGroupConsensus
1571 public boolean isShowGroupConsensus()
1573 return showGroupConsensus;
1577 * @param showGroupConsensus
1578 * the showGroupConsensus to set
1580 public void setShowGroupConsensus(boolean showGroupConsensus)
1582 this.showGroupConsensus = showGroupConsensus;
1587 * @return flag to indicate if the consensus histogram should be rendered by
1590 public boolean isShowConsensusHistogram()
1592 return this.showConsensusHistogram;
1596 * synthesize a column selection if none exists so it covers the given
1597 * selection group. if wholewidth is false, no column selection is made if the
1598 * selection group covers the whole alignment width.
1603 public void expandColSelection(SequenceGroup sg, boolean wholewidth)
1607 && (sgs = sg.getStartRes()) >= 0
1608 && sg.getStartRes() <= (sge = sg.getEndRes())
1609 && (colSel == null || colSel.getSelected() == null || colSel
1610 .getSelected().size() == 0))
1612 if (!wholewidth && alignment.getWidth() == (1 + sge - sgs))
1619 colSel = new ColumnSelection();
1621 for (int cspos = sg.getStartRes(); cspos <= sg.getEndRes(); cspos++)
1623 colSel.addElement(cspos);
1629 public boolean hasHiddenColumns()
1631 return hasHiddenColumns;
1634 public boolean isNormaliseSequenceLogo()
1636 return normaliseSequenceLogo;
1639 public void setNormaliseSequenceLogo(boolean state)
1641 normaliseSequenceLogo = state;
1644 public boolean isCalcInProgress()
1646 // TODO generalise to iterate over all calculators associated with av
1647 return updatingConsensus || updatingConservation || updatingStrucConsensus;
1650 public boolean isCalculationInProgress(
1651 AlignmentAnnotation alignmentAnnotation)
1653 if (!alignmentAnnotation.autoCalculated)
1655 if ((updatingConsensus && consensus==alignmentAnnotation)
1656 || (updatingConservation && (conservation==alignmentAnnotation || quality==alignmentAnnotation))
1657 // || (updatingStrucConsensus && strucConsensus==alignmentAnnotation)
1667 * @return true if alignment characters should be displayed
1669 public boolean isValidCharWidth()
1671 return validCharWidth;
1675 public Hashtable[] getSequenceConsensusHash()
1681 public Hashtable[] getRnaStructureConsensusHash()
1683 return null; // TODO: JAL-891 port to jvlite : refactor and introduce hStrucConsensus;
1687 public AlignmentAnnotation getAlignmentQualityAnnot()
1689 // TODO Auto-generated method stub
1694 public AlignmentAnnotation getAlignmentConservationAnnotation()
1696 // TODO Auto-generated method stub
1701 public boolean isClosed()
1703 System.err.println("Alignment is "+alignment==null ? "closed" : "open");
1704 return alignment==null;
1708 public AlignCalcManagerI getCalcManager()
1710 // TODO Auto-generated method stub