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 jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
24 import jalview.analysis.Conservation;
25 import jalview.api.AlignCalcManagerI;
26 import jalview.api.AlignViewportI;
27 import jalview.api.AlignmentViewPanel;
28 import jalview.api.FeaturesDisplayedI;
29 import jalview.api.ViewStyleI;
30 import jalview.commands.CommandI;
31 import jalview.datamodel.AlignedCodonFrame;
32 import jalview.datamodel.AlignmentAnnotation;
33 import jalview.datamodel.AlignmentI;
34 import jalview.datamodel.AlignmentView;
35 import jalview.datamodel.Annotation;
36 import jalview.datamodel.CigarArray;
37 import jalview.datamodel.ColumnSelection;
38 import jalview.datamodel.HiddenSequences;
39 import jalview.datamodel.SearchResults;
40 import jalview.datamodel.Sequence;
41 import jalview.datamodel.SequenceCollectionI;
42 import jalview.datamodel.SequenceGroup;
43 import jalview.datamodel.SequenceI;
44 import jalview.schemes.Blosum62ColourScheme;
45 import jalview.schemes.ColourSchemeI;
46 import jalview.schemes.PIDColourScheme;
47 import jalview.schemes.ResidueProperties;
48 import jalview.structure.CommandListener;
49 import jalview.structure.StructureSelectionManager;
50 import jalview.structure.VamsasSource;
51 import jalview.util.Comparison;
52 import jalview.util.MappingUtils;
53 import jalview.viewmodel.styles.ViewStyle;
54 import jalview.workers.AlignCalcManager;
55 import jalview.workers.ComplementConsensusThread;
56 import jalview.workers.ConsensusThread;
57 import jalview.workers.StrucConsensusThread;
59 import java.awt.Color;
60 import java.util.ArrayDeque;
61 import java.util.ArrayList;
62 import java.util.BitSet;
63 import java.util.Deque;
64 import java.util.HashMap;
65 import java.util.Hashtable;
66 import java.util.List;
71 * base class holding visualization and analysis attributes and common logic for
72 * an active alignment view displayed in the GUI
77 public abstract class AlignmentViewport implements AlignViewportI,
78 CommandListener, VamsasSource
80 protected ViewStyleI viewStyle = new ViewStyle();
83 * A viewport that hosts the cDna view of this (protein), or vice versa (if
86 AlignViewportI codingComplement = null;
88 FeaturesDisplayedI featuresDisplayed = null;
90 protected Deque<CommandI> historyList = new ArrayDeque<CommandI>();
92 protected Deque<CommandI> redoList = new ArrayDeque<CommandI>();
96 * @see jalview.api.ViewStyleI#setFontName(java.lang.String)
98 public void setFontName(String name)
100 viewStyle.setFontName(name);
105 * @see jalview.api.ViewStyleI#setFontStyle(int)
107 public void setFontStyle(int style)
109 viewStyle.setFontStyle(style);
114 * @see jalview.api.ViewStyleI#setFontSize(int)
116 public void setFontSize(int size)
118 viewStyle.setFontSize(size);
123 * @see jalview.api.ViewStyleI#getFontStyle()
125 public int getFontStyle()
127 return viewStyle.getFontStyle();
132 * @see jalview.api.ViewStyleI#getFontName()
134 public String getFontName()
136 return viewStyle.getFontName();
141 * @see jalview.api.ViewStyleI#getFontSize()
143 public int getFontSize()
145 return viewStyle.getFontSize();
149 * @param upperCasebold
150 * @see jalview.api.ViewStyleI#setUpperCasebold(boolean)
152 public void setUpperCasebold(boolean upperCasebold)
154 viewStyle.setUpperCasebold(upperCasebold);
159 * @see jalview.api.ViewStyleI#isUpperCasebold()
161 public boolean isUpperCasebold()
163 return viewStyle.isUpperCasebold();
168 * @see jalview.api.ViewStyleI#isSeqNameItalics()
170 public boolean isSeqNameItalics()
172 return viewStyle.isSeqNameItalics();
176 * @param colourByReferenceSeq
177 * @see jalview.api.ViewStyleI#setColourByReferenceSeq(boolean)
179 public void setColourByReferenceSeq(boolean colourByReferenceSeq)
181 viewStyle.setColourByReferenceSeq(colourByReferenceSeq);
186 * @see jalview.api.ViewStyleI#setColourAppliesToAllGroups(boolean)
188 public void setColourAppliesToAllGroups(boolean b)
190 viewStyle.setColourAppliesToAllGroups(b);
195 * @see jalview.api.ViewStyleI#getColourAppliesToAllGroups()
197 public boolean getColourAppliesToAllGroups()
199 return viewStyle.getColourAppliesToAllGroups();
204 * @see jalview.api.ViewStyleI#getAbovePIDThreshold()
206 public boolean getAbovePIDThreshold()
208 return viewStyle.getAbovePIDThreshold();
213 * @see jalview.api.ViewStyleI#setIncrement(int)
215 public void setIncrement(int inc)
217 viewStyle.setIncrement(inc);
222 * @see jalview.api.ViewStyleI#getIncrement()
224 public int getIncrement()
226 return viewStyle.getIncrement();
231 * @see jalview.api.ViewStyleI#setConservationSelected(boolean)
233 public void setConservationSelected(boolean b)
235 viewStyle.setConservationSelected(b);
240 * @see jalview.api.ViewStyleI#setShowHiddenMarkers(boolean)
242 public void setShowHiddenMarkers(boolean show)
244 viewStyle.setShowHiddenMarkers(show);
249 * @see jalview.api.ViewStyleI#getShowHiddenMarkers()
251 public boolean getShowHiddenMarkers()
253 return viewStyle.getShowHiddenMarkers();
258 * @see jalview.api.ViewStyleI#setScaleRightWrapped(boolean)
260 public void setScaleRightWrapped(boolean b)
262 viewStyle.setScaleRightWrapped(b);
267 * @see jalview.api.ViewStyleI#setScaleLeftWrapped(boolean)
269 public void setScaleLeftWrapped(boolean b)
271 viewStyle.setScaleLeftWrapped(b);
276 * @see jalview.api.ViewStyleI#setScaleAboveWrapped(boolean)
278 public void setScaleAboveWrapped(boolean b)
280 viewStyle.setScaleAboveWrapped(b);
285 * @see jalview.api.ViewStyleI#getScaleLeftWrapped()
287 public boolean getScaleLeftWrapped()
289 return viewStyle.getScaleLeftWrapped();
294 * @see jalview.api.ViewStyleI#getScaleAboveWrapped()
296 public boolean getScaleAboveWrapped()
298 return viewStyle.getScaleAboveWrapped();
303 * @see jalview.api.ViewStyleI#getScaleRightWrapped()
305 public boolean getScaleRightWrapped()
307 return viewStyle.getScaleRightWrapped();
312 * @see jalview.api.ViewStyleI#setAbovePIDThreshold(boolean)
314 public void setAbovePIDThreshold(boolean b)
316 viewStyle.setAbovePIDThreshold(b);
321 * @see jalview.api.ViewStyleI#setThreshold(int)
323 public void setThreshold(int thresh)
325 viewStyle.setThreshold(thresh);
330 * @see jalview.api.ViewStyleI#getThreshold()
332 public int getThreshold()
334 return viewStyle.getThreshold();
339 * @see jalview.api.ViewStyleI#getShowJVSuffix()
341 public boolean getShowJVSuffix()
343 return viewStyle.getShowJVSuffix();
348 * @see jalview.api.ViewStyleI#setShowJVSuffix(boolean)
350 public void setShowJVSuffix(boolean b)
352 viewStyle.setShowJVSuffix(b);
357 * @see jalview.api.ViewStyleI#setWrapAlignment(boolean)
359 public void setWrapAlignment(boolean state)
361 viewStyle.setWrapAlignment(state);
366 * @see jalview.api.ViewStyleI#setShowText(boolean)
368 public void setShowText(boolean state)
370 viewStyle.setShowText(state);
375 * @see jalview.api.ViewStyleI#setRenderGaps(boolean)
377 public void setRenderGaps(boolean state)
379 viewStyle.setRenderGaps(state);
384 * @see jalview.api.ViewStyleI#getColourText()
386 public boolean getColourText()
388 return viewStyle.getColourText();
393 * @see jalview.api.ViewStyleI#setColourText(boolean)
395 public void setColourText(boolean state)
397 viewStyle.setColourText(state);
402 * @see jalview.api.ViewStyleI#getWrapAlignment()
404 public boolean getWrapAlignment()
406 return viewStyle.getWrapAlignment();
411 * @see jalview.api.ViewStyleI#getShowText()
413 public boolean getShowText()
415 return viewStyle.getShowText();
420 * @see jalview.api.ViewStyleI#getWrappedWidth()
422 public int getWrappedWidth()
424 return viewStyle.getWrappedWidth();
429 * @see jalview.api.ViewStyleI#setWrappedWidth(int)
431 public void setWrappedWidth(int w)
433 viewStyle.setWrappedWidth(w);
438 * @see jalview.api.ViewStyleI#getCharHeight()
440 public int getCharHeight()
442 return viewStyle.getCharHeight();
447 * @see jalview.api.ViewStyleI#setCharHeight(int)
449 public void setCharHeight(int h)
451 viewStyle.setCharHeight(h);
456 * @see jalview.api.ViewStyleI#getCharWidth()
458 public int getCharWidth()
460 return viewStyle.getCharWidth();
465 * @see jalview.api.ViewStyleI#setCharWidth(int)
467 public void setCharWidth(int w)
469 viewStyle.setCharWidth(w);
474 * @see jalview.api.ViewStyleI#getShowBoxes()
476 public boolean getShowBoxes()
478 return viewStyle.getShowBoxes();
483 * @see jalview.api.ViewStyleI#getShowUnconserved()
485 public boolean getShowUnconserved()
487 return viewStyle.getShowUnconserved();
491 * @param showunconserved
492 * @see jalview.api.ViewStyleI#setShowUnconserved(boolean)
494 public void setShowUnconserved(boolean showunconserved)
496 viewStyle.setShowUnconserved(showunconserved);
501 * @see jalview.api.ViewStyleI#setSeqNameItalics(boolean)
503 public void setSeqNameItalics(boolean default1)
505 viewStyle.setSeqNameItalics(default1);
509 * alignment displayed in the viewport. Please use get/setter
511 protected AlignmentI alignment;
514 public AlignmentI getAlignment()
520 public char getGapCharacter()
522 return alignment.getGapCharacter();
525 protected String sequenceSetID;
528 * probably unused indicator that view is of a dataset rather than an
531 protected boolean isDataset = false;
533 public void setDataset(boolean b)
538 public boolean isDataset()
544 private Map<SequenceI, SequenceCollectionI> hiddenRepSequences;
546 protected ColumnSelection colSel = new ColumnSelection();
548 public boolean autoCalculateConsensus = true;
550 protected boolean autoCalculateStrucConsensus = true;
552 protected boolean ignoreGapsInConsensusCalculation = false;
554 protected ColourSchemeI globalColourScheme = null;
558 public void setGlobalColourScheme(ColourSchemeI cs)
560 // TODO: logic refactored from AlignFrame changeColour -
561 // TODO: autorecalc stuff should be changed to rely on the worker system
562 // check to see if we should implement a changeColour(cs) method rather than
563 // put th logic in here
564 // - means that caller decides if they want to just modify state and defer
565 // calculation till later or to do all calculations in thread.
567 globalColourScheme = cs;
568 boolean recalc = false;
571 cs.setConservationApplied(recalc = getConservationSelected());
572 if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
573 || cs instanceof Blosum62ColourScheme)
576 cs.setThreshold(viewStyle.getThreshold(),
577 ignoreGapsInConsensusCalculation);
581 cs.setThreshold(0, ignoreGapsInConsensusCalculation);
585 cs.setConsensus(hconsensus);
586 cs.setConservation(hconservation);
588 cs.alignmentChanged(alignment, hiddenRepSequences);
590 if (getColourAppliesToAllGroups())
592 for (SequenceGroup sg : getAlignment().getGroups())
599 sg.cs = cs.applyTo(sg, getHiddenRepSequences());
600 sg.setConsPercGaps(ConsPercGaps);
601 if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
602 || cs instanceof Blosum62ColourScheme)
604 sg.cs.setThreshold(viewStyle.getThreshold(),
605 isIgnoreGapsConsensus());
610 sg.cs.setThreshold(0, isIgnoreGapsConsensus());
613 if (getConservationSelected())
615 sg.cs.setConservationApplied(true);
620 sg.cs.setConservation(null);
621 // sg.cs.setThreshold(0, getIgnoreGapsConsensus());
625 sg.recalcConservation();
629 sg.cs.alignmentChanged(sg, hiddenRepSequences);
636 public ColourSchemeI getGlobalColourScheme()
638 return globalColourScheme;
641 protected AlignmentAnnotation consensus;
643 protected AlignmentAnnotation complementConsensus;
645 protected AlignmentAnnotation strucConsensus;
647 protected AlignmentAnnotation conservation;
649 protected AlignmentAnnotation quality;
651 protected AlignmentAnnotation[] groupConsensus;
653 protected AlignmentAnnotation[] groupConservation;
656 * results of alignment consensus analysis for visible portion of view
658 protected Hashtable[] hconsensus = null;
661 * results of cDNA complement consensus visible portion of view
663 protected Hashtable[] hcomplementConsensus = null;
666 * results of secondary structure base pair consensus for visible portion of
669 protected Hashtable[] hStrucConsensus = null;
671 protected Conservation hconservation = null;
674 public void setConservation(Conservation cons)
676 hconservation = cons;
680 * percentage gaps allowed in a column before all amino acid properties should
681 * be considered unconserved
683 int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
686 public int getConsPercGaps()
692 public void setSequenceConsensusHash(Hashtable[] hconsensus)
694 this.hconsensus = hconsensus;
698 public void setComplementConsensusHash(Hashtable[] hconsensus)
700 this.hcomplementConsensus = hconsensus;
704 public Hashtable[] getSequenceConsensusHash()
710 public Hashtable[] getComplementConsensusHash()
712 return hcomplementConsensus;
716 public Hashtable[] getRnaStructureConsensusHash()
718 return hStrucConsensus;
722 public void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus)
724 this.hStrucConsensus = hStrucConsensus;
729 public AlignmentAnnotation getAlignmentQualityAnnot()
735 public AlignmentAnnotation getAlignmentConservationAnnotation()
741 public AlignmentAnnotation getAlignmentConsensusAnnotation()
747 public AlignmentAnnotation getComplementConsensusAnnotation()
749 return complementConsensus;
753 public AlignmentAnnotation getAlignmentStrucConsensusAnnotation()
755 return strucConsensus;
758 protected AlignCalcManagerI calculator = new AlignCalcManager();
761 * trigger update of conservation annotation
763 public void updateConservation(final AlignmentViewPanel ap)
765 // see note in mantis : issue number 8585
766 if (alignment.isNucleotide() || conservation == null
767 || !autoCalculateConsensus)
772 .getRegisteredWorkersOfClass(jalview.workers.ConservationThread.class) == null)
774 calculator.registerWorker(new jalview.workers.ConservationThread(
780 * trigger update of consensus annotation
782 public void updateConsensus(final AlignmentViewPanel ap)
784 // see note in mantis : issue number 8585
785 if (consensus == null || !autoCalculateConsensus)
789 if (calculator.getRegisteredWorkersOfClass(ConsensusThread.class) == null)
791 calculator.registerWorker(new ConsensusThread(this, ap));
795 * A separate thread to compute cDNA consensus for a protein alignment
797 final AlignmentI al = this.getAlignment();
798 if (!al.isNucleotide() && al.getCodonFrames() != null
799 && !al.getCodonFrames().isEmpty())
802 .getRegisteredWorkersOfClass(ComplementConsensusThread.class) == null)
804 calculator.registerWorker(new ComplementConsensusThread(this, ap));
809 // --------START Structure Conservation
810 public void updateStrucConsensus(final AlignmentViewPanel ap)
812 if (autoCalculateStrucConsensus && strucConsensus == null
813 && alignment.isNucleotide() && alignment.hasRNAStructure())
815 // secondary structure has been added - so init the consensus line
819 // see note in mantis : issue number 8585
820 if (strucConsensus == null || !autoCalculateStrucConsensus)
824 if (calculator.getRegisteredWorkersOfClass(StrucConsensusThread.class) == null)
826 calculator.registerWorker(new StrucConsensusThread(this, ap));
830 public boolean isCalcInProgress()
832 return calculator.isWorking();
836 public boolean isCalculationInProgress(
837 AlignmentAnnotation alignmentAnnotation)
839 if (!alignmentAnnotation.autoCalculated)
843 if (calculator.workingInvolvedWith(alignmentAnnotation))
845 // System.err.println("grey out ("+alignmentAnnotation.label+")");
852 public boolean isClosed()
854 // TODO: check that this isClosed is only true after panel is closed, not
855 // before it is fully constructed.
856 return alignment == null;
860 public AlignCalcManagerI getCalcManager()
866 * should conservation rows be shown for groups
868 protected boolean showGroupConservation = false;
871 * should consensus rows be shown for groups
873 protected boolean showGroupConsensus = false;
876 * should consensus profile be rendered by default
878 protected boolean showSequenceLogo = false;
881 * should consensus profile be rendered normalised to row height
883 protected boolean normaliseSequenceLogo = false;
886 * should consensus histograms be rendered by default
888 protected boolean showConsensusHistogram = true;
891 * @return the showConsensusProfile
894 public boolean isShowSequenceLogo()
896 return showSequenceLogo;
900 * @param showSequenceLogo
903 public void setShowSequenceLogo(boolean showSequenceLogo)
905 if (showSequenceLogo != this.showSequenceLogo)
907 // TODO: decouple settings setting from calculation when refactoring
908 // annotation update method from alignframe to viewport
909 this.showSequenceLogo = showSequenceLogo;
910 calculator.updateAnnotationFor(ConsensusThread.class);
911 calculator.updateAnnotationFor(ComplementConsensusThread.class);
912 calculator.updateAnnotationFor(StrucConsensusThread.class);
914 this.showSequenceLogo = showSequenceLogo;
918 * @param showConsensusHistogram
919 * the showConsensusHistogram to set
921 public void setShowConsensusHistogram(boolean showConsensusHistogram)
923 this.showConsensusHistogram = showConsensusHistogram;
927 * @return the showGroupConservation
929 public boolean isShowGroupConservation()
931 return showGroupConservation;
935 * @param showGroupConservation
936 * the showGroupConservation to set
938 public void setShowGroupConservation(boolean showGroupConservation)
940 this.showGroupConservation = showGroupConservation;
944 * @return the showGroupConsensus
946 public boolean isShowGroupConsensus()
948 return showGroupConsensus;
952 * @param showGroupConsensus
953 * the showGroupConsensus to set
955 public void setShowGroupConsensus(boolean showGroupConsensus)
957 this.showGroupConsensus = showGroupConsensus;
962 * @return flag to indicate if the consensus histogram should be rendered by
966 public boolean isShowConsensusHistogram()
968 return this.showConsensusHistogram;
972 * when set, updateAlignment will always ensure sequences are of equal length
974 private boolean padGaps = false;
977 * when set, alignment should be reordered according to a newly opened tree
979 public boolean sortByTree = false;
985 * @return null or the currently selected sequence region
988 public SequenceGroup getSelectionGroup()
990 return selectionGroup;
994 * Set the selection group for this window.
997 * - group holding references to sequences in this alignment view
1001 public void setSelectionGroup(SequenceGroup sg)
1003 selectionGroup = sg;
1006 public void setHiddenColumns(ColumnSelection colsel)
1008 this.colSel = colsel;
1012 public ColumnSelection getColumnSelection()
1018 public void setColumnSelection(ColumnSelection colSel)
1020 this.colSel = colSel;
1023 updateHiddenColumns();
1032 public Map<SequenceI, SequenceCollectionI> getHiddenRepSequences()
1034 return hiddenRepSequences;
1038 public void setHiddenRepSequences(
1039 Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
1041 this.hiddenRepSequences = hiddenRepSequences;
1045 public boolean hasHiddenColumns()
1047 return colSel != null && colSel.hasHiddenColumns();
1050 public void updateHiddenColumns()
1052 // this method doesn't really do anything now. But - it could, since a
1053 // column Selection could be in the process of modification
1054 // hasHiddenColumns = colSel.hasHiddenColumns();
1058 public boolean hasHiddenRows()
1060 return alignment.getHiddenSequences().getSize() > 0;
1064 protected SequenceGroup selectionGroup;
1066 public void setSequenceSetId(String newid)
1068 if (sequenceSetID != null)
1071 .println("Warning - overwriting a sequenceSetId for a viewport!");
1073 sequenceSetID = new String(newid);
1077 public String getSequenceSetId()
1079 if (sequenceSetID == null)
1081 sequenceSetID = alignment.hashCode() + "";
1084 return sequenceSetID;
1088 * unique viewId for synchronizing state (e.g. with stored Jalview Project)
1091 protected String viewId = null;
1094 public String getViewId()
1098 viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
1103 public void setIgnoreGapsConsensus(boolean b, AlignmentViewPanel ap)
1105 ignoreGapsInConsensusCalculation = b;
1108 updateConsensus(ap);
1109 if (globalColourScheme != null)
1111 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
1112 ignoreGapsInConsensusCalculation);
1118 private long sgrouphash = -1, colselhash = -1;
1121 * checks current SelectionGroup against record of last hash value, and
1125 * update the record of last hash value
1127 * @return true if SelectionGroup changed since last call (when b is true)
1129 public boolean isSelectionGroupChanged(boolean b)
1131 int hc = (selectionGroup == null || selectionGroup.getSize() == 0) ? -1
1132 : selectionGroup.hashCode();
1133 if (hc != -1 && hc != sgrouphash)
1145 * checks current colsel against record of last hash value, and optionally
1149 * update the record of last hash value
1150 * @return true if colsel changed since last call (when b is true)
1152 public boolean isColSelChanged(boolean b)
1154 int hc = (colSel == null || colSel.size() == 0) ? -1 : colSel
1156 if (hc != -1 && hc != colselhash)
1168 public boolean isIgnoreGapsConsensus()
1170 return ignoreGapsInConsensusCalculation;
1173 // / property change stuff
1175 // JBPNote Prolly only need this in the applet version.
1176 private final java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
1179 protected boolean showConservation = true;
1181 protected boolean showQuality = true;
1183 protected boolean showConsensus = true;
1185 private Map<SequenceI, Color> sequenceColours = new HashMap<SequenceI, Color>();
1187 protected SequenceAnnotationOrder sortAnnotationsBy = null;
1189 protected boolean showAutocalculatedAbove;
1192 * when set, view will scroll to show the highlighted position
1194 private boolean followHighlight = true;
1196 // TODO private with getters and setters?
1197 public int startRes;
1201 public int startSeq;
1206 * Property change listener for changes in alignment
1211 public void addPropertyChangeListener(
1212 java.beans.PropertyChangeListener listener)
1214 changeSupport.addPropertyChangeListener(listener);
1223 public void removePropertyChangeListener(
1224 java.beans.PropertyChangeListener listener)
1226 changeSupport.removePropertyChangeListener(listener);
1230 * Property change listener for changes in alignment
1239 public void firePropertyChange(String prop, Object oldvalue,
1242 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
1245 // common hide/show column stuff
1247 public void hideSelectedColumns()
1249 if (colSel.size() < 1)
1254 colSel.hideSelectedColumns();
1255 setSelectionGroup(null);
1259 public void hideColumns(int start, int end)
1263 colSel.hideColumns(start);
1267 colSel.hideColumns(start, end);
1271 public void showColumn(int col)
1273 colSel.revealHiddenColumns(col);
1277 public void showAllHiddenColumns()
1279 colSel.revealAllHiddenColumns();
1282 // common hide/show seq stuff
1283 public void showAllHiddenSeqs()
1285 if (alignment.getHiddenSequences().getSize() > 0)
1287 if (selectionGroup == null)
1289 selectionGroup = new SequenceGroup();
1290 selectionGroup.setEndRes(alignment.getWidth() - 1);
1292 List<SequenceI> tmp = alignment.getHiddenSequences().showAll(
1293 hiddenRepSequences);
1294 for (SequenceI seq : tmp)
1296 selectionGroup.addSequence(seq, false);
1297 setSequenceAnnotationsVisible(seq, true);
1300 hiddenRepSequences = null;
1302 firePropertyChange("alignment", null, alignment.getSequences());
1303 // used to set hasHiddenRows/hiddenRepSequences here, after the property
1309 public void showSequence(int index)
1311 List<SequenceI> tmp = alignment.getHiddenSequences().showSequence(
1313 hiddenRepSequences);
1316 if (selectionGroup == null)
1318 selectionGroup = new SequenceGroup();
1319 selectionGroup.setEndRes(alignment.getWidth() - 1);
1322 for (SequenceI seq : tmp)
1324 selectionGroup.addSequence(seq, false);
1325 setSequenceAnnotationsVisible(seq, true);
1327 firePropertyChange("alignment", null, alignment.getSequences());
1332 public void hideAllSelectedSeqs()
1334 if (selectionGroup == null || selectionGroup.getSize() < 1)
1339 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1343 setSelectionGroup(null);
1346 public void hideSequence(SequenceI[] seq)
1350 for (int i = 0; i < seq.length; i++)
1352 alignment.getHiddenSequences().hideSequence(seq[i]);
1353 setSequenceAnnotationsVisible(seq[i], false);
1355 firePropertyChange("alignment", null, alignment.getSequences());
1360 * Set visibility for any annotations for the given sequence.
1364 protected void setSequenceAnnotationsVisible(SequenceI sequenceI,
1367 for (AlignmentAnnotation ann : alignment.getAlignmentAnnotation())
1369 if (ann.sequenceRef == sequenceI)
1371 ann.visible = visible;
1376 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1378 int sSize = sg.getSize();
1384 if (hiddenRepSequences == null)
1386 hiddenRepSequences = new Hashtable();
1389 hiddenRepSequences.put(repSequence, sg);
1391 // Hide all sequences except the repSequence
1392 SequenceI[] seqs = new SequenceI[sSize - 1];
1394 for (int i = 0; i < sSize; i++)
1396 if (sg.getSequenceAt(i) != repSequence)
1398 if (index == sSize - 1)
1403 seqs[index++] = sg.getSequenceAt(i);
1406 sg.setSeqrep(repSequence); // note: not done in 2.7applet
1407 sg.setHidereps(true); // note: not done in 2.7applet
1412 public boolean isHiddenRepSequence(SequenceI seq)
1414 return alignment.getSeqrep()==seq || (hiddenRepSequences != null
1415 && hiddenRepSequences.containsKey(seq));
1418 public SequenceGroup getRepresentedSequences(SequenceI seq)
1420 return (SequenceGroup) (hiddenRepSequences == null ? null
1421 : hiddenRepSequences.get(seq));
1425 public int adjustForHiddenSeqs(int alignmentIndex)
1427 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1432 public void invertColumnSelection()
1434 colSel.invertColumnSelection(0, alignment.getWidth());
1439 public SequenceI[] getSelectionAsNewSequence()
1441 SequenceI[] sequences;
1442 // JBPNote: Need to test jalviewLite.getSelectedSequencesAsAlignmentFrom -
1443 // this was the only caller in the applet for this method
1444 // JBPNote: in applet, this method returned references to the alignment
1445 // sequences, and it did not honour the presence/absence of annotation
1446 // attached to the alignment (probably!)
1447 if (selectionGroup == null || selectionGroup.getSize() == 0)
1449 sequences = alignment.getSequencesArray();
1450 AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
1451 for (int i = 0; i < sequences.length; i++)
1453 // construct new sequence with subset of visible annotation
1454 sequences[i] = new Sequence(sequences[i], annots);
1459 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1467 public SequenceI[] getSequenceSelection()
1469 SequenceI[] sequences = null;
1470 if (selectionGroup != null)
1472 sequences = selectionGroup.getSequencesInOrder(alignment);
1474 if (sequences == null)
1476 sequences = alignment.getSequencesArray();
1483 public CigarArray getViewAsCigars(
1484 boolean selectedRegionOnly)
1486 return new CigarArray(alignment, colSel,
1487 (selectedRegionOnly ? selectionGroup : null));
1492 public jalview.datamodel.AlignmentView getAlignmentView(
1493 boolean selectedOnly)
1495 return getAlignmentView(selectedOnly, false);
1500 public jalview.datamodel.AlignmentView getAlignmentView(
1501 boolean selectedOnly, boolean markGroups)
1503 return new AlignmentView(alignment, colSel, selectionGroup,
1504 colSel != null && colSel.hasHiddenColumns(), selectedOnly,
1510 public String[] getViewAsString(boolean selectedRegionOnly)
1512 String[] selection = null;
1513 SequenceI[] seqs = null;
1515 int start = 0, end = 0;
1516 if (selectedRegionOnly && selectionGroup != null)
1518 iSize = selectionGroup.getSize();
1519 seqs = selectionGroup.getSequencesInOrder(alignment);
1520 start = selectionGroup.getStartRes();
1521 end = selectionGroup.getEndRes() + 1;
1525 iSize = alignment.getHeight();
1526 seqs = alignment.getSequencesArray();
1527 end = alignment.getWidth();
1530 selection = new String[iSize];
1531 if (colSel != null && colSel.hasHiddenColumns())
1533 selection = colSel.getVisibleSequenceStrings(start, end, seqs);
1537 for (i = 0; i < iSize; i++)
1539 selection[i] = seqs[i].getSequenceAsString(start, end);
1548 public List<int[]> getVisibleRegionBoundaries(int min, int max)
1550 ArrayList<int[]> regions = new ArrayList<int[]>();
1556 if (colSel != null && colSel.hasHiddenColumns())
1560 start = colSel.adjustForHiddenColumns(start);
1563 end = colSel.getHiddenBoundaryRight(start);
1574 regions.add(new int[]
1577 if (colSel != null && colSel.hasHiddenColumns())
1579 start = colSel.adjustForHiddenColumns(end);
1580 start = colSel.getHiddenBoundaryLeft(start) + 1;
1582 } while (end < max);
1584 int[][] startEnd = new int[regions.size()][2];
1590 public List<AlignmentAnnotation> getVisibleAlignmentAnnotation(boolean selectedOnly)
1592 ArrayList<AlignmentAnnotation> ala = new ArrayList<AlignmentAnnotation>();
1593 AlignmentAnnotation[] aa;
1594 if ((aa=alignment.getAlignmentAnnotation())!=null)
1596 for (AlignmentAnnotation annot:aa)
1598 AlignmentAnnotation clone = new AlignmentAnnotation(annot);
1599 if (selectedOnly && selectionGroup!=null)
1601 colSel.makeVisibleAnnotation(selectionGroup.getStartRes(), selectionGroup.getEndRes(),clone);
1603 colSel.makeVisibleAnnotation(clone);
1613 public boolean isPadGaps()
1620 public void setPadGaps(boolean padGaps)
1622 this.padGaps = padGaps;
1626 * apply any post-edit constraints and trigger any calculations needed after
1627 * an edit has been performed on the alignment
1632 public void alignmentChanged(AlignmentViewPanel ap)
1636 alignment.padGaps();
1638 if (autoCalculateConsensus)
1640 updateConsensus(ap);
1642 if (hconsensus != null && autoCalculateConsensus)
1644 updateConservation(ap);
1646 if (autoCalculateStrucConsensus)
1648 updateStrucConsensus(ap);
1651 // Reset endRes of groups if beyond alignment width
1652 int alWidth = alignment.getWidth();
1653 List<SequenceGroup> groups = alignment.getGroups();
1656 for (SequenceGroup sg : groups)
1658 if (sg.getEndRes() > alWidth)
1660 sg.setEndRes(alWidth - 1);
1665 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1667 selectionGroup.setEndRes(alWidth - 1);
1670 resetAllColourSchemes();
1671 calculator.restartWorkers();
1672 // alignment.adjustSequenceAnnotations();
1676 * reset scope and do calculations for all applied colourschemes on alignment
1678 void resetAllColourSchemes()
1680 ColourSchemeI cs = globalColourScheme;
1683 cs.alignmentChanged(alignment, hiddenRepSequences);
1685 cs.setConsensus(hconsensus);
1686 if (cs.conservationApplied())
1688 cs.setConservation(Conservation.calculateConservation("All",
1689 ResidueProperties.propHash, 3, alignment.getSequences(), 0,
1690 alignment.getWidth(), false, getConsPercGaps(), false));
1694 for (SequenceGroup sg : alignment.getGroups())
1698 sg.cs.alignmentChanged(sg, hiddenRepSequences);
1700 sg.recalcConservation();
1704 protected void initAutoAnnotation()
1706 // TODO: add menu option action that nulls or creates consensus object
1707 // depending on if the user wants to see the annotation or not in a
1708 // specific alignment
1710 if (hconsensus == null && !isDataset)
1712 if (!alignment.isNucleotide())
1721 consensus = new AlignmentAnnotation("Consensus", "PID",
1722 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
1723 initConsensus(consensus);
1725 initComplementConsensus();
1730 * If this is a protein alignment and there are mappings to cDNA, add the cDNA
1731 * consensus annotation.
1733 public void initComplementConsensus()
1735 if (!alignment.isNucleotide())
1737 final Set<AlignedCodonFrame> codonMappings = alignment
1739 if (codonMappings != null && !codonMappings.isEmpty())
1741 complementConsensus = new AlignmentAnnotation("cDNA Consensus",
1742 "PID for cDNA", new Annotation[1], 0f, 100f,
1743 AlignmentAnnotation.BAR_GRAPH);
1744 initConsensus(complementConsensus);
1749 private void initConsensus(AlignmentAnnotation aa)
1752 aa.autoCalculated = true;
1756 alignment.addAnnotation(aa);
1760 private void initConservation()
1762 if (showConservation)
1764 if (conservation == null)
1766 conservation = new AlignmentAnnotation("Conservation",
1767 "Conservation of total alignment less than "
1768 + getConsPercGaps() + "% gaps", new Annotation[1],
1769 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
1770 conservation.hasText = true;
1771 conservation.autoCalculated = true;
1772 alignment.addAnnotation(conservation);
1777 private void initQuality()
1781 if (quality == null)
1783 quality = new AlignmentAnnotation("Quality",
1784 "Alignment Quality based on Blosum62 scores",
1785 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
1786 quality.hasText = true;
1787 quality.autoCalculated = true;
1788 alignment.addAnnotation(quality);
1793 private void initRNAStructure()
1795 if (alignment.hasRNAStructure() && strucConsensus == null)
1797 strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
1798 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
1799 strucConsensus.hasText = true;
1800 strucConsensus.autoCalculated = true;
1804 alignment.addAnnotation(strucConsensus);
1812 * @see jalview.api.AlignViewportI#calcPanelHeight()
1815 public int calcPanelHeight()
1817 // setHeight of panels
1818 AlignmentAnnotation[] anns = getAlignment().getAlignmentAnnotation();
1820 int charHeight = getCharHeight();
1823 BitSet graphgrp = new BitSet();
1824 for (AlignmentAnnotation aa : anns)
1828 System.err.println("Null annotation row: ignoring.");
1835 if (aa.graphGroup > -1)
1837 if (graphgrp.get(aa.graphGroup))
1843 graphgrp.set(aa.graphGroup);
1850 aa.height += charHeight;
1860 aa.height += aa.graphHeight;
1868 height += aa.height;
1880 public void updateGroupAnnotationSettings(boolean applyGlobalSettings,
1881 boolean preserveNewGroupSettings)
1883 boolean updateCalcs = false;
1884 boolean conv = isShowGroupConservation();
1885 boolean cons = isShowGroupConsensus();
1886 boolean showprf = isShowSequenceLogo();
1887 boolean showConsHist = isShowConsensusHistogram();
1888 boolean normLogo = isNormaliseSequenceLogo();
1891 * TODO reorder the annotation rows according to group/sequence ordering on
1894 boolean sortg = true;
1896 // remove old automatic annotation
1897 // add any new annotation
1899 // intersect alignment annotation with alignment groups
1901 AlignmentAnnotation[] aan = alignment.getAlignmentAnnotation();
1902 List<SequenceGroup> oldrfs = new ArrayList<SequenceGroup>();
1905 for (int an = 0; an < aan.length; an++)
1907 if (aan[an].autoCalculated && aan[an].groupRef != null)
1909 oldrfs.add(aan[an].groupRef);
1910 alignment.deleteAnnotation(aan[an], false);
1914 if (alignment.getGroups() != null)
1916 for (SequenceGroup sg : alignment.getGroups())
1918 updateCalcs = false;
1919 if (applyGlobalSettings
1920 || (!preserveNewGroupSettings && !oldrfs.contains(sg)))
1922 // set defaults for this group's conservation/consensus
1923 sg.setshowSequenceLogo(showprf);
1924 sg.setShowConsensusHistogram(showConsHist);
1925 sg.setNormaliseSequenceLogo(normLogo);
1930 alignment.addAnnotation(sg.getConservationRow(), 0);
1935 alignment.addAnnotation(sg.getConsensus(), 0);
1937 // refresh the annotation rows
1940 sg.recalcConservation();
1947 public boolean isDisplayReferenceSeq()
1949 return alignment.hasSeqrep() && viewStyle.isDisplayReferenceSeq();
1953 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
1955 viewStyle.setDisplayReferenceSeq(displayReferenceSeq);
1959 public boolean isColourByReferenceSeq()
1961 return alignment.hasSeqrep() && viewStyle.isColourByReferenceSeq();
1965 public Color getSequenceColour(SequenceI seq)
1967 Color sqc = sequenceColours.get(seq);
1968 return (sqc == null ? Color.white : sqc);
1972 public void setSequenceColour(SequenceI seq, Color col)
1976 sequenceColours.remove(seq);
1980 sequenceColours.put(seq, col);
1985 public void updateSequenceIdColours()
1987 for (SequenceGroup sg : alignment.getGroups())
1989 if (sg.idColour != null)
1991 for (SequenceI s : sg.getSequences(getHiddenRepSequences()))
1993 sequenceColours.put(s, sg.idColour);
2000 public void clearSequenceColours()
2002 sequenceColours.clear();
2006 public AlignViewportI getCodingComplement()
2008 return this.codingComplement;
2012 * Set this as the (cDna/protein) complement of the given viewport. Also
2013 * ensures the reverse relationship is set on the given viewport.
2016 public void setCodingComplement(AlignViewportI av)
2020 System.err.println("Ignoring recursive setCodingComplement request");
2024 this.codingComplement = av;
2025 // avoid infinite recursion!
2026 if (av.getCodingComplement() != this)
2028 av.setCodingComplement(this);
2034 public boolean isNucleotide()
2036 return getAlignment() == null ? false : getAlignment().isNucleotide();
2040 public FeaturesDisplayedI getFeaturesDisplayed()
2042 return featuresDisplayed;
2046 public void setFeaturesDisplayed(FeaturesDisplayedI featuresDisplayedI)
2048 featuresDisplayed = featuresDisplayedI;
2052 public boolean areFeaturesDisplayed()
2054 return featuresDisplayed != null && featuresDisplayed.getRegisterdFeaturesCount()>0;
2061 * features are displayed if true
2064 public void setShowSequenceFeatures(boolean b)
2066 viewStyle.setShowSequenceFeatures(b);
2069 public boolean isShowSequenceFeatures()
2071 return viewStyle.isShowSequenceFeatures();
2075 public void setShowSequenceFeaturesHeight(boolean selected)
2077 viewStyle.setShowSequenceFeaturesHeight(selected);
2081 public boolean isShowSequenceFeaturesHeight()
2083 return viewStyle.isShowSequenceFeaturesHeight();
2089 public void setShowAnnotation(boolean b)
2091 viewStyle.setShowAnnotation(b);
2095 public boolean isShowAnnotation()
2097 return viewStyle.isShowAnnotation();
2101 public boolean isRightAlignIds()
2103 return viewStyle.isRightAlignIds();
2107 public void setRightAlignIds(boolean rightAlignIds)
2109 viewStyle.setRightAlignIds(rightAlignIds);
2113 public boolean getConservationSelected()
2115 return viewStyle.getConservationSelected();
2119 public void setShowBoxes(boolean state)
2121 viewStyle.setShowBoxes(state);
2126 * @see jalview.api.ViewStyleI#getTextColour()
2128 public Color getTextColour()
2130 return viewStyle.getTextColour();
2135 * @see jalview.api.ViewStyleI#getTextColour2()
2137 public Color getTextColour2()
2139 return viewStyle.getTextColour2();
2144 * @see jalview.api.ViewStyleI#getThresholdTextColour()
2146 public int getThresholdTextColour()
2148 return viewStyle.getThresholdTextColour();
2153 * @see jalview.api.ViewStyleI#isConservationColourSelected()
2155 public boolean isConservationColourSelected()
2157 return viewStyle.isConservationColourSelected();
2162 * @see jalview.api.ViewStyleI#isRenderGaps()
2164 public boolean isRenderGaps()
2166 return viewStyle.isRenderGaps();
2171 * @see jalview.api.ViewStyleI#isShowColourText()
2173 public boolean isShowColourText()
2175 return viewStyle.isShowColourText();
2179 * @param conservationColourSelected
2180 * @see jalview.api.ViewStyleI#setConservationColourSelected(boolean)
2182 public void setConservationColourSelected(
2183 boolean conservationColourSelected)
2185 viewStyle.setConservationColourSelected(conservationColourSelected);
2189 * @param showColourText
2190 * @see jalview.api.ViewStyleI#setShowColourText(boolean)
2192 public void setShowColourText(boolean showColourText)
2194 viewStyle.setShowColourText(showColourText);
2199 * @see jalview.api.ViewStyleI#setTextColour(java.awt.Color)
2201 public void setTextColour(Color textColour)
2203 viewStyle.setTextColour(textColour);
2207 * @param thresholdTextColour
2208 * @see jalview.api.ViewStyleI#setThresholdTextColour(int)
2210 public void setThresholdTextColour(int thresholdTextColour)
2212 viewStyle.setThresholdTextColour(thresholdTextColour);
2216 * @param textColour2
2217 * @see jalview.api.ViewStyleI#setTextColour2(java.awt.Color)
2219 public void setTextColour2(Color textColour2)
2221 viewStyle.setTextColour2(textColour2);
2225 public ViewStyleI getViewStyle()
2227 return new ViewStyle(viewStyle);
2231 public void setViewStyle(ViewStyleI settingsForView)
2233 viewStyle = new ViewStyle(settingsForView);
2237 public boolean sameStyle(ViewStyleI them)
2239 return viewStyle.sameStyle(them);
2244 * @see jalview.api.ViewStyleI#getIdWidth()
2246 public int getIdWidth()
2248 return viewStyle.getIdWidth();
2253 * @see jalview.api.ViewStyleI#setIdWidth(int)
2255 public void setIdWidth(int i)
2257 viewStyle.setIdWidth(i);
2262 * @see jalview.api.ViewStyleI#isCentreColumnLabels()
2264 public boolean isCentreColumnLabels()
2266 return viewStyle.isCentreColumnLabels();
2270 * @param centreColumnLabels
2271 * @see jalview.api.ViewStyleI#setCentreColumnLabels(boolean)
2273 public void setCentreColumnLabels(boolean centreColumnLabels)
2275 viewStyle.setCentreColumnLabels(centreColumnLabels);
2280 * @see jalview.api.ViewStyleI#setShowDBRefs(boolean)
2282 public void setShowDBRefs(boolean showdbrefs)
2284 viewStyle.setShowDBRefs(showdbrefs);
2289 * @see jalview.api.ViewStyleI#isShowDBRefs()
2291 public boolean isShowDBRefs()
2293 return viewStyle.isShowDBRefs();
2298 * @see jalview.api.ViewStyleI#isShowNPFeats()
2300 public boolean isShowNPFeats()
2302 return viewStyle.isShowNPFeats();
2306 * @param shownpfeats
2307 * @see jalview.api.ViewStyleI#setShowNPFeats(boolean)
2309 public void setShowNPFeats(boolean shownpfeats)
2311 viewStyle.setShowNPFeats(shownpfeats);
2314 public abstract StructureSelectionManager getStructureSelectionManager();
2317 * Add one command to the command history list.
2321 public void addToHistoryList(CommandI command)
2323 if (this.historyList != null)
2325 this.historyList.push(command);
2326 broadcastCommand(command, false);
2330 protected void broadcastCommand(CommandI command, boolean undo)
2332 getStructureSelectionManager().commandPerformed(command, undo, getVamsasSource());
2336 * Add one command to the command redo list.
2340 public void addToRedoList(CommandI command)
2342 if (this.redoList != null)
2344 this.redoList.push(command);
2346 broadcastCommand(command, true);
2350 * Clear the command redo list.
2352 public void clearRedoList()
2354 if (this.redoList != null)
2356 this.redoList.clear();
2360 public void setHistoryList(Deque<CommandI> list)
2362 this.historyList = list;
2365 public Deque<CommandI> getHistoryList()
2367 return this.historyList;
2370 public void setRedoList(Deque<CommandI> list)
2372 this.redoList = list;
2375 public Deque<CommandI> getRedoList()
2377 return this.redoList;
2381 public VamsasSource getVamsasSource()
2386 public SequenceAnnotationOrder getSortAnnotationsBy()
2388 return sortAnnotationsBy;
2391 public void setSortAnnotationsBy(SequenceAnnotationOrder sortAnnotationsBy)
2393 this.sortAnnotationsBy = sortAnnotationsBy;
2396 public boolean isShowAutocalculatedAbove()
2398 return showAutocalculatedAbove;
2401 public void setShowAutocalculatedAbove(boolean showAutocalculatedAbove)
2403 this.showAutocalculatedAbove = showAutocalculatedAbove;
2407 public boolean isScaleProteinAsCdna()
2409 return viewStyle.isScaleProteinAsCdna();
2413 public void setScaleProteinAsCdna(boolean b)
2415 viewStyle.setScaleProteinAsCdna(b);
2419 * @return true if view should scroll to show the highlighted region of a
2424 public final boolean isFollowHighlight()
2426 return followHighlight;
2430 public final void setFollowHighlight(boolean b)
2432 this.followHighlight = b;
2435 public int getStartRes()
2440 public int getEndRes()
2445 public int getStartSeq()
2450 public void setStartRes(int res)
2452 this.startRes = res;
2455 public void setStartSeq(int seq)
2457 this.startSeq = seq;
2460 public void setEndRes(int res)
2462 if (res > alignment.getWidth() - 1)
2464 // log.System.out.println(" Corrected res from " + res + " to maximum " +
2465 // (alignment.getWidth()-1));
2466 res = alignment.getWidth() - 1;
2475 public void setEndSeq(int seq)
2477 if (seq > alignment.getHeight())
2479 seq = alignment.getHeight();
2488 public int getEndSeq()
2494 * Helper method to populate the SearchResults with the location in the
2495 * complementary alignment to scroll to, in order to match this one.
2498 * the SearchResults to add to
2499 * @return the offset (below top of visible region) of the matched sequence
2501 protected int findComplementScrollTarget(SearchResults sr)
2503 final AlignViewportI complement = getCodingComplement();
2504 if (complement == null || !complement.isFollowHighlight())
2508 boolean iAmProtein = !getAlignment().isNucleotide();
2509 AlignmentI proteinAlignment = iAmProtein ? getAlignment()
2510 : complement.getAlignment();
2511 if (proteinAlignment == null)
2515 final Set<AlignedCodonFrame> mappings = proteinAlignment
2519 * Heuristic: find the first mapped sequence (if any) with a non-gapped
2520 * residue in the middle column of the visible region. Scroll the
2521 * complementary alignment to line up the corresponding residue.
2524 SequenceI sequence = null;
2527 * locate 'middle' column (true middle if an odd number visible, left of
2528 * middle if an even number visible)
2530 int middleColumn = getStartRes() + (getEndRes() - getStartRes()) / 2;
2531 final HiddenSequences hiddenSequences = getAlignment()
2532 .getHiddenSequences();
2535 * searching to the bottom of the alignment gives smoother scrolling across all gapped visible regions
2537 int lastSeq = alignment.getHeight() - 1;
2538 for (int seqNo = getStartSeq(); seqNo < lastSeq; seqNo++, seqOffset++)
2540 sequence = getAlignment().getSequenceAt(seqNo);
2541 if (hiddenSequences != null && hiddenSequences.isHidden(sequence))
2545 if (Comparison.isGap(sequence.getCharAt(middleColumn)))
2549 List<AlignedCodonFrame> seqMappings = MappingUtils
2550 .findMappingsForSequence(sequence, mappings);
2551 if (!seqMappings.isEmpty())
2557 if (sequence == null)
2560 * No ungapped mapped sequence in middle column - do nothing
2564 MappingUtils.addSearchResults(sr, sequence,
2565 sequence.findPosition(middleColumn), mappings);