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.util.ArrayDeque;
25 import java.util.ArrayList;
26 import java.util.BitSet;
27 import java.util.Deque;
28 import java.util.HashMap;
29 import java.util.Hashtable;
30 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.SearchResults;
51 import jalview.datamodel.Sequence;
52 import jalview.datamodel.SequenceCollectionI;
53 import jalview.datamodel.SequenceGroup;
54 import jalview.datamodel.SequenceI;
55 import jalview.schemes.Blosum62ColourScheme;
56 import jalview.schemes.ColourSchemeI;
57 import jalview.schemes.PIDColourScheme;
58 import jalview.schemes.ResidueProperties;
59 import jalview.structure.CommandListener;
60 import jalview.structure.StructureSelectionManager;
61 import jalview.structure.VamsasSource;
62 import jalview.util.Comparison;
63 import jalview.util.MappingUtils;
64 import jalview.viewmodel.styles.ViewStyle;
65 import jalview.workers.AlignCalcManager;
66 import jalview.workers.ComplementConsensusThread;
67 import jalview.workers.ConsensusThread;
68 import jalview.workers.StrucConsensusThread;
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 // 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);
637 public ColourSchemeI getGlobalColourScheme()
639 return globalColourScheme;
642 protected AlignmentAnnotation consensus;
644 protected AlignmentAnnotation complementConsensus;
646 protected AlignmentAnnotation strucConsensus;
648 protected AlignmentAnnotation conservation;
650 protected AlignmentAnnotation quality;
652 protected AlignmentAnnotation[] groupConsensus;
654 protected AlignmentAnnotation[] groupConservation;
657 * results of alignment consensus analysis for visible portion of view
659 protected Hashtable[] hconsensus = null;
662 * results of cDNA complement consensus visible portion of view
664 protected Hashtable[] hcomplementConsensus = null;
667 * results of secondary structure base pair consensus for visible portion of
670 protected Hashtable[] hStrucConsensus = null;
672 protected Conservation hconservation = null;
675 public void setConservation(Conservation cons)
677 hconservation = cons;
681 * percentage gaps allowed in a column before all amino acid properties should
682 * be considered unconserved
684 int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
687 public int getConsPercGaps()
693 public void setSequenceConsensusHash(Hashtable[] hconsensus)
695 this.hconsensus = hconsensus;
699 public void setComplementConsensusHash(Hashtable[] hconsensus)
701 this.hcomplementConsensus = hconsensus;
705 public Hashtable[] getSequenceConsensusHash()
711 public Hashtable[] getComplementConsensusHash()
713 return hcomplementConsensus;
717 public Hashtable[] getRnaStructureConsensusHash()
719 return hStrucConsensus;
723 public void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus)
725 this.hStrucConsensus = hStrucConsensus;
730 public AlignmentAnnotation getAlignmentQualityAnnot()
736 public AlignmentAnnotation getAlignmentConservationAnnotation()
742 public AlignmentAnnotation getAlignmentConsensusAnnotation()
748 public AlignmentAnnotation getComplementConsensusAnnotation()
750 return complementConsensus;
754 public AlignmentAnnotation getAlignmentStrucConsensusAnnotation()
756 return strucConsensus;
759 protected AlignCalcManagerI calculator = new AlignCalcManager();
762 * trigger update of conservation annotation
764 public void updateConservation(final AlignmentViewPanel ap)
766 // see note in mantis : issue number 8585
767 if (alignment.isNucleotide() || conservation == null
768 || !autoCalculateConsensus)
773 .getRegisteredWorkersOfClass(jalview.workers.ConservationThread.class) == null)
775 calculator.registerWorker(new jalview.workers.ConservationThread(
781 * trigger update of consensus annotation
783 public void updateConsensus(final AlignmentViewPanel ap)
785 // see note in mantis : issue number 8585
786 if (consensus == null || !autoCalculateConsensus)
790 if (calculator.getRegisteredWorkersOfClass(ConsensusThread.class) == null)
792 calculator.registerWorker(new ConsensusThread(this, ap));
796 * A separate thread to compute cDNA consensus for a protein alignment
798 final AlignmentI al = this.getAlignment();
799 if (!al.isNucleotide() && al.getCodonFrames() != null
800 && !al.getCodonFrames().isEmpty())
803 .getRegisteredWorkersOfClass(ComplementConsensusThread.class) == null)
805 calculator.registerWorker(new ComplementConsensusThread(this, ap));
810 // --------START Structure Conservation
811 public void updateStrucConsensus(final AlignmentViewPanel ap)
813 if (autoCalculateStrucConsensus && strucConsensus == null
814 && alignment.isNucleotide() && alignment.hasRNAStructure())
816 // secondary structure has been added - so init the consensus line
820 // see note in mantis : issue number 8585
821 if (strucConsensus == null || !autoCalculateStrucConsensus)
825 if (calculator.getRegisteredWorkersOfClass(StrucConsensusThread.class) == null)
827 calculator.registerWorker(new StrucConsensusThread(this, ap));
831 public boolean isCalcInProgress()
833 return calculator.isWorking();
837 public boolean isCalculationInProgress(
838 AlignmentAnnotation alignmentAnnotation)
840 if (!alignmentAnnotation.autoCalculated)
844 if (calculator.workingInvolvedWith(alignmentAnnotation))
846 // System.err.println("grey out ("+alignmentAnnotation.label+")");
853 public boolean isClosed()
855 // TODO: check that this isClosed is only true after panel is closed, not
856 // before it is fully constructed.
857 return alignment == null;
861 public AlignCalcManagerI getCalcManager()
867 * should conservation rows be shown for groups
869 protected boolean showGroupConservation = false;
872 * should consensus rows be shown for groups
874 protected boolean showGroupConsensus = false;
877 * should consensus profile be rendered by default
879 protected boolean showSequenceLogo = false;
882 * should consensus profile be rendered normalised to row height
884 protected boolean normaliseSequenceLogo = false;
887 * should consensus histograms be rendered by default
889 protected boolean showConsensusHistogram = true;
892 * @return the showConsensusProfile
895 public boolean isShowSequenceLogo()
897 return showSequenceLogo;
901 * @param showSequenceLogo
904 public void setShowSequenceLogo(boolean showSequenceLogo)
906 if (showSequenceLogo != this.showSequenceLogo)
908 // TODO: decouple settings setting from calculation when refactoring
909 // annotation update method from alignframe to viewport
910 this.showSequenceLogo = showSequenceLogo;
911 calculator.updateAnnotationFor(ConsensusThread.class);
912 calculator.updateAnnotationFor(ComplementConsensusThread.class);
913 calculator.updateAnnotationFor(StrucConsensusThread.class);
915 this.showSequenceLogo = showSequenceLogo;
919 * @param showConsensusHistogram
920 * the showConsensusHistogram to set
922 public void setShowConsensusHistogram(boolean showConsensusHistogram)
924 this.showConsensusHistogram = showConsensusHistogram;
928 * @return the showGroupConservation
930 public boolean isShowGroupConservation()
932 return showGroupConservation;
936 * @param showGroupConservation
937 * the showGroupConservation to set
939 public void setShowGroupConservation(boolean showGroupConservation)
941 this.showGroupConservation = showGroupConservation;
945 * @return the showGroupConsensus
947 public boolean isShowGroupConsensus()
949 return showGroupConsensus;
953 * @param showGroupConsensus
954 * the showGroupConsensus to set
956 public void setShowGroupConsensus(boolean showGroupConsensus)
958 this.showGroupConsensus = showGroupConsensus;
963 * @return flag to indicate if the consensus histogram should be rendered by
967 public boolean isShowConsensusHistogram()
969 return this.showConsensusHistogram;
973 * when set, updateAlignment will always ensure sequences are of equal length
975 private boolean padGaps = false;
978 * when set, alignment should be reordered according to a newly opened tree
980 public boolean sortByTree = false;
986 * @return null or the currently selected sequence region
989 public SequenceGroup getSelectionGroup()
991 return selectionGroup;
995 * Set the selection group for this window.
998 * - group holding references to sequences in this alignment view
1002 public void setSelectionGroup(SequenceGroup sg)
1004 selectionGroup = sg;
1007 public void setHiddenColumns(ColumnSelection colsel)
1009 this.colSel = colsel;
1013 public ColumnSelection getColumnSelection()
1019 public void setColumnSelection(ColumnSelection colSel)
1021 this.colSel = colSel;
1024 updateHiddenColumns();
1033 public Map<SequenceI, SequenceCollectionI> getHiddenRepSequences()
1035 return hiddenRepSequences;
1039 public void setHiddenRepSequences(
1040 Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
1042 this.hiddenRepSequences = hiddenRepSequences;
1046 public boolean hasHiddenColumns()
1048 return colSel != null && colSel.hasHiddenColumns();
1051 public void updateHiddenColumns()
1053 // this method doesn't really do anything now. But - it could, since a
1054 // column Selection could be in the process of modification
1055 // hasHiddenColumns = colSel.hasHiddenColumns();
1058 protected boolean hasHiddenRows = false;
1061 public boolean hasHiddenRows()
1063 return hasHiddenRows;
1066 protected SequenceGroup selectionGroup;
1068 public void setSequenceSetId(String newid)
1070 if (sequenceSetID != null)
1073 .println("Warning - overwriting a sequenceSetId for a viewport!");
1075 sequenceSetID = new String(newid);
1079 public String getSequenceSetId()
1081 if (sequenceSetID == null)
1083 sequenceSetID = alignment.hashCode() + "";
1086 return sequenceSetID;
1090 * unique viewId for synchronizing state (e.g. with stored Jalview Project)
1093 protected String viewId = null;
1096 public String getViewId()
1100 viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
1105 public void setIgnoreGapsConsensus(boolean b, AlignmentViewPanel ap)
1107 ignoreGapsInConsensusCalculation = b;
1110 updateConsensus(ap);
1111 if (globalColourScheme != null)
1113 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
1114 ignoreGapsInConsensusCalculation);
1120 private long sgrouphash = -1, colselhash = -1;
1123 * checks current SelectionGroup against record of last hash value, and
1127 * update the record of last hash value
1129 * @return true if SelectionGroup changed since last call (when b is true)
1131 public boolean isSelectionGroupChanged(boolean b)
1133 int hc = (selectionGroup == null || selectionGroup.getSize() == 0) ? -1
1134 : selectionGroup.hashCode();
1135 if (hc != -1 && hc != sgrouphash)
1147 * checks current colsel against record of last hash value, and optionally
1151 * update the record of last hash value
1152 * @return true if colsel changed since last call (when b is true)
1154 public boolean isColSelChanged(boolean b)
1156 int hc = (colSel == null || colSel.size() == 0) ? -1 : colSel
1158 if (hc != -1 && hc != colselhash)
1170 public boolean isIgnoreGapsConsensus()
1172 return ignoreGapsInConsensusCalculation;
1175 // / property change stuff
1177 // JBPNote Prolly only need this in the applet version.
1178 private final java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
1181 protected boolean showConservation = true;
1183 protected boolean showQuality = true;
1185 protected boolean showConsensus = true;
1187 private Map<SequenceI, Color> sequenceColours = new HashMap<SequenceI, Color>();
1189 protected SequenceAnnotationOrder sortAnnotationsBy = null;
1191 protected boolean showAutocalculatedAbove;
1194 * when set, view will scroll to show the highlighted position
1196 private boolean followHighlight = true;
1198 // TODO private with getters and setters?
1199 public int startRes;
1203 public int startSeq;
1208 * Property change listener for changes in alignment
1213 public void addPropertyChangeListener(
1214 java.beans.PropertyChangeListener listener)
1216 changeSupport.addPropertyChangeListener(listener);
1225 public void removePropertyChangeListener(
1226 java.beans.PropertyChangeListener listener)
1228 changeSupport.removePropertyChangeListener(listener);
1232 * Property change listener for changes in alignment
1241 public void firePropertyChange(String prop, Object oldvalue,
1244 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
1247 // common hide/show column stuff
1249 public void hideSelectedColumns()
1251 if (colSel.size() < 1)
1256 colSel.hideSelectedColumns();
1257 setSelectionGroup(null);
1261 public void hideColumns(int start, int end)
1265 colSel.hideColumns(start);
1269 colSel.hideColumns(start, end);
1273 public void showColumn(int col)
1275 colSel.revealHiddenColumns(col);
1279 public void showAllHiddenColumns()
1281 colSel.revealAllHiddenColumns();
1284 // common hide/show seq stuff
1285 public void showAllHiddenSeqs()
1287 if (alignment.getHiddenSequences().getSize() > 0)
1289 if (selectionGroup == null)
1291 selectionGroup = new SequenceGroup();
1292 selectionGroup.setEndRes(alignment.getWidth() - 1);
1294 List<SequenceI> tmp = alignment.getHiddenSequences().showAll(
1295 hiddenRepSequences);
1296 for (SequenceI seq : tmp)
1298 selectionGroup.addSequence(seq, false);
1299 setSequenceAnnotationsVisible(seq, true);
1302 hasHiddenRows = false;
1303 hiddenRepSequences = null;
1305 firePropertyChange("alignment", null, alignment.getSequences());
1306 // used to set hasHiddenRows/hiddenRepSequences here, after the property
1312 public void showSequence(int index)
1314 List<SequenceI> tmp = alignment.getHiddenSequences().showSequence(
1316 hiddenRepSequences);
1319 if (selectionGroup == null)
1321 selectionGroup = new SequenceGroup();
1322 selectionGroup.setEndRes(alignment.getWidth() - 1);
1325 for (SequenceI seq : tmp)
1327 selectionGroup.addSequence(seq, false);
1328 setSequenceAnnotationsVisible(seq, true);
1330 // JBPNote: refactor: only update flag if we modified visiblity (used to
1331 // do this regardless)
1332 if (alignment.getHiddenSequences().getSize() < 1)
1334 hasHiddenRows = false;
1336 firePropertyChange("alignment", null, alignment.getSequences());
1341 public void hideAllSelectedSeqs()
1343 if (selectionGroup == null || selectionGroup.getSize() < 1)
1348 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1352 setSelectionGroup(null);
1355 public void hideSequence(SequenceI[] seq)
1359 for (int i = 0; i < seq.length; i++)
1361 alignment.getHiddenSequences().hideSequence(seq[i]);
1362 setSequenceAnnotationsVisible(seq[i], false);
1364 hasHiddenRows = true;
1365 firePropertyChange("alignment", null, alignment.getSequences());
1370 * Set visibility for any annotations for the given sequence.
1374 protected void setSequenceAnnotationsVisible(SequenceI sequenceI,
1377 for (AlignmentAnnotation ann : alignment.getAlignmentAnnotation())
1379 if (ann.sequenceRef == sequenceI)
1381 ann.visible = visible;
1386 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1388 int sSize = sg.getSize();
1394 if (hiddenRepSequences == null)
1396 hiddenRepSequences = new Hashtable();
1399 hiddenRepSequences.put(repSequence, sg);
1401 // Hide all sequences except the repSequence
1402 SequenceI[] seqs = new SequenceI[sSize - 1];
1404 for (int i = 0; i < sSize; i++)
1406 if (sg.getSequenceAt(i) != repSequence)
1408 if (index == sSize - 1)
1413 seqs[index++] = sg.getSequenceAt(i);
1416 sg.setSeqrep(repSequence); // note: not done in 2.7applet
1417 sg.setHidereps(true); // note: not done in 2.7applet
1422 public boolean isHiddenRepSequence(SequenceI seq)
1424 return alignment.getSeqrep()==seq || (hiddenRepSequences != null
1425 && hiddenRepSequences.containsKey(seq));
1428 public SequenceGroup getRepresentedSequences(SequenceI seq)
1430 return (SequenceGroup) (hiddenRepSequences == null ? null
1431 : hiddenRepSequences.get(seq));
1435 public int adjustForHiddenSeqs(int alignmentIndex)
1437 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1442 public void invertColumnSelection()
1444 colSel.invertColumnSelection(0, alignment.getWidth());
1449 public SequenceI[] getSelectionAsNewSequence()
1451 SequenceI[] sequences;
1452 // JBPNote: Need to test jalviewLite.getSelectedSequencesAsAlignmentFrom -
1453 // this was the only caller in the applet for this method
1454 // JBPNote: in applet, this method returned references to the alignment
1455 // sequences, and it did not honour the presence/absence of annotation
1456 // attached to the alignment (probably!)
1457 if (selectionGroup == null || selectionGroup.getSize() == 0)
1459 sequences = alignment.getSequencesArray();
1460 AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
1461 for (int i = 0; i < sequences.length; i++)
1463 // construct new sequence with subset of visible annotation
1464 sequences[i] = new Sequence(sequences[i], annots);
1469 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1477 public SequenceI[] getSequenceSelection()
1479 SequenceI[] sequences = null;
1480 if (selectionGroup != null)
1482 sequences = selectionGroup.getSequencesInOrder(alignment);
1484 if (sequences == null)
1486 sequences = alignment.getSequencesArray();
1493 public CigarArray getViewAsCigars(
1494 boolean selectedRegionOnly)
1496 return new CigarArray(alignment, colSel,
1497 (selectedRegionOnly ? selectionGroup : null));
1502 public jalview.datamodel.AlignmentView getAlignmentView(
1503 boolean selectedOnly)
1505 return getAlignmentView(selectedOnly, false);
1510 public jalview.datamodel.AlignmentView getAlignmentView(
1511 boolean selectedOnly, boolean markGroups)
1513 return new AlignmentView(alignment, colSel, selectionGroup,
1514 colSel != null && colSel.hasHiddenColumns(), selectedOnly,
1520 public String[] getViewAsString(boolean selectedRegionOnly)
1522 String[] selection = null;
1523 SequenceI[] seqs = null;
1525 int start = 0, end = 0;
1526 if (selectedRegionOnly && selectionGroup != null)
1528 iSize = selectionGroup.getSize();
1529 seqs = selectionGroup.getSequencesInOrder(alignment);
1530 start = selectionGroup.getStartRes();
1531 end = selectionGroup.getEndRes() + 1;
1535 iSize = alignment.getHeight();
1536 seqs = alignment.getSequencesArray();
1537 end = alignment.getWidth();
1540 selection = new String[iSize];
1541 if (colSel != null && colSel.hasHiddenColumns())
1543 selection = colSel.getVisibleSequenceStrings(start, end, seqs);
1547 for (i = 0; i < iSize; i++)
1549 selection[i] = seqs[i].getSequenceAsString(start, end);
1558 public List<int[]> getVisibleRegionBoundaries(int min, int max)
1560 ArrayList<int[]> regions = new ArrayList<int[]>();
1566 if (colSel != null && colSel.hasHiddenColumns())
1570 start = colSel.adjustForHiddenColumns(start);
1573 end = colSel.getHiddenBoundaryRight(start);
1584 regions.add(new int[]
1587 if (colSel != null && colSel.hasHiddenColumns())
1589 start = colSel.adjustForHiddenColumns(end);
1590 start = colSel.getHiddenBoundaryLeft(start) + 1;
1592 } while (end < max);
1594 int[][] startEnd = new int[regions.size()][2];
1600 public List<AlignmentAnnotation> getVisibleAlignmentAnnotation(boolean selectedOnly)
1602 ArrayList<AlignmentAnnotation> ala = new ArrayList<AlignmentAnnotation>();
1603 AlignmentAnnotation[] aa;
1604 if ((aa=alignment.getAlignmentAnnotation())!=null)
1606 for (AlignmentAnnotation annot:aa)
1608 AlignmentAnnotation clone = new AlignmentAnnotation(annot);
1609 if (selectedOnly && selectionGroup!=null)
1611 colSel.makeVisibleAnnotation(selectionGroup.getStartRes(), selectionGroup.getEndRes(),clone);
1613 colSel.makeVisibleAnnotation(clone);
1623 public boolean isPadGaps()
1630 public void setPadGaps(boolean padGaps)
1632 this.padGaps = padGaps;
1636 * apply any post-edit constraints and trigger any calculations needed after
1637 * an edit has been performed on the alignment
1642 public void alignmentChanged(AlignmentViewPanel ap)
1646 alignment.padGaps();
1648 if (autoCalculateConsensus)
1650 updateConsensus(ap);
1652 if (hconsensus != null && autoCalculateConsensus)
1654 updateConservation(ap);
1656 if (autoCalculateStrucConsensus)
1658 updateStrucConsensus(ap);
1661 // Reset endRes of groups if beyond alignment width
1662 int alWidth = alignment.getWidth();
1663 List<SequenceGroup> groups = alignment.getGroups();
1666 for (SequenceGroup sg : groups)
1668 if (sg.getEndRes() > alWidth)
1670 sg.setEndRes(alWidth - 1);
1675 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1677 selectionGroup.setEndRes(alWidth - 1);
1680 resetAllColourSchemes();
1681 calculator.restartWorkers();
1682 // alignment.adjustSequenceAnnotations();
1686 * reset scope and do calculations for all applied colourschemes on alignment
1688 void resetAllColourSchemes()
1690 ColourSchemeI cs = globalColourScheme;
1693 cs.alignmentChanged(alignment, hiddenRepSequences);
1695 cs.setConsensus(hconsensus);
1696 if (cs.conservationApplied())
1698 cs.setConservation(Conservation.calculateConservation("All",
1699 ResidueProperties.propHash, 3, alignment.getSequences(), 0,
1700 alignment.getWidth(), false, getConsPercGaps(), false));
1704 for (SequenceGroup sg : alignment.getGroups())
1708 sg.cs.alignmentChanged(sg, hiddenRepSequences);
1710 sg.recalcConservation();
1714 protected void initAutoAnnotation()
1716 // TODO: add menu option action that nulls or creates consensus object
1717 // depending on if the user wants to see the annotation or not in a
1718 // specific alignment
1720 if (hconsensus == null && !isDataset)
1722 if (!alignment.isNucleotide())
1731 consensus = new AlignmentAnnotation("Consensus", "PID",
1732 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
1733 initConsensus(consensus);
1735 initComplementConsensus();
1740 * If this is a protein alignment and there are mappings to cDNA, add the cDNA
1741 * consensus annotation.
1743 public void initComplementConsensus()
1745 if (!alignment.isNucleotide())
1747 final Set<AlignedCodonFrame> codonMappings = alignment
1749 if (codonMappings != null && !codonMappings.isEmpty())
1751 complementConsensus = new AlignmentAnnotation("cDNA Consensus",
1752 "PID for cDNA", new Annotation[1], 0f, 100f,
1753 AlignmentAnnotation.BAR_GRAPH);
1754 initConsensus(complementConsensus);
1759 private void initConsensus(AlignmentAnnotation aa)
1762 aa.autoCalculated = true;
1766 alignment.addAnnotation(aa);
1770 private void initConservation()
1772 if (showConservation)
1774 if (conservation == null)
1776 conservation = new AlignmentAnnotation("Conservation",
1777 "Conservation of total alignment less than "
1778 + getConsPercGaps() + "% gaps", new Annotation[1],
1779 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
1780 conservation.hasText = true;
1781 conservation.autoCalculated = true;
1782 alignment.addAnnotation(conservation);
1787 private void initQuality()
1791 if (quality == null)
1793 quality = new AlignmentAnnotation("Quality",
1794 "Alignment Quality based on Blosum62 scores",
1795 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
1796 quality.hasText = true;
1797 quality.autoCalculated = true;
1798 alignment.addAnnotation(quality);
1803 private void initRNAStructure()
1805 if (alignment.hasRNAStructure() && strucConsensus == null)
1807 strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
1808 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
1809 strucConsensus.hasText = true;
1810 strucConsensus.autoCalculated = true;
1814 alignment.addAnnotation(strucConsensus);
1822 * @see jalview.api.AlignViewportI#calcPanelHeight()
1825 public int calcPanelHeight()
1827 // setHeight of panels
1828 AlignmentAnnotation[] anns = getAlignment().getAlignmentAnnotation();
1830 int charHeight = getCharHeight();
1833 BitSet graphgrp = new BitSet();
1834 for (AlignmentAnnotation aa : anns)
1838 System.err.println("Null annotation row: ignoring.");
1845 if (aa.graphGroup > -1)
1847 if (graphgrp.get(aa.graphGroup))
1853 graphgrp.set(aa.graphGroup);
1860 aa.height += charHeight;
1870 aa.height += aa.graphHeight;
1878 height += aa.height;
1890 public void updateGroupAnnotationSettings(boolean applyGlobalSettings,
1891 boolean preserveNewGroupSettings)
1893 boolean updateCalcs = false;
1894 boolean conv = isShowGroupConservation();
1895 boolean cons = isShowGroupConsensus();
1896 boolean showprf = isShowSequenceLogo();
1897 boolean showConsHist = isShowConsensusHistogram();
1898 boolean normLogo = isNormaliseSequenceLogo();
1901 * TODO reorder the annotation rows according to group/sequence ordering on
1904 boolean sortg = true;
1906 // remove old automatic annotation
1907 // add any new annotation
1909 // intersect alignment annotation with alignment groups
1911 AlignmentAnnotation[] aan = alignment.getAlignmentAnnotation();
1912 List<SequenceGroup> oldrfs = new ArrayList<SequenceGroup>();
1915 for (int an = 0; an < aan.length; an++)
1917 if (aan[an].autoCalculated && aan[an].groupRef != null)
1919 oldrfs.add(aan[an].groupRef);
1920 alignment.deleteAnnotation(aan[an], false);
1924 if (alignment.getGroups() != null)
1926 for (SequenceGroup sg : alignment.getGroups())
1928 updateCalcs = false;
1929 if (applyGlobalSettings
1930 || (!preserveNewGroupSettings && !oldrfs.contains(sg)))
1932 // set defaults for this group's conservation/consensus
1933 sg.setshowSequenceLogo(showprf);
1934 sg.setShowConsensusHistogram(showConsHist);
1935 sg.setNormaliseSequenceLogo(normLogo);
1940 alignment.addAnnotation(sg.getConservationRow(), 0);
1945 alignment.addAnnotation(sg.getConsensus(), 0);
1947 // refresh the annotation rows
1950 sg.recalcConservation();
1957 public boolean isDisplayReferenceSeq()
1959 return alignment.hasSeqrep() && viewStyle.isDisplayReferenceSeq();
1963 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
1965 viewStyle.setDisplayReferenceSeq(displayReferenceSeq);
1969 public boolean isColourByReferenceSeq()
1971 return alignment.hasSeqrep() && viewStyle.isColourByReferenceSeq();
1975 public Color getSequenceColour(SequenceI seq)
1977 Color sqc = sequenceColours.get(seq);
1978 return (sqc == null ? Color.white : sqc);
1982 public void setSequenceColour(SequenceI seq, Color col)
1986 sequenceColours.remove(seq);
1990 sequenceColours.put(seq, col);
1995 public void updateSequenceIdColours()
1997 for (SequenceGroup sg : alignment.getGroups())
1999 if (sg.idColour != null)
2001 for (SequenceI s : sg.getSequences(getHiddenRepSequences()))
2003 sequenceColours.put(s, sg.idColour);
2010 public void clearSequenceColours()
2012 sequenceColours.clear();
2016 public AlignViewportI getCodingComplement()
2018 return this.codingComplement;
2022 * Set this as the (cDna/protein) complement of the given viewport. Also
2023 * ensures the reverse relationship is set on the given viewport.
2026 public void setCodingComplement(AlignViewportI av)
2030 System.err.println("Ignoring recursive setCodingComplement request");
2034 this.codingComplement = av;
2035 // avoid infinite recursion!
2036 if (av.getCodingComplement() != this)
2038 av.setCodingComplement(this);
2044 public boolean isNucleotide()
2046 return getAlignment() == null ? false : getAlignment().isNucleotide();
2050 public FeaturesDisplayedI getFeaturesDisplayed()
2052 return featuresDisplayed;
2056 public void setFeaturesDisplayed(FeaturesDisplayedI featuresDisplayedI)
2058 featuresDisplayed = featuresDisplayedI;
2062 public boolean areFeaturesDisplayed()
2064 return featuresDisplayed != null && featuresDisplayed.getRegisterdFeaturesCount()>0;
2071 * features are displayed if true
2074 public void setShowSequenceFeatures(boolean b)
2076 viewStyle.setShowSequenceFeatures(b);
2079 public boolean isShowSequenceFeatures()
2081 return viewStyle.isShowSequenceFeatures();
2085 public void setShowSequenceFeaturesHeight(boolean selected)
2087 viewStyle.setShowSequenceFeaturesHeight(selected);
2091 public boolean isShowSequenceFeaturesHeight()
2093 return viewStyle.isShowSequenceFeaturesHeight();
2099 public void setShowAnnotation(boolean b)
2101 viewStyle.setShowAnnotation(b);
2105 public boolean isShowAnnotation()
2107 return viewStyle.isShowAnnotation();
2111 public boolean isRightAlignIds()
2113 return viewStyle.isRightAlignIds();
2117 public void setRightAlignIds(boolean rightAlignIds)
2119 viewStyle.setRightAlignIds(rightAlignIds);
2123 public boolean getConservationSelected()
2125 return viewStyle.getConservationSelected();
2129 public void setShowBoxes(boolean state)
2131 viewStyle.setShowBoxes(state);
2136 * @see jalview.api.ViewStyleI#getTextColour()
2138 public Color getTextColour()
2140 return viewStyle.getTextColour();
2145 * @see jalview.api.ViewStyleI#getTextColour2()
2147 public Color getTextColour2()
2149 return viewStyle.getTextColour2();
2154 * @see jalview.api.ViewStyleI#getThresholdTextColour()
2156 public int getThresholdTextColour()
2158 return viewStyle.getThresholdTextColour();
2163 * @see jalview.api.ViewStyleI#isConservationColourSelected()
2165 public boolean isConservationColourSelected()
2167 return viewStyle.isConservationColourSelected();
2172 * @see jalview.api.ViewStyleI#isRenderGaps()
2174 public boolean isRenderGaps()
2176 return viewStyle.isRenderGaps();
2181 * @see jalview.api.ViewStyleI#isShowColourText()
2183 public boolean isShowColourText()
2185 return viewStyle.isShowColourText();
2189 * @param conservationColourSelected
2190 * @see jalview.api.ViewStyleI#setConservationColourSelected(boolean)
2192 public void setConservationColourSelected(
2193 boolean conservationColourSelected)
2195 viewStyle.setConservationColourSelected(conservationColourSelected);
2199 * @param showColourText
2200 * @see jalview.api.ViewStyleI#setShowColourText(boolean)
2202 public void setShowColourText(boolean showColourText)
2204 viewStyle.setShowColourText(showColourText);
2209 * @see jalview.api.ViewStyleI#setTextColour(java.awt.Color)
2211 public void setTextColour(Color textColour)
2213 viewStyle.setTextColour(textColour);
2217 * @param thresholdTextColour
2218 * @see jalview.api.ViewStyleI#setThresholdTextColour(int)
2220 public void setThresholdTextColour(int thresholdTextColour)
2222 viewStyle.setThresholdTextColour(thresholdTextColour);
2226 * @param textColour2
2227 * @see jalview.api.ViewStyleI#setTextColour2(java.awt.Color)
2229 public void setTextColour2(Color textColour2)
2231 viewStyle.setTextColour2(textColour2);
2235 public ViewStyleI getViewStyle()
2237 return new ViewStyle(viewStyle);
2241 public void setViewStyle(ViewStyleI settingsForView)
2243 viewStyle = new ViewStyle(settingsForView);
2247 public boolean sameStyle(ViewStyleI them)
2249 return viewStyle.sameStyle(them);
2254 * @see jalview.api.ViewStyleI#getIdWidth()
2256 public int getIdWidth()
2258 return viewStyle.getIdWidth();
2263 * @see jalview.api.ViewStyleI#setIdWidth(int)
2265 public void setIdWidth(int i)
2267 viewStyle.setIdWidth(i);
2272 * @see jalview.api.ViewStyleI#isCentreColumnLabels()
2274 public boolean isCentreColumnLabels()
2276 return viewStyle.isCentreColumnLabels();
2280 * @param centreColumnLabels
2281 * @see jalview.api.ViewStyleI#setCentreColumnLabels(boolean)
2283 public void setCentreColumnLabels(boolean centreColumnLabels)
2285 viewStyle.setCentreColumnLabels(centreColumnLabels);
2290 * @see jalview.api.ViewStyleI#setShowDBRefs(boolean)
2292 public void setShowDBRefs(boolean showdbrefs)
2294 viewStyle.setShowDBRefs(showdbrefs);
2299 * @see jalview.api.ViewStyleI#isShowDBRefs()
2301 public boolean isShowDBRefs()
2303 return viewStyle.isShowDBRefs();
2308 * @see jalview.api.ViewStyleI#isShowNPFeats()
2310 public boolean isShowNPFeats()
2312 return viewStyle.isShowNPFeats();
2316 * @param shownpfeats
2317 * @see jalview.api.ViewStyleI#setShowNPFeats(boolean)
2319 public void setShowNPFeats(boolean shownpfeats)
2321 viewStyle.setShowNPFeats(shownpfeats);
2324 public abstract StructureSelectionManager getStructureSelectionManager();
2327 * Add one command to the command history list.
2331 public void addToHistoryList(CommandI command)
2333 if (this.historyList != null)
2335 this.historyList.push(command);
2336 broadcastCommand(command, false);
2340 protected void broadcastCommand(CommandI command, boolean undo)
2342 getStructureSelectionManager().commandPerformed(command, undo, getVamsasSource());
2346 * Add one command to the command redo list.
2350 public void addToRedoList(CommandI command)
2352 if (this.redoList != null)
2354 this.redoList.push(command);
2356 broadcastCommand(command, true);
2360 * Clear the command redo list.
2362 public void clearRedoList()
2364 if (this.redoList != null)
2366 this.redoList.clear();
2370 public void setHistoryList(Deque<CommandI> list)
2372 this.historyList = list;
2375 public Deque<CommandI> getHistoryList()
2377 return this.historyList;
2380 public void setRedoList(Deque<CommandI> list)
2382 this.redoList = list;
2385 public Deque<CommandI> getRedoList()
2387 return this.redoList;
2391 public VamsasSource getVamsasSource()
2396 public SequenceAnnotationOrder getSortAnnotationsBy()
2398 return sortAnnotationsBy;
2401 public void setSortAnnotationsBy(SequenceAnnotationOrder sortAnnotationsBy)
2403 this.sortAnnotationsBy = sortAnnotationsBy;
2406 public boolean isShowAutocalculatedAbove()
2408 return showAutocalculatedAbove;
2411 public void setShowAutocalculatedAbove(boolean showAutocalculatedAbove)
2413 this.showAutocalculatedAbove = showAutocalculatedAbove;
2417 public boolean isScaleProteinAsCdna()
2419 return viewStyle.isScaleProteinAsCdna();
2423 public void setScaleProteinAsCdna(boolean b)
2425 viewStyle.setScaleProteinAsCdna(b);
2429 * @return true if view should scroll to show the highlighted region of a
2434 public final boolean isFollowHighlight()
2436 return followHighlight;
2440 public final void setFollowHighlight(boolean b)
2442 this.followHighlight = b;
2445 public int getStartRes()
2450 public int getEndRes()
2455 public int getStartSeq()
2460 public void setStartRes(int res)
2462 this.startRes = res;
2465 public void setStartSeq(int seq)
2467 this.startSeq = seq;
2470 public void setEndRes(int res)
2472 if (res > alignment.getWidth() - 1)
2474 // log.System.out.println(" Corrected res from " + res + " to maximum " +
2475 // (alignment.getWidth()-1));
2476 res = alignment.getWidth() - 1;
2485 public void setEndSeq(int seq)
2487 if (seq > alignment.getHeight())
2489 seq = alignment.getHeight();
2498 public int getEndSeq()
2504 * Helper method to populate the SearchResults with the location in the
2505 * complementary alignment to scroll to, in order to match this one.
2508 * the SearchResults to add to
2509 * @return the offset (below top of visible region) of the matched sequence
2511 protected int findComplementScrollTarget(SearchResults sr)
2513 final AlignViewportI codingComplement = getCodingComplement();
2514 if (codingComplement == null || !codingComplement.isFollowHighlight())
2518 boolean iAmProtein = !getAlignment().isNucleotide();
2519 AlignmentI proteinAlignment = iAmProtein ? getAlignment()
2520 : codingComplement.getAlignment();
2521 if (proteinAlignment == null)
2525 final Set<AlignedCodonFrame> mappings = proteinAlignment
2529 * Heuristic: find the first mapped sequence (if any) with a non-gapped
2530 * residue in the middle column of the visible region. Scroll the
2531 * complementary alignment to line up the corresponding residue.
2534 SequenceI sequence = null;
2537 * locate 'middle' column (true middle if an odd number visible, left of
2538 * middle if an even number visible)
2540 int middleColumn = getStartRes() + (getEndRes() - getStartRes()) / 2;
2541 final HiddenSequences hiddenSequences = getAlignment()
2542 .getHiddenSequences();
2543 for (int seqNo = getStartSeq(); seqNo < getEndSeq(); seqNo++, seqOffset++)
2545 sequence = getAlignment().getSequenceAt(seqNo);
2546 if (hiddenSequences != null && hiddenSequences.isHidden(sequence))
2550 if (Comparison.isGap(sequence.getCharAt(middleColumn)))
2554 List<AlignedCodonFrame> seqMappings = MappingUtils
2555 .findMappingsForSequence(sequence, mappings);
2556 if (!seqMappings.isEmpty())
2562 if (sequence == null)
2565 * No ungapped mapped sequence in middle column - do nothing
2569 MappingUtils.addSearchResults(sr, sequence,
2570 sequence.findPosition(middleColumn), mappings);