2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.viewmodel;
23 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
24 import jalview.analysis.Conservation;
25 import jalview.api.AlignCalcManagerI;
26 import jalview.api.AlignViewportI;
27 import jalview.api.AlignmentViewPanel;
28 import jalview.api.FeaturesDisplayedI;
29 import jalview.api.ViewStyleI;
30 import jalview.commands.CommandI;
31 import jalview.datamodel.AlignedCodonFrame;
32 import jalview.datamodel.AlignmentAnnotation;
33 import jalview.datamodel.AlignmentI;
34 import jalview.datamodel.AlignmentView;
35 import jalview.datamodel.Annotation;
36 import jalview.datamodel.CigarArray;
37 import jalview.datamodel.ColumnSelection;
38 import jalview.datamodel.HiddenSequences;
39 import jalview.datamodel.SearchResults;
40 import jalview.datamodel.Sequence;
41 import jalview.datamodel.SequenceCollectionI;
42 import jalview.datamodel.SequenceGroup;
43 import jalview.datamodel.SequenceI;
44 import jalview.schemes.Blosum62ColourScheme;
45 import jalview.schemes.ColourSchemeI;
46 import jalview.schemes.PIDColourScheme;
47 import jalview.schemes.ResidueProperties;
48 import jalview.structure.CommandListener;
49 import jalview.structure.StructureSelectionManager;
50 import jalview.structure.VamsasSource;
51 import jalview.util.Comparison;
52 import jalview.util.MappingUtils;
53 import jalview.viewmodel.styles.ViewStyle;
54 import jalview.workers.AlignCalcManager;
55 import jalview.workers.ComplementConsensusThread;
56 import jalview.workers.ConsensusThread;
57 import jalview.workers.StrucConsensusThread;
59 import java.awt.Color;
60 import java.util.ArrayDeque;
61 import java.util.ArrayList;
62 import java.util.BitSet;
63 import java.util.Deque;
64 import java.util.HashMap;
65 import java.util.Hashtable;
66 import java.util.List;
71 * base class holding visualization and analysis attributes and common logic for
72 * an active alignment view displayed in the GUI
77 public abstract class AlignmentViewport implements AlignViewportI,
78 CommandListener, VamsasSource
80 protected ViewStyleI viewStyle = new ViewStyle();
83 * A viewport that hosts the cDna view of this (protein), or vice versa (if
86 AlignViewportI codingComplement = null;
88 FeaturesDisplayedI featuresDisplayed = null;
90 protected Deque<CommandI> historyList = new ArrayDeque<CommandI>();
92 protected Deque<CommandI> redoList = new ArrayDeque<CommandI>();
96 * @see jalview.api.ViewStyleI#setFontName(java.lang.String)
98 public void setFontName(String name)
100 viewStyle.setFontName(name);
105 * @see jalview.api.ViewStyleI#setFontStyle(int)
107 public void setFontStyle(int style)
109 viewStyle.setFontStyle(style);
114 * @see jalview.api.ViewStyleI#setFontSize(int)
116 public void setFontSize(int size)
118 viewStyle.setFontSize(size);
123 * @see jalview.api.ViewStyleI#getFontStyle()
125 public int getFontStyle()
127 return viewStyle.getFontStyle();
132 * @see jalview.api.ViewStyleI#getFontName()
134 public String getFontName()
136 return viewStyle.getFontName();
141 * @see jalview.api.ViewStyleI#getFontSize()
143 public int getFontSize()
145 return viewStyle.getFontSize();
149 * @param upperCasebold
150 * @see jalview.api.ViewStyleI#setUpperCasebold(boolean)
152 public void setUpperCasebold(boolean upperCasebold)
154 viewStyle.setUpperCasebold(upperCasebold);
159 * @see jalview.api.ViewStyleI#isUpperCasebold()
161 public boolean isUpperCasebold()
163 return viewStyle.isUpperCasebold();
168 * @see jalview.api.ViewStyleI#isSeqNameItalics()
170 public boolean isSeqNameItalics()
172 return viewStyle.isSeqNameItalics();
176 * @param colourByReferenceSeq
177 * @see jalview.api.ViewStyleI#setColourByReferenceSeq(boolean)
179 public void setColourByReferenceSeq(boolean colourByReferenceSeq)
181 viewStyle.setColourByReferenceSeq(colourByReferenceSeq);
186 * @see jalview.api.ViewStyleI#setColourAppliesToAllGroups(boolean)
188 public void setColourAppliesToAllGroups(boolean b)
190 viewStyle.setColourAppliesToAllGroups(b);
195 * @see jalview.api.ViewStyleI#getColourAppliesToAllGroups()
197 public boolean getColourAppliesToAllGroups()
199 return viewStyle.getColourAppliesToAllGroups();
204 * @see jalview.api.ViewStyleI#getAbovePIDThreshold()
206 public boolean getAbovePIDThreshold()
208 return viewStyle.getAbovePIDThreshold();
213 * @see jalview.api.ViewStyleI#setIncrement(int)
215 public void setIncrement(int inc)
217 viewStyle.setIncrement(inc);
222 * @see jalview.api.ViewStyleI#getIncrement()
224 public int getIncrement()
226 return viewStyle.getIncrement();
231 * @see jalview.api.ViewStyleI#setConservationSelected(boolean)
233 public void setConservationSelected(boolean b)
235 viewStyle.setConservationSelected(b);
240 * @see jalview.api.ViewStyleI#setShowHiddenMarkers(boolean)
242 public void setShowHiddenMarkers(boolean show)
244 viewStyle.setShowHiddenMarkers(show);
249 * @see jalview.api.ViewStyleI#getShowHiddenMarkers()
251 public boolean getShowHiddenMarkers()
253 return viewStyle.getShowHiddenMarkers();
258 * @see jalview.api.ViewStyleI#setScaleRightWrapped(boolean)
260 public void setScaleRightWrapped(boolean b)
262 viewStyle.setScaleRightWrapped(b);
267 * @see jalview.api.ViewStyleI#setScaleLeftWrapped(boolean)
269 public void setScaleLeftWrapped(boolean b)
271 viewStyle.setScaleLeftWrapped(b);
276 * @see jalview.api.ViewStyleI#setScaleAboveWrapped(boolean)
278 public void setScaleAboveWrapped(boolean b)
280 viewStyle.setScaleAboveWrapped(b);
285 * @see jalview.api.ViewStyleI#getScaleLeftWrapped()
287 public boolean getScaleLeftWrapped()
289 return viewStyle.getScaleLeftWrapped();
294 * @see jalview.api.ViewStyleI#getScaleAboveWrapped()
296 public boolean getScaleAboveWrapped()
298 return viewStyle.getScaleAboveWrapped();
303 * @see jalview.api.ViewStyleI#getScaleRightWrapped()
305 public boolean getScaleRightWrapped()
307 return viewStyle.getScaleRightWrapped();
312 * @see jalview.api.ViewStyleI#setAbovePIDThreshold(boolean)
314 public void setAbovePIDThreshold(boolean b)
316 viewStyle.setAbovePIDThreshold(b);
321 * @see jalview.api.ViewStyleI#setThreshold(int)
323 public void setThreshold(int thresh)
325 viewStyle.setThreshold(thresh);
330 * @see jalview.api.ViewStyleI#getThreshold()
332 public int getThreshold()
334 return viewStyle.getThreshold();
339 * @see jalview.api.ViewStyleI#getShowJVSuffix()
341 public boolean getShowJVSuffix()
343 return viewStyle.getShowJVSuffix();
348 * @see jalview.api.ViewStyleI#setShowJVSuffix(boolean)
350 public void setShowJVSuffix(boolean b)
352 viewStyle.setShowJVSuffix(b);
357 * @see jalview.api.ViewStyleI#setWrapAlignment(boolean)
359 public void setWrapAlignment(boolean state)
361 viewStyle.setWrapAlignment(state);
366 * @see jalview.api.ViewStyleI#setShowText(boolean)
368 public void setShowText(boolean state)
370 viewStyle.setShowText(state);
375 * @see jalview.api.ViewStyleI#setRenderGaps(boolean)
377 public void setRenderGaps(boolean state)
379 viewStyle.setRenderGaps(state);
384 * @see jalview.api.ViewStyleI#getColourText()
386 public boolean getColourText()
388 return viewStyle.getColourText();
393 * @see jalview.api.ViewStyleI#setColourText(boolean)
395 public void setColourText(boolean state)
397 viewStyle.setColourText(state);
402 * @see jalview.api.ViewStyleI#getWrapAlignment()
404 public boolean getWrapAlignment()
406 return viewStyle.getWrapAlignment();
411 * @see jalview.api.ViewStyleI#getShowText()
413 public boolean getShowText()
415 return viewStyle.getShowText();
420 * @see jalview.api.ViewStyleI#getWrappedWidth()
422 public int getWrappedWidth()
424 return viewStyle.getWrappedWidth();
429 * @see jalview.api.ViewStyleI#setWrappedWidth(int)
431 public void setWrappedWidth(int w)
433 viewStyle.setWrappedWidth(w);
438 * @see jalview.api.ViewStyleI#getCharHeight()
440 public int getCharHeight()
442 return viewStyle.getCharHeight();
447 * @see jalview.api.ViewStyleI#setCharHeight(int)
449 public void setCharHeight(int h)
451 viewStyle.setCharHeight(h);
456 * @see jalview.api.ViewStyleI#getCharWidth()
458 public int getCharWidth()
460 return viewStyle.getCharWidth();
465 * @see jalview.api.ViewStyleI#setCharWidth(int)
467 public void setCharWidth(int w)
469 viewStyle.setCharWidth(w);
474 * @see jalview.api.ViewStyleI#getShowBoxes()
476 public boolean getShowBoxes()
478 return viewStyle.getShowBoxes();
483 * @see jalview.api.ViewStyleI#getShowUnconserved()
485 public boolean getShowUnconserved()
487 return viewStyle.getShowUnconserved();
491 * @param showunconserved
492 * @see jalview.api.ViewStyleI#setShowUnconserved(boolean)
494 public void setShowUnconserved(boolean showunconserved)
496 viewStyle.setShowUnconserved(showunconserved);
501 * @see jalview.api.ViewStyleI#setSeqNameItalics(boolean)
503 public void setSeqNameItalics(boolean default1)
505 viewStyle.setSeqNameItalics(default1);
509 * alignment displayed in the viewport. Please use get/setter
511 protected AlignmentI alignment;
514 public AlignmentI getAlignment()
520 public char getGapCharacter()
522 return alignment.getGapCharacter();
525 protected String sequenceSetID;
528 * probably unused indicator that view is of a dataset rather than an
531 protected boolean isDataset = false;
533 public void setDataset(boolean b)
538 public boolean isDataset()
543 private Map<SequenceI, SequenceCollectionI> hiddenRepSequences;
545 protected ColumnSelection colSel = new ColumnSelection();
547 public boolean autoCalculateConsensus = true;
549 protected boolean autoCalculateStrucConsensus = true;
551 protected boolean ignoreGapsInConsensusCalculation = false;
553 protected ColourSchemeI globalColourScheme = null;
556 public void setGlobalColourScheme(ColourSchemeI cs)
558 // TODO: logic refactored from AlignFrame changeColour -
559 // TODO: autorecalc stuff should be changed to rely on the worker system
560 // check to see if we should implement a changeColour(cs) method rather than
561 // put th logic in here
562 // - means that caller decides if they want to just modify state and defer
563 // calculation till later or to do all calculations in thread.
565 globalColourScheme = cs;
566 boolean recalc = false;
569 cs.setConservationApplied(recalc = getConservationSelected());
570 if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
571 || cs instanceof Blosum62ColourScheme)
574 cs.setThreshold(viewStyle.getThreshold(),
575 ignoreGapsInConsensusCalculation);
579 cs.setThreshold(0, ignoreGapsInConsensusCalculation);
583 cs.setConsensus(hconsensus);
584 cs.setConservation(hconservation);
586 cs.alignmentChanged(alignment, hiddenRepSequences);
588 if (getColourAppliesToAllGroups())
590 for (SequenceGroup sg : getAlignment().getGroups())
597 sg.cs = cs.applyTo(sg, getHiddenRepSequences());
598 sg.setConsPercGaps(ConsPercGaps);
599 if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
600 || cs instanceof Blosum62ColourScheme)
602 sg.cs.setThreshold(viewStyle.getThreshold(),
603 isIgnoreGapsConsensus());
608 sg.cs.setThreshold(0, isIgnoreGapsConsensus());
611 if (getConservationSelected())
613 sg.cs.setConservationApplied(true);
618 sg.cs.setConservation(null);
619 // sg.cs.setThreshold(0, getIgnoreGapsConsensus());
623 sg.recalcConservation();
627 sg.cs.alignmentChanged(sg, hiddenRepSequences);
634 public ColourSchemeI getGlobalColourScheme()
636 return globalColourScheme;
639 protected AlignmentAnnotation consensus;
641 protected AlignmentAnnotation complementConsensus;
643 protected AlignmentAnnotation strucConsensus;
645 protected AlignmentAnnotation conservation;
647 protected AlignmentAnnotation quality;
649 protected AlignmentAnnotation[] groupConsensus;
651 protected AlignmentAnnotation[] groupConservation;
654 * results of alignment consensus analysis for visible portion of view
656 protected Hashtable[] hconsensus = null;
659 * results of cDNA complement consensus visible portion of view
661 protected Hashtable[] hcomplementConsensus = null;
664 * results of secondary structure base pair consensus for visible portion of
667 protected Hashtable[] hStrucConsensus = null;
669 protected Conservation hconservation = null;
672 public void setConservation(Conservation cons)
674 hconservation = cons;
678 * percentage gaps allowed in a column before all amino acid properties should
679 * be considered unconserved
681 int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
684 public int getConsPercGaps()
690 public void setSequenceConsensusHash(Hashtable[] hconsensus)
692 this.hconsensus = hconsensus;
696 public void setComplementConsensusHash(Hashtable[] hconsensus)
698 this.hcomplementConsensus = hconsensus;
702 public Hashtable[] getSequenceConsensusHash()
708 public Hashtable[] getComplementConsensusHash()
710 return hcomplementConsensus;
714 public Hashtable[] getRnaStructureConsensusHash()
716 return hStrucConsensus;
720 public void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus)
722 this.hStrucConsensus = hStrucConsensus;
727 public AlignmentAnnotation getAlignmentQualityAnnot()
733 public AlignmentAnnotation getAlignmentConservationAnnotation()
739 public AlignmentAnnotation getAlignmentConsensusAnnotation()
745 public AlignmentAnnotation getComplementConsensusAnnotation()
747 return complementConsensus;
751 public AlignmentAnnotation getAlignmentStrucConsensusAnnotation()
753 return strucConsensus;
756 protected AlignCalcManagerI calculator = new AlignCalcManager();
759 * trigger update of conservation annotation
761 public void updateConservation(final AlignmentViewPanel ap)
763 // see note in mantis : issue number 8585
764 if (alignment.isNucleotide() || conservation == null
765 || !autoCalculateConsensus)
770 .getRegisteredWorkersOfClass(jalview.workers.ConservationThread.class) == null)
772 calculator.registerWorker(new jalview.workers.ConservationThread(
778 * trigger update of consensus annotation
780 public void updateConsensus(final AlignmentViewPanel ap)
782 // see note in mantis : issue number 8585
783 if (consensus == null || !autoCalculateConsensus)
787 if (calculator.getRegisteredWorkersOfClass(ConsensusThread.class) == null)
789 calculator.registerWorker(new ConsensusThread(this, ap));
793 * A separate thread to compute cDNA consensus for a protein alignment
795 final AlignmentI al = this.getAlignment();
796 if (!al.isNucleotide() && al.getCodonFrames() != null
797 && !al.getCodonFrames().isEmpty())
800 .getRegisteredWorkersOfClass(ComplementConsensusThread.class) == null)
802 calculator.registerWorker(new ComplementConsensusThread(this, ap));
807 // --------START Structure Conservation
808 public void updateStrucConsensus(final AlignmentViewPanel ap)
810 if (autoCalculateStrucConsensus && strucConsensus == null
811 && alignment.isNucleotide() && alignment.hasRNAStructure())
813 // secondary structure has been added - so init the consensus line
817 // see note in mantis : issue number 8585
818 if (strucConsensus == null || !autoCalculateStrucConsensus)
822 if (calculator.getRegisteredWorkersOfClass(StrucConsensusThread.class) == null)
824 calculator.registerWorker(new StrucConsensusThread(this, ap));
828 public boolean isCalcInProgress()
830 return calculator.isWorking();
834 public boolean isCalculationInProgress(
835 AlignmentAnnotation alignmentAnnotation)
837 if (!alignmentAnnotation.autoCalculated)
841 if (calculator.workingInvolvedWith(alignmentAnnotation))
843 // System.err.println("grey out ("+alignmentAnnotation.label+")");
850 public boolean isClosed()
852 // TODO: check that this isClosed is only true after panel is closed, not
853 // before it is fully constructed.
854 return alignment == null;
858 public AlignCalcManagerI getCalcManager()
864 * should conservation rows be shown for groups
866 protected boolean showGroupConservation = false;
869 * should consensus rows be shown for groups
871 protected boolean showGroupConsensus = false;
874 * should consensus profile be rendered by default
876 protected boolean showSequenceLogo = false;
879 * should consensus profile be rendered normalised to row height
881 protected boolean normaliseSequenceLogo = false;
884 * should consensus histograms be rendered by default
886 protected boolean showConsensusHistogram = true;
889 * @return the showConsensusProfile
892 public boolean isShowSequenceLogo()
894 return showSequenceLogo;
898 * @param showSequenceLogo
901 public void setShowSequenceLogo(boolean showSequenceLogo)
903 if (showSequenceLogo != this.showSequenceLogo)
905 // TODO: decouple settings setting from calculation when refactoring
906 // annotation update method from alignframe to viewport
907 this.showSequenceLogo = showSequenceLogo;
908 calculator.updateAnnotationFor(ConsensusThread.class);
909 calculator.updateAnnotationFor(ComplementConsensusThread.class);
910 calculator.updateAnnotationFor(StrucConsensusThread.class);
912 this.showSequenceLogo = showSequenceLogo;
916 * @param showConsensusHistogram
917 * the showConsensusHistogram to set
919 public void setShowConsensusHistogram(boolean showConsensusHistogram)
921 this.showConsensusHistogram = showConsensusHistogram;
925 * @return the showGroupConservation
927 public boolean isShowGroupConservation()
929 return showGroupConservation;
933 * @param showGroupConservation
934 * the showGroupConservation to set
936 public void setShowGroupConservation(boolean showGroupConservation)
938 this.showGroupConservation = showGroupConservation;
942 * @return the showGroupConsensus
944 public boolean isShowGroupConsensus()
946 return showGroupConsensus;
950 * @param showGroupConsensus
951 * the showGroupConsensus to set
953 public void setShowGroupConsensus(boolean showGroupConsensus)
955 this.showGroupConsensus = showGroupConsensus;
960 * @return flag to indicate if the consensus histogram should be rendered by
964 public boolean isShowConsensusHistogram()
966 return this.showConsensusHistogram;
970 * when set, updateAlignment will always ensure sequences are of equal length
972 private boolean padGaps = false;
975 * when set, alignment should be reordered according to a newly opened tree
977 public boolean sortByTree = false;
982 * @return null or the currently selected sequence region
985 public SequenceGroup getSelectionGroup()
987 return selectionGroup;
991 * Set the selection group for this window.
994 * - group holding references to sequences in this alignment view
998 public void setSelectionGroup(SequenceGroup sg)
1000 selectionGroup = sg;
1003 public void setHiddenColumns(ColumnSelection colsel)
1005 this.colSel = colsel;
1009 public ColumnSelection getColumnSelection()
1015 public void setColumnSelection(ColumnSelection colSel)
1017 this.colSel = colSel;
1020 updateHiddenColumns();
1029 public Map<SequenceI, SequenceCollectionI> getHiddenRepSequences()
1031 return hiddenRepSequences;
1035 public void setHiddenRepSequences(
1036 Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
1038 this.hiddenRepSequences = hiddenRepSequences;
1042 public boolean hasHiddenColumns()
1044 return colSel != null && colSel.hasHiddenColumns();
1047 public void updateHiddenColumns()
1049 // this method doesn't really do anything now. But - it could, since a
1050 // column Selection could be in the process of modification
1051 // hasHiddenColumns = colSel.hasHiddenColumns();
1055 public boolean hasHiddenRows()
1057 return alignment.getHiddenSequences().getSize() > 0;
1060 protected SequenceGroup selectionGroup;
1062 public void setSequenceSetId(String newid)
1064 if (sequenceSetID != null)
1067 .println("Warning - overwriting a sequenceSetId for a viewport!");
1069 sequenceSetID = new String(newid);
1073 public String getSequenceSetId()
1075 if (sequenceSetID == null)
1077 sequenceSetID = alignment.hashCode() + "";
1080 return sequenceSetID;
1084 * unique viewId for synchronizing state (e.g. with stored Jalview Project)
1087 protected String viewId = null;
1090 public String getViewId()
1094 viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
1099 public void setIgnoreGapsConsensus(boolean b, AlignmentViewPanel ap)
1101 ignoreGapsInConsensusCalculation = b;
1104 updateConsensus(ap);
1105 if (globalColourScheme != null)
1107 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
1108 ignoreGapsInConsensusCalculation);
1114 private long sgrouphash = -1, colselhash = -1;
1117 * checks current SelectionGroup against record of last hash value, and
1121 * update the record of last hash value
1123 * @return true if SelectionGroup changed since last call (when b is true)
1125 public boolean isSelectionGroupChanged(boolean b)
1127 int hc = (selectionGroup == null || selectionGroup.getSize() == 0) ? -1
1128 : selectionGroup.hashCode();
1129 if (hc != -1 && hc != sgrouphash)
1141 * checks current colsel against record of last hash value, and optionally
1145 * update the record of last hash value
1146 * @return true if colsel changed since last call (when b is true)
1148 public boolean isColSelChanged(boolean b)
1150 int hc = (colSel == null || colSel.size() == 0) ? -1 : colSel
1152 if (hc != -1 && hc != colselhash)
1164 public boolean isIgnoreGapsConsensus()
1166 return ignoreGapsInConsensusCalculation;
1169 // / property change stuff
1171 // JBPNote Prolly only need this in the applet version.
1172 private final java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
1175 protected boolean showConservation = true;
1177 protected boolean showQuality = true;
1179 protected boolean showConsensus = true;
1181 private Map<SequenceI, Color> sequenceColours = new HashMap<SequenceI, Color>();
1183 protected SequenceAnnotationOrder sortAnnotationsBy = null;
1185 protected boolean showAutocalculatedAbove;
1188 * when set, view will scroll to show the highlighted position
1190 private boolean followHighlight = true;
1192 // TODO private with getters and setters?
1193 public int startRes;
1197 public int startSeq;
1202 * Property change listener for changes in alignment
1207 public void addPropertyChangeListener(
1208 java.beans.PropertyChangeListener listener)
1210 changeSupport.addPropertyChangeListener(listener);
1219 public void removePropertyChangeListener(
1220 java.beans.PropertyChangeListener listener)
1222 changeSupport.removePropertyChangeListener(listener);
1226 * Property change listener for changes in alignment
1235 public void firePropertyChange(String prop, Object oldvalue,
1238 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
1241 // common hide/show column stuff
1243 public void hideSelectedColumns()
1245 if (colSel.size() < 1)
1250 colSel.hideSelectedColumns();
1251 setSelectionGroup(null);
1255 public void hideColumns(int start, int end)
1259 colSel.hideColumns(start);
1263 colSel.hideColumns(start, end);
1267 public void showColumn(int col)
1269 colSel.revealHiddenColumns(col);
1273 public void showAllHiddenColumns()
1275 colSel.revealAllHiddenColumns();
1278 // common hide/show seq stuff
1279 public void showAllHiddenSeqs()
1281 if (alignment.getHiddenSequences().getSize() > 0)
1283 if (selectionGroup == null)
1285 selectionGroup = new SequenceGroup();
1286 selectionGroup.setEndRes(alignment.getWidth() - 1);
1288 List<SequenceI> tmp = alignment.getHiddenSequences().showAll(
1289 hiddenRepSequences);
1290 for (SequenceI seq : tmp)
1292 selectionGroup.addSequence(seq, false);
1293 setSequenceAnnotationsVisible(seq, true);
1296 hiddenRepSequences = null;
1298 firePropertyChange("alignment", null, alignment.getSequences());
1299 // used to set hasHiddenRows/hiddenRepSequences here, after the property
1305 public void showSequence(int index)
1307 List<SequenceI> tmp = alignment.getHiddenSequences().showSequence(
1308 index, hiddenRepSequences);
1311 if (selectionGroup == null)
1313 selectionGroup = new SequenceGroup();
1314 selectionGroup.setEndRes(alignment.getWidth() - 1);
1317 for (SequenceI seq : tmp)
1319 selectionGroup.addSequence(seq, false);
1320 setSequenceAnnotationsVisible(seq, true);
1322 firePropertyChange("alignment", null, alignment.getSequences());
1327 public void hideAllSelectedSeqs()
1329 if (selectionGroup == null || selectionGroup.getSize() < 1)
1334 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1338 setSelectionGroup(null);
1341 public void hideSequence(SequenceI[] seq)
1345 for (int i = 0; i < seq.length; i++)
1347 alignment.getHiddenSequences().hideSequence(seq[i]);
1348 setSequenceAnnotationsVisible(seq[i], false);
1350 firePropertyChange("alignment", null, alignment.getSequences());
1355 * Set visibility for any annotations for the given sequence.
1359 protected void setSequenceAnnotationsVisible(SequenceI sequenceI,
1362 for (AlignmentAnnotation ann : alignment.getAlignmentAnnotation())
1364 if (ann.sequenceRef == sequenceI)
1366 ann.visible = visible;
1371 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1373 int sSize = sg.getSize();
1379 if (hiddenRepSequences == null)
1381 hiddenRepSequences = new Hashtable();
1384 hiddenRepSequences.put(repSequence, sg);
1386 // Hide all sequences except the repSequence
1387 SequenceI[] seqs = new SequenceI[sSize - 1];
1389 for (int i = 0; i < sSize; i++)
1391 if (sg.getSequenceAt(i) != repSequence)
1393 if (index == sSize - 1)
1398 seqs[index++] = sg.getSequenceAt(i);
1401 sg.setSeqrep(repSequence); // note: not done in 2.7applet
1402 sg.setHidereps(true); // note: not done in 2.7applet
1407 public boolean isHiddenRepSequence(SequenceI seq)
1409 return alignment.getSeqrep() == seq
1410 || (hiddenRepSequences != null && hiddenRepSequences
1414 public SequenceGroup getRepresentedSequences(SequenceI seq)
1416 return (SequenceGroup) (hiddenRepSequences == null ? null
1417 : hiddenRepSequences.get(seq));
1421 public int adjustForHiddenSeqs(int alignmentIndex)
1423 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1428 public void invertColumnSelection()
1430 colSel.invertColumnSelection(0, alignment.getWidth());
1434 public SequenceI[] getSelectionAsNewSequence()
1436 SequenceI[] sequences;
1437 // JBPNote: Need to test jalviewLite.getSelectedSequencesAsAlignmentFrom -
1438 // this was the only caller in the applet for this method
1439 // JBPNote: in applet, this method returned references to the alignment
1440 // sequences, and it did not honour the presence/absence of annotation
1441 // attached to the alignment (probably!)
1442 if (selectionGroup == null || selectionGroup.getSize() == 0)
1444 sequences = alignment.getSequencesArray();
1445 AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
1446 for (int i = 0; i < sequences.length; i++)
1448 // construct new sequence with subset of visible annotation
1449 sequences[i] = new Sequence(sequences[i], annots);
1454 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1461 public SequenceI[] getSequenceSelection()
1463 SequenceI[] sequences = null;
1464 if (selectionGroup != null)
1466 sequences = selectionGroup.getSequencesInOrder(alignment);
1468 if (sequences == null)
1470 sequences = alignment.getSequencesArray();
1476 public CigarArray getViewAsCigars(boolean selectedRegionOnly)
1478 return new CigarArray(alignment, colSel,
1479 (selectedRegionOnly ? selectionGroup : null));
1483 public jalview.datamodel.AlignmentView getAlignmentView(
1484 boolean selectedOnly)
1486 return getAlignmentView(selectedOnly, false);
1490 public jalview.datamodel.AlignmentView getAlignmentView(
1491 boolean selectedOnly, boolean markGroups)
1493 return new AlignmentView(alignment, colSel, selectionGroup,
1494 colSel != null && colSel.hasHiddenColumns(), selectedOnly,
1499 public String[] getViewAsString(boolean selectedRegionOnly)
1501 String[] selection = null;
1502 SequenceI[] seqs = null;
1504 int start = 0, end = 0;
1505 if (selectedRegionOnly && selectionGroup != null)
1507 iSize = selectionGroup.getSize();
1508 seqs = selectionGroup.getSequencesInOrder(alignment);
1509 start = selectionGroup.getStartRes();
1510 end = selectionGroup.getEndRes() + 1;
1514 iSize = alignment.getHeight();
1515 seqs = alignment.getSequencesArray();
1516 end = alignment.getWidth();
1519 selection = new String[iSize];
1520 if (colSel != null && colSel.hasHiddenColumns())
1522 selection = colSel.getVisibleSequenceStrings(start, end, seqs);
1526 for (i = 0; i < iSize; i++)
1528 selection[i] = seqs[i].getSequenceAsString(start, end);
1536 public List<int[]> getVisibleRegionBoundaries(int min, int max)
1538 ArrayList<int[]> regions = new ArrayList<int[]>();
1544 if (colSel != null && colSel.hasHiddenColumns())
1548 start = colSel.adjustForHiddenColumns(start);
1551 end = colSel.getHiddenBoundaryRight(start);
1562 regions.add(new int[] { start, end });
1564 if (colSel != null && colSel.hasHiddenColumns())
1566 start = colSel.adjustForHiddenColumns(end);
1567 start = colSel.getHiddenBoundaryLeft(start) + 1;
1569 } while (end < max);
1571 int[][] startEnd = new int[regions.size()][2];
1577 public List<AlignmentAnnotation> getVisibleAlignmentAnnotation(
1578 boolean selectedOnly)
1580 ArrayList<AlignmentAnnotation> ala = new ArrayList<AlignmentAnnotation>();
1581 AlignmentAnnotation[] aa;
1582 if ((aa = alignment.getAlignmentAnnotation()) != null)
1584 for (AlignmentAnnotation annot : aa)
1586 AlignmentAnnotation clone = new AlignmentAnnotation(annot);
1587 if (selectedOnly && selectionGroup != null)
1589 colSel.makeVisibleAnnotation(selectionGroup.getStartRes(),
1590 selectionGroup.getEndRes(), clone);
1594 colSel.makeVisibleAnnotation(clone);
1603 public boolean isPadGaps()
1609 public void setPadGaps(boolean padGaps)
1611 this.padGaps = padGaps;
1615 * apply any post-edit constraints and trigger any calculations needed after
1616 * an edit has been performed on the alignment
1621 public void alignmentChanged(AlignmentViewPanel ap)
1625 alignment.padGaps();
1627 if (autoCalculateConsensus)
1629 updateConsensus(ap);
1631 if (hconsensus != null && autoCalculateConsensus)
1633 updateConservation(ap);
1635 if (autoCalculateStrucConsensus)
1637 updateStrucConsensus(ap);
1640 // Reset endRes of groups if beyond alignment width
1641 int alWidth = alignment.getWidth();
1642 List<SequenceGroup> groups = alignment.getGroups();
1645 for (SequenceGroup sg : groups)
1647 if (sg.getEndRes() > alWidth)
1649 sg.setEndRes(alWidth - 1);
1654 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1656 selectionGroup.setEndRes(alWidth - 1);
1659 resetAllColourSchemes();
1660 calculator.restartWorkers();
1661 // alignment.adjustSequenceAnnotations();
1665 * reset scope and do calculations for all applied colourschemes on alignment
1667 void resetAllColourSchemes()
1669 ColourSchemeI cs = globalColourScheme;
1672 cs.alignmentChanged(alignment, hiddenRepSequences);
1674 cs.setConsensus(hconsensus);
1675 if (cs.conservationApplied())
1677 cs.setConservation(Conservation.calculateConservation("All",
1678 ResidueProperties.propHash, 3, alignment.getSequences(), 0,
1679 alignment.getWidth(), false, getConsPercGaps(), false));
1683 for (SequenceGroup sg : alignment.getGroups())
1687 sg.cs.alignmentChanged(sg, hiddenRepSequences);
1689 sg.recalcConservation();
1693 protected void initAutoAnnotation()
1695 // TODO: add menu option action that nulls or creates consensus object
1696 // depending on if the user wants to see the annotation or not in a
1697 // specific alignment
1699 if (hconsensus == null && !isDataset)
1701 if (!alignment.isNucleotide())
1710 consensus = new AlignmentAnnotation("Consensus", "PID",
1711 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
1712 initConsensus(consensus);
1714 initComplementConsensus();
1719 * If this is a protein alignment and there are mappings to cDNA, add the cDNA
1720 * consensus annotation.
1722 public void initComplementConsensus()
1724 if (!alignment.isNucleotide())
1726 final Set<AlignedCodonFrame> codonMappings = alignment
1728 if (codonMappings != null && !codonMappings.isEmpty())
1730 complementConsensus = new AlignmentAnnotation("cDNA Consensus",
1731 "PID for cDNA", new Annotation[1], 0f, 100f,
1732 AlignmentAnnotation.BAR_GRAPH);
1733 initConsensus(complementConsensus);
1738 private void initConsensus(AlignmentAnnotation aa)
1741 aa.autoCalculated = true;
1745 alignment.addAnnotation(aa);
1749 private void initConservation()
1751 if (showConservation)
1753 if (conservation == null)
1755 conservation = new AlignmentAnnotation("Conservation",
1756 "Conservation of total alignment less than "
1757 + getConsPercGaps() + "% gaps", new Annotation[1],
1758 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
1759 conservation.hasText = true;
1760 conservation.autoCalculated = true;
1761 alignment.addAnnotation(conservation);
1766 private void initQuality()
1770 if (quality == null)
1772 quality = new AlignmentAnnotation("Quality",
1773 "Alignment Quality based on Blosum62 scores",
1774 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
1775 quality.hasText = true;
1776 quality.autoCalculated = true;
1777 alignment.addAnnotation(quality);
1782 private void initRNAStructure()
1784 if (alignment.hasRNAStructure() && strucConsensus == null)
1786 strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
1787 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
1788 strucConsensus.hasText = true;
1789 strucConsensus.autoCalculated = true;
1793 alignment.addAnnotation(strucConsensus);
1801 * @see jalview.api.AlignViewportI#calcPanelHeight()
1804 public int calcPanelHeight()
1806 // setHeight of panels
1807 AlignmentAnnotation[] anns = getAlignment().getAlignmentAnnotation();
1809 int charHeight = getCharHeight();
1812 BitSet graphgrp = new BitSet();
1813 for (AlignmentAnnotation aa : anns)
1817 System.err.println("Null annotation row: ignoring.");
1824 if (aa.graphGroup > -1)
1826 if (graphgrp.get(aa.graphGroup))
1832 graphgrp.set(aa.graphGroup);
1839 aa.height += charHeight;
1849 aa.height += aa.graphHeight;
1857 height += aa.height;
1869 public void updateGroupAnnotationSettings(boolean applyGlobalSettings,
1870 boolean preserveNewGroupSettings)
1872 boolean updateCalcs = false;
1873 boolean conv = isShowGroupConservation();
1874 boolean cons = isShowGroupConsensus();
1875 boolean showprf = isShowSequenceLogo();
1876 boolean showConsHist = isShowConsensusHistogram();
1877 boolean normLogo = isNormaliseSequenceLogo();
1880 * TODO reorder the annotation rows according to group/sequence ordering on
1883 boolean sortg = true;
1885 // remove old automatic annotation
1886 // add any new annotation
1888 // intersect alignment annotation with alignment groups
1890 AlignmentAnnotation[] aan = alignment.getAlignmentAnnotation();
1891 List<SequenceGroup> oldrfs = new ArrayList<SequenceGroup>();
1894 for (int an = 0; an < aan.length; an++)
1896 if (aan[an].autoCalculated && aan[an].groupRef != null)
1898 oldrfs.add(aan[an].groupRef);
1899 alignment.deleteAnnotation(aan[an], false);
1903 if (alignment.getGroups() != null)
1905 for (SequenceGroup sg : alignment.getGroups())
1907 updateCalcs = false;
1908 if (applyGlobalSettings
1909 || (!preserveNewGroupSettings && !oldrfs.contains(sg)))
1911 // set defaults for this group's conservation/consensus
1912 sg.setshowSequenceLogo(showprf);
1913 sg.setShowConsensusHistogram(showConsHist);
1914 sg.setNormaliseSequenceLogo(normLogo);
1919 alignment.addAnnotation(sg.getConservationRow(), 0);
1924 alignment.addAnnotation(sg.getConsensus(), 0);
1926 // refresh the annotation rows
1929 sg.recalcConservation();
1937 public boolean isDisplayReferenceSeq()
1939 return alignment.hasSeqrep() && viewStyle.isDisplayReferenceSeq();
1943 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
1945 viewStyle.setDisplayReferenceSeq(displayReferenceSeq);
1949 public boolean isColourByReferenceSeq()
1951 return alignment.hasSeqrep() && viewStyle.isColourByReferenceSeq();
1955 public Color getSequenceColour(SequenceI seq)
1957 Color sqc = sequenceColours.get(seq);
1958 return (sqc == null ? Color.white : sqc);
1962 public void setSequenceColour(SequenceI seq, Color col)
1966 sequenceColours.remove(seq);
1970 sequenceColours.put(seq, col);
1975 public void updateSequenceIdColours()
1977 for (SequenceGroup sg : alignment.getGroups())
1979 if (sg.idColour != null)
1981 for (SequenceI s : sg.getSequences(getHiddenRepSequences()))
1983 sequenceColours.put(s, sg.idColour);
1990 public void clearSequenceColours()
1992 sequenceColours.clear();
1996 public AlignViewportI getCodingComplement()
1998 return this.codingComplement;
2002 * Set this as the (cDna/protein) complement of the given viewport. Also
2003 * ensures the reverse relationship is set on the given viewport.
2006 public void setCodingComplement(AlignViewportI av)
2010 System.err.println("Ignoring recursive setCodingComplement request");
2014 this.codingComplement = av;
2015 // avoid infinite recursion!
2016 if (av.getCodingComplement() != this)
2018 av.setCodingComplement(this);
2024 public boolean isNucleotide()
2026 return getAlignment() == null ? false : getAlignment().isNucleotide();
2030 public FeaturesDisplayedI getFeaturesDisplayed()
2032 return featuresDisplayed;
2036 public void setFeaturesDisplayed(FeaturesDisplayedI featuresDisplayedI)
2038 featuresDisplayed = featuresDisplayedI;
2042 public boolean areFeaturesDisplayed()
2044 return featuresDisplayed != null
2045 && featuresDisplayed.getRegisterdFeaturesCount() > 0;
2052 * features are displayed if true
2055 public void setShowSequenceFeatures(boolean b)
2057 viewStyle.setShowSequenceFeatures(b);
2061 public boolean isShowSequenceFeatures()
2063 return viewStyle.isShowSequenceFeatures();
2067 public void setShowSequenceFeaturesHeight(boolean selected)
2069 viewStyle.setShowSequenceFeaturesHeight(selected);
2073 public boolean isShowSequenceFeaturesHeight()
2075 return viewStyle.isShowSequenceFeaturesHeight();
2079 public void setShowAnnotation(boolean b)
2081 viewStyle.setShowAnnotation(b);
2085 public boolean isShowAnnotation()
2087 return viewStyle.isShowAnnotation();
2091 public boolean isRightAlignIds()
2093 return viewStyle.isRightAlignIds();
2097 public void setRightAlignIds(boolean rightAlignIds)
2099 viewStyle.setRightAlignIds(rightAlignIds);
2103 public boolean getConservationSelected()
2105 return viewStyle.getConservationSelected();
2109 public void setShowBoxes(boolean state)
2111 viewStyle.setShowBoxes(state);
2116 * @see jalview.api.ViewStyleI#getTextColour()
2118 public Color getTextColour()
2120 return viewStyle.getTextColour();
2125 * @see jalview.api.ViewStyleI#getTextColour2()
2127 public Color getTextColour2()
2129 return viewStyle.getTextColour2();
2134 * @see jalview.api.ViewStyleI#getThresholdTextColour()
2136 public int getThresholdTextColour()
2138 return viewStyle.getThresholdTextColour();
2143 * @see jalview.api.ViewStyleI#isConservationColourSelected()
2145 public boolean isConservationColourSelected()
2147 return viewStyle.isConservationColourSelected();
2152 * @see jalview.api.ViewStyleI#isRenderGaps()
2154 public boolean isRenderGaps()
2156 return viewStyle.isRenderGaps();
2161 * @see jalview.api.ViewStyleI#isShowColourText()
2163 public boolean isShowColourText()
2165 return viewStyle.isShowColourText();
2169 * @param conservationColourSelected
2170 * @see jalview.api.ViewStyleI#setConservationColourSelected(boolean)
2172 public void setConservationColourSelected(
2173 boolean conservationColourSelected)
2175 viewStyle.setConservationColourSelected(conservationColourSelected);
2179 * @param showColourText
2180 * @see jalview.api.ViewStyleI#setShowColourText(boolean)
2182 public void setShowColourText(boolean showColourText)
2184 viewStyle.setShowColourText(showColourText);
2189 * @see jalview.api.ViewStyleI#setTextColour(java.awt.Color)
2191 public void setTextColour(Color textColour)
2193 viewStyle.setTextColour(textColour);
2197 * @param thresholdTextColour
2198 * @see jalview.api.ViewStyleI#setThresholdTextColour(int)
2200 public void setThresholdTextColour(int thresholdTextColour)
2202 viewStyle.setThresholdTextColour(thresholdTextColour);
2206 * @param textColour2
2207 * @see jalview.api.ViewStyleI#setTextColour2(java.awt.Color)
2209 public void setTextColour2(Color textColour2)
2211 viewStyle.setTextColour2(textColour2);
2215 public ViewStyleI getViewStyle()
2217 return new ViewStyle(viewStyle);
2221 public void setViewStyle(ViewStyleI settingsForView)
2223 viewStyle = new ViewStyle(settingsForView);
2227 public boolean sameStyle(ViewStyleI them)
2229 return viewStyle.sameStyle(them);
2234 * @see jalview.api.ViewStyleI#getIdWidth()
2236 public int getIdWidth()
2238 return viewStyle.getIdWidth();
2243 * @see jalview.api.ViewStyleI#setIdWidth(int)
2245 public void setIdWidth(int i)
2247 viewStyle.setIdWidth(i);
2252 * @see jalview.api.ViewStyleI#isCentreColumnLabels()
2254 public boolean isCentreColumnLabels()
2256 return viewStyle.isCentreColumnLabels();
2260 * @param centreColumnLabels
2261 * @see jalview.api.ViewStyleI#setCentreColumnLabels(boolean)
2263 public void setCentreColumnLabels(boolean centreColumnLabels)
2265 viewStyle.setCentreColumnLabels(centreColumnLabels);
2270 * @see jalview.api.ViewStyleI#setShowDBRefs(boolean)
2272 public void setShowDBRefs(boolean showdbrefs)
2274 viewStyle.setShowDBRefs(showdbrefs);
2279 * @see jalview.api.ViewStyleI#isShowDBRefs()
2281 public boolean isShowDBRefs()
2283 return viewStyle.isShowDBRefs();
2288 * @see jalview.api.ViewStyleI#isShowNPFeats()
2290 public boolean isShowNPFeats()
2292 return viewStyle.isShowNPFeats();
2296 * @param shownpfeats
2297 * @see jalview.api.ViewStyleI#setShowNPFeats(boolean)
2299 public void setShowNPFeats(boolean shownpfeats)
2301 viewStyle.setShowNPFeats(shownpfeats);
2304 public abstract StructureSelectionManager getStructureSelectionManager();
2307 * Add one command to the command history list.
2311 public void addToHistoryList(CommandI command)
2313 if (this.historyList != null)
2315 this.historyList.push(command);
2316 broadcastCommand(command, false);
2320 protected void broadcastCommand(CommandI command, boolean undo)
2322 getStructureSelectionManager().commandPerformed(command, undo,
2327 * Add one command to the command redo list.
2331 public void addToRedoList(CommandI command)
2333 if (this.redoList != null)
2335 this.redoList.push(command);
2337 broadcastCommand(command, true);
2341 * Clear the command redo list.
2343 public void clearRedoList()
2345 if (this.redoList != null)
2347 this.redoList.clear();
2351 public void setHistoryList(Deque<CommandI> list)
2353 this.historyList = list;
2356 public Deque<CommandI> getHistoryList()
2358 return this.historyList;
2361 public void setRedoList(Deque<CommandI> list)
2363 this.redoList = list;
2366 public Deque<CommandI> getRedoList()
2368 return this.redoList;
2372 public VamsasSource getVamsasSource()
2377 public SequenceAnnotationOrder getSortAnnotationsBy()
2379 return sortAnnotationsBy;
2382 public void setSortAnnotationsBy(SequenceAnnotationOrder sortAnnotationsBy)
2384 this.sortAnnotationsBy = sortAnnotationsBy;
2387 public boolean isShowAutocalculatedAbove()
2389 return showAutocalculatedAbove;
2392 public void setShowAutocalculatedAbove(boolean showAutocalculatedAbove)
2394 this.showAutocalculatedAbove = showAutocalculatedAbove;
2398 public boolean isScaleProteinAsCdna()
2400 return viewStyle.isScaleProteinAsCdna();
2404 public void setScaleProteinAsCdna(boolean b)
2406 viewStyle.setScaleProteinAsCdna(b);
2410 * @return true if view should scroll to show the highlighted region of a
2415 public final boolean isFollowHighlight()
2417 return followHighlight;
2421 public final void setFollowHighlight(boolean b)
2423 this.followHighlight = b;
2426 public int getStartRes()
2431 public int getEndRes()
2436 public int getStartSeq()
2441 public void setStartRes(int res)
2443 this.startRes = res;
2446 public void setStartSeq(int seq)
2448 this.startSeq = seq;
2451 public void setEndRes(int res)
2453 if (res > alignment.getWidth() - 1)
2455 // log.System.out.println(" Corrected res from " + res + " to maximum " +
2456 // (alignment.getWidth()-1));
2457 res = alignment.getWidth() - 1;
2466 public void setEndSeq(int seq)
2468 if (seq > alignment.getHeight())
2470 seq = alignment.getHeight();
2479 public int getEndSeq()
2485 * Helper method to populate the SearchResults with the location in the
2486 * complementary alignment to scroll to, in order to match this one.
2489 * the SearchResults to add to
2490 * @return the offset (below top of visible region) of the matched sequence
2492 protected int findComplementScrollTarget(SearchResults sr)
2494 final AlignViewportI complement = getCodingComplement();
2495 if (complement == null || !complement.isFollowHighlight())
2499 boolean iAmProtein = !getAlignment().isNucleotide();
2500 AlignmentI proteinAlignment = iAmProtein ? getAlignment() : complement
2502 if (proteinAlignment == null)
2506 final Set<AlignedCodonFrame> mappings = proteinAlignment
2510 * Heuristic: find the first mapped sequence (if any) with a non-gapped
2511 * residue in the middle column of the visible region. Scroll the
2512 * complementary alignment to line up the corresponding residue.
2515 SequenceI sequence = null;
2518 * locate 'middle' column (true middle if an odd number visible, left of
2519 * middle if an even number visible)
2521 int middleColumn = getStartRes() + (getEndRes() - getStartRes()) / 2;
2522 final HiddenSequences hiddenSequences = getAlignment()
2523 .getHiddenSequences();
2526 * searching to the bottom of the alignment gives smoother scrolling across
2527 * all gapped visible regions
2529 int lastSeq = alignment.getHeight() - 1;
2530 for (int seqNo = getStartSeq(); seqNo < lastSeq; seqNo++, seqOffset++)
2532 sequence = getAlignment().getSequenceAt(seqNo);
2533 if (hiddenSequences != null && hiddenSequences.isHidden(sequence))
2537 if (Comparison.isGap(sequence.getCharAt(middleColumn)))
2541 List<AlignedCodonFrame> seqMappings = MappingUtils
2542 .findMappingsForSequence(sequence, mappings);
2543 if (!seqMappings.isEmpty())
2549 if (sequence == null)
2552 * No ungapped mapped sequence in middle column - do nothing
2556 MappingUtils.addSearchResults(sr, sequence,
2557 sequence.findPosition(middleColumn), mappings);