2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
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
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.viewmodel;
23 import java.awt.Color;
24 import java.beans.PropertyChangeSupport;
25 import java.util.ArrayDeque;
26 import java.util.ArrayList;
27 import java.util.BitSet;
28 import java.util.Deque;
29 import java.util.HashMap;
30 import java.util.Hashtable;
31 import java.util.List;
34 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
35 import jalview.analysis.Conservation;
36 import jalview.api.AlignCalcManagerI;
37 import jalview.api.AlignViewportI;
38 import jalview.api.AlignmentViewPanel;
39 import jalview.api.FeaturesDisplayedI;
40 import jalview.api.ViewStyleI;
41 import jalview.commands.CommandI;
42 import jalview.datamodel.AlignedCodonFrame;
43 import jalview.datamodel.AlignmentAnnotation;
44 import jalview.datamodel.AlignmentI;
45 import jalview.datamodel.AlignmentView;
46 import jalview.datamodel.Annotation;
47 import jalview.datamodel.CigarArray;
48 import jalview.datamodel.ColumnSelection;
49 import jalview.datamodel.HiddenSequences;
50 import jalview.datamodel.ProfilesI;
51 import jalview.datamodel.SearchResultsI;
52 import jalview.datamodel.Sequence;
53 import jalview.datamodel.SequenceCollectionI;
54 import jalview.datamodel.SequenceGroup;
55 import jalview.datamodel.SequenceI;
56 import jalview.renderer.ResidueShader;
57 import jalview.renderer.ResidueShaderI;
58 import jalview.schemes.ColourSchemeI;
59 import jalview.structure.CommandListener;
60 import jalview.structure.StructureSelectionManager;
61 import jalview.structure.VamsasSource;
62 import jalview.util.Comparison;
63 import jalview.util.MapList;
64 import jalview.util.MappingUtils;
65 import jalview.viewmodel.styles.ViewStyle;
66 import jalview.workers.AlignCalcManager;
67 import jalview.workers.ComplementConsensusThread;
68 import jalview.workers.ConsensusThread;
69 import jalview.workers.StrucConsensusThread;
72 * base class holding visualization and analysis attributes and common logic for
73 * an active alignment view displayed in the GUI
78 public abstract class AlignmentViewport implements AlignViewportI,
79 CommandListener, VamsasSource
81 protected ViewportRanges ranges;
83 protected ViewStyleI viewStyle = new ViewStyle();
86 * A viewport that hosts the cDna view of this (protein), or vice versa (if
89 AlignViewportI codingComplement = null;
91 FeaturesDisplayedI featuresDisplayed = null;
93 protected Deque<CommandI> historyList = new ArrayDeque<CommandI>();
95 protected Deque<CommandI> redoList = new ArrayDeque<CommandI>();
99 * @see jalview.api.ViewStyleI#setFontName(java.lang.String)
102 public void setFontName(String name)
104 viewStyle.setFontName(name);
109 * @see jalview.api.ViewStyleI#setFontStyle(int)
112 public void setFontStyle(int style)
114 viewStyle.setFontStyle(style);
119 * @see jalview.api.ViewStyleI#setFontSize(int)
122 public void setFontSize(int size)
124 viewStyle.setFontSize(size);
129 * @see jalview.api.ViewStyleI#getFontStyle()
132 public int getFontStyle()
134 return viewStyle.getFontStyle();
139 * @see jalview.api.ViewStyleI#getFontName()
142 public String getFontName()
144 return viewStyle.getFontName();
149 * @see jalview.api.ViewStyleI#getFontSize()
152 public int getFontSize()
154 return viewStyle.getFontSize();
158 * @param upperCasebold
159 * @see jalview.api.ViewStyleI#setUpperCasebold(boolean)
162 public void setUpperCasebold(boolean upperCasebold)
164 viewStyle.setUpperCasebold(upperCasebold);
169 * @see jalview.api.ViewStyleI#isUpperCasebold()
172 public boolean isUpperCasebold()
174 return viewStyle.isUpperCasebold();
179 * @see jalview.api.ViewStyleI#isSeqNameItalics()
182 public boolean isSeqNameItalics()
184 return viewStyle.isSeqNameItalics();
188 * @param colourByReferenceSeq
189 * @see jalview.api.ViewStyleI#setColourByReferenceSeq(boolean)
192 public void setColourByReferenceSeq(boolean colourByReferenceSeq)
194 viewStyle.setColourByReferenceSeq(colourByReferenceSeq);
199 * @see jalview.api.ViewStyleI#setColourAppliesToAllGroups(boolean)
202 public void setColourAppliesToAllGroups(boolean b)
204 viewStyle.setColourAppliesToAllGroups(b);
209 * @see jalview.api.ViewStyleI#getColourAppliesToAllGroups()
212 public boolean getColourAppliesToAllGroups()
214 return viewStyle.getColourAppliesToAllGroups();
219 * @see jalview.api.ViewStyleI#getAbovePIDThreshold()
222 public boolean getAbovePIDThreshold()
224 return viewStyle.getAbovePIDThreshold();
229 * @see jalview.api.ViewStyleI#setIncrement(int)
232 public void setIncrement(int inc)
234 viewStyle.setIncrement(inc);
239 * @see jalview.api.ViewStyleI#getIncrement()
242 public int getIncrement()
244 return viewStyle.getIncrement();
249 * @see jalview.api.ViewStyleI#setConservationSelected(boolean)
252 public void setConservationSelected(boolean b)
254 viewStyle.setConservationSelected(b);
259 * @see jalview.api.ViewStyleI#setShowHiddenMarkers(boolean)
262 public void setShowHiddenMarkers(boolean show)
264 viewStyle.setShowHiddenMarkers(show);
269 * @see jalview.api.ViewStyleI#getShowHiddenMarkers()
272 public boolean getShowHiddenMarkers()
274 return viewStyle.getShowHiddenMarkers();
279 * @see jalview.api.ViewStyleI#setScaleRightWrapped(boolean)
282 public void setScaleRightWrapped(boolean b)
284 viewStyle.setScaleRightWrapped(b);
289 * @see jalview.api.ViewStyleI#setScaleLeftWrapped(boolean)
292 public void setScaleLeftWrapped(boolean b)
294 viewStyle.setScaleLeftWrapped(b);
299 * @see jalview.api.ViewStyleI#setScaleAboveWrapped(boolean)
302 public void setScaleAboveWrapped(boolean b)
304 viewStyle.setScaleAboveWrapped(b);
309 * @see jalview.api.ViewStyleI#getScaleLeftWrapped()
312 public boolean getScaleLeftWrapped()
314 return viewStyle.getScaleLeftWrapped();
319 * @see jalview.api.ViewStyleI#getScaleAboveWrapped()
322 public boolean getScaleAboveWrapped()
324 return viewStyle.getScaleAboveWrapped();
329 * @see jalview.api.ViewStyleI#getScaleRightWrapped()
332 public boolean getScaleRightWrapped()
334 return viewStyle.getScaleRightWrapped();
339 * @see jalview.api.ViewStyleI#setAbovePIDThreshold(boolean)
342 public void setAbovePIDThreshold(boolean b)
344 viewStyle.setAbovePIDThreshold(b);
349 * @see jalview.api.ViewStyleI#setThreshold(int)
352 public void setThreshold(int thresh)
354 viewStyle.setThreshold(thresh);
359 * @see jalview.api.ViewStyleI#getThreshold()
362 public int getThreshold()
364 return viewStyle.getThreshold();
369 * @see jalview.api.ViewStyleI#getShowJVSuffix()
372 public boolean getShowJVSuffix()
374 return viewStyle.getShowJVSuffix();
379 * @see jalview.api.ViewStyleI#setShowJVSuffix(boolean)
382 public void setShowJVSuffix(boolean b)
384 viewStyle.setShowJVSuffix(b);
389 * @see jalview.api.ViewStyleI#setWrapAlignment(boolean)
392 public void setWrapAlignment(boolean state)
394 viewStyle.setWrapAlignment(state);
399 * @see jalview.api.ViewStyleI#setShowText(boolean)
402 public void setShowText(boolean state)
404 viewStyle.setShowText(state);
409 * @see jalview.api.ViewStyleI#setRenderGaps(boolean)
412 public void setRenderGaps(boolean state)
414 viewStyle.setRenderGaps(state);
419 * @see jalview.api.ViewStyleI#getColourText()
422 public boolean getColourText()
424 return viewStyle.getColourText();
429 * @see jalview.api.ViewStyleI#setColourText(boolean)
432 public void setColourText(boolean state)
434 viewStyle.setColourText(state);
439 * @see jalview.api.ViewStyleI#getWrapAlignment()
442 public boolean getWrapAlignment()
444 return viewStyle.getWrapAlignment();
449 * @see jalview.api.ViewStyleI#getShowText()
452 public boolean getShowText()
454 return viewStyle.getShowText();
459 * @see jalview.api.ViewStyleI#getWrappedWidth()
462 public int getWrappedWidth()
464 return viewStyle.getWrappedWidth();
469 * @see jalview.api.ViewStyleI#setWrappedWidth(int)
472 public void setWrappedWidth(int w)
474 viewStyle.setWrappedWidth(w);
479 * @see jalview.api.ViewStyleI#getCharHeight()
482 public int getCharHeight()
484 return viewStyle.getCharHeight();
489 * @see jalview.api.ViewStyleI#setCharHeight(int)
492 public void setCharHeight(int h)
494 viewStyle.setCharHeight(h);
499 * @see jalview.api.ViewStyleI#getCharWidth()
502 public int getCharWidth()
504 return viewStyle.getCharWidth();
509 * @see jalview.api.ViewStyleI#setCharWidth(int)
512 public void setCharWidth(int w)
514 viewStyle.setCharWidth(w);
519 * @see jalview.api.ViewStyleI#getShowBoxes()
522 public boolean getShowBoxes()
524 return viewStyle.getShowBoxes();
529 * @see jalview.api.ViewStyleI#getShowUnconserved()
532 public boolean getShowUnconserved()
534 return viewStyle.getShowUnconserved();
538 * @param showunconserved
539 * @see jalview.api.ViewStyleI#setShowUnconserved(boolean)
542 public void setShowUnconserved(boolean showunconserved)
544 viewStyle.setShowUnconserved(showunconserved);
549 * @see jalview.api.ViewStyleI#setSeqNameItalics(boolean)
552 public void setSeqNameItalics(boolean default1)
554 viewStyle.setSeqNameItalics(default1);
558 * alignment displayed in the viewport. Please use get/setter
560 protected AlignmentI alignment;
563 public AlignmentI getAlignment()
569 public char getGapCharacter()
571 return alignment.getGapCharacter();
574 protected String sequenceSetID;
577 * probably unused indicator that view is of a dataset rather than an
580 protected boolean isDataset = false;
582 public void setDataset(boolean b)
587 public boolean isDataset()
592 private Map<SequenceI, SequenceCollectionI> hiddenRepSequences;
594 protected ColumnSelection colSel = new ColumnSelection();
596 public boolean autoCalculateConsensus = true;
598 protected boolean autoCalculateStrucConsensus = true;
600 protected boolean ignoreGapsInConsensusCalculation = false;
602 protected ResidueShaderI residueShading;
605 public void setGlobalColourScheme(ColourSchemeI cs)
607 // TODO: logic refactored from AlignFrame changeColour -
608 // TODO: autorecalc stuff should be changed to rely on the worker system
609 // check to see if we should implement a changeColour(cs) method rather than
610 // put the logic in here
611 // - means that caller decides if they want to just modify state and defer
612 // calculation till later or to do all calculations in thread.
616 * only instantiate alignment colouring once, thereafter update it;
617 * this means that any conservation or PID threshold settings
618 * persist when the alignment colour scheme is changed
620 if (residueShading == null)
622 residueShading = new ResidueShader(viewStyle);
624 residueShading.setColourScheme(cs);
626 // TODO: do threshold and increment belong in ViewStyle or ResidueShader?
627 // ...problem: groups need these, but do not currently have a ViewStyle
631 if (getConservationSelected())
633 residueShading.setConservation(hconservation);
635 residueShading.alignmentChanged(alignment, hiddenRepSequences);
639 * if 'apply colour to all groups' is selected... do so
640 * (but don't transfer any colour threshold settings to groups)
642 if (getColourAppliesToAllGroups())
644 for (SequenceGroup sg : getAlignment().getGroups())
647 * retain any colour thresholds per group while
648 * changing choice of colour scheme (JAL-2386)
650 sg.setColourScheme(cs);
653 sg.getGroupColourScheme()
654 .alignmentChanged(sg, hiddenRepSequences);
661 public ColourSchemeI getGlobalColourScheme()
663 return residueShading == null ? null : residueShading
668 public ResidueShaderI getResidueShading()
670 return residueShading;
673 protected AlignmentAnnotation consensus;
675 protected AlignmentAnnotation complementConsensus;
677 protected AlignmentAnnotation gapcounts;
679 protected AlignmentAnnotation strucConsensus;
681 protected AlignmentAnnotation conservation;
683 protected AlignmentAnnotation quality;
685 protected AlignmentAnnotation[] groupConsensus;
687 protected AlignmentAnnotation[] groupConservation;
690 * results of alignment consensus analysis for visible portion of view
692 protected ProfilesI hconsensus = null;
695 * results of cDNA complement consensus visible portion of view
697 protected Hashtable[] hcomplementConsensus = null;
700 * results of secondary structure base pair consensus for visible portion of
703 protected Hashtable[] hStrucConsensus = null;
705 protected Conservation hconservation = null;
708 public void setConservation(Conservation cons)
710 hconservation = cons;
714 * percentage gaps allowed in a column before all amino acid properties should
715 * be considered unconserved
717 int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
720 public int getConsPercGaps()
726 public void setSequenceConsensusHash(ProfilesI hconsensus)
728 this.hconsensus = hconsensus;
732 public void setComplementConsensusHash(Hashtable[] hconsensus)
734 this.hcomplementConsensus = hconsensus;
738 public ProfilesI getSequenceConsensusHash()
744 public Hashtable[] getComplementConsensusHash()
746 return hcomplementConsensus;
750 public Hashtable[] getRnaStructureConsensusHash()
752 return hStrucConsensus;
756 public void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus)
758 this.hStrucConsensus = hStrucConsensus;
763 public AlignmentAnnotation getAlignmentQualityAnnot()
769 public AlignmentAnnotation getAlignmentConservationAnnotation()
775 public AlignmentAnnotation getAlignmentConsensusAnnotation()
781 public AlignmentAnnotation getAlignmentGapAnnotation()
787 public AlignmentAnnotation getComplementConsensusAnnotation()
789 return complementConsensus;
793 public AlignmentAnnotation getAlignmentStrucConsensusAnnotation()
795 return strucConsensus;
798 protected AlignCalcManagerI calculator = new AlignCalcManager();
801 * trigger update of conservation annotation
803 public void updateConservation(final AlignmentViewPanel ap)
805 // see note in mantis : issue number 8585
806 if (alignment.isNucleotide()
807 || (conservation == null && quality == null)
808 || !autoCalculateConsensus)
813 .getRegisteredWorkersOfClass(jalview.workers.ConservationThread.class) == null)
815 calculator.registerWorker(new jalview.workers.ConservationThread(
821 * trigger update of consensus annotation
823 public void updateConsensus(final AlignmentViewPanel ap)
825 // see note in mantis : issue number 8585
826 if (consensus == null || !autoCalculateConsensus)
830 if (calculator.getRegisteredWorkersOfClass(ConsensusThread.class) == null)
832 calculator.registerWorker(new ConsensusThread(this, ap));
836 * A separate thread to compute cDNA consensus for a protein alignment
837 * which has mapping to cDNA
839 final AlignmentI al = this.getAlignment();
840 if (!al.isNucleotide() && al.getCodonFrames() != null
841 && !al.getCodonFrames().isEmpty())
844 * fudge - check first for protein-to-nucleotide mappings
845 * (we don't want to do this for protein-to-protein)
847 boolean doConsensus = false;
848 for (AlignedCodonFrame mapping : al.getCodonFrames())
850 // TODO hold mapping type e.g. dna-to-protein in AlignedCodonFrame?
851 MapList[] mapLists = mapping.getdnaToProt();
852 // mapLists can be empty if project load has not finished resolving seqs
853 if (mapLists.length > 0 && mapLists[0].getFromRatio() == 3)
862 .getRegisteredWorkersOfClass(ComplementConsensusThread.class) == null)
865 .registerWorker(new ComplementConsensusThread(this, ap));
871 // --------START Structure Conservation
872 public void updateStrucConsensus(final AlignmentViewPanel ap)
874 if (autoCalculateStrucConsensus && strucConsensus == null
875 && alignment.isNucleotide() && alignment.hasRNAStructure())
877 // secondary structure has been added - so init the consensus line
881 // see note in mantis : issue number 8585
882 if (strucConsensus == null || !autoCalculateStrucConsensus)
886 if (calculator.getRegisteredWorkersOfClass(StrucConsensusThread.class) == null)
888 calculator.registerWorker(new StrucConsensusThread(this, ap));
892 public boolean isCalcInProgress()
894 return calculator.isWorking();
898 public boolean isCalculationInProgress(
899 AlignmentAnnotation alignmentAnnotation)
901 if (!alignmentAnnotation.autoCalculated)
905 if (calculator.workingInvolvedWith(alignmentAnnotation))
907 // System.err.println("grey out ("+alignmentAnnotation.label+")");
913 public void setAlignment(AlignmentI align)
915 this.alignment = align;
919 * Clean up references when this viewport is closed
922 public void dispose()
925 * defensively null out references to large objects in case
926 * this object is not garbage collected (as if!)
929 complementConsensus = null;
930 strucConsensus = null;
933 groupConsensus = null;
934 groupConservation = null;
936 hcomplementConsensus = null;
937 // colour scheme may hold reference to consensus
938 residueShading = null;
939 // TODO remove listeners from changeSupport?
940 changeSupport = null;
945 public boolean isClosed()
947 // TODO: check that this isClosed is only true after panel is closed, not
948 // before it is fully constructed.
949 return alignment == null;
953 public AlignCalcManagerI getCalcManager()
959 * should conservation rows be shown for groups
961 protected boolean showGroupConservation = false;
964 * should consensus rows be shown for groups
966 protected boolean showGroupConsensus = false;
969 * should consensus profile be rendered by default
971 protected boolean showSequenceLogo = false;
974 * should consensus profile be rendered normalised to row height
976 protected boolean normaliseSequenceLogo = false;
979 * should consensus histograms be rendered by default
981 protected boolean showConsensusHistogram = true;
984 * @return the showConsensusProfile
987 public boolean isShowSequenceLogo()
989 return showSequenceLogo;
993 * @param showSequenceLogo
996 public void setShowSequenceLogo(boolean showSequenceLogo)
998 if (showSequenceLogo != this.showSequenceLogo)
1000 // TODO: decouple settings setting from calculation when refactoring
1001 // annotation update method from alignframe to viewport
1002 this.showSequenceLogo = showSequenceLogo;
1003 calculator.updateAnnotationFor(ConsensusThread.class);
1004 calculator.updateAnnotationFor(ComplementConsensusThread.class);
1005 calculator.updateAnnotationFor(StrucConsensusThread.class);
1007 this.showSequenceLogo = showSequenceLogo;
1011 * @param showConsensusHistogram
1012 * the showConsensusHistogram to set
1014 public void setShowConsensusHistogram(boolean showConsensusHistogram)
1016 this.showConsensusHistogram = showConsensusHistogram;
1020 * @return the showGroupConservation
1022 public boolean isShowGroupConservation()
1024 return showGroupConservation;
1028 * @param showGroupConservation
1029 * the showGroupConservation to set
1031 public void setShowGroupConservation(boolean showGroupConservation)
1033 this.showGroupConservation = showGroupConservation;
1037 * @return the showGroupConsensus
1039 public boolean isShowGroupConsensus()
1041 return showGroupConsensus;
1045 * @param showGroupConsensus
1046 * the showGroupConsensus to set
1048 public void setShowGroupConsensus(boolean showGroupConsensus)
1050 this.showGroupConsensus = showGroupConsensus;
1055 * @return flag to indicate if the consensus histogram should be rendered by
1059 public boolean isShowConsensusHistogram()
1061 return this.showConsensusHistogram;
1065 * when set, updateAlignment will always ensure sequences are of equal length
1067 private boolean padGaps = false;
1070 * when set, alignment should be reordered according to a newly opened tree
1072 public boolean sortByTree = false;
1077 * @return null or the currently selected sequence region
1080 public SequenceGroup getSelectionGroup()
1082 return selectionGroup;
1086 * Set the selection group for this window. Also sets the current alignment as
1087 * the context for the group, if it does not already have one.
1090 * - group holding references to sequences in this alignment view
1094 public void setSelectionGroup(SequenceGroup sg)
1096 selectionGroup = sg;
1097 if (sg != null && sg.getContext() == null)
1099 sg.setContext(alignment);
1103 public void setHiddenColumns(ColumnSelection colsel)
1105 this.colSel = colsel;
1109 public ColumnSelection getColumnSelection()
1115 public void setColumnSelection(ColumnSelection colSel)
1117 this.colSel = colSel;
1120 updateHiddenColumns();
1122 isColSelChanged(true);
1130 public Map<SequenceI, SequenceCollectionI> getHiddenRepSequences()
1132 return hiddenRepSequences;
1136 public void setHiddenRepSequences(
1137 Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
1139 this.hiddenRepSequences = hiddenRepSequences;
1143 public boolean hasSelectedColumns()
1145 ColumnSelection columnSelection = getColumnSelection();
1146 return columnSelection != null && columnSelection.hasSelectedColumns();
1150 public boolean hasHiddenColumns()
1152 return colSel != null && colSel.hasHiddenColumns();
1155 public void updateHiddenColumns()
1157 // this method doesn't really do anything now. But - it could, since a
1158 // column Selection could be in the process of modification
1159 // hasHiddenColumns = colSel.hasHiddenColumns();
1163 public boolean hasHiddenRows()
1165 return alignment.getHiddenSequences().getSize() > 0;
1168 protected SequenceGroup selectionGroup;
1170 public void setSequenceSetId(String newid)
1172 if (sequenceSetID != null)
1175 .println("Warning - overwriting a sequenceSetId for a viewport!");
1177 sequenceSetID = new String(newid);
1181 public String getSequenceSetId()
1183 if (sequenceSetID == null)
1185 sequenceSetID = alignment.hashCode() + "";
1188 return sequenceSetID;
1192 * unique viewId for synchronizing state (e.g. with stored Jalview Project)
1195 protected String viewId = null;
1198 public String getViewId()
1202 viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
1207 public void setIgnoreGapsConsensus(boolean b, AlignmentViewPanel ap)
1209 ignoreGapsInConsensusCalculation = b;
1212 updateConsensus(ap);
1213 if (residueShading != null)
1215 residueShading.setThreshold(residueShading.getThreshold(),
1216 ignoreGapsInConsensusCalculation);
1222 private long sgrouphash = -1, colselhash = -1;
1225 * checks current SelectionGroup against record of last hash value, and
1229 * update the record of last hash value
1231 * @return true if SelectionGroup changed since last call (when b is true)
1233 public boolean isSelectionGroupChanged(boolean b)
1235 int hc = (selectionGroup == null || selectionGroup.getSize() == 0) ? -1
1236 : selectionGroup.hashCode();
1237 if (hc != -1 && hc != sgrouphash)
1249 * checks current colsel against record of last hash value, and optionally
1253 * update the record of last hash value
1254 * @return true if colsel changed since last call (when b is true)
1256 public boolean isColSelChanged(boolean b)
1258 int hc = (colSel == null || colSel.isEmpty()) ? -1 : colSel.hashCode();
1259 if (hc != -1 && hc != colselhash)
1271 public boolean isIgnoreGapsConsensus()
1273 return ignoreGapsInConsensusCalculation;
1276 // property change stuff
1277 // JBPNote Prolly only need this in the applet version.
1278 private PropertyChangeSupport changeSupport = new PropertyChangeSupport(
1281 protected boolean showConservation = true;
1283 protected boolean showQuality = true;
1285 protected boolean showConsensus = true;
1287 protected boolean showOccupancy = true;
1289 private Map<SequenceI, Color> sequenceColours = new HashMap<SequenceI, Color>();
1291 protected SequenceAnnotationOrder sortAnnotationsBy = null;
1293 protected boolean showAutocalculatedAbove;
1296 * when set, view will scroll to show the highlighted position
1298 private boolean followHighlight = true;
1301 * Property change listener for changes in alignment
1306 public void addPropertyChangeListener(
1307 java.beans.PropertyChangeListener listener)
1309 changeSupport.addPropertyChangeListener(listener);
1318 public void removePropertyChangeListener(
1319 java.beans.PropertyChangeListener listener)
1321 changeSupport.removePropertyChangeListener(listener);
1325 * Property change listener for changes in alignment
1334 public void firePropertyChange(String prop, Object oldvalue,
1337 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
1340 // common hide/show column stuff
1342 public void hideSelectedColumns()
1344 if (colSel.isEmpty())
1349 colSel.hideSelectedColumns();
1350 setSelectionGroup(null);
1351 isColSelChanged(true);
1354 public void hideColumns(int start, int end)
1358 colSel.hideColumns(start);
1362 colSel.hideColumns(start, end);
1364 isColSelChanged(true);
1367 public void showColumn(int col)
1369 colSel.revealHiddenColumns(col);
1370 isColSelChanged(true);
1373 public void showAllHiddenColumns()
1375 colSel.revealAllHiddenColumns();
1376 isColSelChanged(true);
1379 // common hide/show seq stuff
1380 public void showAllHiddenSeqs()
1382 if (alignment.getHiddenSequences().getSize() > 0)
1384 if (selectionGroup == null)
1386 selectionGroup = new SequenceGroup();
1387 selectionGroup.setEndRes(alignment.getWidth() - 1);
1389 List<SequenceI> tmp = alignment.getHiddenSequences().showAll(
1390 hiddenRepSequences);
1391 for (SequenceI seq : tmp)
1393 selectionGroup.addSequence(seq, false);
1394 setSequenceAnnotationsVisible(seq, true);
1397 hiddenRepSequences = null;
1399 firePropertyChange("alignment", null, alignment.getSequences());
1400 // used to set hasHiddenRows/hiddenRepSequences here, after the property
1406 public void showSequence(int index)
1408 List<SequenceI> tmp = alignment.getHiddenSequences().showSequence(
1409 index, hiddenRepSequences);
1412 if (selectionGroup == null)
1414 selectionGroup = new SequenceGroup();
1415 selectionGroup.setEndRes(alignment.getWidth() - 1);
1418 for (SequenceI seq : tmp)
1420 selectionGroup.addSequence(seq, false);
1421 setSequenceAnnotationsVisible(seq, true);
1423 firePropertyChange("alignment", null, alignment.getSequences());
1428 public void hideAllSelectedSeqs()
1430 if (selectionGroup == null || selectionGroup.getSize() < 1)
1435 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1439 setSelectionGroup(null);
1442 public void hideSequence(SequenceI[] seq)
1446 for (int i = 0; i < seq.length; i++)
1448 alignment.getHiddenSequences().hideSequence(seq[i]);
1449 setSequenceAnnotationsVisible(seq[i], false);
1451 firePropertyChange("alignment", null, alignment.getSequences());
1456 * Hides the specified sequence, or the sequences it represents
1459 * the sequence to hide, or keep as representative
1460 * @param representGroup
1461 * if true, hide the current selection group except for the
1462 * representative sequence
1464 public void hideSequences(SequenceI sequence, boolean representGroup)
1466 if (selectionGroup == null || selectionGroup.getSize() < 1)
1468 hideSequence(new SequenceI[] { sequence });
1474 hideRepSequences(sequence, selectionGroup);
1475 setSelectionGroup(null);
1479 int gsize = selectionGroup.getSize();
1480 SequenceI[] hseqs = selectionGroup.getSequences().toArray(
1481 new SequenceI[gsize]);
1483 hideSequence(hseqs);
1484 setSelectionGroup(null);
1489 * Set visibility for any annotations for the given sequence.
1493 protected void setSequenceAnnotationsVisible(SequenceI sequenceI,
1496 AlignmentAnnotation[] anns = alignment.getAlignmentAnnotation();
1499 for (AlignmentAnnotation ann : anns)
1501 if (ann.sequenceRef == sequenceI)
1503 ann.visible = visible;
1509 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1511 int sSize = sg.getSize();
1517 if (hiddenRepSequences == null)
1519 hiddenRepSequences = new Hashtable<SequenceI, SequenceCollectionI>();
1522 hiddenRepSequences.put(repSequence, sg);
1524 // Hide all sequences except the repSequence
1525 SequenceI[] seqs = new SequenceI[sSize - 1];
1527 for (int i = 0; i < sSize; i++)
1529 if (sg.getSequenceAt(i) != repSequence)
1531 if (index == sSize - 1)
1536 seqs[index++] = sg.getSequenceAt(i);
1539 sg.setSeqrep(repSequence); // note: not done in 2.7applet
1540 sg.setHidereps(true); // note: not done in 2.7applet
1547 * @return null or the current reference sequence
1549 public SequenceI getReferenceSeq()
1551 return alignment.getSeqrep();
1556 * @return true iff seq is the reference for the alignment
1558 public boolean isReferenceSeq(SequenceI seq)
1560 return alignment.getSeqrep() == seq;
1566 * @return true if there are sequences represented by this sequence that are
1569 public boolean isHiddenRepSequence(SequenceI seq)
1571 return (hiddenRepSequences != null && hiddenRepSequences
1578 * @return null or a sequence group containing the sequences that seq
1581 public SequenceGroup getRepresentedSequences(SequenceI seq)
1583 return (SequenceGroup) (hiddenRepSequences == null ? null
1584 : hiddenRepSequences.get(seq));
1588 public int adjustForHiddenSeqs(int alignmentIndex)
1590 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1595 public void invertColumnSelection()
1597 colSel.invertColumnSelection(0, alignment.getWidth());
1601 public SequenceI[] getSelectionAsNewSequence()
1603 SequenceI[] sequences;
1604 // JBPNote: Need to test jalviewLite.getSelectedSequencesAsAlignmentFrom -
1605 // this was the only caller in the applet for this method
1606 // JBPNote: in applet, this method returned references to the alignment
1607 // sequences, and it did not honour the presence/absence of annotation
1608 // attached to the alignment (probably!)
1609 if (selectionGroup == null || selectionGroup.getSize() == 0)
1611 sequences = alignment.getSequencesArray();
1612 AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
1613 for (int i = 0; i < sequences.length; i++)
1615 // construct new sequence with subset of visible annotation
1616 sequences[i] = new Sequence(sequences[i], annots);
1621 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1628 public SequenceI[] getSequenceSelection()
1630 SequenceI[] sequences = null;
1631 if (selectionGroup != null)
1633 sequences = selectionGroup.getSequencesInOrder(alignment);
1635 if (sequences == null)
1637 sequences = alignment.getSequencesArray();
1643 public CigarArray getViewAsCigars(boolean selectedRegionOnly)
1645 return new CigarArray(alignment, colSel,
1646 (selectedRegionOnly ? selectionGroup : null));
1650 public jalview.datamodel.AlignmentView getAlignmentView(
1651 boolean selectedOnly)
1653 return getAlignmentView(selectedOnly, false);
1657 public jalview.datamodel.AlignmentView getAlignmentView(
1658 boolean selectedOnly, boolean markGroups)
1660 return new AlignmentView(alignment, colSel, selectionGroup,
1661 colSel != null && colSel.hasHiddenColumns(), selectedOnly,
1666 public String[] getViewAsString(boolean selectedRegionOnly)
1668 return getViewAsString(selectedRegionOnly, true);
1672 public String[] getViewAsString(boolean selectedRegionOnly,
1673 boolean exportHiddenSeqs)
1675 String[] selection = null;
1676 SequenceI[] seqs = null;
1678 int start = 0, end = 0;
1679 if (selectedRegionOnly && selectionGroup != null)
1681 iSize = selectionGroup.getSize();
1682 seqs = selectionGroup.getSequencesInOrder(alignment);
1683 start = selectionGroup.getStartRes();
1684 end = selectionGroup.getEndRes() + 1;
1688 if (hasHiddenRows() && exportHiddenSeqs)
1690 AlignmentI fullAlignment = alignment.getHiddenSequences()
1691 .getFullAlignment();
1692 iSize = fullAlignment.getHeight();
1693 seqs = fullAlignment.getSequencesArray();
1694 end = fullAlignment.getWidth();
1698 iSize = alignment.getHeight();
1699 seqs = alignment.getSequencesArray();
1700 end = alignment.getWidth();
1704 selection = new String[iSize];
1705 if (colSel != null && colSel.hasHiddenColumns())
1707 selection = colSel.getVisibleSequenceStrings(start, end, seqs);
1711 for (i = 0; i < iSize; i++)
1713 selection[i] = seqs[i].getSequenceAsString(start, end);
1721 public List<int[]> getVisibleRegionBoundaries(int min, int max)
1723 ArrayList<int[]> regions = new ArrayList<int[]>();
1729 if (colSel != null && colSel.hasHiddenColumns())
1733 start = colSel.adjustForHiddenColumns(start);
1736 end = colSel.getHiddenBoundaryRight(start);
1747 regions.add(new int[] { start, end });
1749 if (colSel != null && colSel.hasHiddenColumns())
1751 start = colSel.adjustForHiddenColumns(end);
1752 start = colSel.getHiddenBoundaryLeft(start) + 1;
1754 } while (end < max);
1756 int[][] startEnd = new int[regions.size()][2];
1762 public List<AlignmentAnnotation> getVisibleAlignmentAnnotation(
1763 boolean selectedOnly)
1765 ArrayList<AlignmentAnnotation> ala = new ArrayList<AlignmentAnnotation>();
1766 AlignmentAnnotation[] aa;
1767 if ((aa = alignment.getAlignmentAnnotation()) != null)
1769 for (AlignmentAnnotation annot : aa)
1771 AlignmentAnnotation clone = new AlignmentAnnotation(annot);
1772 if (selectedOnly && selectionGroup != null)
1774 colSel.makeVisibleAnnotation(selectionGroup.getStartRes(),
1775 selectionGroup.getEndRes(), clone);
1779 colSel.makeVisibleAnnotation(clone);
1788 public boolean isPadGaps()
1794 public void setPadGaps(boolean padGaps)
1796 this.padGaps = padGaps;
1800 * apply any post-edit constraints and trigger any calculations needed after
1801 * an edit has been performed on the alignment
1806 public void alignmentChanged(AlignmentViewPanel ap)
1810 alignment.padGaps();
1812 if (autoCalculateConsensus)
1814 updateConsensus(ap);
1816 if (hconsensus != null && autoCalculateConsensus)
1818 updateConservation(ap);
1820 if (autoCalculateStrucConsensus)
1822 updateStrucConsensus(ap);
1825 // Reset endRes of groups if beyond alignment width
1826 int alWidth = alignment.getWidth();
1827 List<SequenceGroup> groups = alignment.getGroups();
1830 for (SequenceGroup sg : groups)
1832 if (sg.getEndRes() > alWidth)
1834 sg.setEndRes(alWidth - 1);
1839 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1841 selectionGroup.setEndRes(alWidth - 1);
1844 updateAllColourSchemes();
1845 calculator.restartWorkers();
1846 // alignment.adjustSequenceAnnotations();
1850 * reset scope and do calculations for all applied colourschemes on alignment
1852 void updateAllColourSchemes()
1854 ResidueShaderI rs = residueShading;
1857 rs.alignmentChanged(alignment, hiddenRepSequences);
1859 rs.setConsensus(hconsensus);
1860 if (rs.conservationApplied())
1862 rs.setConservation(Conservation.calculateConservation("All",
1863 alignment.getSequences(), 0, alignment.getWidth(), false,
1864 getConsPercGaps(), false));
1868 for (SequenceGroup sg : alignment.getGroups())
1872 sg.cs.alignmentChanged(sg, hiddenRepSequences);
1874 sg.recalcConservation();
1878 protected void initAutoAnnotation()
1880 // TODO: add menu option action that nulls or creates consensus object
1881 // depending on if the user wants to see the annotation or not in a
1882 // specific alignment
1884 if (hconsensus == null && !isDataset)
1886 if (!alignment.isNucleotide())
1895 consensus = new AlignmentAnnotation("Consensus", "PID",
1896 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
1897 initConsensus(consensus);
1900 initComplementConsensus();
1905 * If this is a protein alignment and there are mappings to cDNA, adds the
1906 * cDNA consensus annotation and returns true, else returns false.
1908 public boolean initComplementConsensus()
1910 if (!alignment.isNucleotide())
1912 final List<AlignedCodonFrame> codonMappings = alignment
1914 if (codonMappings != null && !codonMappings.isEmpty())
1916 boolean doConsensus = false;
1917 for (AlignedCodonFrame mapping : codonMappings)
1919 // TODO hold mapping type e.g. dna-to-protein in AlignedCodonFrame?
1920 MapList[] mapLists = mapping.getdnaToProt();
1921 // mapLists can be empty if project load has not finished resolving
1923 if (mapLists.length > 0 && mapLists[0].getFromRatio() == 3)
1931 complementConsensus = new AlignmentAnnotation("cDNA Consensus",
1932 "PID for cDNA", new Annotation[1], 0f, 100f,
1933 AlignmentAnnotation.BAR_GRAPH);
1934 initConsensus(complementConsensus);
1942 private void initConsensus(AlignmentAnnotation aa)
1945 aa.autoCalculated = true;
1949 alignment.addAnnotation(aa);
1953 // these should be extracted from the view model - style and settings for
1954 // derived annotation
1955 private void initGapCounts()
1959 gapcounts = new AlignmentAnnotation("Occupancy",
1960 "Number of aligned positions", new Annotation[1], 0f,
1961 alignment.getHeight(), AlignmentAnnotation.BAR_GRAPH);
1962 gapcounts.hasText = true;
1963 gapcounts.autoCalculated = true;
1964 gapcounts.scaleColLabel = true;
1965 gapcounts.graph = AlignmentAnnotation.BAR_GRAPH;
1967 alignment.addAnnotation(gapcounts);
1971 private void initConservation()
1973 if (showConservation)
1975 if (conservation == null)
1977 conservation = new AlignmentAnnotation("Conservation",
1978 "Conservation of total alignment less than "
1979 + getConsPercGaps() + "% gaps", new Annotation[1],
1980 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
1981 conservation.hasText = true;
1982 conservation.autoCalculated = true;
1983 alignment.addAnnotation(conservation);
1988 private void initQuality()
1992 if (quality == null)
1994 quality = new AlignmentAnnotation("Quality",
1995 "Alignment Quality based on Blosum62 scores",
1996 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
1997 quality.hasText = true;
1998 quality.autoCalculated = true;
1999 alignment.addAnnotation(quality);
2004 private void initRNAStructure()
2006 if (alignment.hasRNAStructure() && strucConsensus == null)
2008 strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
2009 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
2010 strucConsensus.hasText = true;
2011 strucConsensus.autoCalculated = true;
2015 alignment.addAnnotation(strucConsensus);
2023 * @see jalview.api.AlignViewportI#calcPanelHeight()
2026 public int calcPanelHeight()
2028 // setHeight of panels
2029 AlignmentAnnotation[] anns = getAlignment().getAlignmentAnnotation();
2031 int charHeight = getCharHeight();
2034 BitSet graphgrp = new BitSet();
2035 for (AlignmentAnnotation aa : anns)
2039 System.err.println("Null annotation row: ignoring.");
2046 if (aa.graphGroup > -1)
2048 if (graphgrp.get(aa.graphGroup))
2054 graphgrp.set(aa.graphGroup);
2061 aa.height += charHeight;
2071 aa.height += aa.graphHeight;
2079 height += aa.height;
2091 public void updateGroupAnnotationSettings(boolean applyGlobalSettings,
2092 boolean preserveNewGroupSettings)
2094 boolean updateCalcs = false;
2095 boolean conv = isShowGroupConservation();
2096 boolean cons = isShowGroupConsensus();
2097 boolean showprf = isShowSequenceLogo();
2098 boolean showConsHist = isShowConsensusHistogram();
2099 boolean normLogo = isNormaliseSequenceLogo();
2102 * TODO reorder the annotation rows according to group/sequence ordering on
2105 boolean sortg = true;
2107 // remove old automatic annotation
2108 // add any new annotation
2110 // intersect alignment annotation with alignment groups
2112 AlignmentAnnotation[] aan = alignment.getAlignmentAnnotation();
2113 List<SequenceGroup> oldrfs = new ArrayList<SequenceGroup>();
2116 for (int an = 0; an < aan.length; an++)
2118 if (aan[an].autoCalculated && aan[an].groupRef != null)
2120 oldrfs.add(aan[an].groupRef);
2121 alignment.deleteAnnotation(aan[an], false);
2125 if (alignment.getGroups() != null)
2127 for (SequenceGroup sg : alignment.getGroups())
2129 updateCalcs = false;
2130 if (applyGlobalSettings
2131 || (!preserveNewGroupSettings && !oldrfs.contains(sg)))
2133 // set defaults for this group's conservation/consensus
2134 sg.setshowSequenceLogo(showprf);
2135 sg.setShowConsensusHistogram(showConsHist);
2136 sg.setNormaliseSequenceLogo(normLogo);
2141 alignment.addAnnotation(sg.getConservationRow(), 0);
2146 alignment.addAnnotation(sg.getConsensus(), 0);
2148 // refresh the annotation rows
2151 sg.recalcConservation();
2159 public boolean isDisplayReferenceSeq()
2161 return alignment.hasSeqrep() && viewStyle.isDisplayReferenceSeq();
2165 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
2167 viewStyle.setDisplayReferenceSeq(displayReferenceSeq);
2171 public boolean isColourByReferenceSeq()
2173 return alignment.hasSeqrep() && viewStyle.isColourByReferenceSeq();
2177 public Color getSequenceColour(SequenceI seq)
2179 Color sqc = sequenceColours.get(seq);
2180 return (sqc == null ? Color.white : sqc);
2184 public void setSequenceColour(SequenceI seq, Color col)
2188 sequenceColours.remove(seq);
2192 sequenceColours.put(seq, col);
2197 public void updateSequenceIdColours()
2199 for (SequenceGroup sg : alignment.getGroups())
2201 if (sg.idColour != null)
2203 for (SequenceI s : sg.getSequences(getHiddenRepSequences()))
2205 sequenceColours.put(s, sg.idColour);
2212 public void clearSequenceColours()
2214 sequenceColours.clear();
2218 public AlignViewportI getCodingComplement()
2220 return this.codingComplement;
2224 * Set this as the (cDna/protein) complement of the given viewport. Also
2225 * ensures the reverse relationship is set on the given viewport.
2228 public void setCodingComplement(AlignViewportI av)
2232 System.err.println("Ignoring recursive setCodingComplement request");
2236 this.codingComplement = av;
2237 // avoid infinite recursion!
2238 if (av.getCodingComplement() != this)
2240 av.setCodingComplement(this);
2246 public boolean isNucleotide()
2248 return getAlignment() == null ? false : getAlignment().isNucleotide();
2252 public FeaturesDisplayedI getFeaturesDisplayed()
2254 return featuresDisplayed;
2258 public void setFeaturesDisplayed(FeaturesDisplayedI featuresDisplayedI)
2260 featuresDisplayed = featuresDisplayedI;
2264 public boolean areFeaturesDisplayed()
2266 return featuresDisplayed != null
2267 && featuresDisplayed.getRegisteredFeaturesCount() > 0;
2274 * features are displayed if true
2277 public void setShowSequenceFeatures(boolean b)
2279 viewStyle.setShowSequenceFeatures(b);
2283 public boolean isShowSequenceFeatures()
2285 return viewStyle.isShowSequenceFeatures();
2289 public void setShowSequenceFeaturesHeight(boolean selected)
2291 viewStyle.setShowSequenceFeaturesHeight(selected);
2295 public boolean isShowSequenceFeaturesHeight()
2297 return viewStyle.isShowSequenceFeaturesHeight();
2301 public void setShowAnnotation(boolean b)
2303 viewStyle.setShowAnnotation(b);
2307 public boolean isShowAnnotation()
2309 return viewStyle.isShowAnnotation();
2313 public boolean isRightAlignIds()
2315 return viewStyle.isRightAlignIds();
2319 public void setRightAlignIds(boolean rightAlignIds)
2321 viewStyle.setRightAlignIds(rightAlignIds);
2325 public boolean getConservationSelected()
2327 return viewStyle.getConservationSelected();
2331 public void setShowBoxes(boolean state)
2333 viewStyle.setShowBoxes(state);
2338 * @see jalview.api.ViewStyleI#getTextColour()
2341 public Color getTextColour()
2343 return viewStyle.getTextColour();
2348 * @see jalview.api.ViewStyleI#getTextColour2()
2351 public Color getTextColour2()
2353 return viewStyle.getTextColour2();
2358 * @see jalview.api.ViewStyleI#getThresholdTextColour()
2361 public int getThresholdTextColour()
2363 return viewStyle.getThresholdTextColour();
2368 * @see jalview.api.ViewStyleI#isConservationColourSelected()
2371 public boolean isConservationColourSelected()
2373 return viewStyle.isConservationColourSelected();
2378 * @see jalview.api.ViewStyleI#isRenderGaps()
2381 public boolean isRenderGaps()
2383 return viewStyle.isRenderGaps();
2388 * @see jalview.api.ViewStyleI#isShowColourText()
2391 public boolean isShowColourText()
2393 return viewStyle.isShowColourText();
2397 * @param conservationColourSelected
2398 * @see jalview.api.ViewStyleI#setConservationColourSelected(boolean)
2401 public void setConservationColourSelected(
2402 boolean conservationColourSelected)
2404 viewStyle.setConservationColourSelected(conservationColourSelected);
2408 * @param showColourText
2409 * @see jalview.api.ViewStyleI#setShowColourText(boolean)
2412 public void setShowColourText(boolean showColourText)
2414 viewStyle.setShowColourText(showColourText);
2419 * @see jalview.api.ViewStyleI#setTextColour(java.awt.Color)
2422 public void setTextColour(Color textColour)
2424 viewStyle.setTextColour(textColour);
2428 * @param thresholdTextColour
2429 * @see jalview.api.ViewStyleI#setThresholdTextColour(int)
2432 public void setThresholdTextColour(int thresholdTextColour)
2434 viewStyle.setThresholdTextColour(thresholdTextColour);
2438 * @param textColour2
2439 * @see jalview.api.ViewStyleI#setTextColour2(java.awt.Color)
2442 public void setTextColour2(Color textColour2)
2444 viewStyle.setTextColour2(textColour2);
2448 public ViewStyleI getViewStyle()
2450 return new ViewStyle(viewStyle);
2454 public void setViewStyle(ViewStyleI settingsForView)
2456 viewStyle = new ViewStyle(settingsForView);
2457 if (residueShading != null)
2459 residueShading.setConservationApplied(settingsForView
2460 .isConservationColourSelected());
2465 public boolean sameStyle(ViewStyleI them)
2467 return viewStyle.sameStyle(them);
2472 * @see jalview.api.ViewStyleI#getIdWidth()
2475 public int getIdWidth()
2477 return viewStyle.getIdWidth();
2482 * @see jalview.api.ViewStyleI#setIdWidth(int)
2485 public void setIdWidth(int i)
2487 viewStyle.setIdWidth(i);
2492 * @see jalview.api.ViewStyleI#isCentreColumnLabels()
2495 public boolean isCentreColumnLabels()
2497 return viewStyle.isCentreColumnLabels();
2501 * @param centreColumnLabels
2502 * @see jalview.api.ViewStyleI#setCentreColumnLabels(boolean)
2505 public void setCentreColumnLabels(boolean centreColumnLabels)
2507 viewStyle.setCentreColumnLabels(centreColumnLabels);
2512 * @see jalview.api.ViewStyleI#setShowDBRefs(boolean)
2515 public void setShowDBRefs(boolean showdbrefs)
2517 viewStyle.setShowDBRefs(showdbrefs);
2522 * @see jalview.api.ViewStyleI#isShowDBRefs()
2525 public boolean isShowDBRefs()
2527 return viewStyle.isShowDBRefs();
2532 * @see jalview.api.ViewStyleI#isShowNPFeats()
2535 public boolean isShowNPFeats()
2537 return viewStyle.isShowNPFeats();
2541 * @param shownpfeats
2542 * @see jalview.api.ViewStyleI#setShowNPFeats(boolean)
2545 public void setShowNPFeats(boolean shownpfeats)
2547 viewStyle.setShowNPFeats(shownpfeats);
2550 public abstract StructureSelectionManager getStructureSelectionManager();
2553 * Add one command to the command history list.
2557 public void addToHistoryList(CommandI command)
2559 if (this.historyList != null)
2561 this.historyList.push(command);
2562 broadcastCommand(command, false);
2566 protected void broadcastCommand(CommandI command, boolean undo)
2568 getStructureSelectionManager().commandPerformed(command, undo,
2573 * Add one command to the command redo list.
2577 public void addToRedoList(CommandI command)
2579 if (this.redoList != null)
2581 this.redoList.push(command);
2583 broadcastCommand(command, true);
2587 * Clear the command redo list.
2589 public void clearRedoList()
2591 if (this.redoList != null)
2593 this.redoList.clear();
2597 public void setHistoryList(Deque<CommandI> list)
2599 this.historyList = list;
2602 public Deque<CommandI> getHistoryList()
2604 return this.historyList;
2607 public void setRedoList(Deque<CommandI> list)
2609 this.redoList = list;
2612 public Deque<CommandI> getRedoList()
2614 return this.redoList;
2618 public VamsasSource getVamsasSource()
2623 public SequenceAnnotationOrder getSortAnnotationsBy()
2625 return sortAnnotationsBy;
2628 public void setSortAnnotationsBy(SequenceAnnotationOrder sortAnnotationsBy)
2630 this.sortAnnotationsBy = sortAnnotationsBy;
2633 public boolean isShowAutocalculatedAbove()
2635 return showAutocalculatedAbove;
2638 public void setShowAutocalculatedAbove(boolean showAutocalculatedAbove)
2640 this.showAutocalculatedAbove = showAutocalculatedAbove;
2644 public boolean isScaleProteinAsCdna()
2646 return viewStyle.isScaleProteinAsCdna();
2650 public void setScaleProteinAsCdna(boolean b)
2652 viewStyle.setScaleProteinAsCdna(b);
2656 * @return true if view should scroll to show the highlighted region of a
2661 public final boolean isFollowHighlight()
2663 return followHighlight;
2667 public final void setFollowHighlight(boolean b)
2669 this.followHighlight = b;
2673 public ViewportRanges getRanges()
2679 * Helper method to populate the SearchResults with the location in the
2680 * complementary alignment to scroll to, in order to match this one.
2683 * the SearchResults to add to
2684 * @return the offset (below top of visible region) of the matched sequence
2686 protected int findComplementScrollTarget(SearchResultsI sr)
2688 final AlignViewportI complement = getCodingComplement();
2689 if (complement == null || !complement.isFollowHighlight())
2693 boolean iAmProtein = !getAlignment().isNucleotide();
2694 AlignmentI proteinAlignment = iAmProtein ? getAlignment() : complement
2696 if (proteinAlignment == null)
2700 final List<AlignedCodonFrame> mappings = proteinAlignment
2704 * Heuristic: find the first mapped sequence (if any) with a non-gapped
2705 * residue in the middle column of the visible region. Scroll the
2706 * complementary alignment to line up the corresponding residue.
2709 SequenceI sequence = null;
2712 * locate 'middle' column (true middle if an odd number visible, left of
2713 * middle if an even number visible)
2715 int middleColumn = ranges.getStartRes()
2716 + (ranges.getEndRes() - ranges.getStartRes()) / 2;
2717 final HiddenSequences hiddenSequences = getAlignment()
2718 .getHiddenSequences();
2721 * searching to the bottom of the alignment gives smoother scrolling across
2722 * all gapped visible regions
2724 int lastSeq = alignment.getHeight() - 1;
2725 List<AlignedCodonFrame> seqMappings = null;
2726 for (int seqNo = ranges.getStartSeq(); seqNo < lastSeq; seqNo++, seqOffset++)
2728 sequence = getAlignment().getSequenceAt(seqNo);
2729 if (hiddenSequences != null && hiddenSequences.isHidden(sequence))
2733 if (Comparison.isGap(sequence.getCharAt(middleColumn)))
2737 seqMappings = MappingUtils
2738 .findMappingsForSequenceAndOthers(sequence, mappings,
2739 getCodingComplement().getAlignment().getSequences());
2740 if (!seqMappings.isEmpty())
2746 if (sequence == null || seqMappings == null || seqMappings.isEmpty())
2749 * No ungapped mapped sequence in middle column - do nothing
2753 MappingUtils.addSearchResults(sr, sequence,
2754 sequence.findPosition(middleColumn), seqMappings);
2759 * synthesize a column selection if none exists so it covers the given
2760 * selection group. if wholewidth is false, no column selection is made if the
2761 * selection group covers the whole alignment width.
2766 public void expandColSelection(SequenceGroup sg, boolean wholewidth)
2769 if (sg != null && (sgs = sg.getStartRes()) >= 0
2770 && sg.getStartRes() <= (sge = sg.getEndRes())
2771 && !this.hasSelectedColumns())
2773 if (!wholewidth && alignment.getWidth() == (1 + sge - sgs))
2780 colSel = new ColumnSelection();
2782 for (int cspos = sg.getStartRes(); cspos <= sg.getEndRes(); cspos++)
2784 colSel.addElement(cspos);
2790 * hold status of current selection group - defined on alignment or not.
2792 private boolean selectionIsDefinedGroup = false;
2795 public boolean isSelectionDefinedGroup()
2797 if (selectionGroup == null)
2801 if (isSelectionGroupChanged(true))
2803 selectionIsDefinedGroup = false;
2804 List<SequenceGroup> gps = alignment.getGroups();
2805 if (gps == null || gps.size() == 0)
2807 selectionIsDefinedGroup = false;
2811 selectionIsDefinedGroup = gps.contains(selectionGroup);
2814 return selectionGroup.getContext() == alignment
2815 || selectionIsDefinedGroup;
2819 * null, or currently highlighted results on this view
2821 private SearchResultsI searchResults = null;
2824 public boolean hasSearchResults()
2826 return searchResults != null;
2830 public void setSearchResults(SearchResultsI results)
2832 searchResults = results;
2836 public SearchResultsI getSearchResults()
2838 return searchResults;