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)
99 public void setFontName(String name)
101 viewStyle.setFontName(name);
106 * @see jalview.api.ViewStyleI#setFontStyle(int)
109 public void setFontStyle(int style)
111 viewStyle.setFontStyle(style);
116 * @see jalview.api.ViewStyleI#setFontSize(int)
119 public void setFontSize(int size)
121 viewStyle.setFontSize(size);
126 * @see jalview.api.ViewStyleI#getFontStyle()
129 public int getFontStyle()
131 return viewStyle.getFontStyle();
136 * @see jalview.api.ViewStyleI#getFontName()
139 public String getFontName()
141 return viewStyle.getFontName();
146 * @see jalview.api.ViewStyleI#getFontSize()
149 public int getFontSize()
151 return viewStyle.getFontSize();
155 * @param upperCasebold
156 * @see jalview.api.ViewStyleI#setUpperCasebold(boolean)
159 public void setUpperCasebold(boolean upperCasebold)
161 viewStyle.setUpperCasebold(upperCasebold);
166 * @see jalview.api.ViewStyleI#isUpperCasebold()
169 public boolean isUpperCasebold()
171 return viewStyle.isUpperCasebold();
176 * @see jalview.api.ViewStyleI#isSeqNameItalics()
179 public boolean isSeqNameItalics()
181 return viewStyle.isSeqNameItalics();
185 * @param colourByReferenceSeq
186 * @see jalview.api.ViewStyleI#setColourByReferenceSeq(boolean)
189 public void setColourByReferenceSeq(boolean colourByReferenceSeq)
191 viewStyle.setColourByReferenceSeq(colourByReferenceSeq);
196 * @see jalview.api.ViewStyleI#setColourAppliesToAllGroups(boolean)
199 public void setColourAppliesToAllGroups(boolean b)
201 viewStyle.setColourAppliesToAllGroups(b);
206 * @see jalview.api.ViewStyleI#getColourAppliesToAllGroups()
209 public boolean getColourAppliesToAllGroups()
211 return viewStyle.getColourAppliesToAllGroups();
216 * @see jalview.api.ViewStyleI#getAbovePIDThreshold()
219 public boolean getAbovePIDThreshold()
221 return viewStyle.getAbovePIDThreshold();
226 * @see jalview.api.ViewStyleI#setIncrement(int)
229 public void setIncrement(int inc)
231 viewStyle.setIncrement(inc);
236 * @see jalview.api.ViewStyleI#getIncrement()
239 public int getIncrement()
241 return viewStyle.getIncrement();
246 * @see jalview.api.ViewStyleI#setConservationSelected(boolean)
249 public void setConservationSelected(boolean b)
251 viewStyle.setConservationSelected(b);
256 * @see jalview.api.ViewStyleI#setShowHiddenMarkers(boolean)
259 public void setShowHiddenMarkers(boolean show)
261 viewStyle.setShowHiddenMarkers(show);
266 * @see jalview.api.ViewStyleI#getShowHiddenMarkers()
269 public boolean getShowHiddenMarkers()
271 return viewStyle.getShowHiddenMarkers();
276 * @see jalview.api.ViewStyleI#setScaleRightWrapped(boolean)
279 public void setScaleRightWrapped(boolean b)
281 viewStyle.setScaleRightWrapped(b);
286 * @see jalview.api.ViewStyleI#setScaleLeftWrapped(boolean)
289 public void setScaleLeftWrapped(boolean b)
291 viewStyle.setScaleLeftWrapped(b);
296 * @see jalview.api.ViewStyleI#setScaleAboveWrapped(boolean)
299 public void setScaleAboveWrapped(boolean b)
301 viewStyle.setScaleAboveWrapped(b);
306 * @see jalview.api.ViewStyleI#getScaleLeftWrapped()
309 public boolean getScaleLeftWrapped()
311 return viewStyle.getScaleLeftWrapped();
316 * @see jalview.api.ViewStyleI#getScaleAboveWrapped()
319 public boolean getScaleAboveWrapped()
321 return viewStyle.getScaleAboveWrapped();
326 * @see jalview.api.ViewStyleI#getScaleRightWrapped()
329 public boolean getScaleRightWrapped()
331 return viewStyle.getScaleRightWrapped();
336 * @see jalview.api.ViewStyleI#setAbovePIDThreshold(boolean)
339 public void setAbovePIDThreshold(boolean b)
341 viewStyle.setAbovePIDThreshold(b);
346 * @see jalview.api.ViewStyleI#setThreshold(int)
349 public void setThreshold(int thresh)
351 viewStyle.setThreshold(thresh);
356 * @see jalview.api.ViewStyleI#getThreshold()
359 public int getThreshold()
361 return viewStyle.getThreshold();
366 * @see jalview.api.ViewStyleI#getShowJVSuffix()
369 public boolean getShowJVSuffix()
371 return viewStyle.getShowJVSuffix();
376 * @see jalview.api.ViewStyleI#setShowJVSuffix(boolean)
379 public void setShowJVSuffix(boolean b)
381 viewStyle.setShowJVSuffix(b);
386 * @see jalview.api.ViewStyleI#setWrapAlignment(boolean)
389 public void setWrapAlignment(boolean state)
391 viewStyle.setWrapAlignment(state);
396 * @see jalview.api.ViewStyleI#setShowText(boolean)
399 public void setShowText(boolean state)
401 viewStyle.setShowText(state);
406 * @see jalview.api.ViewStyleI#setRenderGaps(boolean)
409 public void setRenderGaps(boolean state)
411 viewStyle.setRenderGaps(state);
416 * @see jalview.api.ViewStyleI#getColourText()
419 public boolean getColourText()
421 return viewStyle.getColourText();
426 * @see jalview.api.ViewStyleI#setColourText(boolean)
429 public void setColourText(boolean state)
431 viewStyle.setColourText(state);
436 * @see jalview.api.ViewStyleI#getWrapAlignment()
439 public boolean getWrapAlignment()
441 return viewStyle.getWrapAlignment();
446 * @see jalview.api.ViewStyleI#getShowText()
449 public boolean getShowText()
451 return viewStyle.getShowText();
456 * @see jalview.api.ViewStyleI#getWrappedWidth()
459 public int getWrappedWidth()
461 return viewStyle.getWrappedWidth();
466 * @see jalview.api.ViewStyleI#setWrappedWidth(int)
469 public void setWrappedWidth(int w)
471 viewStyle.setWrappedWidth(w);
476 * @see jalview.api.ViewStyleI#getCharHeight()
479 public int getCharHeight()
481 return viewStyle.getCharHeight();
486 * @see jalview.api.ViewStyleI#setCharHeight(int)
489 public void setCharHeight(int h)
491 viewStyle.setCharHeight(h);
496 * @see jalview.api.ViewStyleI#getCharWidth()
499 public int getCharWidth()
501 return viewStyle.getCharWidth();
506 * @see jalview.api.ViewStyleI#setCharWidth(int)
509 public void setCharWidth(int w)
511 viewStyle.setCharWidth(w);
516 * @see jalview.api.ViewStyleI#getShowBoxes()
519 public boolean getShowBoxes()
521 return viewStyle.getShowBoxes();
526 * @see jalview.api.ViewStyleI#getShowUnconserved()
529 public boolean getShowUnconserved()
531 return viewStyle.getShowUnconserved();
535 * @param showunconserved
536 * @see jalview.api.ViewStyleI#setShowUnconserved(boolean)
539 public void setShowUnconserved(boolean showunconserved)
541 viewStyle.setShowUnconserved(showunconserved);
546 * @see jalview.api.ViewStyleI#setSeqNameItalics(boolean)
549 public void setSeqNameItalics(boolean default1)
551 viewStyle.setSeqNameItalics(default1);
555 * alignment displayed in the viewport. Please use get/setter
557 protected AlignmentI alignment;
560 public AlignmentI getAlignment()
566 public char getGapCharacter()
568 return alignment.getGapCharacter();
571 protected String sequenceSetID;
574 * probably unused indicator that view is of a dataset rather than an
577 protected boolean isDataset = false;
579 public void setDataset(boolean b)
584 public boolean isDataset()
589 private Map<SequenceI, SequenceCollectionI> hiddenRepSequences;
591 protected ColumnSelection colSel = new ColumnSelection();
593 public boolean autoCalculateConsensus = true;
595 protected boolean autoCalculateStrucConsensus = true;
597 protected boolean ignoreGapsInConsensusCalculation = false;
599 protected ColourSchemeI globalColourScheme = null;
602 public void setGlobalColourScheme(ColourSchemeI cs)
604 // TODO: logic refactored from AlignFrame changeColour -
605 // TODO: autorecalc stuff should be changed to rely on the worker system
606 // check to see if we should implement a changeColour(cs) method rather than
607 // put th logic in here
608 // - means that caller decides if they want to just modify state and defer
609 // calculation till later or to do all calculations in thread.
611 globalColourScheme = cs;
612 boolean recalc = false;
615 cs.setConservationApplied(recalc = getConservationSelected());
616 if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
617 || cs instanceof Blosum62ColourScheme)
620 cs.setThreshold(viewStyle.getThreshold(),
621 ignoreGapsInConsensusCalculation);
625 cs.setThreshold(0, ignoreGapsInConsensusCalculation);
629 cs.setConsensus(hconsensus);
630 cs.setConservation(hconservation);
632 cs.alignmentChanged(alignment, hiddenRepSequences);
634 if (getColourAppliesToAllGroups())
636 for (SequenceGroup sg : getAlignment().getGroups())
643 sg.cs = cs.applyTo(sg, getHiddenRepSequences());
644 sg.setConsPercGaps(ConsPercGaps);
645 if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
646 || cs instanceof Blosum62ColourScheme)
648 sg.cs.setThreshold(viewStyle.getThreshold(),
649 isIgnoreGapsConsensus());
654 sg.cs.setThreshold(0, isIgnoreGapsConsensus());
657 if (getConservationSelected())
659 sg.cs.setConservationApplied(true);
664 sg.cs.setConservation(null);
665 // sg.cs.setThreshold(0, getIgnoreGapsConsensus());
669 sg.recalcConservation();
673 sg.cs.alignmentChanged(sg, hiddenRepSequences);
680 public ColourSchemeI getGlobalColourScheme()
682 return globalColourScheme;
685 protected AlignmentAnnotation consensus;
687 protected AlignmentAnnotation complementConsensus;
689 protected AlignmentAnnotation strucConsensus;
691 protected AlignmentAnnotation conservation;
693 protected AlignmentAnnotation quality;
695 protected AlignmentAnnotation[] groupConsensus;
697 protected AlignmentAnnotation[] groupConservation;
700 * results of alignment consensus analysis for visible portion of view
702 protected Hashtable[] hconsensus = null;
705 * results of cDNA complement consensus visible portion of view
707 protected Hashtable[] hcomplementConsensus = null;
710 * results of secondary structure base pair consensus for visible portion of
713 protected Hashtable[] hStrucConsensus = null;
715 protected Conservation hconservation = null;
718 public void setConservation(Conservation cons)
720 hconservation = cons;
724 * percentage gaps allowed in a column before all amino acid properties should
725 * be considered unconserved
727 int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
730 public int getConsPercGaps()
736 public void setSequenceConsensusHash(Hashtable[] hconsensus)
738 this.hconsensus = hconsensus;
742 public void setComplementConsensusHash(Hashtable[] hconsensus)
744 this.hcomplementConsensus = hconsensus;
748 public Hashtable[] getSequenceConsensusHash()
754 public Hashtable[] getComplementConsensusHash()
756 return hcomplementConsensus;
760 public Hashtable[] getRnaStructureConsensusHash()
762 return hStrucConsensus;
766 public void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus)
768 this.hStrucConsensus = hStrucConsensus;
773 public AlignmentAnnotation getAlignmentQualityAnnot()
779 public AlignmentAnnotation getAlignmentConservationAnnotation()
785 public AlignmentAnnotation getAlignmentConsensusAnnotation()
791 public AlignmentAnnotation getComplementConsensusAnnotation()
793 return complementConsensus;
797 public AlignmentAnnotation getAlignmentStrucConsensusAnnotation()
799 return strucConsensus;
802 protected AlignCalcManagerI calculator = new AlignCalcManager();
805 * trigger update of conservation annotation
807 public void updateConservation(final AlignmentViewPanel ap)
809 // see note in mantis : issue number 8585
810 if (alignment.isNucleotide() || conservation == null
811 || !autoCalculateConsensus)
816 .getRegisteredWorkersOfClass(jalview.workers.ConservationThread.class) == null)
818 calculator.registerWorker(new jalview.workers.ConservationThread(
824 * trigger update of consensus annotation
826 public void updateConsensus(final AlignmentViewPanel ap)
828 // see note in mantis : issue number 8585
829 if (consensus == null || !autoCalculateConsensus)
833 if (calculator.getRegisteredWorkersOfClass(ConsensusThread.class) == null)
835 calculator.registerWorker(new ConsensusThread(this, ap));
839 * A separate thread to compute cDNA consensus for a protein alignment
841 final AlignmentI al = this.getAlignment();
842 if (!al.isNucleotide() && al.getCodonFrames() != null
843 && !al.getCodonFrames().isEmpty())
846 .getRegisteredWorkersOfClass(ComplementConsensusThread.class) == null)
848 calculator.registerWorker(new ComplementConsensusThread(this, ap));
853 // --------START Structure Conservation
854 public void updateStrucConsensus(final AlignmentViewPanel ap)
856 if (autoCalculateStrucConsensus && strucConsensus == null
857 && alignment.isNucleotide() && alignment.hasRNAStructure())
859 // secondary structure has been added - so init the consensus line
863 // see note in mantis : issue number 8585
864 if (strucConsensus == null || !autoCalculateStrucConsensus)
868 if (calculator.getRegisteredWorkersOfClass(StrucConsensusThread.class) == null)
870 calculator.registerWorker(new StrucConsensusThread(this, ap));
874 public boolean isCalcInProgress()
876 return calculator.isWorking();
880 public boolean isCalculationInProgress(
881 AlignmentAnnotation alignmentAnnotation)
883 if (!alignmentAnnotation.autoCalculated)
887 if (calculator.workingInvolvedWith(alignmentAnnotation))
889 // System.err.println("grey out ("+alignmentAnnotation.label+")");
896 public boolean isClosed()
898 // TODO: check that this isClosed is only true after panel is closed, not
899 // before it is fully constructed.
900 return alignment == null;
904 public AlignCalcManagerI getCalcManager()
910 * should conservation rows be shown for groups
912 protected boolean showGroupConservation = false;
915 * should consensus rows be shown for groups
917 protected boolean showGroupConsensus = false;
920 * should consensus profile be rendered by default
922 protected boolean showSequenceLogo = false;
925 * should consensus profile be rendered normalised to row height
927 protected boolean normaliseSequenceLogo = false;
930 * should consensus histograms be rendered by default
932 protected boolean showConsensusHistogram = true;
935 * @return the showConsensusProfile
938 public boolean isShowSequenceLogo()
940 return showSequenceLogo;
944 * @param showSequenceLogo
947 public void setShowSequenceLogo(boolean showSequenceLogo)
949 if (showSequenceLogo != this.showSequenceLogo)
951 // TODO: decouple settings setting from calculation when refactoring
952 // annotation update method from alignframe to viewport
953 this.showSequenceLogo = showSequenceLogo;
954 calculator.updateAnnotationFor(ConsensusThread.class);
955 calculator.updateAnnotationFor(ComplementConsensusThread.class);
956 calculator.updateAnnotationFor(StrucConsensusThread.class);
958 this.showSequenceLogo = showSequenceLogo;
962 * @param showConsensusHistogram
963 * the showConsensusHistogram to set
965 public void setShowConsensusHistogram(boolean showConsensusHistogram)
967 this.showConsensusHistogram = showConsensusHistogram;
971 * @return the showGroupConservation
973 public boolean isShowGroupConservation()
975 return showGroupConservation;
979 * @param showGroupConservation
980 * the showGroupConservation to set
982 public void setShowGroupConservation(boolean showGroupConservation)
984 this.showGroupConservation = showGroupConservation;
988 * @return the showGroupConsensus
990 public boolean isShowGroupConsensus()
992 return showGroupConsensus;
996 * @param showGroupConsensus
997 * the showGroupConsensus to set
999 public void setShowGroupConsensus(boolean showGroupConsensus)
1001 this.showGroupConsensus = showGroupConsensus;
1006 * @return flag to indicate if the consensus histogram should be rendered by
1010 public boolean isShowConsensusHistogram()
1012 return this.showConsensusHistogram;
1016 * when set, updateAlignment will always ensure sequences are of equal length
1018 private boolean padGaps = false;
1021 * when set, alignment should be reordered according to a newly opened tree
1023 public boolean sortByTree = false;
1028 * @return null or the currently selected sequence region
1031 public SequenceGroup getSelectionGroup()
1033 return selectionGroup;
1037 * Set the selection group for this window.
1040 * - group holding references to sequences in this alignment view
1044 public void setSelectionGroup(SequenceGroup sg)
1046 selectionGroup = sg;
1049 public void setHiddenColumns(ColumnSelection colsel)
1051 this.colSel = colsel;
1055 public ColumnSelection getColumnSelection()
1061 public void setColumnSelection(ColumnSelection colSel)
1063 this.colSel = colSel;
1066 updateHiddenColumns();
1075 public Map<SequenceI, SequenceCollectionI> getHiddenRepSequences()
1077 return hiddenRepSequences;
1081 public void setHiddenRepSequences(
1082 Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
1084 this.hiddenRepSequences = hiddenRepSequences;
1088 public boolean hasHiddenColumns()
1090 return colSel != null && colSel.hasHiddenColumns();
1093 public void updateHiddenColumns()
1095 // this method doesn't really do anything now. But - it could, since a
1096 // column Selection could be in the process of modification
1097 // hasHiddenColumns = colSel.hasHiddenColumns();
1101 public boolean hasHiddenRows()
1103 return alignment.getHiddenSequences().getSize() > 0;
1106 protected SequenceGroup selectionGroup;
1108 public void setSequenceSetId(String newid)
1110 if (sequenceSetID != null)
1113 .println("Warning - overwriting a sequenceSetId for a viewport!");
1115 sequenceSetID = new String(newid);
1119 public String getSequenceSetId()
1121 if (sequenceSetID == null)
1123 sequenceSetID = alignment.hashCode() + "";
1126 return sequenceSetID;
1130 * unique viewId for synchronizing state (e.g. with stored Jalview Project)
1133 protected String viewId = null;
1136 public String getViewId()
1140 viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
1145 public void setIgnoreGapsConsensus(boolean b, AlignmentViewPanel ap)
1147 ignoreGapsInConsensusCalculation = b;
1150 updateConsensus(ap);
1151 if (globalColourScheme != null)
1153 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
1154 ignoreGapsInConsensusCalculation);
1160 private long sgrouphash = -1, colselhash = -1;
1163 * checks current SelectionGroup against record of last hash value, and
1167 * update the record of last hash value
1169 * @return true if SelectionGroup changed since last call (when b is true)
1171 public boolean isSelectionGroupChanged(boolean b)
1173 int hc = (selectionGroup == null || selectionGroup.getSize() == 0) ? -1
1174 : selectionGroup.hashCode();
1175 if (hc != -1 && hc != sgrouphash)
1187 * checks current colsel against record of last hash value, and optionally
1191 * update the record of last hash value
1192 * @return true if colsel changed since last call (when b is true)
1194 public boolean isColSelChanged(boolean b)
1196 int hc = (colSel == null || colSel.isEmpty()) ? -1 : colSel
1198 if (hc != -1 && hc != colselhash)
1210 public boolean isIgnoreGapsConsensus()
1212 return ignoreGapsInConsensusCalculation;
1215 // / property change stuff
1217 // JBPNote Prolly only need this in the applet version.
1218 private final java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
1221 protected boolean showConservation = true;
1223 protected boolean showQuality = true;
1225 protected boolean showConsensus = true;
1227 private Map<SequenceI, Color> sequenceColours = new HashMap<SequenceI, Color>();
1229 protected SequenceAnnotationOrder sortAnnotationsBy = null;
1231 protected boolean showAutocalculatedAbove;
1234 * when set, view will scroll to show the highlighted position
1236 private boolean followHighlight = true;
1238 // TODO private with getters and setters?
1239 public int startRes;
1243 public int startSeq;
1248 * Property change listener for changes in alignment
1253 public void addPropertyChangeListener(
1254 java.beans.PropertyChangeListener listener)
1256 changeSupport.addPropertyChangeListener(listener);
1265 public void removePropertyChangeListener(
1266 java.beans.PropertyChangeListener listener)
1268 changeSupport.removePropertyChangeListener(listener);
1272 * Property change listener for changes in alignment
1281 public void firePropertyChange(String prop, Object oldvalue,
1284 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
1287 // common hide/show column stuff
1289 public void hideSelectedColumns()
1291 if (colSel.isEmpty())
1296 colSel.hideSelectedColumns();
1297 setSelectionGroup(null);
1301 public void hideColumns(int start, int end)
1305 colSel.hideColumns(start);
1309 colSel.hideColumns(start, end);
1313 public void showColumn(int col)
1315 colSel.revealHiddenColumns(col);
1319 public void showAllHiddenColumns()
1321 colSel.revealAllHiddenColumns();
1324 // common hide/show seq stuff
1325 public void showAllHiddenSeqs()
1327 if (alignment.getHiddenSequences().getSize() > 0)
1329 if (selectionGroup == null)
1331 selectionGroup = new SequenceGroup();
1332 selectionGroup.setEndRes(alignment.getWidth() - 1);
1334 List<SequenceI> tmp = alignment.getHiddenSequences().showAll(
1335 hiddenRepSequences);
1336 for (SequenceI seq : tmp)
1338 selectionGroup.addSequence(seq, false);
1339 setSequenceAnnotationsVisible(seq, true);
1342 hiddenRepSequences = null;
1344 firePropertyChange("alignment", null, alignment.getSequences());
1345 // used to set hasHiddenRows/hiddenRepSequences here, after the property
1351 public void showSequence(int index)
1353 List<SequenceI> tmp = alignment.getHiddenSequences().showSequence(
1354 index, hiddenRepSequences);
1357 if (selectionGroup == null)
1359 selectionGroup = new SequenceGroup();
1360 selectionGroup.setEndRes(alignment.getWidth() - 1);
1363 for (SequenceI seq : tmp)
1365 selectionGroup.addSequence(seq, false);
1366 setSequenceAnnotationsVisible(seq, true);
1368 firePropertyChange("alignment", null, alignment.getSequences());
1373 public void hideAllSelectedSeqs()
1375 if (selectionGroup == null || selectionGroup.getSize() < 1)
1380 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1384 setSelectionGroup(null);
1387 public void hideSequence(SequenceI[] seq)
1391 for (int i = 0; i < seq.length; i++)
1393 alignment.getHiddenSequences().hideSequence(seq[i]);
1394 setSequenceAnnotationsVisible(seq[i], false);
1396 firePropertyChange("alignment", null, alignment.getSequences());
1401 * Set visibility for any annotations for the given sequence.
1405 protected void setSequenceAnnotationsVisible(SequenceI sequenceI,
1408 for (AlignmentAnnotation ann : alignment.getAlignmentAnnotation())
1410 if (ann.sequenceRef == sequenceI)
1412 ann.visible = visible;
1417 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1419 int sSize = sg.getSize();
1425 if (hiddenRepSequences == null)
1427 hiddenRepSequences = new Hashtable();
1430 hiddenRepSequences.put(repSequence, sg);
1432 // Hide all sequences except the repSequence
1433 SequenceI[] seqs = new SequenceI[sSize - 1];
1435 for (int i = 0; i < sSize; i++)
1437 if (sg.getSequenceAt(i) != repSequence)
1439 if (index == sSize - 1)
1444 seqs[index++] = sg.getSequenceAt(i);
1447 sg.setSeqrep(repSequence); // note: not done in 2.7applet
1448 sg.setHidereps(true); // note: not done in 2.7applet
1453 public boolean isHiddenRepSequence(SequenceI seq)
1455 return alignment.getSeqrep() == seq
1456 || (hiddenRepSequences != null && hiddenRepSequences
1460 public SequenceGroup getRepresentedSequences(SequenceI seq)
1462 return (SequenceGroup) (hiddenRepSequences == null ? null
1463 : hiddenRepSequences.get(seq));
1467 public int adjustForHiddenSeqs(int alignmentIndex)
1469 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1474 public void invertColumnSelection()
1476 colSel.invertColumnSelection(0, alignment.getWidth());
1480 public SequenceI[] getSelectionAsNewSequence()
1482 SequenceI[] sequences;
1483 // JBPNote: Need to test jalviewLite.getSelectedSequencesAsAlignmentFrom -
1484 // this was the only caller in the applet for this method
1485 // JBPNote: in applet, this method returned references to the alignment
1486 // sequences, and it did not honour the presence/absence of annotation
1487 // attached to the alignment (probably!)
1488 if (selectionGroup == null || selectionGroup.getSize() == 0)
1490 sequences = alignment.getSequencesArray();
1491 AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
1492 for (int i = 0; i < sequences.length; i++)
1494 // construct new sequence with subset of visible annotation
1495 sequences[i] = new Sequence(sequences[i], annots);
1500 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1507 public SequenceI[] getSequenceSelection()
1509 SequenceI[] sequences = null;
1510 if (selectionGroup != null)
1512 sequences = selectionGroup.getSequencesInOrder(alignment);
1514 if (sequences == null)
1516 sequences = alignment.getSequencesArray();
1522 public CigarArray getViewAsCigars(boolean selectedRegionOnly)
1524 return new CigarArray(alignment, colSel,
1525 (selectedRegionOnly ? selectionGroup : null));
1529 public jalview.datamodel.AlignmentView getAlignmentView(
1530 boolean selectedOnly)
1532 return getAlignmentView(selectedOnly, false);
1536 public jalview.datamodel.AlignmentView getAlignmentView(
1537 boolean selectedOnly, boolean markGroups)
1539 return new AlignmentView(alignment, colSel, selectionGroup,
1540 colSel != null && colSel.hasHiddenColumns(), selectedOnly,
1545 public String[] getViewAsString(boolean selectedRegionOnly)
1547 String[] selection = null;
1548 SequenceI[] seqs = null;
1550 int start = 0, end = 0;
1551 if (selectedRegionOnly && selectionGroup != null)
1553 iSize = selectionGroup.getSize();
1554 seqs = selectionGroup.getSequencesInOrder(alignment);
1555 start = selectionGroup.getStartRes();
1556 end = selectionGroup.getEndRes() + 1;
1560 if (hasHiddenRows())
1562 iSize = alignment.getHiddenSequences().getFullAlignment()
1564 seqs = alignment.getHiddenSequences().getFullAlignment()
1565 .getSequencesArray();
1566 end = alignment.getHiddenSequences().getFullAlignment().getWidth();
1570 iSize = alignment.getHeight();
1571 seqs = alignment.getSequencesArray();
1572 end = alignment.getWidth();
1576 selection = new String[iSize];
1577 if (colSel != null && colSel.hasHiddenColumns())
1579 selection = colSel.getVisibleSequenceStrings(start, end, seqs);
1583 for (i = 0; i < iSize; i++)
1585 selection[i] = seqs[i].getSequenceAsString(start, end);
1593 public List<int[]> getVisibleRegionBoundaries(int min, int max)
1595 ArrayList<int[]> regions = new ArrayList<int[]>();
1601 if (colSel != null && colSel.hasHiddenColumns())
1605 start = colSel.adjustForHiddenColumns(start);
1608 end = colSel.getHiddenBoundaryRight(start);
1619 regions.add(new int[] { start, end });
1621 if (colSel != null && colSel.hasHiddenColumns())
1623 start = colSel.adjustForHiddenColumns(end);
1624 start = colSel.getHiddenBoundaryLeft(start) + 1;
1626 } while (end < max);
1628 int[][] startEnd = new int[regions.size()][2];
1634 public List<AlignmentAnnotation> getVisibleAlignmentAnnotation(
1635 boolean selectedOnly)
1637 ArrayList<AlignmentAnnotation> ala = new ArrayList<AlignmentAnnotation>();
1638 AlignmentAnnotation[] aa;
1639 if ((aa = alignment.getAlignmentAnnotation()) != null)
1641 for (AlignmentAnnotation annot : aa)
1643 AlignmentAnnotation clone = new AlignmentAnnotation(annot);
1644 if (selectedOnly && selectionGroup != null)
1646 colSel.makeVisibleAnnotation(selectionGroup.getStartRes(),
1647 selectionGroup.getEndRes(), clone);
1651 colSel.makeVisibleAnnotation(clone);
1660 public boolean isPadGaps()
1666 public void setPadGaps(boolean padGaps)
1668 this.padGaps = padGaps;
1672 * apply any post-edit constraints and trigger any calculations needed after
1673 * an edit has been performed on the alignment
1678 public void alignmentChanged(AlignmentViewPanel ap)
1682 alignment.padGaps();
1684 if (autoCalculateConsensus)
1686 updateConsensus(ap);
1688 if (hconsensus != null && autoCalculateConsensus)
1690 updateConservation(ap);
1692 if (autoCalculateStrucConsensus)
1694 updateStrucConsensus(ap);
1697 // Reset endRes of groups if beyond alignment width
1698 int alWidth = alignment.getWidth();
1699 List<SequenceGroup> groups = alignment.getGroups();
1702 for (SequenceGroup sg : groups)
1704 if (sg.getEndRes() > alWidth)
1706 sg.setEndRes(alWidth - 1);
1711 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1713 selectionGroup.setEndRes(alWidth - 1);
1716 resetAllColourSchemes();
1717 calculator.restartWorkers();
1718 // alignment.adjustSequenceAnnotations();
1722 * reset scope and do calculations for all applied colourschemes on alignment
1724 void resetAllColourSchemes()
1726 ColourSchemeI cs = globalColourScheme;
1729 cs.alignmentChanged(alignment, hiddenRepSequences);
1731 cs.setConsensus(hconsensus);
1732 if (cs.conservationApplied())
1734 cs.setConservation(Conservation.calculateConservation("All",
1735 ResidueProperties.propHash, 3, alignment.getSequences(), 0,
1736 alignment.getWidth(), false, getConsPercGaps(), false));
1740 for (SequenceGroup sg : alignment.getGroups())
1744 sg.cs.alignmentChanged(sg, hiddenRepSequences);
1746 sg.recalcConservation();
1750 protected void initAutoAnnotation()
1752 // TODO: add menu option action that nulls or creates consensus object
1753 // depending on if the user wants to see the annotation or not in a
1754 // specific alignment
1756 if (hconsensus == null && !isDataset)
1758 if (!alignment.isNucleotide())
1767 consensus = new AlignmentAnnotation("Consensus", "PID",
1768 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
1769 initConsensus(consensus);
1771 initComplementConsensus();
1776 * If this is a protein alignment and there are mappings to cDNA, add the cDNA
1777 * consensus annotation.
1779 public void initComplementConsensus()
1781 if (!alignment.isNucleotide())
1783 final Set<AlignedCodonFrame> codonMappings = alignment
1785 if (codonMappings != null && !codonMappings.isEmpty())
1787 complementConsensus = new AlignmentAnnotation("cDNA Consensus",
1788 "PID for cDNA", new Annotation[1], 0f, 100f,
1789 AlignmentAnnotation.BAR_GRAPH);
1790 initConsensus(complementConsensus);
1795 private void initConsensus(AlignmentAnnotation aa)
1798 aa.autoCalculated = true;
1802 alignment.addAnnotation(aa);
1806 private void initConservation()
1808 if (showConservation)
1810 if (conservation == null)
1812 conservation = new AlignmentAnnotation("Conservation",
1813 "Conservation of total alignment less than "
1814 + getConsPercGaps() + "% gaps", new Annotation[1],
1815 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
1816 conservation.hasText = true;
1817 conservation.autoCalculated = true;
1818 alignment.addAnnotation(conservation);
1823 private void initQuality()
1827 if (quality == null)
1829 quality = new AlignmentAnnotation("Quality",
1830 "Alignment Quality based on Blosum62 scores",
1831 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
1832 quality.hasText = true;
1833 quality.autoCalculated = true;
1834 alignment.addAnnotation(quality);
1839 private void initRNAStructure()
1841 if (alignment.hasRNAStructure() && strucConsensus == null)
1843 strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
1844 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
1845 strucConsensus.hasText = true;
1846 strucConsensus.autoCalculated = true;
1850 alignment.addAnnotation(strucConsensus);
1858 * @see jalview.api.AlignViewportI#calcPanelHeight()
1861 public int calcPanelHeight()
1863 // setHeight of panels
1864 AlignmentAnnotation[] anns = getAlignment().getAlignmentAnnotation();
1866 int charHeight = getCharHeight();
1869 BitSet graphgrp = new BitSet();
1870 for (AlignmentAnnotation aa : anns)
1874 System.err.println("Null annotation row: ignoring.");
1881 if (aa.graphGroup > -1)
1883 if (graphgrp.get(aa.graphGroup))
1889 graphgrp.set(aa.graphGroup);
1896 aa.height += charHeight;
1906 aa.height += aa.graphHeight;
1914 height += aa.height;
1926 public void updateGroupAnnotationSettings(boolean applyGlobalSettings,
1927 boolean preserveNewGroupSettings)
1929 boolean updateCalcs = false;
1930 boolean conv = isShowGroupConservation();
1931 boolean cons = isShowGroupConsensus();
1932 boolean showprf = isShowSequenceLogo();
1933 boolean showConsHist = isShowConsensusHistogram();
1934 boolean normLogo = isNormaliseSequenceLogo();
1937 * TODO reorder the annotation rows according to group/sequence ordering on
1940 boolean sortg = true;
1942 // remove old automatic annotation
1943 // add any new annotation
1945 // intersect alignment annotation with alignment groups
1947 AlignmentAnnotation[] aan = alignment.getAlignmentAnnotation();
1948 List<SequenceGroup> oldrfs = new ArrayList<SequenceGroup>();
1951 for (int an = 0; an < aan.length; an++)
1953 if (aan[an].autoCalculated && aan[an].groupRef != null)
1955 oldrfs.add(aan[an].groupRef);
1956 alignment.deleteAnnotation(aan[an], false);
1960 if (alignment.getGroups() != null)
1962 for (SequenceGroup sg : alignment.getGroups())
1964 updateCalcs = false;
1965 if (applyGlobalSettings
1966 || (!preserveNewGroupSettings && !oldrfs.contains(sg)))
1968 // set defaults for this group's conservation/consensus
1969 sg.setshowSequenceLogo(showprf);
1970 sg.setShowConsensusHistogram(showConsHist);
1971 sg.setNormaliseSequenceLogo(normLogo);
1976 alignment.addAnnotation(sg.getConservationRow(), 0);
1981 alignment.addAnnotation(sg.getConsensus(), 0);
1983 // refresh the annotation rows
1986 sg.recalcConservation();
1994 public boolean isDisplayReferenceSeq()
1996 return alignment.hasSeqrep() && viewStyle.isDisplayReferenceSeq();
2000 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
2002 viewStyle.setDisplayReferenceSeq(displayReferenceSeq);
2006 public boolean isColourByReferenceSeq()
2008 return alignment.hasSeqrep() && viewStyle.isColourByReferenceSeq();
2012 public Color getSequenceColour(SequenceI seq)
2014 Color sqc = sequenceColours.get(seq);
2015 return (sqc == null ? Color.white : sqc);
2019 public void setSequenceColour(SequenceI seq, Color col)
2023 sequenceColours.remove(seq);
2027 sequenceColours.put(seq, col);
2032 public void updateSequenceIdColours()
2034 for (SequenceGroup sg : alignment.getGroups())
2036 if (sg.idColour != null)
2038 for (SequenceI s : sg.getSequences(getHiddenRepSequences()))
2040 sequenceColours.put(s, sg.idColour);
2047 public void clearSequenceColours()
2049 sequenceColours.clear();
2053 public AlignViewportI getCodingComplement()
2055 return this.codingComplement;
2059 * Set this as the (cDna/protein) complement of the given viewport. Also
2060 * ensures the reverse relationship is set on the given viewport.
2063 public void setCodingComplement(AlignViewportI av)
2067 System.err.println("Ignoring recursive setCodingComplement request");
2071 this.codingComplement = av;
2072 // avoid infinite recursion!
2073 if (av.getCodingComplement() != this)
2075 av.setCodingComplement(this);
2081 public boolean isNucleotide()
2083 return getAlignment() == null ? false : getAlignment().isNucleotide();
2087 public FeaturesDisplayedI getFeaturesDisplayed()
2089 return featuresDisplayed;
2093 public void setFeaturesDisplayed(FeaturesDisplayedI featuresDisplayedI)
2095 featuresDisplayed = featuresDisplayedI;
2099 public boolean areFeaturesDisplayed()
2101 return featuresDisplayed != null
2102 && featuresDisplayed.getRegisterdFeaturesCount() > 0;
2109 * features are displayed if true
2112 public void setShowSequenceFeatures(boolean b)
2114 viewStyle.setShowSequenceFeatures(b);
2118 public boolean isShowSequenceFeatures()
2120 return viewStyle.isShowSequenceFeatures();
2124 public void setShowSequenceFeaturesHeight(boolean selected)
2126 viewStyle.setShowSequenceFeaturesHeight(selected);
2130 public boolean isShowSequenceFeaturesHeight()
2132 return viewStyle.isShowSequenceFeaturesHeight();
2136 public void setShowAnnotation(boolean b)
2138 viewStyle.setShowAnnotation(b);
2142 public boolean isShowAnnotation()
2144 return viewStyle.isShowAnnotation();
2148 public boolean isRightAlignIds()
2150 return viewStyle.isRightAlignIds();
2154 public void setRightAlignIds(boolean rightAlignIds)
2156 viewStyle.setRightAlignIds(rightAlignIds);
2160 public boolean getConservationSelected()
2162 return viewStyle.getConservationSelected();
2166 public void setShowBoxes(boolean state)
2168 viewStyle.setShowBoxes(state);
2173 * @see jalview.api.ViewStyleI#getTextColour()
2176 public Color getTextColour()
2178 return viewStyle.getTextColour();
2183 * @see jalview.api.ViewStyleI#getTextColour2()
2186 public Color getTextColour2()
2188 return viewStyle.getTextColour2();
2193 * @see jalview.api.ViewStyleI#getThresholdTextColour()
2196 public int getThresholdTextColour()
2198 return viewStyle.getThresholdTextColour();
2203 * @see jalview.api.ViewStyleI#isConservationColourSelected()
2206 public boolean isConservationColourSelected()
2208 return viewStyle.isConservationColourSelected();
2213 * @see jalview.api.ViewStyleI#isRenderGaps()
2216 public boolean isRenderGaps()
2218 return viewStyle.isRenderGaps();
2223 * @see jalview.api.ViewStyleI#isShowColourText()
2226 public boolean isShowColourText()
2228 return viewStyle.isShowColourText();
2232 * @param conservationColourSelected
2233 * @see jalview.api.ViewStyleI#setConservationColourSelected(boolean)
2236 public void setConservationColourSelected(
2237 boolean conservationColourSelected)
2239 viewStyle.setConservationColourSelected(conservationColourSelected);
2243 * @param showColourText
2244 * @see jalview.api.ViewStyleI#setShowColourText(boolean)
2247 public void setShowColourText(boolean showColourText)
2249 viewStyle.setShowColourText(showColourText);
2254 * @see jalview.api.ViewStyleI#setTextColour(java.awt.Color)
2257 public void setTextColour(Color textColour)
2259 viewStyle.setTextColour(textColour);
2263 * @param thresholdTextColour
2264 * @see jalview.api.ViewStyleI#setThresholdTextColour(int)
2267 public void setThresholdTextColour(int thresholdTextColour)
2269 viewStyle.setThresholdTextColour(thresholdTextColour);
2273 * @param textColour2
2274 * @see jalview.api.ViewStyleI#setTextColour2(java.awt.Color)
2277 public void setTextColour2(Color textColour2)
2279 viewStyle.setTextColour2(textColour2);
2283 public ViewStyleI getViewStyle()
2285 return new ViewStyle(viewStyle);
2289 public void setViewStyle(ViewStyleI settingsForView)
2291 viewStyle = new ViewStyle(settingsForView);
2295 public boolean sameStyle(ViewStyleI them)
2297 return viewStyle.sameStyle(them);
2302 * @see jalview.api.ViewStyleI#getIdWidth()
2305 public int getIdWidth()
2307 return viewStyle.getIdWidth();
2312 * @see jalview.api.ViewStyleI#setIdWidth(int)
2315 public void setIdWidth(int i)
2317 viewStyle.setIdWidth(i);
2322 * @see jalview.api.ViewStyleI#isCentreColumnLabels()
2325 public boolean isCentreColumnLabels()
2327 return viewStyle.isCentreColumnLabels();
2331 * @param centreColumnLabels
2332 * @see jalview.api.ViewStyleI#setCentreColumnLabels(boolean)
2335 public void setCentreColumnLabels(boolean centreColumnLabels)
2337 viewStyle.setCentreColumnLabels(centreColumnLabels);
2342 * @see jalview.api.ViewStyleI#setShowDBRefs(boolean)
2345 public void setShowDBRefs(boolean showdbrefs)
2347 viewStyle.setShowDBRefs(showdbrefs);
2352 * @see jalview.api.ViewStyleI#isShowDBRefs()
2355 public boolean isShowDBRefs()
2357 return viewStyle.isShowDBRefs();
2362 * @see jalview.api.ViewStyleI#isShowNPFeats()
2365 public boolean isShowNPFeats()
2367 return viewStyle.isShowNPFeats();
2371 * @param shownpfeats
2372 * @see jalview.api.ViewStyleI#setShowNPFeats(boolean)
2375 public void setShowNPFeats(boolean shownpfeats)
2377 viewStyle.setShowNPFeats(shownpfeats);
2380 public abstract StructureSelectionManager getStructureSelectionManager();
2383 * Add one command to the command history list.
2387 public void addToHistoryList(CommandI command)
2389 if (this.historyList != null)
2391 this.historyList.push(command);
2392 broadcastCommand(command, false);
2396 protected void broadcastCommand(CommandI command, boolean undo)
2398 getStructureSelectionManager().commandPerformed(command, undo,
2403 * Add one command to the command redo list.
2407 public void addToRedoList(CommandI command)
2409 if (this.redoList != null)
2411 this.redoList.push(command);
2413 broadcastCommand(command, true);
2417 * Clear the command redo list.
2419 public void clearRedoList()
2421 if (this.redoList != null)
2423 this.redoList.clear();
2427 public void setHistoryList(Deque<CommandI> list)
2429 this.historyList = list;
2432 public Deque<CommandI> getHistoryList()
2434 return this.historyList;
2437 public void setRedoList(Deque<CommandI> list)
2439 this.redoList = list;
2442 public Deque<CommandI> getRedoList()
2444 return this.redoList;
2448 public VamsasSource getVamsasSource()
2453 public SequenceAnnotationOrder getSortAnnotationsBy()
2455 return sortAnnotationsBy;
2458 public void setSortAnnotationsBy(SequenceAnnotationOrder sortAnnotationsBy)
2460 this.sortAnnotationsBy = sortAnnotationsBy;
2463 public boolean isShowAutocalculatedAbove()
2465 return showAutocalculatedAbove;
2468 public void setShowAutocalculatedAbove(boolean showAutocalculatedAbove)
2470 this.showAutocalculatedAbove = showAutocalculatedAbove;
2474 public boolean isScaleProteinAsCdna()
2476 return viewStyle.isScaleProteinAsCdna();
2480 public void setScaleProteinAsCdna(boolean b)
2482 viewStyle.setScaleProteinAsCdna(b);
2486 * @return true if view should scroll to show the highlighted region of a
2491 public final boolean isFollowHighlight()
2493 return followHighlight;
2497 public final void setFollowHighlight(boolean b)
2499 this.followHighlight = b;
2502 public int getStartRes()
2508 public int getEndRes()
2513 public int getStartSeq()
2518 public void setStartRes(int res)
2520 this.startRes = res;
2523 public void setStartSeq(int seq)
2525 this.startSeq = seq;
2528 public void setEndRes(int res)
2530 if (res > alignment.getWidth() - 1)
2532 // log.System.out.println(" Corrected res from " + res + " to maximum " +
2533 // (alignment.getWidth()-1));
2534 res = alignment.getWidth() - 1;
2543 public void setEndSeq(int seq)
2545 if (seq > alignment.getHeight())
2547 seq = alignment.getHeight();
2556 public int getEndSeq()
2562 * Helper method to populate the SearchResults with the location in the
2563 * complementary alignment to scroll to, in order to match this one.
2566 * the SearchResults to add to
2567 * @return the offset (below top of visible region) of the matched sequence
2569 protected int findComplementScrollTarget(SearchResults sr)
2571 final AlignViewportI complement = getCodingComplement();
2572 if (complement == null || !complement.isFollowHighlight())
2576 boolean iAmProtein = !getAlignment().isNucleotide();
2577 AlignmentI proteinAlignment = iAmProtein ? getAlignment() : complement
2579 if (proteinAlignment == null)
2583 final Set<AlignedCodonFrame> mappings = proteinAlignment
2587 * Heuristic: find the first mapped sequence (if any) with a non-gapped
2588 * residue in the middle column of the visible region. Scroll the
2589 * complementary alignment to line up the corresponding residue.
2592 SequenceI sequence = null;
2595 * locate 'middle' column (true middle if an odd number visible, left of
2596 * middle if an even number visible)
2598 int middleColumn = getStartRes() + (getEndRes() - getStartRes()) / 2;
2599 final HiddenSequences hiddenSequences = getAlignment()
2600 .getHiddenSequences();
2603 * searching to the bottom of the alignment gives smoother scrolling across
2604 * all gapped visible regions
2606 int lastSeq = alignment.getHeight() - 1;
2607 for (int seqNo = getStartSeq(); seqNo < lastSeq; seqNo++, seqOffset++)
2609 sequence = getAlignment().getSequenceAt(seqNo);
2610 if (hiddenSequences != null && hiddenSequences.isHidden(sequence))
2614 if (Comparison.isGap(sequence.getCharAt(middleColumn)))
2618 List<AlignedCodonFrame> seqMappings = MappingUtils
2619 .findMappingsForSequence(sequence, mappings);
2620 if (!seqMappings.isEmpty())
2626 if (sequence == null)
2629 * No ungapped mapped sequence in middle column - do nothing
2633 MappingUtils.addSearchResults(sr, sequence,
2634 sequence.findPosition(middleColumn), mappings);