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.ConservationThread;
58 import jalview.workers.StrucConsensusThread;
60 import java.awt.Color;
61 import java.util.ArrayDeque;
62 import java.util.ArrayList;
63 import java.util.BitSet;
64 import java.util.Deque;
65 import java.util.HashMap;
66 import java.util.Hashtable;
67 import java.util.List;
72 * base class holding visualization and analysis attributes and common logic for
73 * an active alignment view displayed in the GUI
78 public abstract class AlignmentViewport implements AlignViewportI,
79 CommandListener, VamsasSource
81 protected ViewStyleI viewStyle = new ViewStyle();
84 * A viewport that hosts the cDna view of this (protein), or vice versa (if
87 AlignViewportI codingComplement = null;
89 FeaturesDisplayedI featuresDisplayed = null;
91 protected Deque<CommandI> historyList = new ArrayDeque<CommandI>();
93 protected Deque<CommandI> redoList = new ArrayDeque<CommandI>();
97 * @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)
108 public void setFontStyle(int style)
110 viewStyle.setFontStyle(style);
115 * @see jalview.api.ViewStyleI#setFontSize(int)
117 public void setFontSize(int size)
119 viewStyle.setFontSize(size);
124 * @see jalview.api.ViewStyleI#getFontStyle()
126 public int getFontStyle()
128 return viewStyle.getFontStyle();
133 * @see jalview.api.ViewStyleI#getFontName()
135 public String getFontName()
137 return viewStyle.getFontName();
142 * @see jalview.api.ViewStyleI#getFontSize()
144 public int getFontSize()
146 return viewStyle.getFontSize();
150 * @param upperCasebold
151 * @see jalview.api.ViewStyleI#setUpperCasebold(boolean)
153 public void setUpperCasebold(boolean upperCasebold)
155 viewStyle.setUpperCasebold(upperCasebold);
160 * @see jalview.api.ViewStyleI#isUpperCasebold()
162 public boolean isUpperCasebold()
164 return viewStyle.isUpperCasebold();
169 * @see jalview.api.ViewStyleI#isSeqNameItalics()
171 public boolean isSeqNameItalics()
173 return viewStyle.isSeqNameItalics();
177 * @param colourByReferenceSeq
178 * @see jalview.api.ViewStyleI#setColourByReferenceSeq(boolean)
180 public void setColourByReferenceSeq(boolean colourByReferenceSeq)
182 viewStyle.setColourByReferenceSeq(colourByReferenceSeq);
187 * @see jalview.api.ViewStyleI#setColourAppliesToAllGroups(boolean)
189 public void setColourAppliesToAllGroups(boolean b)
191 viewStyle.setColourAppliesToAllGroups(b);
196 * @see jalview.api.ViewStyleI#getColourAppliesToAllGroups()
198 public boolean getColourAppliesToAllGroups()
200 return viewStyle.getColourAppliesToAllGroups();
205 * @see jalview.api.ViewStyleI#getAbovePIDThreshold()
207 public boolean getAbovePIDThreshold()
209 return viewStyle.getAbovePIDThreshold();
214 * @see jalview.api.ViewStyleI#setIncrement(int)
216 public void setIncrement(int inc)
218 viewStyle.setIncrement(inc);
223 * @see jalview.api.ViewStyleI#getIncrement()
225 public int getIncrement()
227 return viewStyle.getIncrement();
232 * @see jalview.api.ViewStyleI#setConservationSelected(boolean)
234 public void setConservationSelected(boolean b)
236 viewStyle.setConservationSelected(b);
241 * @see jalview.api.ViewStyleI#setShowHiddenMarkers(boolean)
243 public void setShowHiddenMarkers(boolean show)
245 viewStyle.setShowHiddenMarkers(show);
250 * @see jalview.api.ViewStyleI#getShowHiddenMarkers()
252 public boolean getShowHiddenMarkers()
254 return viewStyle.getShowHiddenMarkers();
259 * @see jalview.api.ViewStyleI#setScaleRightWrapped(boolean)
261 public void setScaleRightWrapped(boolean b)
263 viewStyle.setScaleRightWrapped(b);
268 * @see jalview.api.ViewStyleI#setScaleLeftWrapped(boolean)
270 public void setScaleLeftWrapped(boolean b)
272 viewStyle.setScaleLeftWrapped(b);
277 * @see jalview.api.ViewStyleI#setScaleAboveWrapped(boolean)
279 public void setScaleAboveWrapped(boolean b)
281 viewStyle.setScaleAboveWrapped(b);
286 * @see jalview.api.ViewStyleI#getScaleLeftWrapped()
288 public boolean getScaleLeftWrapped()
290 return viewStyle.getScaleLeftWrapped();
295 * @see jalview.api.ViewStyleI#getScaleAboveWrapped()
297 public boolean getScaleAboveWrapped()
299 return viewStyle.getScaleAboveWrapped();
304 * @see jalview.api.ViewStyleI#getScaleRightWrapped()
306 public boolean getScaleRightWrapped()
308 return viewStyle.getScaleRightWrapped();
313 * @see jalview.api.ViewStyleI#setAbovePIDThreshold(boolean)
315 public void setAbovePIDThreshold(boolean b)
317 viewStyle.setAbovePIDThreshold(b);
322 * @see jalview.api.ViewStyleI#setThreshold(int)
324 public void setThreshold(int thresh)
326 viewStyle.setThreshold(thresh);
331 * @see jalview.api.ViewStyleI#getThreshold()
333 public int getThreshold()
335 return viewStyle.getThreshold();
340 * @see jalview.api.ViewStyleI#getShowJVSuffix()
342 public boolean getShowJVSuffix()
344 return viewStyle.getShowJVSuffix();
349 * @see jalview.api.ViewStyleI#setShowJVSuffix(boolean)
351 public void setShowJVSuffix(boolean b)
353 viewStyle.setShowJVSuffix(b);
358 * @see jalview.api.ViewStyleI#setWrapAlignment(boolean)
360 public void setWrapAlignment(boolean state)
362 viewStyle.setWrapAlignment(state);
367 * @see jalview.api.ViewStyleI#setShowText(boolean)
369 public void setShowText(boolean state)
371 viewStyle.setShowText(state);
376 * @see jalview.api.ViewStyleI#setRenderGaps(boolean)
378 public void setRenderGaps(boolean state)
380 viewStyle.setRenderGaps(state);
385 * @see jalview.api.ViewStyleI#getColourText()
387 public boolean getColourText()
389 return viewStyle.getColourText();
394 * @see jalview.api.ViewStyleI#setColourText(boolean)
396 public void setColourText(boolean state)
398 viewStyle.setColourText(state);
403 * @see jalview.api.ViewStyleI#getWrapAlignment()
405 public boolean getWrapAlignment()
407 return viewStyle.getWrapAlignment();
412 * @see jalview.api.ViewStyleI#getShowText()
414 public boolean getShowText()
416 return viewStyle.getShowText();
421 * @see jalview.api.ViewStyleI#getWrappedWidth()
423 public int getWrappedWidth()
425 return viewStyle.getWrappedWidth();
430 * @see jalview.api.ViewStyleI#setWrappedWidth(int)
432 public void setWrappedWidth(int w)
434 viewStyle.setWrappedWidth(w);
439 * @see jalview.api.ViewStyleI#getCharHeight()
441 public int getCharHeight()
443 return viewStyle.getCharHeight();
448 * @see jalview.api.ViewStyleI#setCharHeight(int)
450 public void setCharHeight(int h)
452 viewStyle.setCharHeight(h);
457 * @see jalview.api.ViewStyleI#getCharWidth()
459 public int getCharWidth()
461 return viewStyle.getCharWidth();
466 * @see jalview.api.ViewStyleI#setCharWidth(int)
468 public void setCharWidth(int w)
470 viewStyle.setCharWidth(w);
475 * @see jalview.api.ViewStyleI#getShowBoxes()
477 public boolean getShowBoxes()
479 return viewStyle.getShowBoxes();
484 * @see jalview.api.ViewStyleI#getShowUnconserved()
486 public boolean getShowUnconserved()
488 return viewStyle.getShowUnconserved();
492 * @param showunconserved
493 * @see jalview.api.ViewStyleI#setShowUnconserved(boolean)
495 public void setShowUnconserved(boolean showunconserved)
497 viewStyle.setShowUnconserved(showunconserved);
502 * @see jalview.api.ViewStyleI#setSeqNameItalics(boolean)
504 public void setSeqNameItalics(boolean default1)
506 viewStyle.setSeqNameItalics(default1);
510 * alignment displayed in the viewport. Please use get/setter
512 protected AlignmentI alignment;
515 public AlignmentI getAlignment()
521 public char getGapCharacter()
523 return alignment.getGapCharacter();
526 protected String sequenceSetID;
529 * probably unused indicator that view is of a dataset rather than an
532 protected boolean isDataset = false;
534 public void setDataset(boolean b)
539 public boolean isDataset()
545 private Map<SequenceI, SequenceCollectionI> hiddenRepSequences;
547 protected ColumnSelection colSel = new ColumnSelection();
549 public boolean autoCalculateConsensus = true;
551 protected boolean autoCalculateStrucConsensus = true;
553 protected boolean ignoreGapsInConsensusCalculation = false;
555 protected ColourSchemeI globalColourScheme = null;
559 public void setGlobalColourScheme(ColourSchemeI cs)
561 // TODO: logic refactored from AlignFrame changeColour -
562 // autorecalc stuff should be changed to rely on the worker system
563 // check to see if we should implement a changeColour(cs) method rather than
564 // put th logic in here
565 // - means that caller decides if they want to just modify state and defer
566 // calculation till later or to do all calculations in thread.
568 globalColourScheme = cs;
569 boolean recalc = false;
572 cs.setConservationApplied(recalc = getConservationSelected());
573 if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
574 || cs instanceof Blosum62ColourScheme)
577 cs.setThreshold(viewStyle.getThreshold(),
578 ignoreGapsInConsensusCalculation);
582 cs.setThreshold(0, ignoreGapsInConsensusCalculation);
586 cs.setConsensus(hconsensus);
587 cs.setConservation(hconservation);
589 cs.alignmentChanged(alignment, hiddenRepSequences);
591 if (getColourAppliesToAllGroups())
593 for (SequenceGroup sg : getAlignment().getGroups())
600 sg.cs = cs.applyTo(sg, getHiddenRepSequences());
601 sg.setConsPercGaps(ConsPercGaps);
602 if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
603 || cs instanceof Blosum62ColourScheme)
605 sg.cs.setThreshold(viewStyle.getThreshold(),
606 isIgnoreGapsConsensus());
611 sg.cs.setThreshold(0, isIgnoreGapsConsensus());
614 if (getConservationSelected())
616 sg.cs.setConservationApplied(true);
621 sg.cs.setConservation(null);
622 // sg.cs.setThreshold(0, getIgnoreGapsConsensus());
626 sg.recalcConservation();
630 sg.cs.alignmentChanged(sg, hiddenRepSequences);
638 public ColourSchemeI getGlobalColourScheme()
640 return globalColourScheme;
643 protected AlignmentAnnotation consensus;
645 protected AlignmentAnnotation complementConsensus;
647 protected AlignmentAnnotation strucConsensus;
649 protected AlignmentAnnotation conservation;
651 protected AlignmentAnnotation quality;
653 protected AlignmentAnnotation[] groupConsensus;
655 protected AlignmentAnnotation[] groupConservation;
658 * results of alignment consensus analysis for visible portion of view
660 protected Hashtable[] hconsensus = null;
663 * results of cDNA complement consensus visible portion of view
665 protected Hashtable[] hcomplementConsensus = null;
668 * results of secondary structure base pair consensus for visible portion of
671 protected Hashtable[] hStrucConsensus = null;
673 protected Conservation hconservation = null;
676 public void setConservation(Conservation cons)
678 hconservation = cons;
682 * percentage gaps allowed in a column before all amino acid properties should
683 * be considered unconserved
685 int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
688 public int getConsPercGaps()
694 public void setSequenceConsensusHash(Hashtable[] hconsensus)
696 this.hconsensus = hconsensus;
700 public void setComplementConsensusHash(Hashtable[] hconsensus)
702 this.hcomplementConsensus = hconsensus;
706 public Hashtable[] getSequenceConsensusHash()
712 public Hashtable[] getComplementConsensusHash()
714 return hcomplementConsensus;
718 public Hashtable[] getRnaStructureConsensusHash()
720 return hStrucConsensus;
724 public void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus)
726 this.hStrucConsensus = hStrucConsensus;
731 public AlignmentAnnotation getAlignmentQualityAnnot()
737 public AlignmentAnnotation getAlignmentConservationAnnotation()
743 public AlignmentAnnotation getAlignmentConsensusAnnotation()
749 public AlignmentAnnotation getComplementConsensusAnnotation()
751 return complementConsensus;
755 public AlignmentAnnotation getAlignmentStrucConsensusAnnotation()
757 return strucConsensus;
760 protected AlignCalcManagerI calculator = new AlignCalcManager();
763 * trigger update of conservation annotation
765 public void updateConservation(final AlignmentViewPanel ap)
767 // see note in mantis : issue number 8585
768 if (alignment.isNucleotide() || conservation == null
769 || !autoCalculateConsensus)
774 .getRegisteredWorkersOfClass(ConservationThread.class) == null)
776 calculator.registerWorker(new ConservationThread(
782 * trigger update of consensus annotation
784 public void updateConsensus(final AlignmentViewPanel ap)
786 // see note in mantis : issue number 8585
787 if (consensus == null || !autoCalculateConsensus)
791 if (calculator.getRegisteredWorkersOfClass(ConsensusThread.class) == null)
793 calculator.registerWorker(new ConsensusThread(this, ap));
797 * A separate thread to compute cDNA consensus for a protein alignment
799 final AlignmentI al = this.getAlignment();
800 if (!al.isNucleotide() && al.getCodonFrames() != null
801 && !al.getCodonFrames().isEmpty())
804 .getRegisteredWorkersOfClass(ComplementConsensusThread.class) == null)
806 calculator.registerWorker(new ComplementConsensusThread(this, ap));
811 // --------START Structure Conservation
812 public void updateStrucConsensus(final AlignmentViewPanel ap)
814 if (autoCalculateStrucConsensus && strucConsensus == null
815 && alignment.isNucleotide() && alignment.hasRNAStructure())
817 // secondary structure has been added - so init the consensus line
821 // see note in mantis : issue number 8585
822 if (strucConsensus == null || !autoCalculateStrucConsensus)
826 if (calculator.getRegisteredWorkersOfClass(StrucConsensusThread.class) == null)
828 calculator.registerWorker(new StrucConsensusThread(this, ap));
832 public boolean isCalcInProgress()
834 return calculator.isWorking();
838 public boolean isCalculationInProgress(
839 AlignmentAnnotation alignmentAnnotation)
841 if (!alignmentAnnotation.autoCalculated)
845 if (calculator.workingInvolvedWith(alignmentAnnotation))
847 // System.err.println("grey out ("+alignmentAnnotation.label+")");
854 public boolean isClosed()
856 // TODO: check that this isClosed is only true after panel is closed, not
857 // before it is fully constructed.
858 return alignment == null;
862 public AlignCalcManagerI getCalcManager()
868 * should conservation rows be shown for groups
870 protected boolean showGroupConservation = false;
873 * should consensus rows be shown for groups
875 protected boolean showGroupConsensus = false;
878 * should consensus profile be rendered by default
880 protected boolean showSequenceLogo = false;
883 * should consensus profile be rendered normalised to row height
885 protected boolean normaliseSequenceLogo = false;
888 * should consensus histograms be rendered by default
890 protected boolean showConsensusHistogram = true;
893 * @return the showConsensusProfile
896 public boolean isShowSequenceLogo()
898 return showSequenceLogo;
902 * @param showSequenceLogo
905 public void setShowSequenceLogo(boolean showSequenceLogo)
907 if (showSequenceLogo != this.showSequenceLogo)
909 // TODO: decouple settings setting from calculation when refactoring
910 // annotation update method from alignframe to viewport
911 this.showSequenceLogo = showSequenceLogo;
912 calculator.updateAnnotationFor(ConsensusThread.class);
913 calculator.updateAnnotationFor(ComplementConsensusThread.class);
914 calculator.updateAnnotationFor(StrucConsensusThread.class);
916 this.showSequenceLogo = showSequenceLogo;
920 * @param showConsensusHistogram
921 * the showConsensusHistogram to set
923 public void setShowConsensusHistogram(boolean showConsensusHistogram)
925 this.showConsensusHistogram = showConsensusHistogram;
929 * @return the showGroupConservation
931 public boolean isShowGroupConservation()
933 return showGroupConservation;
937 * @param showGroupConservation
938 * the showGroupConservation to set
940 public void setShowGroupConservation(boolean showGroupConservation)
942 this.showGroupConservation = showGroupConservation;
946 * @return the showGroupConsensus
948 public boolean isShowGroupConsensus()
950 return showGroupConsensus;
954 * @param showGroupConsensus
955 * the showGroupConsensus to set
957 public void setShowGroupConsensus(boolean showGroupConsensus)
959 this.showGroupConsensus = showGroupConsensus;
964 * @return flag to indicate if the consensus histogram should be rendered by
968 public boolean isShowConsensusHistogram()
970 return this.showConsensusHistogram;
974 * when set, updateAlignment will always ensure sequences are of equal length
976 private boolean padGaps = false;
979 * when set, alignment should be reordered according to a newly opened tree
981 public boolean sortByTree = false;
987 * @return null or the currently selected sequence region
990 public SequenceGroup getSelectionGroup()
992 return selectionGroup;
996 * Set the selection group for this window.
999 * - group holding references to sequences in this alignment view
1003 public void setSelectionGroup(SequenceGroup sg)
1005 selectionGroup = sg;
1008 public void setHiddenColumns(ColumnSelection colsel)
1010 this.colSel = colsel;
1014 public ColumnSelection getColumnSelection()
1020 public void setColumnSelection(ColumnSelection colSel)
1022 this.colSel = colSel;
1025 updateHiddenColumns();
1034 public Map<SequenceI, SequenceCollectionI> getHiddenRepSequences()
1036 return hiddenRepSequences;
1040 public void setHiddenRepSequences(
1041 Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
1043 this.hiddenRepSequences = hiddenRepSequences;
1047 public boolean hasHiddenColumns()
1049 return colSel != null && colSel.hasHiddenColumns();
1052 public void updateHiddenColumns()
1054 // this method doesn't really do anything now. But - it could, since a
1055 // column Selection could be in the process of modification
1056 // hasHiddenColumns = colSel.hasHiddenColumns();
1060 public boolean hasHiddenRows()
1062 return alignment.getHiddenSequences().getSize() > 0;
1066 protected SequenceGroup selectionGroup;
1068 public void setSequenceSetId(String newid)
1070 if (sequenceSetID != null)
1073 .println("Warning - overwriting a sequenceSetId for a viewport!");
1075 sequenceSetID = new String(newid);
1079 public String getSequenceSetId()
1081 if (sequenceSetID == null)
1083 sequenceSetID = alignment.hashCode() + "";
1086 return sequenceSetID;
1090 * unique viewId for synchronizing state (e.g. with stored Jalview Project)
1093 protected String viewId = null;
1096 public String getViewId()
1100 viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
1105 public void setIgnoreGapsConsensus(boolean b, AlignmentViewPanel ap)
1107 ignoreGapsInConsensusCalculation = b;
1110 updateConsensus(ap);
1111 if (globalColourScheme != null)
1113 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
1114 ignoreGapsInConsensusCalculation);
1120 private long sgrouphash = -1, colselhash = -1;
1123 * checks current SelectionGroup against record of last hash value, and
1127 * update the record of last hash value
1129 * @return true if SelectionGroup changed since last call (when b is true)
1131 public boolean isSelectionGroupChanged(boolean b)
1133 int hc = (selectionGroup == null || selectionGroup.getSize() == 0) ? -1
1134 : selectionGroup.hashCode();
1135 if (hc != -1 && hc != sgrouphash)
1147 * checks current colsel against record of last hash value, and optionally
1151 * update the record of last hash value
1152 * @return true if colsel changed since last call (when b is true)
1154 public boolean isColSelChanged(boolean b)
1156 int hc = (colSel == null || colSel.size() == 0) ? -1 : colSel
1158 if (hc != -1 && hc != colselhash)
1170 public boolean isIgnoreGapsConsensus()
1172 return ignoreGapsInConsensusCalculation;
1175 // / property change stuff
1177 // JBPNote Prolly only need this in the applet version.
1178 private final java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
1181 protected boolean showConservation = true;
1183 protected boolean showQuality = true;
1185 protected boolean showConsensus = true;
1187 private Map<SequenceI, Color> sequenceColours = new HashMap<SequenceI, Color>();
1189 protected SequenceAnnotationOrder sortAnnotationsBy = null;
1191 protected boolean showAutocalculatedAbove;
1194 * when set, view will scroll to show the highlighted position
1196 private boolean followHighlight = true;
1198 // TODO private with getters and setters?
1199 public int startRes;
1203 public int startSeq;
1208 * Property change listener for changes in alignment
1213 public void addPropertyChangeListener(
1214 java.beans.PropertyChangeListener listener)
1216 changeSupport.addPropertyChangeListener(listener);
1225 public void removePropertyChangeListener(
1226 java.beans.PropertyChangeListener listener)
1228 changeSupport.removePropertyChangeListener(listener);
1232 * Property change listener for changes in alignment
1241 public void firePropertyChange(String prop, Object oldvalue,
1244 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
1247 // common hide/show column stuff
1249 public void hideSelectedColumns()
1251 if (colSel.size() < 1)
1256 colSel.hideSelectedColumns();
1257 setSelectionGroup(null);
1261 public void hideColumns(int start, int end)
1265 colSel.hideColumns(start);
1269 colSel.hideColumns(start, end);
1273 public void showColumn(int col)
1275 colSel.revealHiddenColumns(col);
1279 public void showAllHiddenColumns()
1281 colSel.revealAllHiddenColumns();
1284 // common hide/show seq stuff
1285 public void showAllHiddenSeqs()
1287 if (alignment.getHiddenSequences().getSize() > 0)
1289 if (selectionGroup == null)
1291 selectionGroup = new SequenceGroup();
1292 selectionGroup.setEndRes(alignment.getWidth() - 1);
1294 List<SequenceI> tmp = alignment.getHiddenSequences().showAll(
1295 hiddenRepSequences);
1296 for (SequenceI seq : tmp)
1298 selectionGroup.addSequence(seq, false);
1299 setSequenceAnnotationsVisible(seq, true);
1302 hiddenRepSequences = null;
1304 firePropertyChange("alignment", null, alignment.getSequences());
1305 // used to set hasHiddenRows/hiddenRepSequences here, after the property
1311 public void showSequence(int index)
1313 List<SequenceI> tmp = alignment.getHiddenSequences().showSequence(
1315 hiddenRepSequences);
1318 if (selectionGroup == null)
1320 selectionGroup = new SequenceGroup();
1321 selectionGroup.setEndRes(alignment.getWidth() - 1);
1324 for (SequenceI seq : tmp)
1326 selectionGroup.addSequence(seq, false);
1327 setSequenceAnnotationsVisible(seq, true);
1329 firePropertyChange("alignment", null, alignment.getSequences());
1334 public void hideAllSelectedSeqs()
1336 if (selectionGroup == null || selectionGroup.getSize() < 1)
1341 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1345 setSelectionGroup(null);
1348 public void hideSequence(SequenceI[] seq)
1352 for (int i = 0; i < seq.length; i++)
1354 alignment.getHiddenSequences().hideSequence(seq[i]);
1355 setSequenceAnnotationsVisible(seq[i], false);
1357 firePropertyChange("alignment", null, alignment.getSequences());
1362 * Set visibility for any annotations for the given sequence.
1366 protected void setSequenceAnnotationsVisible(SequenceI sequenceI,
1369 for (AlignmentAnnotation ann : alignment.getAlignmentAnnotation())
1371 if (ann.sequenceRef == sequenceI)
1373 ann.visible = visible;
1378 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1380 int sSize = sg.getSize();
1386 if (hiddenRepSequences == null)
1388 hiddenRepSequences = new Hashtable();
1391 hiddenRepSequences.put(repSequence, sg);
1393 // Hide all sequences except the repSequence
1394 SequenceI[] seqs = new SequenceI[sSize - 1];
1396 for (int i = 0; i < sSize; i++)
1398 if (sg.getSequenceAt(i) != repSequence)
1400 if (index == sSize - 1)
1405 seqs[index++] = sg.getSequenceAt(i);
1408 sg.setSeqrep(repSequence); // note: not done in 2.7applet
1409 sg.setHidereps(true); // note: not done in 2.7applet
1414 public boolean isHiddenRepSequence(SequenceI seq)
1416 return alignment.getSeqrep()==seq || (hiddenRepSequences != null
1417 && hiddenRepSequences.containsKey(seq));
1420 public SequenceGroup getRepresentedSequences(SequenceI seq)
1422 return (SequenceGroup) (hiddenRepSequences == null ? null
1423 : hiddenRepSequences.get(seq));
1427 public int adjustForHiddenSeqs(int alignmentIndex)
1429 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1434 public void invertColumnSelection()
1436 colSel.invertColumnSelection(0, alignment.getWidth());
1441 public SequenceI[] getSelectionAsNewSequence()
1443 SequenceI[] sequences;
1444 // JBPNote: Need to test jalviewLite.getSelectedSequencesAsAlignmentFrom -
1445 // this was the only caller in the applet for this method
1446 // JBPNote: in applet, this method returned references to the alignment
1447 // sequences, and it did not honour the presence/absence of annotation
1448 // attached to the alignment (probably!)
1449 if (selectionGroup == null || selectionGroup.getSize() == 0)
1451 sequences = alignment.getSequencesArray();
1452 AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
1453 for (int i = 0; i < sequences.length; i++)
1455 // construct new sequence with subset of visible annotation
1456 sequences[i] = new Sequence(sequences[i], annots);
1461 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1469 public SequenceI[] getSequenceSelection()
1471 SequenceI[] sequences = null;
1472 if (selectionGroup != null)
1474 sequences = selectionGroup.getSequencesInOrder(alignment);
1476 if (sequences == null)
1478 sequences = alignment.getSequencesArray();
1485 public CigarArray getViewAsCigars(
1486 boolean selectedRegionOnly)
1488 return new CigarArray(alignment, colSel,
1489 (selectedRegionOnly ? selectionGroup : null));
1494 public AlignmentView getAlignmentView(boolean selectedOnly)
1496 return getAlignmentView(selectedOnly, false);
1501 public AlignmentView getAlignmentView(boolean selectedOnly,
1504 return new AlignmentView(alignment, colSel, selectionGroup,
1505 colSel != null && colSel.hasHiddenColumns(), selectedOnly,
1511 public String[] getViewAsString(boolean selectedRegionOnly)
1513 String[] selection = null;
1514 SequenceI[] seqs = null;
1516 int start = 0, end = 0;
1517 if (selectedRegionOnly && selectionGroup != null)
1519 iSize = selectionGroup.getSize();
1520 seqs = selectionGroup.getSequencesInOrder(alignment);
1521 start = selectionGroup.getStartRes();
1522 end = selectionGroup.getEndRes() + 1;
1526 iSize = alignment.getHeight();
1527 seqs = alignment.getSequencesArray();
1528 end = alignment.getWidth();
1531 selection = new String[iSize];
1532 if (colSel != null && colSel.hasHiddenColumns())
1534 selection = colSel.getVisibleSequenceStrings(start, end, seqs);
1538 for (i = 0; i < iSize; i++)
1540 selection[i] = seqs[i].getSequenceAsString(start, end);
1549 public List<int[]> getVisibleRegionBoundaries(int min, int max)
1551 ArrayList<int[]> regions = new ArrayList<int[]>();
1557 if (colSel != null && colSel.hasHiddenColumns())
1561 start = colSel.adjustForHiddenColumns(start);
1564 end = colSel.getHiddenBoundaryRight(start);
1575 regions.add(new int[]
1578 if (colSel != null && colSel.hasHiddenColumns())
1580 start = colSel.adjustForHiddenColumns(end);
1581 start = colSel.getHiddenBoundaryLeft(start) + 1;
1583 } while (end < max);
1585 int[][] startEnd = new int[regions.size()][2];
1591 public List<AlignmentAnnotation> getVisibleAlignmentAnnotation(boolean selectedOnly)
1593 ArrayList<AlignmentAnnotation> ala = new ArrayList<AlignmentAnnotation>();
1594 AlignmentAnnotation[] aa;
1595 if ((aa=alignment.getAlignmentAnnotation())!=null)
1597 for (AlignmentAnnotation annot:aa)
1599 AlignmentAnnotation clone = new AlignmentAnnotation(annot);
1600 if (selectedOnly && selectionGroup!=null)
1602 colSel.makeVisibleAnnotation(selectionGroup.getStartRes(), selectionGroup.getEndRes(),clone);
1604 colSel.makeVisibleAnnotation(clone);
1614 public boolean isPadGaps()
1621 public void setPadGaps(boolean padGaps)
1623 this.padGaps = padGaps;
1627 * apply any post-edit constraints and trigger any calculations needed after
1628 * an edit has been performed on the alignment
1633 public void alignmentChanged(AlignmentViewPanel ap)
1637 alignment.padGaps();
1639 if (autoCalculateConsensus)
1641 updateConsensus(ap);
1643 if (hconsensus != null && autoCalculateConsensus)
1645 updateConservation(ap);
1647 if (autoCalculateStrucConsensus)
1649 updateStrucConsensus(ap);
1652 // Reset endRes of groups if beyond alignment width
1653 int alWidth = alignment.getWidth();
1654 List<SequenceGroup> groups = alignment.getGroups();
1657 for (SequenceGroup sg : groups)
1659 if (sg.getEndRes() > alWidth)
1661 sg.setEndRes(alWidth - 1);
1666 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1668 selectionGroup.setEndRes(alWidth - 1);
1671 resetAllColourSchemes();
1672 calculator.restartWorkers();
1673 // alignment.adjustSequenceAnnotations();
1677 * reset scope and do calculations for all applied colourschemes on alignment
1679 void resetAllColourSchemes()
1681 ColourSchemeI cs = globalColourScheme;
1684 cs.alignmentChanged(alignment, hiddenRepSequences);
1686 cs.setConsensus(hconsensus);
1687 if (cs.conservationApplied())
1689 cs.setConservation(Conservation.calculateConservation("All",
1690 ResidueProperties.propHash, 3, alignment.getSequences(), 0,
1691 alignment.getWidth(), false, getConsPercGaps(), false));
1695 for (SequenceGroup sg : alignment.getGroups())
1699 sg.cs.alignmentChanged(sg, hiddenRepSequences);
1701 sg.recalcConservation();
1705 protected void initAutoAnnotation()
1707 // TODO: add menu option action that nulls or creates consensus object
1708 // depending on if the user wants to see the annotation or not in a
1709 // specific alignment
1711 if (hconsensus == null && !isDataset)
1713 if (!alignment.isNucleotide())
1722 consensus = new AlignmentAnnotation("Consensus", "PID",
1723 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
1724 initConsensus(consensus);
1726 initComplementConsensus();
1731 * If this is a protein alignment and there are mappings to cDNA, add the cDNA
1732 * consensus annotation.
1734 public void initComplementConsensus()
1736 if (!alignment.isNucleotide())
1738 final Set<AlignedCodonFrame> codonMappings = alignment
1740 if (codonMappings != null && !codonMappings.isEmpty())
1742 complementConsensus = new AlignmentAnnotation("cDNA Consensus",
1743 "PID for cDNA", new Annotation[1], 0f, 100f,
1744 AlignmentAnnotation.BAR_GRAPH);
1745 initConsensus(complementConsensus);
1750 private void initConsensus(AlignmentAnnotation aa)
1753 aa.autoCalculated = true;
1757 alignment.addAnnotation(aa);
1761 private void initConservation()
1763 if (showConservation)
1765 if (conservation == null)
1767 conservation = new AlignmentAnnotation("Conservation",
1768 "Conservation of total alignment less than "
1769 + getConsPercGaps() + "% gaps", new Annotation[1],
1770 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
1771 conservation.hasText = true;
1772 conservation.autoCalculated = true;
1773 alignment.addAnnotation(conservation);
1778 private void initQuality()
1782 if (quality == null)
1784 quality = new AlignmentAnnotation("Quality",
1785 "Alignment Quality based on Blosum62 scores",
1786 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
1787 quality.hasText = true;
1788 quality.autoCalculated = true;
1789 alignment.addAnnotation(quality);
1794 private void initRNAStructure()
1796 if (alignment.hasRNAStructure() && strucConsensus == null)
1798 strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
1799 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
1800 strucConsensus.hasText = true;
1801 strucConsensus.autoCalculated = true;
1805 alignment.addAnnotation(strucConsensus);
1813 * @see jalview.api.AlignViewportI#calcPanelHeight()
1816 public int calcPanelHeight()
1818 // setHeight of panels
1819 AlignmentAnnotation[] anns = getAlignment().getAlignmentAnnotation();
1821 int charHeight = getCharHeight();
1824 BitSet graphgrp = new BitSet();
1825 for (AlignmentAnnotation aa : anns)
1829 System.err.println("Null annotation row: ignoring.");
1836 if (aa.graphGroup > -1)
1838 if (graphgrp.get(aa.graphGroup))
1844 graphgrp.set(aa.graphGroup);
1851 aa.height += charHeight;
1861 aa.height += aa.graphHeight;
1869 height += aa.height;
1881 public void updateGroupAnnotationSettings(boolean applyGlobalSettings,
1882 boolean preserveNewGroupSettings)
1884 boolean updateCalcs = false;
1885 boolean conv = isShowGroupConservation();
1886 boolean cons = isShowGroupConsensus();
1887 boolean showprf = isShowSequenceLogo();
1888 boolean showConsHist = isShowConsensusHistogram();
1889 boolean normLogo = isNormaliseSequenceLogo();
1892 * TODO reorder the annotation rows according to group/sequence ordering on
1895 boolean sortg = true;
1897 // remove old automatic annotation
1898 // add any new annotation
1900 // intersect alignment annotation with alignment groups
1902 AlignmentAnnotation[] aan = alignment.getAlignmentAnnotation();
1903 List<SequenceGroup> oldrfs = new ArrayList<SequenceGroup>();
1906 for (int an = 0; an < aan.length; an++)
1908 if (aan[an].autoCalculated && aan[an].groupRef != null)
1910 oldrfs.add(aan[an].groupRef);
1911 alignment.deleteAnnotation(aan[an], false);
1915 if (alignment.getGroups() != null)
1917 for (SequenceGroup sg : alignment.getGroups())
1919 updateCalcs = false;
1920 if (applyGlobalSettings
1921 || (!preserveNewGroupSettings && !oldrfs.contains(sg)))
1923 // set defaults for this group's conservation/consensus
1924 sg.setshowSequenceLogo(showprf);
1925 sg.setShowConsensusHistogram(showConsHist);
1926 sg.setNormaliseSequenceLogo(normLogo);
1931 alignment.addAnnotation(sg.getConservationRow(), 0);
1936 alignment.addAnnotation(sg.getConsensus(), 0);
1938 // refresh the annotation rows
1941 sg.recalcConservation();
1948 public boolean isDisplayReferenceSeq()
1950 return alignment.hasSeqrep() && viewStyle.isDisplayReferenceSeq();
1954 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
1956 viewStyle.setDisplayReferenceSeq(displayReferenceSeq);
1960 public boolean isColourByReferenceSeq()
1962 return alignment.hasSeqrep() && viewStyle.isColourByReferenceSeq();
1966 public Color getSequenceColour(SequenceI seq)
1968 Color sqc = sequenceColours.get(seq);
1969 return (sqc == null ? Color.white : sqc);
1973 public void setSequenceColour(SequenceI seq, Color col)
1977 sequenceColours.remove(seq);
1981 sequenceColours.put(seq, col);
1986 public void updateSequenceIdColours()
1988 for (SequenceGroup sg : alignment.getGroups())
1990 if (sg.idColour != null)
1992 for (SequenceI s : sg.getSequences(getHiddenRepSequences()))
1994 sequenceColours.put(s, sg.idColour);
2001 public void clearSequenceColours()
2003 sequenceColours.clear();
2007 public AlignViewportI getCodingComplement()
2009 return this.codingComplement;
2013 * Set this as the (cDna/protein) complement of the given viewport. Also
2014 * ensures the reverse relationship is set on the given viewport.
2017 public void setCodingComplement(AlignViewportI av)
2021 System.err.println("Ignoring recursive setCodingComplement request");
2025 this.codingComplement = av;
2026 // avoid infinite recursion!
2027 if (av.getCodingComplement() != this)
2029 av.setCodingComplement(this);
2035 public boolean isNucleotide()
2037 return getAlignment() == null ? false : getAlignment().isNucleotide();
2041 public FeaturesDisplayedI getFeaturesDisplayed()
2043 return featuresDisplayed;
2047 public void setFeaturesDisplayed(FeaturesDisplayedI featuresDisplayedI)
2049 featuresDisplayed = featuresDisplayedI;
2053 public boolean areFeaturesDisplayed()
2055 return featuresDisplayed != null && featuresDisplayed.getRegisterdFeaturesCount()>0;
2062 * features are displayed if true
2065 public void setShowSequenceFeatures(boolean b)
2067 viewStyle.setShowSequenceFeatures(b);
2070 public boolean isShowSequenceFeatures()
2072 return viewStyle.isShowSequenceFeatures();
2076 public void setShowSequenceFeaturesHeight(boolean selected)
2078 viewStyle.setShowSequenceFeaturesHeight(selected);
2082 public boolean isShowSequenceFeaturesHeight()
2084 return viewStyle.isShowSequenceFeaturesHeight();
2090 public void setShowAnnotation(boolean b)
2092 viewStyle.setShowAnnotation(b);
2096 public boolean isShowAnnotation()
2098 return viewStyle.isShowAnnotation();
2102 public boolean isRightAlignIds()
2104 return viewStyle.isRightAlignIds();
2108 public void setRightAlignIds(boolean rightAlignIds)
2110 viewStyle.setRightAlignIds(rightAlignIds);
2114 public boolean getConservationSelected()
2116 return viewStyle.getConservationSelected();
2120 public void setShowBoxes(boolean state)
2122 viewStyle.setShowBoxes(state);
2127 * @see jalview.api.ViewStyleI#getTextColour()
2129 public Color getTextColour()
2131 return viewStyle.getTextColour();
2136 * @see jalview.api.ViewStyleI#getTextColour2()
2138 public Color getTextColour2()
2140 return viewStyle.getTextColour2();
2145 * @see jalview.api.ViewStyleI#getThresholdTextColour()
2147 public int getThresholdTextColour()
2149 return viewStyle.getThresholdTextColour();
2154 * @see jalview.api.ViewStyleI#isConservationColourSelected()
2156 public boolean isConservationColourSelected()
2158 return viewStyle.isConservationColourSelected();
2163 * @see jalview.api.ViewStyleI#isRenderGaps()
2165 public boolean isRenderGaps()
2167 return viewStyle.isRenderGaps();
2172 * @see jalview.api.ViewStyleI#isShowColourText()
2174 public boolean isShowColourText()
2176 return viewStyle.isShowColourText();
2180 * @param conservationColourSelected
2181 * @see jalview.api.ViewStyleI#setConservationColourSelected(boolean)
2183 public void setConservationColourSelected(
2184 boolean conservationColourSelected)
2186 viewStyle.setConservationColourSelected(conservationColourSelected);
2190 * @param showColourText
2191 * @see jalview.api.ViewStyleI#setShowColourText(boolean)
2193 public void setShowColourText(boolean showColourText)
2195 viewStyle.setShowColourText(showColourText);
2200 * @see jalview.api.ViewStyleI#setTextColour(java.awt.Color)
2202 public void setTextColour(Color textColour)
2204 viewStyle.setTextColour(textColour);
2208 * @param thresholdTextColour
2209 * @see jalview.api.ViewStyleI#setThresholdTextColour(int)
2211 public void setThresholdTextColour(int thresholdTextColour)
2213 viewStyle.setThresholdTextColour(thresholdTextColour);
2217 * @param textColour2
2218 * @see jalview.api.ViewStyleI#setTextColour2(java.awt.Color)
2220 public void setTextColour2(Color textColour2)
2222 viewStyle.setTextColour2(textColour2);
2226 public ViewStyleI getViewStyle()
2228 return new ViewStyle(viewStyle);
2232 public void setViewStyle(ViewStyleI settingsForView)
2234 viewStyle = new ViewStyle(settingsForView);
2238 public boolean sameStyle(ViewStyleI them)
2240 return viewStyle.sameStyle(them);
2245 * @see jalview.api.ViewStyleI#getIdWidth()
2247 public int getIdWidth()
2249 return viewStyle.getIdWidth();
2254 * @see jalview.api.ViewStyleI#setIdWidth(int)
2256 public void setIdWidth(int i)
2258 viewStyle.setIdWidth(i);
2263 * @see jalview.api.ViewStyleI#isCentreColumnLabels()
2265 public boolean isCentreColumnLabels()
2267 return viewStyle.isCentreColumnLabels();
2271 * @param centreColumnLabels
2272 * @see jalview.api.ViewStyleI#setCentreColumnLabels(boolean)
2274 public void setCentreColumnLabels(boolean centreColumnLabels)
2276 viewStyle.setCentreColumnLabels(centreColumnLabels);
2281 * @see jalview.api.ViewStyleI#setShowDBRefs(boolean)
2283 public void setShowDBRefs(boolean showdbrefs)
2285 viewStyle.setShowDBRefs(showdbrefs);
2290 * @see jalview.api.ViewStyleI#isShowDBRefs()
2292 public boolean isShowDBRefs()
2294 return viewStyle.isShowDBRefs();
2299 * @see jalview.api.ViewStyleI#isShowNPFeats()
2301 public boolean isShowNPFeats()
2303 return viewStyle.isShowNPFeats();
2307 * @param shownpfeats
2308 * @see jalview.api.ViewStyleI#setShowNPFeats(boolean)
2310 public void setShowNPFeats(boolean shownpfeats)
2312 viewStyle.setShowNPFeats(shownpfeats);
2315 public abstract StructureSelectionManager getStructureSelectionManager();
2318 * Add one command to the command history list.
2322 public void addToHistoryList(CommandI command)
2324 if (this.historyList != null)
2326 this.historyList.push(command);
2327 broadcastCommand(command, false);
2331 protected void broadcastCommand(CommandI command, boolean undo)
2333 getStructureSelectionManager().commandPerformed(command, undo, getVamsasSource());
2337 * Add one command to the command redo list.
2341 public void addToRedoList(CommandI command)
2343 if (this.redoList != null)
2345 this.redoList.push(command);
2347 broadcastCommand(command, true);
2351 * Clear the command redo list.
2353 public void clearRedoList()
2355 if (this.redoList != null)
2357 this.redoList.clear();
2361 public void setHistoryList(Deque<CommandI> list)
2363 this.historyList = list;
2366 public Deque<CommandI> getHistoryList()
2368 return this.historyList;
2371 public void setRedoList(Deque<CommandI> list)
2373 this.redoList = list;
2376 public Deque<CommandI> getRedoList()
2378 return this.redoList;
2382 public VamsasSource getVamsasSource()
2387 public SequenceAnnotationOrder getSortAnnotationsBy()
2389 return sortAnnotationsBy;
2392 public void setSortAnnotationsBy(SequenceAnnotationOrder sortAnnotationsBy)
2394 this.sortAnnotationsBy = sortAnnotationsBy;
2397 public boolean isShowAutocalculatedAbove()
2399 return showAutocalculatedAbove;
2402 public void setShowAutocalculatedAbove(boolean showAutocalculatedAbove)
2404 this.showAutocalculatedAbove = showAutocalculatedAbove;
2408 public boolean isScaleProteinAsCdna()
2410 return viewStyle.isScaleProteinAsCdna();
2414 public void setScaleProteinAsCdna(boolean b)
2416 viewStyle.setScaleProteinAsCdna(b);
2420 * @return true if view should scroll to show the highlighted region of a
2425 public final boolean isFollowHighlight()
2427 return followHighlight;
2431 public final void setFollowHighlight(boolean b)
2433 this.followHighlight = b;
2436 public int getStartRes()
2441 public int getEndRes()
2446 public int getStartSeq()
2451 public void setStartRes(int res)
2453 this.startRes = res;
2456 public void setStartSeq(int seq)
2458 this.startSeq = seq;
2461 public void setEndRes(int res)
2463 if (res > alignment.getWidth() - 1)
2465 // log.System.out.println(" Corrected res from " + res + " to maximum " +
2466 // (alignment.getWidth()-1));
2467 res = alignment.getWidth() - 1;
2476 public void setEndSeq(int seq)
2478 if (seq > alignment.getHeight())
2480 seq = alignment.getHeight();
2489 public int getEndSeq()
2495 * Helper method to populate the SearchResults with the location in the
2496 * complementary alignment to scroll to, in order to match this one.
2499 * the SearchResults to add to
2500 * @return the offset (below top of visible region) of the matched sequence
2502 protected int findComplementScrollTarget(SearchResults sr)
2504 final AlignViewportI complement = getCodingComplement();
2505 if (complement == null || !complement.isFollowHighlight())
2509 boolean iAmProtein = !getAlignment().isNucleotide();
2510 AlignmentI proteinAlignment = iAmProtein ? getAlignment()
2511 : complement.getAlignment();
2512 if (proteinAlignment == null)
2516 final Set<AlignedCodonFrame> mappings = proteinAlignment
2520 * Heuristic: find the first mapped sequence (if any) with a non-gapped
2521 * residue in the middle column of the visible region. Scroll the
2522 * complementary alignment to line up the corresponding residue.
2525 SequenceI sequence = null;
2528 * locate 'middle' column (true middle if an odd number visible, left of
2529 * middle if an even number visible)
2531 int middleColumn = getStartRes() + (getEndRes() - getStartRes()) / 2;
2532 final HiddenSequences hiddenSequences = getAlignment()
2533 .getHiddenSequences();
2534 for (int seqNo = getStartSeq(); seqNo < getEndSeq(); seqNo++, seqOffset++)
2536 sequence = getAlignment().getSequenceAt(seqNo);
2537 if (hiddenSequences != null && hiddenSequences.isHidden(sequence))
2541 if (Comparison.isGap(sequence.getCharAt(middleColumn)))
2545 List<AlignedCodonFrame> seqMappings = MappingUtils
2546 .findMappingsForSequence(sequence, mappings);
2547 if (!seqMappings.isEmpty())
2553 if (sequence == null)
2556 * No ungapped mapped sequence in middle column - do nothing
2560 MappingUtils.addSearchResults(sr, sequence,
2561 sequence.findPosition(middleColumn), mappings);