2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
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.viewmodel;
20 import jalview.analysis.AAFrequency;
21 import jalview.analysis.Conservation;
22 import jalview.api.AlignCalcManagerI;
23 import jalview.api.AlignViewportI;
24 import jalview.api.AlignmentViewPanel;
25 import jalview.datamodel.AlignmentAnnotation;
26 import jalview.datamodel.AlignmentI;
27 import jalview.datamodel.AlignmentView;
28 import jalview.datamodel.Annotation;
29 import jalview.datamodel.ColumnSelection;
30 import jalview.datamodel.Sequence;
31 import jalview.datamodel.SequenceCollectionI;
32 import jalview.datamodel.SequenceGroup;
33 import jalview.datamodel.SequenceI;
34 import jalview.schemes.Blosum62ColourScheme;
35 import jalview.schemes.ClustalxColourScheme;
36 import jalview.schemes.ColourSchemeI;
37 import jalview.schemes.PIDColourScheme;
38 import jalview.schemes.ResidueProperties;
39 import jalview.workers.AlignCalcManager;
40 import jalview.workers.ConsensusThread;
41 import jalview.workers.StrucConsensusThread;
43 import java.util.Hashtable;
44 import java.util.List;
46 import java.util.Vector;
49 * base class holding visualization and analysis attributes and common logic for
50 * an active alignment view displayed in the GUI
55 public abstract class AlignmentViewport implements AlignViewportI
58 * alignment displayed in the viewport. Please use get/setter
60 protected AlignmentI alignment;
62 protected String sequenceSetID;
65 * probably unused indicator that view is of a dataset rather than an
68 protected boolean isDataset = false;
70 private Map<SequenceI, SequenceCollectionI> hiddenRepSequences;
72 protected ColumnSelection colSel = new ColumnSelection();
74 public boolean autoCalculateConsensus = true;
76 protected boolean autoCalculateStrucConsensus = true;
78 protected boolean ignoreGapsInConsensusCalculation = false;
80 protected ColourSchemeI globalColourScheme = null;
83 * gui state - changes to colour scheme propagated to all groups
85 private boolean colourAppliesToAllGroups;
89 * indicating if subsequent colourscheme changes will be propagated
92 public void setColourAppliesToAllGroups(boolean b)
94 colourAppliesToAllGroups = b;
100 * @return flag indicating if colourchanges propagated to all groups
102 public boolean getColourAppliesToAllGroups()
104 return colourAppliesToAllGroups;
107 boolean abovePIDThreshold = false;
112 * @return true if percent identity threshold is applied to shading
114 public boolean getAbovePIDThreshold()
116 return abovePIDThreshold;
124 * indicate if percent identity threshold is applied to shading
126 public void setAbovePIDThreshold(boolean b)
128 abovePIDThreshold = b;
139 public void setThreshold(int thresh)
147 * @return DOCUMENT ME!
149 public int getThreshold()
159 * set the scalar for bleaching colourschemes according to degree of
162 public void setIncrement(int inc)
170 * @return get scalar for bleaching colourschemes by conservation
172 public int getIncrement()
177 boolean conservationColourSelected = false;
182 * @return true if conservation based shading is enabled
184 public boolean getConservationSelected()
186 return conservationColourSelected;
193 * enable conservation based shading
195 public void setConservationSelected(boolean b)
197 conservationColourSelected = b;
201 public void setGlobalColourScheme(ColourSchemeI cs)
203 // TODO: logic refactored from AlignFrame changeColour -
204 // autorecalc stuff should be changed to rely on the worker system
205 // check to see if we should implement a changeColour(cs) method rather than
206 // put th logic in here
207 // - means that caller decides if they want to just modify state and defer
208 // calculation till later or to do all calculations in thread.
210 globalColourScheme = cs;
211 if (getColourAppliesToAllGroups())
213 for (SequenceGroup sg : getAlignment().getGroups())
220 if (cs instanceof ClustalxColourScheme)
222 sg.cs = new ClustalxColourScheme(sg, getHiddenRepSequences());
228 sg.cs = cs.getClass().newInstance();
229 } catch (Exception ex)
231 ex.printStackTrace();
236 if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
237 || cs instanceof Blosum62ColourScheme)
239 sg.cs.setThreshold(threshold, getIgnoreGapsConsensus());
240 sg.cs.setConsensus(AAFrequency.calculate(
241 sg.getSequences(getHiddenRepSequences()), 0,
246 sg.cs.setThreshold(0, getIgnoreGapsConsensus());
249 if (getConservationSelected())
251 Conservation c = new Conservation("Group",
252 ResidueProperties.propHash, 3,
253 sg.getSequences(getHiddenRepSequences()), 0,
254 getAlignment().getWidth() - 1);
256 c.verdict(false, getConsPercGaps());
257 sg.cs.setConservation(c);
261 sg.cs.setConservation(null);
262 sg.cs.setThreshold(0, getIgnoreGapsConsensus());
271 public ColourSchemeI getGlobalColourScheme()
273 return globalColourScheme;
276 protected AlignmentAnnotation consensus;
278 protected AlignmentAnnotation strucConsensus;
280 protected AlignmentAnnotation conservation;
282 protected AlignmentAnnotation quality;
284 protected AlignmentAnnotation[] groupConsensus;
286 protected AlignmentAnnotation[] groupConservation;
289 * results of alignment consensus analysis for visible portion of view
291 protected Hashtable[] hconsensus = null;
294 * results of secondary structure base pair consensus for visible portion of
297 protected Hashtable[] hStrucConsensus = null;
300 * percentage gaps allowed in a column before all amino acid properties should
301 * be considered unconserved
303 int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
306 public int getConsPercGaps()
312 public void setSequenceConsensusHash(Hashtable[] hconsensus)
314 this.hconsensus = hconsensus;
319 public Hashtable[] getSequenceConsensusHash()
325 public Hashtable[] getRnaStructureConsensusHash()
327 return hStrucConsensus;
331 public void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus)
333 this.hStrucConsensus = hStrucConsensus;
338 public AlignmentAnnotation getAlignmentQualityAnnot()
344 public AlignmentAnnotation getAlignmentConservationAnnotation()
350 public AlignmentAnnotation getAlignmentConsensusAnnotation()
356 public AlignmentAnnotation getAlignmentStrucConsensusAnnotation()
358 return strucConsensus;
361 protected AlignCalcManagerI calculator = new AlignCalcManager();
364 * trigger update of conservation annotation
366 public void updateConservation(final AlignmentViewPanel ap)
368 // see note in mantis : issue number 8585
369 if (alignment.isNucleotide() || conservation == null
370 || !autoCalculateConsensus)
375 .getRegisteredWorkersOfClass(jalview.workers.ConservationThread.class)==null)
377 calculator.registerWorker(new jalview.workers.ConservationThread(
383 * trigger update of consensus annotation
385 public void updateConsensus(final AlignmentViewPanel ap)
387 // see note in mantis : issue number 8585
388 if (consensus == null || !autoCalculateConsensus)
392 if (calculator.getRegisteredWorkersOfClass(ConsensusThread.class)==null)
394 calculator.registerWorker(new ConsensusThread(this, ap));
398 // --------START Structure Conservation
399 public void updateStrucConsensus(final AlignmentViewPanel ap)
401 if (autoCalculateStrucConsensus && strucConsensus == null
402 && alignment.isNucleotide() && alignment.hasRNAStructure())
407 // see note in mantis : issue number 8585
408 if (strucConsensus == null || !autoCalculateStrucConsensus)
413 .getRegisteredWorkersOfClass(StrucConsensusThread.class)==null)
415 calculator.registerWorker(new StrucConsensusThread(this, ap));
419 public boolean isCalcInProgress()
421 return calculator.isWorking();
425 public boolean isCalculationInProgress(
426 AlignmentAnnotation alignmentAnnotation)
428 if (!alignmentAnnotation.autoCalculated)
430 if (calculator.workingInvolvedWith(alignmentAnnotation))
432 // System.err.println("grey out ("+alignmentAnnotation.label+")");
439 public boolean isClosed()
441 // TODO: check that this isClosed is only true after panel is closed, not
442 // before it is fully constructed.
443 return alignment == null;
447 public AlignCalcManagerI getCalcManager()
453 * should conservation rows be shown for groups
455 protected boolean showGroupConservation = false;
458 * should consensus rows be shown for groups
460 protected boolean showGroupConsensus = false;
463 * should consensus profile be rendered by default
465 protected boolean showSequenceLogo = false;
468 * should consensus profile be rendered normalised to row height
470 protected boolean normaliseSequenceLogo = false;
473 * should consensus histograms be rendered by default
475 protected boolean showConsensusHistogram = true;
478 * @return the showConsensusProfile
481 public boolean isShowSequenceLogo()
483 return showSequenceLogo;
487 * @param showSequenceLogo
490 public void setShowSequenceLogo(boolean showSequenceLogo)
492 if (showSequenceLogo != this.showSequenceLogo)
494 // TODO: decouple settings setting from calculation when refactoring
495 // annotation update method from alignframe to viewport
496 this.showSequenceLogo = showSequenceLogo;
497 calculator.updateAnnotationFor(ConsensusThread.class);
498 calculator.updateAnnotationFor(StrucConsensusThread.class);
500 this.showSequenceLogo = showSequenceLogo;
504 * @param showConsensusHistogram
505 * the showConsensusHistogram to set
507 public void setShowConsensusHistogram(boolean showConsensusHistogram)
509 this.showConsensusHistogram = showConsensusHistogram;
513 * @return the showGroupConservation
515 public boolean isShowGroupConservation()
517 return showGroupConservation;
521 * @param showGroupConservation
522 * the showGroupConservation to set
524 public void setShowGroupConservation(boolean showGroupConservation)
526 this.showGroupConservation = showGroupConservation;
530 * @return the showGroupConsensus
532 public boolean isShowGroupConsensus()
534 return showGroupConsensus;
538 * @param showGroupConsensus
539 * the showGroupConsensus to set
541 public void setShowGroupConsensus(boolean showGroupConsensus)
543 this.showGroupConsensus = showGroupConsensus;
548 * @return flag to indicate if the consensus histogram should be rendered by
552 public boolean isShowConsensusHistogram()
554 return this.showConsensusHistogram;
558 * show non-conserved residues only
560 protected boolean showUnconserved = false;
563 * when set, updateAlignment will always ensure sequences are of equal length
565 private boolean padGaps = false;
568 * when set, alignment should be reordered according to a newly opened tree
570 public boolean sortByTree = false;
572 public boolean getShowUnconserved()
574 return showUnconserved;
577 public void setShowUnconserved(boolean showunconserved)
579 showUnconserved = showunconserved;
583 * @param showNonconserved
584 * the showUnconserved to set
586 public void setShowunconserved(boolean displayNonconserved)
588 this.showUnconserved = displayNonconserved;
594 * @return null or the currently selected sequence region
596 public SequenceGroup getSelectionGroup()
598 return selectionGroup;
602 * Set the selection group for this window.
605 * - group holding references to sequences in this alignment view
608 public void setSelectionGroup(SequenceGroup sg)
613 public void setHiddenColumns(ColumnSelection colsel)
615 this.colSel = colsel;
616 if (colSel.getHiddenColumns() != null)
618 hasHiddenColumns = true;
623 public ColumnSelection getColumnSelection()
628 public void setColumnSelection(ColumnSelection colSel)
630 this.colSel = colSel;
638 public Map<SequenceI, SequenceCollectionI> getHiddenRepSequences()
640 return hiddenRepSequences;
644 public void setHiddenRepSequences(
645 Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
647 this.hiddenRepSequences = hiddenRepSequences;
650 protected boolean hasHiddenColumns = false;
652 public void updateHiddenColumns()
654 hasHiddenColumns = colSel.getHiddenColumns() != null;
657 protected boolean hasHiddenRows = false;
659 public boolean hasHiddenRows()
661 return hasHiddenRows;
664 protected SequenceGroup selectionGroup;
666 public void setSequenceSetId(String newid)
668 if (sequenceSetID != null)
671 .println("Warning - overwriting a sequenceSetId for a viewport!");
673 sequenceSetID = new String(newid);
676 public String getSequenceSetId()
678 if (sequenceSetID == null)
680 sequenceSetID = alignment.hashCode() + "";
683 return sequenceSetID;
687 * unique viewId for synchronizing state (e.g. with stored Jalview Project)
690 protected String viewId = null;
692 public String getViewId()
696 viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
701 public void setIgnoreGapsConsensus(boolean b, AlignmentViewPanel ap)
703 ignoreGapsInConsensusCalculation = b;
707 if (globalColourScheme != null)
709 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
710 ignoreGapsInConsensusCalculation);
716 private long sgrouphash = -1, colselhash = -1;
719 * checks current SelectionGroup against record of last hash value, and
723 * update the record of last hash value
725 * @return true if SelectionGroup changed since last call (when b is true)
727 public boolean isSelectionGroupChanged(boolean b)
729 int hc = (selectionGroup == null || selectionGroup.getSize() == 0) ? -1
730 : selectionGroup.hashCode();
731 if (hc != -1 && hc != sgrouphash)
743 * checks current colsel against record of last hash value, and optionally
747 * update the record of last hash value
748 * @return true if colsel changed since last call (when b is true)
750 public boolean isColSelChanged(boolean b)
752 int hc = (colSel == null || colSel.size() == 0) ? -1 : colSel
754 if (hc != -1 && hc != colselhash)
766 public boolean getIgnoreGapsConsensus()
768 return ignoreGapsInConsensusCalculation;
771 // / property change stuff
773 // JBPNote Prolly only need this in the applet version.
774 private final java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
777 protected boolean showConservation = true;
779 protected boolean showQuality = true;
781 protected boolean showConsensus = true;
784 * Property change listener for changes in alignment
789 public void addPropertyChangeListener(
790 java.beans.PropertyChangeListener listener)
792 changeSupport.addPropertyChangeListener(listener);
801 public void removePropertyChangeListener(
802 java.beans.PropertyChangeListener listener)
804 changeSupport.removePropertyChangeListener(listener);
808 * Property change listener for changes in alignment
817 public void firePropertyChange(String prop, Object oldvalue,
820 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
823 // common hide/show column stuff
825 public void hideSelectedColumns()
827 if (colSel.size() < 1)
832 colSel.hideSelectedColumns();
833 setSelectionGroup(null);
835 hasHiddenColumns = true;
838 public void hideColumns(int start, int end)
842 colSel.hideColumns(start);
846 colSel.hideColumns(start, end);
849 hasHiddenColumns = true;
852 public void showColumn(int col)
854 colSel.revealHiddenColumns(col);
855 if (colSel.getHiddenColumns() == null)
857 hasHiddenColumns = false;
861 public void showAllHiddenColumns()
863 colSel.revealAllHiddenColumns();
864 hasHiddenColumns = false;
867 // common hide/show seq stuff
868 public void showAllHiddenSeqs()
870 if (alignment.getHiddenSequences().getSize() > 0)
872 if (selectionGroup == null)
874 selectionGroup = new SequenceGroup();
875 selectionGroup.setEndRes(alignment.getWidth() - 1);
877 Vector tmp = alignment.getHiddenSequences().showAll(
879 for (int t = 0; t < tmp.size(); t++)
881 selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
884 hasHiddenRows = false;
885 hiddenRepSequences = null;
887 firePropertyChange("alignment", null, alignment.getSequences());
888 // used to set hasHiddenRows/hiddenRepSequences here, after the property
894 public void showSequence(int index)
896 Vector tmp = alignment.getHiddenSequences().showSequence(index,
900 if (selectionGroup == null)
902 selectionGroup = new SequenceGroup();
903 selectionGroup.setEndRes(alignment.getWidth() - 1);
906 for (int t = 0; t < tmp.size(); t++)
908 selectionGroup.addSequence((SequenceI) tmp.elementAt(t), false);
910 // JBPNote: refactor: only update flag if we modified visiblity (used to
911 // do this regardless)
912 if (alignment.getHiddenSequences().getSize() < 1)
914 hasHiddenRows = false;
916 firePropertyChange("alignment", null, alignment.getSequences());
921 public void hideAllSelectedSeqs()
923 if (selectionGroup == null || selectionGroup.getSize() < 1)
928 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
932 setSelectionGroup(null);
935 public void hideSequence(SequenceI[] seq)
939 for (int i = 0; i < seq.length; i++)
941 alignment.getHiddenSequences().hideSequence(seq[i]);
943 hasHiddenRows = true;
944 firePropertyChange("alignment", null, alignment.getSequences());
948 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
950 int sSize = sg.getSize();
956 if (hiddenRepSequences == null)
958 hiddenRepSequences = new Hashtable();
961 hiddenRepSequences.put(repSequence, sg);
963 // Hide all sequences except the repSequence
964 SequenceI[] seqs = new SequenceI[sSize - 1];
966 for (int i = 0; i < sSize; i++)
968 if (sg.getSequenceAt(i) != repSequence)
970 if (index == sSize - 1)
975 seqs[index++] = sg.getSequenceAt(i);
978 sg.setSeqrep(repSequence); // note: not done in 2.7applet
979 sg.setHidereps(true); // note: not done in 2.7applet
984 public boolean isHiddenRepSequence(SequenceI seq)
986 return hiddenRepSequences != null
987 && hiddenRepSequences.containsKey(seq);
990 public SequenceGroup getRepresentedSequences(SequenceI seq)
992 return (SequenceGroup) (hiddenRepSequences == null ? null
993 : hiddenRepSequences.get(seq));
996 public int adjustForHiddenSeqs(int alignmentIndex)
998 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1002 // Selection manipulation
1004 * broadcast selection to any interested parties
1006 public abstract void sendSelection();
1008 public void invertColumnSelection()
1010 colSel.invertColumnSelection(0, alignment.getWidth());
1014 * This method returns an array of new SequenceI objects derived from the
1015 * whole alignment or just the current selection with start and end points
1018 * @note if you need references to the actual SequenceI objects in the
1019 * alignment or currently selected then use getSequenceSelection()
1020 * @return selection as new sequenceI objects
1022 public SequenceI[] getSelectionAsNewSequence()
1024 SequenceI[] sequences;
1025 // JBPNote: Need to test jalviewLite.getSelectedSequencesAsAlignmentFrom -
1026 // this was the only caller in the applet for this method
1027 // JBPNote: in applet, this method returned references to the alignment
1028 // sequences, and it did not honour the presence/absence of annotation
1029 // attached to the alignment (probably!)
1030 if (selectionGroup == null)
1032 sequences = alignment.getSequencesArray();
1033 AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
1034 for (int i = 0; i < sequences.length; i++)
1036 sequences[i] = new Sequence(sequences[i], annots); // construct new
1038 // subset of visible
1044 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1051 * get the currently selected sequence objects or all the sequences in the
1054 * @return array of references to sequence objects
1056 public SequenceI[] getSequenceSelection()
1058 SequenceI[] sequences = null;
1059 if (selectionGroup != null)
1061 sequences = selectionGroup.getSequencesInOrder(alignment);
1063 if (sequences == null)
1065 sequences = alignment.getSequencesArray();
1071 * This method returns the visible alignment as text, as seen on the GUI, ie
1072 * if columns are hidden they will not be returned in the result. Use this for
1073 * calculating trees, PCA, redundancy etc on views which contain hidden
1078 public jalview.datamodel.CigarArray getViewAsCigars(
1079 boolean selectedRegionOnly)
1081 return new jalview.datamodel.CigarArray(alignment,
1082 (hasHiddenColumns ? colSel : null),
1083 (selectedRegionOnly ? selectionGroup : null));
1087 * return a compact representation of the current alignment selection to pass
1088 * to an analysis function
1090 * @param selectedOnly
1091 * boolean true to just return the selected view
1092 * @return AlignmentView
1094 public jalview.datamodel.AlignmentView getAlignmentView(
1095 boolean selectedOnly)
1097 return getAlignmentView(selectedOnly, false);
1101 * return a compact representation of the current alignment selection to pass
1102 * to an analysis function
1104 * @param selectedOnly
1105 * boolean true to just return the selected view
1107 * boolean true to annotate the alignment view with groups on the
1108 * alignment (and intersecting with selected region if selectedOnly
1110 * @return AlignmentView
1112 public jalview.datamodel.AlignmentView getAlignmentView(
1113 boolean selectedOnly, boolean markGroups)
1115 return new AlignmentView(alignment, colSel, selectionGroup,
1116 hasHiddenColumns, selectedOnly, markGroups);
1120 * This method returns the visible alignment as text, as seen on the GUI, ie
1121 * if columns are hidden they will not be returned in the result. Use this for
1122 * calculating trees, PCA, redundancy etc on views which contain hidden
1127 public String[] getViewAsString(boolean selectedRegionOnly)
1129 String[] selection = null;
1130 SequenceI[] seqs = null;
1132 int start = 0, end = 0;
1133 if (selectedRegionOnly && selectionGroup != null)
1135 iSize = selectionGroup.getSize();
1136 seqs = selectionGroup.getSequencesInOrder(alignment);
1137 start = selectionGroup.getStartRes();
1138 end = selectionGroup.getEndRes() + 1;
1142 iSize = alignment.getHeight();
1143 seqs = alignment.getSequencesArray();
1144 end = alignment.getWidth();
1147 selection = new String[iSize];
1148 if (hasHiddenColumns)
1150 selection = colSel.getVisibleSequenceStrings(start, end, seqs);
1154 for (i = 0; i < iSize; i++)
1156 selection[i] = seqs[i].getSequenceAsString(start, end);
1164 * return visible region boundaries within given column range
1167 * first column (inclusive, from 0)
1169 * last column (exclusive)
1170 * @return int[][] range of {start,end} visible positions
1172 public int[][] getVisibleRegionBoundaries(int min, int max)
1174 Vector regions = new Vector();
1180 if (hasHiddenColumns)
1184 start = colSel.adjustForHiddenColumns(start);
1187 end = colSel.getHiddenBoundaryRight(start);
1198 regions.addElement(new int[]
1201 if (hasHiddenColumns)
1203 start = colSel.adjustForHiddenColumns(end);
1204 start = colSel.getHiddenBoundaryLeft(start) + 1;
1206 } while (end < max);
1208 int[][] startEnd = new int[regions.size()][2];
1210 regions.copyInto(startEnd);
1217 * @return the padGaps
1219 public boolean isPadGaps()
1226 * the padGaps to set
1228 public void setPadGaps(boolean padGaps)
1230 this.padGaps = padGaps;
1234 * apply any post-edit constraints and trigger any calculations needed after
1235 * an edit has been performed on the alignment
1239 public void alignmentChanged(AlignmentViewPanel ap)
1243 alignment.padGaps();
1245 if (autoCalculateConsensus)
1247 updateConsensus(ap);
1249 if (hconsensus != null && autoCalculateConsensus)
1251 updateConservation(ap);
1253 if (autoCalculateStrucConsensus)
1255 updateStrucConsensus(ap);
1258 // Reset endRes of groups if beyond alignment width
1259 int alWidth = alignment.getWidth();
1260 List<SequenceGroup> groups = alignment.getGroups();
1263 for (SequenceGroup sg : groups)
1265 if (sg.getEndRes() > alWidth)
1267 sg.setEndRes(alWidth - 1);
1272 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1274 selectionGroup.setEndRes(alWidth - 1);
1277 resetAllColourSchemes();
1278 calculator.restartWorkers();
1279 // alignment.adjustSequenceAnnotations();
1283 * reset scope and do calculations for all applied colourschemes on alignment
1285 void resetAllColourSchemes()
1287 ColourSchemeI cs = globalColourScheme;
1290 cs.alignmentChanged(alignment, null);
1292 cs.setConsensus(hconsensus);
1293 if (cs.conservationApplied())
1295 cs.setConservation(Conservation.calculateConservation("All",
1296 ResidueProperties.propHash, 3, alignment.getSequences(), 0,
1297 alignment.getWidth(), false, getConsPercGaps(), false));
1301 for (SequenceGroup sg : alignment.getGroups())
1305 sg.cs.alignmentChanged(sg, hiddenRepSequences);
1307 sg.recalcConservation();
1311 protected void initAutoAnnotation()
1313 // TODO: add menu option action that nulls or creates consensus object
1314 // depending on if the user wants to see the annotation or not in a
1315 // specific alignment
1317 if (hconsensus == null && !isDataset)
1319 if (!alignment.isNucleotide())
1321 if (showConservation)
1323 if (conservation == null)
1325 conservation = new AlignmentAnnotation("Conservation",
1326 "Conservation of total alignment less than "
1327 + getConsPercGaps() + "% gaps",
1328 new Annotation[1], 0f, 11f,
1329 AlignmentAnnotation.BAR_GRAPH);
1330 conservation.hasText = true;
1331 conservation.autoCalculated = true;
1332 alignment.addAnnotation(conservation);
1337 if (quality == null)
1339 quality = new AlignmentAnnotation("Quality",
1340 "Alignment Quality based on Blosum62 scores",
1341 new Annotation[1], 0f, 11f,
1342 AlignmentAnnotation.BAR_GRAPH);
1343 quality.hasText = true;
1344 quality.autoCalculated = true;
1345 alignment.addAnnotation(quality);
1351 if (alignment.hasRNAStructure())
1353 strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
1354 new Annotation[1], 0f, 100f,
1355 AlignmentAnnotation.BAR_GRAPH);
1356 strucConsensus.hasText = true;
1357 strucConsensus.autoCalculated = true;
1361 consensus = new AlignmentAnnotation("Consensus", "PID",
1362 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
1363 consensus.hasText = true;
1364 consensus.autoCalculated = true;
1368 alignment.addAnnotation(consensus);
1369 if (strucConsensus != null)
1371 alignment.addAnnotation(strucConsensus);