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.ColorI;
29 import jalview.api.FeaturesDisplayedI;
30 import jalview.api.ViewStyleI;
31 import jalview.commands.CommandI;
32 import jalview.datamodel.AlignedCodonFrame;
33 import jalview.datamodel.AlignmentAnnotation;
34 import jalview.datamodel.AlignmentI;
35 import jalview.datamodel.AlignmentView;
36 import jalview.datamodel.Annotation;
37 import jalview.datamodel.CigarArray;
38 import jalview.datamodel.ColumnSelection;
39 import jalview.datamodel.HiddenSequences;
40 import jalview.datamodel.SearchResults;
41 import jalview.datamodel.Sequence;
42 import jalview.datamodel.SequenceCollectionI;
43 import jalview.datamodel.SequenceGroup;
44 import jalview.datamodel.SequenceI;
45 import jalview.schemes.Blosum62ColourScheme;
46 import jalview.schemes.Colour;
47 import jalview.schemes.ColourSchemeI;
48 import jalview.schemes.PIDColourScheme;
49 import jalview.schemes.ResidueProperties;
50 import jalview.structure.CommandListener;
51 import jalview.structure.StructureSelectionManager;
52 import jalview.structure.VamsasSource;
53 import jalview.util.Comparison;
54 import jalview.util.MapList;
55 import jalview.util.MappingUtils;
56 import jalview.viewmodel.styles.ViewStyle;
57 import jalview.workers.AlignCalcManager;
58 import jalview.workers.ComplementConsensusThread;
59 import jalview.workers.ConsensusThread;
60 import jalview.workers.StrucConsensusThread;
62 import java.util.ArrayDeque;
63 import java.util.ArrayList;
64 import java.util.BitSet;
65 import java.util.Deque;
66 import java.util.HashMap;
67 import java.util.Hashtable;
68 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)
100 public void setFontName(String name)
102 viewStyle.setFontName(name);
107 * @see jalview.api.ViewStyleI#setFontStyle(int)
110 public void setFontStyle(int style)
112 viewStyle.setFontStyle(style);
117 * @see jalview.api.ViewStyleI#setFontSize(int)
120 public void setFontSize(int size)
122 viewStyle.setFontSize(size);
127 * @see jalview.api.ViewStyleI#getFontStyle()
130 public int getFontStyle()
132 return viewStyle.getFontStyle();
137 * @see jalview.api.ViewStyleI#getFontName()
140 public String getFontName()
142 return viewStyle.getFontName();
147 * @see jalview.api.ViewStyleI#getFontSize()
150 public int getFontSize()
152 return viewStyle.getFontSize();
156 * @param upperCasebold
157 * @see jalview.api.ViewStyleI#setUpperCasebold(boolean)
160 public void setUpperCasebold(boolean upperCasebold)
162 viewStyle.setUpperCasebold(upperCasebold);
167 * @see jalview.api.ViewStyleI#isUpperCasebold()
170 public boolean isUpperCasebold()
172 return viewStyle.isUpperCasebold();
177 * @see jalview.api.ViewStyleI#isSeqNameItalics()
180 public boolean isSeqNameItalics()
182 return viewStyle.isSeqNameItalics();
186 * @param colourByReferenceSeq
187 * @see jalview.api.ViewStyleI#setColourByReferenceSeq(boolean)
190 public void setColourByReferenceSeq(boolean colourByReferenceSeq)
192 viewStyle.setColourByReferenceSeq(colourByReferenceSeq);
197 * @see jalview.api.ViewStyleI#setColourAppliesToAllGroups(boolean)
200 public void setColourAppliesToAllGroups(boolean b)
202 viewStyle.setColourAppliesToAllGroups(b);
207 * @see jalview.api.ViewStyleI#getColourAppliesToAllGroups()
210 public boolean getColourAppliesToAllGroups()
212 return viewStyle.getColourAppliesToAllGroups();
217 * @see jalview.api.ViewStyleI#getAbovePIDThreshold()
220 public boolean getAbovePIDThreshold()
222 return viewStyle.getAbovePIDThreshold();
227 * @see jalview.api.ViewStyleI#setIncrement(int)
230 public void setIncrement(int inc)
232 viewStyle.setIncrement(inc);
237 * @see jalview.api.ViewStyleI#getIncrement()
240 public int getIncrement()
242 return viewStyle.getIncrement();
247 * @see jalview.api.ViewStyleI#setConservationSelected(boolean)
250 public void setConservationSelected(boolean b)
252 viewStyle.setConservationSelected(b);
257 * @see jalview.api.ViewStyleI#setShowHiddenMarkers(boolean)
260 public void setShowHiddenMarkers(boolean show)
262 viewStyle.setShowHiddenMarkers(show);
267 * @see jalview.api.ViewStyleI#getShowHiddenMarkers()
270 public boolean getShowHiddenMarkers()
272 return viewStyle.getShowHiddenMarkers();
277 * @see jalview.api.ViewStyleI#setScaleRightWrapped(boolean)
280 public void setScaleRightWrapped(boolean b)
282 viewStyle.setScaleRightWrapped(b);
287 * @see jalview.api.ViewStyleI#setScaleLeftWrapped(boolean)
290 public void setScaleLeftWrapped(boolean b)
292 viewStyle.setScaleLeftWrapped(b);
297 * @see jalview.api.ViewStyleI#setScaleAboveWrapped(boolean)
300 public void setScaleAboveWrapped(boolean b)
302 viewStyle.setScaleAboveWrapped(b);
307 * @see jalview.api.ViewStyleI#getScaleLeftWrapped()
310 public boolean getScaleLeftWrapped()
312 return viewStyle.getScaleLeftWrapped();
317 * @see jalview.api.ViewStyleI#getScaleAboveWrapped()
320 public boolean getScaleAboveWrapped()
322 return viewStyle.getScaleAboveWrapped();
327 * @see jalview.api.ViewStyleI#getScaleRightWrapped()
330 public boolean getScaleRightWrapped()
332 return viewStyle.getScaleRightWrapped();
337 * @see jalview.api.ViewStyleI#setAbovePIDThreshold(boolean)
340 public void setAbovePIDThreshold(boolean b)
342 viewStyle.setAbovePIDThreshold(b);
347 * @see jalview.api.ViewStyleI#setThreshold(int)
350 public void setThreshold(int thresh)
352 viewStyle.setThreshold(thresh);
357 * @see jalview.api.ViewStyleI#getThreshold()
360 public int getThreshold()
362 return viewStyle.getThreshold();
367 * @see jalview.api.ViewStyleI#getShowJVSuffix()
370 public boolean getShowJVSuffix()
372 return viewStyle.getShowJVSuffix();
377 * @see jalview.api.ViewStyleI#setShowJVSuffix(boolean)
380 public void setShowJVSuffix(boolean b)
382 viewStyle.setShowJVSuffix(b);
387 * @see jalview.api.ViewStyleI#setWrapAlignment(boolean)
390 public void setWrapAlignment(boolean state)
392 viewStyle.setWrapAlignment(state);
397 * @see jalview.api.ViewStyleI#setShowText(boolean)
400 public void setShowText(boolean state)
402 viewStyle.setShowText(state);
407 * @see jalview.api.ViewStyleI#setRenderGaps(boolean)
410 public void setRenderGaps(boolean state)
412 viewStyle.setRenderGaps(state);
417 * @see jalview.api.ViewStyleI#getColourText()
420 public boolean getColourText()
422 return viewStyle.getColourText();
427 * @see jalview.api.ViewStyleI#setColourText(boolean)
430 public void setColourText(boolean state)
432 viewStyle.setColourText(state);
437 * @see jalview.api.ViewStyleI#getWrapAlignment()
440 public boolean getWrapAlignment()
442 return viewStyle.getWrapAlignment();
447 * @see jalview.api.ViewStyleI#getShowText()
450 public boolean getShowText()
452 return viewStyle.getShowText();
457 * @see jalview.api.ViewStyleI#getWrappedWidth()
460 public int getWrappedWidth()
462 return viewStyle.getWrappedWidth();
467 * @see jalview.api.ViewStyleI#setWrappedWidth(int)
470 public void setWrappedWidth(int w)
472 viewStyle.setWrappedWidth(w);
477 * @see jalview.api.ViewStyleI#getCharHeight()
480 public int getCharHeight()
482 return viewStyle.getCharHeight();
487 * @see jalview.api.ViewStyleI#setCharHeight(int)
490 public void setCharHeight(int h)
492 viewStyle.setCharHeight(h);
497 * @see jalview.api.ViewStyleI#getCharWidth()
500 public int getCharWidth()
502 return viewStyle.getCharWidth();
507 * @see jalview.api.ViewStyleI#setCharWidth(int)
510 public void setCharWidth(int w)
512 viewStyle.setCharWidth(w);
517 * @see jalview.api.ViewStyleI#getShowBoxes()
520 public boolean getShowBoxes()
522 return viewStyle.getShowBoxes();
527 * @see jalview.api.ViewStyleI#getShowUnconserved()
530 public boolean getShowUnconserved()
532 return viewStyle.getShowUnconserved();
536 * @param showunconserved
537 * @see jalview.api.ViewStyleI#setShowUnconserved(boolean)
540 public void setShowUnconserved(boolean showunconserved)
542 viewStyle.setShowUnconserved(showunconserved);
547 * @see jalview.api.ViewStyleI#setSeqNameItalics(boolean)
550 public void setSeqNameItalics(boolean default1)
552 viewStyle.setSeqNameItalics(default1);
556 * alignment displayed in the viewport. Please use get/setter
558 protected AlignmentI alignment;
561 public AlignmentI getAlignment()
567 public char getGapCharacter()
569 return alignment.getGapCharacter();
572 protected String sequenceSetID;
575 * probably unused indicator that view is of a dataset rather than an
578 protected boolean isDataset = false;
580 public void setDataset(boolean b)
585 public boolean isDataset()
590 private Map<SequenceI, SequenceCollectionI> hiddenRepSequences;
592 protected ColumnSelection colSel = new ColumnSelection();
594 public boolean autoCalculateConsensus = true;
596 protected boolean autoCalculateStrucConsensus = true;
598 protected boolean ignoreGapsInConsensusCalculation = false;
600 protected ColourSchemeI globalColourScheme = null;
603 public void setGlobalColourScheme(ColourSchemeI cs)
605 // TODO: logic refactored from AlignFrame changeColour -
606 // TODO: autorecalc stuff should be changed to rely on the worker system
607 // check to see if we should implement a changeColour(cs) method rather than
608 // put th logic in here
609 // - means that caller decides if they want to just modify state and defer
610 // calculation till later or to do all calculations in thread.
612 globalColourScheme = cs;
613 boolean recalc = false;
616 cs.setConservationApplied(recalc = getConservationSelected());
617 if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
618 || cs instanceof Blosum62ColourScheme)
621 cs.setThreshold(viewStyle.getThreshold(),
622 ignoreGapsInConsensusCalculation);
626 cs.setThreshold(0, ignoreGapsInConsensusCalculation);
630 cs.setConsensus(hconsensus);
631 cs.setConservation(hconservation);
633 cs.alignmentChanged(alignment, hiddenRepSequences);
635 if (getColourAppliesToAllGroups())
637 for (SequenceGroup sg : getAlignment().getGroups())
644 sg.cs = cs.applyTo(sg, getHiddenRepSequences());
645 sg.setConsPercGaps(ConsPercGaps);
646 if (getAbovePIDThreshold() || cs instanceof PIDColourScheme
647 || cs instanceof Blosum62ColourScheme)
649 sg.cs.setThreshold(viewStyle.getThreshold(),
650 isIgnoreGapsConsensus());
655 sg.cs.setThreshold(0, isIgnoreGapsConsensus());
658 if (getConservationSelected())
660 sg.cs.setConservationApplied(true);
665 sg.cs.setConservation(null);
666 // sg.cs.setThreshold(0, getIgnoreGapsConsensus());
670 sg.recalcConservation();
674 sg.cs.alignmentChanged(sg, hiddenRepSequences);
681 public ColourSchemeI getGlobalColourScheme()
683 return globalColourScheme;
686 protected AlignmentAnnotation consensus;
688 protected AlignmentAnnotation complementConsensus;
690 protected AlignmentAnnotation strucConsensus;
692 protected AlignmentAnnotation conservation;
694 protected AlignmentAnnotation quality;
696 protected AlignmentAnnotation[] groupConsensus;
698 protected AlignmentAnnotation[] groupConservation;
701 * results of alignment consensus analysis for visible portion of view
703 protected Hashtable[] hconsensus = null;
706 * results of cDNA complement consensus visible portion of view
708 protected Hashtable[] hcomplementConsensus = null;
711 * results of secondary structure base pair consensus for visible portion of
714 protected Hashtable[] hStrucConsensus = null;
716 protected Conservation hconservation = null;
719 public void setConservation(Conservation cons)
721 hconservation = cons;
725 * percentage gaps allowed in a column before all amino acid properties should
726 * be considered unconserved
728 int ConsPercGaps = 25; // JBPNote : This should be a scalable property!
731 public int getConsPercGaps()
737 public void setSequenceConsensusHash(Hashtable[] hconsensus)
739 this.hconsensus = hconsensus;
743 public void setComplementConsensusHash(Hashtable[] hconsensus)
745 this.hcomplementConsensus = hconsensus;
749 public Hashtable[] getSequenceConsensusHash()
755 public Hashtable[] getComplementConsensusHash()
757 return hcomplementConsensus;
761 public Hashtable[] getRnaStructureConsensusHash()
763 return hStrucConsensus;
767 public void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus)
769 this.hStrucConsensus = hStrucConsensus;
774 public AlignmentAnnotation getAlignmentQualityAnnot()
780 public AlignmentAnnotation getAlignmentConservationAnnotation()
786 public AlignmentAnnotation getAlignmentConsensusAnnotation()
792 public AlignmentAnnotation getComplementConsensusAnnotation()
794 return complementConsensus;
798 public AlignmentAnnotation getAlignmentStrucConsensusAnnotation()
800 return strucConsensus;
803 protected AlignCalcManagerI calculator = new AlignCalcManager();
806 * trigger update of conservation annotation
808 public void updateConservation(final AlignmentViewPanel ap)
810 // see note in mantis : issue number 8585
811 if (alignment.isNucleotide() || conservation == null
812 || !autoCalculateConsensus)
817 .getRegisteredWorkersOfClass(jalview.workers.ConservationThread.class) == null)
819 calculator.registerWorker(new jalview.workers.ConservationThread(
825 * trigger update of consensus annotation
827 public void updateConsensus(final AlignmentViewPanel ap)
829 // see note in mantis : issue number 8585
830 if (consensus == null || !autoCalculateConsensus)
834 if (calculator.getRegisteredWorkersOfClass(ConsensusThread.class) == null)
836 calculator.registerWorker(new ConsensusThread(this, ap));
840 * A separate thread to compute cDNA consensus for a protein alignment
841 * which has mapping to cDNA
843 final AlignmentI al = this.getAlignment();
844 if (!al.isNucleotide() && al.getCodonFrames() != null
845 && !al.getCodonFrames().isEmpty())
848 * fudge - check first mapping is protein-to-nucleotide
849 * (we don't want to do this for protein-to-protein)
851 AlignedCodonFrame mapping = al.getCodonFrames().iterator().next();
852 // TODO hold mapping type e.g. dna-to-protein in AlignedCodonFrame?
853 MapList[] mapLists = mapping.getdnaToProt();
854 // mapLists can be empty if project load has not finished resolving seqs
855 if (mapLists.length > 0 && mapLists[0].getFromRatio() == 3)
858 .getRegisteredWorkersOfClass(ComplementConsensusThread.class) == null)
861 .registerWorker(new ComplementConsensusThread(this, ap));
867 // --------START Structure Conservation
868 public void updateStrucConsensus(final AlignmentViewPanel ap)
870 if (autoCalculateStrucConsensus && strucConsensus == null
871 && alignment.isNucleotide() && alignment.hasRNAStructure())
873 // secondary structure has been added - so init the consensus line
877 // see note in mantis : issue number 8585
878 if (strucConsensus == null || !autoCalculateStrucConsensus)
882 if (calculator.getRegisteredWorkersOfClass(StrucConsensusThread.class) == null)
884 calculator.registerWorker(new StrucConsensusThread(this, ap));
888 public boolean isCalcInProgress()
890 return calculator.isWorking();
894 public boolean isCalculationInProgress(
895 AlignmentAnnotation alignmentAnnotation)
897 if (!alignmentAnnotation.autoCalculated)
901 if (calculator.workingInvolvedWith(alignmentAnnotation))
903 // System.err.println("grey out ("+alignmentAnnotation.label+")");
910 public boolean isClosed()
912 // TODO: check that this isClosed is only true after panel is closed, not
913 // before it is fully constructed.
914 return alignment == null;
918 public AlignCalcManagerI getCalcManager()
924 * should conservation rows be shown for groups
926 protected boolean showGroupConservation = false;
929 * should consensus rows be shown for groups
931 protected boolean showGroupConsensus = false;
934 * should consensus profile be rendered by default
936 protected boolean showSequenceLogo = false;
939 * should consensus profile be rendered normalised to row height
941 protected boolean normaliseSequenceLogo = false;
944 * should consensus histograms be rendered by default
946 protected boolean showConsensusHistogram = true;
949 * @return the showConsensusProfile
952 public boolean isShowSequenceLogo()
954 return showSequenceLogo;
958 * @param showSequenceLogo
961 public void setShowSequenceLogo(boolean showSequenceLogo)
963 if (showSequenceLogo != this.showSequenceLogo)
965 // TODO: decouple settings setting from calculation when refactoring
966 // annotation update method from alignframe to viewport
967 this.showSequenceLogo = showSequenceLogo;
968 calculator.updateAnnotationFor(ConsensusThread.class);
969 calculator.updateAnnotationFor(ComplementConsensusThread.class);
970 calculator.updateAnnotationFor(StrucConsensusThread.class);
972 this.showSequenceLogo = showSequenceLogo;
976 * @param showConsensusHistogram
977 * the showConsensusHistogram to set
979 public void setShowConsensusHistogram(boolean showConsensusHistogram)
981 this.showConsensusHistogram = showConsensusHistogram;
985 * @return the showGroupConservation
987 public boolean isShowGroupConservation()
989 return showGroupConservation;
993 * @param showGroupConservation
994 * the showGroupConservation to set
996 public void setShowGroupConservation(boolean showGroupConservation)
998 this.showGroupConservation = showGroupConservation;
1002 * @return the showGroupConsensus
1004 public boolean isShowGroupConsensus()
1006 return showGroupConsensus;
1010 * @param showGroupConsensus
1011 * the showGroupConsensus to set
1013 public void setShowGroupConsensus(boolean showGroupConsensus)
1015 this.showGroupConsensus = showGroupConsensus;
1020 * @return flag to indicate if the consensus histogram should be rendered by
1024 public boolean isShowConsensusHistogram()
1026 return this.showConsensusHistogram;
1030 * when set, updateAlignment will always ensure sequences are of equal length
1032 private boolean padGaps = false;
1035 * when set, alignment should be reordered according to a newly opened tree
1037 public boolean sortByTree = false;
1042 * @return null or the currently selected sequence region
1045 public SequenceGroup getSelectionGroup()
1047 return selectionGroup;
1051 * Set the selection group for this window.
1054 * - group holding references to sequences in this alignment view
1058 public void setSelectionGroup(SequenceGroup sg)
1060 selectionGroup = sg;
1063 public void setHiddenColumns(ColumnSelection colsel)
1065 this.colSel = colsel;
1069 public ColumnSelection getColumnSelection()
1075 public void setColumnSelection(ColumnSelection colSel)
1077 this.colSel = colSel;
1080 updateHiddenColumns();
1089 public Map<SequenceI, SequenceCollectionI> getHiddenRepSequences()
1091 return hiddenRepSequences;
1095 public void setHiddenRepSequences(
1096 Map<SequenceI, SequenceCollectionI> hiddenRepSequences)
1098 this.hiddenRepSequences = hiddenRepSequences;
1102 public boolean hasHiddenColumns()
1104 return colSel != null && colSel.hasHiddenColumns();
1107 public void updateHiddenColumns()
1109 // this method doesn't really do anything now. But - it could, since a
1110 // column Selection could be in the process of modification
1111 // hasHiddenColumns = colSel.hasHiddenColumns();
1115 public boolean hasHiddenRows()
1117 return alignment.getHiddenSequences().getSize() > 0;
1120 protected SequenceGroup selectionGroup;
1122 public void setSequenceSetId(String newid)
1124 if (sequenceSetID != null)
1127 .println("Warning - overwriting a sequenceSetId for a viewport!");
1129 sequenceSetID = new String(newid);
1133 public String getSequenceSetId()
1135 if (sequenceSetID == null)
1137 sequenceSetID = alignment.hashCode() + "";
1140 return sequenceSetID;
1144 * unique viewId for synchronizing state (e.g. with stored Jalview Project)
1147 protected String viewId = null;
1150 public String getViewId()
1154 viewId = this.getSequenceSetId() + "." + this.hashCode() + "";
1159 public void setIgnoreGapsConsensus(boolean b, AlignmentViewPanel ap)
1161 ignoreGapsInConsensusCalculation = b;
1164 updateConsensus(ap);
1165 if (globalColourScheme != null)
1167 globalColourScheme.setThreshold(globalColourScheme.getThreshold(),
1168 ignoreGapsInConsensusCalculation);
1174 private long sgrouphash = -1, colselhash = -1;
1177 * checks current SelectionGroup against record of last hash value, and
1181 * update the record of last hash value
1183 * @return true if SelectionGroup changed since last call (when b is true)
1185 public boolean isSelectionGroupChanged(boolean b)
1187 int hc = (selectionGroup == null || selectionGroup.getSize() == 0) ? -1
1188 : selectionGroup.hashCode();
1189 if (hc != -1 && hc != sgrouphash)
1201 * checks current colsel against record of last hash value, and optionally
1205 * update the record of last hash value
1206 * @return true if colsel changed since last call (when b is true)
1208 public boolean isColSelChanged(boolean b)
1210 int hc = (colSel == null || colSel.isEmpty()) ? -1 : colSel
1212 if (hc != -1 && hc != colselhash)
1224 public boolean isIgnoreGapsConsensus()
1226 return ignoreGapsInConsensusCalculation;
1229 // / property change stuff
1231 // JBPNote Prolly only need this in the applet version.
1232 private final java.beans.PropertyChangeSupport changeSupport = new java.beans.PropertyChangeSupport(
1235 protected boolean showConservation = true;
1237 protected boolean showQuality = true;
1239 protected boolean showConsensus = true;
1241 private Map<SequenceI, ColorI> sequenceColours = new HashMap<SequenceI, ColorI>();
1243 protected SequenceAnnotationOrder sortAnnotationsBy = null;
1245 protected boolean showAutocalculatedAbove;
1248 * when set, view will scroll to show the highlighted position
1250 private boolean followHighlight = true;
1252 // TODO private with getters and setters?
1253 public int startRes;
1257 public int startSeq;
1262 * Property change listener for changes in alignment
1267 public void addPropertyChangeListener(
1268 java.beans.PropertyChangeListener listener)
1270 changeSupport.addPropertyChangeListener(listener);
1279 public void removePropertyChangeListener(
1280 java.beans.PropertyChangeListener listener)
1282 changeSupport.removePropertyChangeListener(listener);
1286 * Property change listener for changes in alignment
1295 public void firePropertyChange(String prop, Object oldvalue,
1298 changeSupport.firePropertyChange(prop, oldvalue, newvalue);
1301 // common hide/show column stuff
1303 public void hideSelectedColumns()
1305 if (colSel.isEmpty())
1310 colSel.hideSelectedColumns();
1311 setSelectionGroup(null);
1315 public void hideColumns(int start, int end)
1319 colSel.hideColumns(start);
1323 colSel.hideColumns(start, end);
1327 public void showColumn(int col)
1329 colSel.revealHiddenColumns(col);
1333 public void showAllHiddenColumns()
1335 colSel.revealAllHiddenColumns();
1338 // common hide/show seq stuff
1339 public void showAllHiddenSeqs()
1341 if (alignment.getHiddenSequences().getSize() > 0)
1343 if (selectionGroup == null)
1345 selectionGroup = new SequenceGroup();
1346 selectionGroup.setEndRes(alignment.getWidth() - 1);
1348 List<SequenceI> tmp = alignment.getHiddenSequences().showAll(
1349 hiddenRepSequences);
1350 for (SequenceI seq : tmp)
1352 selectionGroup.addSequence(seq, false);
1353 setSequenceAnnotationsVisible(seq, true);
1356 hiddenRepSequences = null;
1358 firePropertyChange("alignment", null, alignment.getSequences());
1359 // used to set hasHiddenRows/hiddenRepSequences here, after the property
1365 public void showSequence(int index)
1367 List<SequenceI> tmp = alignment.getHiddenSequences().showSequence(
1368 index, hiddenRepSequences);
1371 if (selectionGroup == null)
1373 selectionGroup = new SequenceGroup();
1374 selectionGroup.setEndRes(alignment.getWidth() - 1);
1377 for (SequenceI seq : tmp)
1379 selectionGroup.addSequence(seq, false);
1380 setSequenceAnnotationsVisible(seq, true);
1382 firePropertyChange("alignment", null, alignment.getSequences());
1387 public void hideAllSelectedSeqs()
1389 if (selectionGroup == null || selectionGroup.getSize() < 1)
1394 SequenceI[] seqs = selectionGroup.getSequencesInOrder(alignment);
1398 setSelectionGroup(null);
1401 public void hideSequence(SequenceI[] seq)
1405 for (int i = 0; i < seq.length; i++)
1407 alignment.getHiddenSequences().hideSequence(seq[i]);
1408 setSequenceAnnotationsVisible(seq[i], false);
1410 firePropertyChange("alignment", null, alignment.getSequences());
1415 * Set visibility for any annotations for the given sequence.
1419 protected void setSequenceAnnotationsVisible(SequenceI sequenceI,
1422 for (AlignmentAnnotation ann : alignment.getAlignmentAnnotation())
1424 if (ann.sequenceRef == sequenceI)
1426 ann.visible = visible;
1431 public void hideRepSequences(SequenceI repSequence, SequenceGroup sg)
1433 int sSize = sg.getSize();
1439 if (hiddenRepSequences == null)
1441 hiddenRepSequences = new Hashtable<SequenceI, SequenceCollectionI>();
1444 hiddenRepSequences.put(repSequence, sg);
1446 // Hide all sequences except the repSequence
1447 SequenceI[] seqs = new SequenceI[sSize - 1];
1449 for (int i = 0; i < sSize; i++)
1451 if (sg.getSequenceAt(i) != repSequence)
1453 if (index == sSize - 1)
1458 seqs[index++] = sg.getSequenceAt(i);
1461 sg.setSeqrep(repSequence); // note: not done in 2.7applet
1462 sg.setHidereps(true); // note: not done in 2.7applet
1469 * @return null or the current reference sequence
1471 public SequenceI getReferenceSeq()
1473 return alignment.getSeqrep();
1478 * @return true iff seq is the reference for the alignment
1480 public boolean isReferenceSeq(SequenceI seq)
1482 return alignment.getSeqrep() == seq;
1488 * @return true if there are sequences represented by this sequence that are
1491 public boolean isHiddenRepSequence(SequenceI seq)
1493 return (hiddenRepSequences != null && hiddenRepSequences
1500 * @return null or a sequence group containing the sequences that seq
1503 public SequenceGroup getRepresentedSequences(SequenceI seq)
1505 return (SequenceGroup) (hiddenRepSequences == null ? null
1506 : hiddenRepSequences.get(seq));
1510 public int adjustForHiddenSeqs(int alignmentIndex)
1512 return alignment.getHiddenSequences().adjustForHiddenSeqs(
1517 public void invertColumnSelection()
1519 colSel.invertColumnSelection(0, alignment.getWidth());
1523 public SequenceI[] getSelectionAsNewSequence()
1525 SequenceI[] sequences;
1526 // JBPNote: Need to test jalviewLite.getSelectedSequencesAsAlignmentFrom -
1527 // this was the only caller in the applet for this method
1528 // JBPNote: in applet, this method returned references to the alignment
1529 // sequences, and it did not honour the presence/absence of annotation
1530 // attached to the alignment (probably!)
1531 if (selectionGroup == null || selectionGroup.getSize() == 0)
1533 sequences = alignment.getSequencesArray();
1534 AlignmentAnnotation[] annots = alignment.getAlignmentAnnotation();
1535 for (int i = 0; i < sequences.length; i++)
1537 // construct new sequence with subset of visible annotation
1538 sequences[i] = new Sequence(sequences[i], annots);
1543 sequences = selectionGroup.getSelectionAsNewSequences(alignment);
1550 public SequenceI[] getSequenceSelection()
1552 SequenceI[] sequences = null;
1553 if (selectionGroup != null)
1555 sequences = selectionGroup.getSequencesInOrder(alignment);
1557 if (sequences == null)
1559 sequences = alignment.getSequencesArray();
1565 public CigarArray getViewAsCigars(boolean selectedRegionOnly)
1567 return new CigarArray(alignment, colSel,
1568 (selectedRegionOnly ? selectionGroup : null));
1572 public jalview.datamodel.AlignmentView getAlignmentView(
1573 boolean selectedOnly)
1575 return getAlignmentView(selectedOnly, false);
1579 public jalview.datamodel.AlignmentView getAlignmentView(
1580 boolean selectedOnly, boolean markGroups)
1582 return new AlignmentView(alignment, colSel, selectionGroup,
1583 colSel != null && colSel.hasHiddenColumns(), selectedOnly,
1588 public String[] getViewAsString(boolean selectedRegionOnly)
1590 String[] selection = null;
1591 SequenceI[] seqs = null;
1593 int start = 0, end = 0;
1594 if (selectedRegionOnly && selectionGroup != null)
1596 iSize = selectionGroup.getSize();
1597 seqs = selectionGroup.getSequencesInOrder(alignment);
1598 start = selectionGroup.getStartRes();
1599 end = selectionGroup.getEndRes() + 1;
1603 if (hasHiddenRows())
1605 iSize = alignment.getHiddenSequences().getFullAlignment()
1607 seqs = alignment.getHiddenSequences().getFullAlignment()
1608 .getSequencesArray();
1609 end = alignment.getHiddenSequences().getFullAlignment().getWidth();
1613 iSize = alignment.getHeight();
1614 seqs = alignment.getSequencesArray();
1615 end = alignment.getWidth();
1619 selection = new String[iSize];
1620 if (colSel != null && colSel.hasHiddenColumns())
1622 selection = colSel.getVisibleSequenceStrings(start, end, seqs);
1626 for (i = 0; i < iSize; i++)
1628 selection[i] = seqs[i].getSequenceAsString(start, end);
1636 public List<int[]> getVisibleRegionBoundaries(int min, int max)
1638 ArrayList<int[]> regions = new ArrayList<int[]>();
1644 if (colSel != null && colSel.hasHiddenColumns())
1648 start = colSel.adjustForHiddenColumns(start);
1651 end = colSel.getHiddenBoundaryRight(start);
1662 regions.add(new int[] { start, end });
1664 if (colSel != null && colSel.hasHiddenColumns())
1666 start = colSel.adjustForHiddenColumns(end);
1667 start = colSel.getHiddenBoundaryLeft(start) + 1;
1669 } while (end < max);
1671 int[][] startEnd = new int[regions.size()][2];
1677 public List<AlignmentAnnotation> getVisibleAlignmentAnnotation(
1678 boolean selectedOnly)
1680 ArrayList<AlignmentAnnotation> ala = new ArrayList<AlignmentAnnotation>();
1681 AlignmentAnnotation[] aa;
1682 if ((aa = alignment.getAlignmentAnnotation()) != null)
1684 for (AlignmentAnnotation annot : aa)
1686 AlignmentAnnotation clone = new AlignmentAnnotation(annot);
1687 if (selectedOnly && selectionGroup != null)
1689 colSel.makeVisibleAnnotation(selectionGroup.getStartRes(),
1690 selectionGroup.getEndRes(), clone);
1694 colSel.makeVisibleAnnotation(clone);
1703 public boolean isPadGaps()
1709 public void setPadGaps(boolean padGaps)
1711 this.padGaps = padGaps;
1715 * apply any post-edit constraints and trigger any calculations needed after
1716 * an edit has been performed on the alignment
1721 public void alignmentChanged(AlignmentViewPanel ap)
1725 alignment.padGaps();
1727 if (autoCalculateConsensus)
1729 updateConsensus(ap);
1731 if (hconsensus != null && autoCalculateConsensus)
1733 updateConservation(ap);
1735 if (autoCalculateStrucConsensus)
1737 updateStrucConsensus(ap);
1740 // Reset endRes of groups if beyond alignment width
1741 int alWidth = alignment.getWidth();
1742 List<SequenceGroup> groups = alignment.getGroups();
1745 for (SequenceGroup sg : groups)
1747 if (sg.getEndRes() > alWidth)
1749 sg.setEndRes(alWidth - 1);
1754 if (selectionGroup != null && selectionGroup.getEndRes() > alWidth)
1756 selectionGroup.setEndRes(alWidth - 1);
1759 resetAllColourSchemes();
1760 calculator.restartWorkers();
1761 // alignment.adjustSequenceAnnotations();
1765 * reset scope and do calculations for all applied colourschemes on alignment
1767 void resetAllColourSchemes()
1769 ColourSchemeI cs = globalColourScheme;
1772 cs.alignmentChanged(alignment, hiddenRepSequences);
1774 cs.setConsensus(hconsensus);
1775 if (cs.conservationApplied())
1777 cs.setConservation(Conservation.calculateConservation("All",
1778 ResidueProperties.propHash, 3, alignment.getSequences(), 0,
1779 alignment.getWidth(), false, getConsPercGaps(), false));
1783 for (SequenceGroup sg : alignment.getGroups())
1787 sg.cs.alignmentChanged(sg, hiddenRepSequences);
1789 sg.recalcConservation();
1793 protected void initAutoAnnotation()
1795 // TODO: add menu option action that nulls or creates consensus object
1796 // depending on if the user wants to see the annotation or not in a
1797 // specific alignment
1799 if (hconsensus == null && !isDataset)
1801 if (!alignment.isNucleotide())
1810 consensus = new AlignmentAnnotation("Consensus", "PID",
1811 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
1812 initConsensus(consensus);
1814 initComplementConsensus();
1819 * If this is a protein alignment and there are mappings to cDNA, add the cDNA
1820 * consensus annotation.
1822 public void initComplementConsensus()
1824 if (!alignment.isNucleotide())
1826 final List<AlignedCodonFrame> codonMappings = alignment
1828 if (codonMappings != null && !codonMappings.isEmpty())
1830 // fudge: check mappings are not protein-to-protein
1832 AlignedCodonFrame mapping = codonMappings.iterator().next();
1833 MapList[] mapLists = mapping.getdnaToProt();
1834 // mapLists can be empty if project load has not finished resolving seqs
1835 if (mapLists.length > 0 && mapLists[0].getFromRatio() == 3)
1837 complementConsensus = new AlignmentAnnotation("cDNA Consensus",
1838 "PID for cDNA", new Annotation[1], 0f, 100f,
1839 AlignmentAnnotation.BAR_GRAPH);
1840 initConsensus(complementConsensus);
1846 private void initConsensus(AlignmentAnnotation aa)
1849 aa.autoCalculated = true;
1853 alignment.addAnnotation(aa);
1857 private void initConservation()
1859 if (showConservation)
1861 if (conservation == null)
1863 conservation = new AlignmentAnnotation("Conservation",
1864 "Conservation of total alignment less than "
1865 + getConsPercGaps() + "% gaps", new Annotation[1],
1866 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
1867 conservation.hasText = true;
1868 conservation.autoCalculated = true;
1869 alignment.addAnnotation(conservation);
1874 private void initQuality()
1878 if (quality == null)
1880 quality = new AlignmentAnnotation("Quality",
1881 "Alignment Quality based on Blosum62 scores",
1882 new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
1883 quality.hasText = true;
1884 quality.autoCalculated = true;
1885 alignment.addAnnotation(quality);
1890 private void initRNAStructure()
1892 if (alignment.hasRNAStructure() && strucConsensus == null)
1894 strucConsensus = new AlignmentAnnotation("StrucConsensus", "PID",
1895 new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
1896 strucConsensus.hasText = true;
1897 strucConsensus.autoCalculated = true;
1901 alignment.addAnnotation(strucConsensus);
1909 * @see jalview.api.AlignViewportI#calcPanelHeight()
1912 public int calcPanelHeight()
1914 // setHeight of panels
1915 AlignmentAnnotation[] anns = getAlignment().getAlignmentAnnotation();
1917 int charHeight = getCharHeight();
1920 BitSet graphgrp = new BitSet();
1921 for (AlignmentAnnotation aa : anns)
1925 System.err.println("Null annotation row: ignoring.");
1932 if (aa.graphGroup > -1)
1934 if (graphgrp.get(aa.graphGroup))
1940 graphgrp.set(aa.graphGroup);
1947 aa.height += charHeight;
1957 aa.height += aa.graphHeight;
1965 height += aa.height;
1977 public void updateGroupAnnotationSettings(boolean applyGlobalSettings,
1978 boolean preserveNewGroupSettings)
1980 boolean updateCalcs = false;
1981 boolean conv = isShowGroupConservation();
1982 boolean cons = isShowGroupConsensus();
1983 boolean showprf = isShowSequenceLogo();
1984 boolean showConsHist = isShowConsensusHistogram();
1985 boolean normLogo = isNormaliseSequenceLogo();
1988 * TODO reorder the annotation rows according to group/sequence ordering on
1991 boolean sortg = true;
1993 // remove old automatic annotation
1994 // add any new annotation
1996 // intersect alignment annotation with alignment groups
1998 AlignmentAnnotation[] aan = alignment.getAlignmentAnnotation();
1999 List<SequenceGroup> oldrfs = new ArrayList<SequenceGroup>();
2002 for (int an = 0; an < aan.length; an++)
2004 if (aan[an].autoCalculated && aan[an].groupRef != null)
2006 oldrfs.add(aan[an].groupRef);
2007 alignment.deleteAnnotation(aan[an], false);
2011 if (alignment.getGroups() != null)
2013 for (SequenceGroup sg : alignment.getGroups())
2015 updateCalcs = false;
2016 if (applyGlobalSettings
2017 || (!preserveNewGroupSettings && !oldrfs.contains(sg)))
2019 // set defaults for this group's conservation/consensus
2020 sg.setshowSequenceLogo(showprf);
2021 sg.setShowConsensusHistogram(showConsHist);
2022 sg.setNormaliseSequenceLogo(normLogo);
2027 alignment.addAnnotation(sg.getConservationRow(), 0);
2032 alignment.addAnnotation(sg.getConsensus(), 0);
2034 // refresh the annotation rows
2037 sg.recalcConservation();
2045 public boolean isDisplayReferenceSeq()
2047 return alignment.hasSeqrep() && viewStyle.isDisplayReferenceSeq();
2051 public void setDisplayReferenceSeq(boolean displayReferenceSeq)
2053 viewStyle.setDisplayReferenceSeq(displayReferenceSeq);
2057 public boolean isColourByReferenceSeq()
2059 return alignment.hasSeqrep() && viewStyle.isColourByReferenceSeq();
2063 public ColorI getSequenceColour(SequenceI seq)
2065 ColorI sqc = sequenceColours.get(seq);
2066 return (sqc == null ? Colour.white : sqc);
2070 public void setSequenceColour(SequenceI seq, ColorI col)
2074 sequenceColours.remove(seq);
2078 sequenceColours.put(seq, col);
2083 public void updateSequenceIdColours()
2085 for (SequenceGroup sg : alignment.getGroups())
2087 if (sg.idColour != null)
2089 for (SequenceI s : sg.getSequences(getHiddenRepSequences()))
2091 sequenceColours.put(s, sg.idColour);
2098 public void clearSequenceColours()
2100 sequenceColours.clear();
2104 public AlignViewportI getCodingComplement()
2106 return this.codingComplement;
2110 * Set this as the (cDna/protein) complement of the given viewport. Also
2111 * ensures the reverse relationship is set on the given viewport.
2114 public void setCodingComplement(AlignViewportI av)
2118 System.err.println("Ignoring recursive setCodingComplement request");
2122 this.codingComplement = av;
2123 // avoid infinite recursion!
2124 if (av.getCodingComplement() != this)
2126 av.setCodingComplement(this);
2132 public boolean isNucleotide()
2134 return getAlignment() == null ? false : getAlignment().isNucleotide();
2138 public FeaturesDisplayedI getFeaturesDisplayed()
2140 return featuresDisplayed;
2144 public void setFeaturesDisplayed(FeaturesDisplayedI featuresDisplayedI)
2146 featuresDisplayed = featuresDisplayedI;
2150 public boolean areFeaturesDisplayed()
2152 return featuresDisplayed != null
2153 && featuresDisplayed.getRegisteredFeaturesCount() > 0;
2160 * features are displayed if true
2163 public void setShowSequenceFeatures(boolean b)
2165 viewStyle.setShowSequenceFeatures(b);
2169 public boolean isShowSequenceFeatures()
2171 return viewStyle.isShowSequenceFeatures();
2175 public void setShowSequenceFeaturesHeight(boolean selected)
2177 viewStyle.setShowSequenceFeaturesHeight(selected);
2181 public boolean isShowSequenceFeaturesHeight()
2183 return viewStyle.isShowSequenceFeaturesHeight();
2187 public void setShowAnnotation(boolean b)
2189 viewStyle.setShowAnnotation(b);
2193 public boolean isShowAnnotation()
2195 return viewStyle.isShowAnnotation();
2199 public boolean isRightAlignIds()
2201 return viewStyle.isRightAlignIds();
2205 public void setRightAlignIds(boolean rightAlignIds)
2207 viewStyle.setRightAlignIds(rightAlignIds);
2211 public boolean getConservationSelected()
2213 return viewStyle.getConservationSelected();
2217 public void setShowBoxes(boolean state)
2219 viewStyle.setShowBoxes(state);
2224 * @see jalview.api.ViewStyleI#getTextColour()
2227 public ColorI getTextColour()
2229 return viewStyle.getTextColour();
2234 * @see jalview.api.ViewStyleI#getTextColour2()
2237 public ColorI getTextColour2()
2239 return viewStyle.getTextColour2();
2244 * @see jalview.api.ViewStyleI#getThresholdTextColour()
2247 public int getThresholdTextColour()
2249 return viewStyle.getThresholdTextColour();
2254 * @see jalview.api.ViewStyleI#isConservationColourSelected()
2257 public boolean isConservationColourSelected()
2259 return viewStyle.isConservationColourSelected();
2264 * @see jalview.api.ViewStyleI#isRenderGaps()
2267 public boolean isRenderGaps()
2269 return viewStyle.isRenderGaps();
2274 * @see jalview.api.ViewStyleI#isShowColourText()
2277 public boolean isShowColourText()
2279 return viewStyle.isShowColourText();
2283 * @param conservationColourSelected
2284 * @see jalview.api.ViewStyleI#setConservationColourSelected(boolean)
2287 public void setConservationColourSelected(
2288 boolean conservationColourSelected)
2290 viewStyle.setConservationColourSelected(conservationColourSelected);
2294 * @param showColourText
2295 * @see jalview.api.ViewStyleI#setShowColourText(boolean)
2298 public void setShowColourText(boolean showColourText)
2300 viewStyle.setShowColourText(showColourText);
2305 * @see jalview.api.ViewStyleI#setTextColour(java.awt.Color)
2308 public void setTextColour(ColorI textColour)
2310 viewStyle.setTextColour(textColour);
2314 * @param thresholdTextColour
2315 * @see jalview.api.ViewStyleI#setThresholdTextColour(int)
2318 public void setThresholdTextColour(int thresholdTextColour)
2320 viewStyle.setThresholdTextColour(thresholdTextColour);
2324 * @param textColour2
2325 * @see jalview.api.ViewStyleI#setTextColour2(java.awt.Color)
2328 public void setTextColour2(ColorI textColour2)
2330 viewStyle.setTextColour2(textColour2);
2334 public ViewStyleI getViewStyle()
2336 return new ViewStyle(viewStyle);
2340 public void setViewStyle(ViewStyleI settingsForView)
2342 viewStyle = new ViewStyle(settingsForView);
2346 public boolean sameStyle(ViewStyleI them)
2348 return viewStyle.sameStyle(them);
2353 * @see jalview.api.ViewStyleI#getIdWidth()
2356 public int getIdWidth()
2358 return viewStyle.getIdWidth();
2363 * @see jalview.api.ViewStyleI#setIdWidth(int)
2366 public void setIdWidth(int i)
2368 viewStyle.setIdWidth(i);
2373 * @see jalview.api.ViewStyleI#isCentreColumnLabels()
2376 public boolean isCentreColumnLabels()
2378 return viewStyle.isCentreColumnLabels();
2382 * @param centreColumnLabels
2383 * @see jalview.api.ViewStyleI#setCentreColumnLabels(boolean)
2386 public void setCentreColumnLabels(boolean centreColumnLabels)
2388 viewStyle.setCentreColumnLabels(centreColumnLabels);
2393 * @see jalview.api.ViewStyleI#setShowDBRefs(boolean)
2396 public void setShowDBRefs(boolean showdbrefs)
2398 viewStyle.setShowDBRefs(showdbrefs);
2403 * @see jalview.api.ViewStyleI#isShowDBRefs()
2406 public boolean isShowDBRefs()
2408 return viewStyle.isShowDBRefs();
2413 * @see jalview.api.ViewStyleI#isShowNPFeats()
2416 public boolean isShowNPFeats()
2418 return viewStyle.isShowNPFeats();
2422 * @param shownpfeats
2423 * @see jalview.api.ViewStyleI#setShowNPFeats(boolean)
2426 public void setShowNPFeats(boolean shownpfeats)
2428 viewStyle.setShowNPFeats(shownpfeats);
2431 public abstract StructureSelectionManager getStructureSelectionManager();
2434 * Add one command to the command history list.
2438 public void addToHistoryList(CommandI command)
2440 if (this.historyList != null)
2442 this.historyList.push(command);
2443 broadcastCommand(command, false);
2447 protected void broadcastCommand(CommandI command, boolean undo)
2449 getStructureSelectionManager().commandPerformed(command, undo,
2454 * Add one command to the command redo list.
2458 public void addToRedoList(CommandI command)
2460 if (this.redoList != null)
2462 this.redoList.push(command);
2464 broadcastCommand(command, true);
2468 * Clear the command redo list.
2470 public void clearRedoList()
2472 if (this.redoList != null)
2474 this.redoList.clear();
2478 public void setHistoryList(Deque<CommandI> list)
2480 this.historyList = list;
2483 public Deque<CommandI> getHistoryList()
2485 return this.historyList;
2488 public void setRedoList(Deque<CommandI> list)
2490 this.redoList = list;
2493 public Deque<CommandI> getRedoList()
2495 return this.redoList;
2499 public VamsasSource getVamsasSource()
2504 public SequenceAnnotationOrder getSortAnnotationsBy()
2506 return sortAnnotationsBy;
2509 public void setSortAnnotationsBy(SequenceAnnotationOrder sortAnnotationsBy)
2511 this.sortAnnotationsBy = sortAnnotationsBy;
2514 public boolean isShowAutocalculatedAbove()
2516 return showAutocalculatedAbove;
2519 public void setShowAutocalculatedAbove(boolean showAutocalculatedAbove)
2521 this.showAutocalculatedAbove = showAutocalculatedAbove;
2525 public boolean isScaleProteinAsCdna()
2527 return viewStyle.isScaleProteinAsCdna();
2531 public void setScaleProteinAsCdna(boolean b)
2533 viewStyle.setScaleProteinAsCdna(b);
2537 * @return true if view should scroll to show the highlighted region of a
2542 public final boolean isFollowHighlight()
2544 return followHighlight;
2548 public final void setFollowHighlight(boolean b)
2550 this.followHighlight = b;
2553 public int getStartRes()
2559 public int getEndRes()
2564 public int getStartSeq()
2569 public void setStartRes(int res)
2571 this.startRes = res;
2574 public void setStartSeq(int seq)
2576 this.startSeq = seq;
2579 public void setEndRes(int res)
2581 if (res > alignment.getWidth() - 1)
2583 // log.System.out.println(" Corrected res from " + res + " to maximum " +
2584 // (alignment.getWidth()-1));
2585 res = alignment.getWidth() - 1;
2594 public void setEndSeq(int seq)
2596 if (seq > alignment.getHeight())
2598 seq = alignment.getHeight();
2607 public int getEndSeq()
2613 * Helper method to populate the SearchResults with the location in the
2614 * complementary alignment to scroll to, in order to match this one.
2617 * the SearchResults to add to
2618 * @return the offset (below top of visible region) of the matched sequence
2620 protected int findComplementScrollTarget(SearchResults sr)
2622 final AlignViewportI complement = getCodingComplement();
2623 if (complement == null || !complement.isFollowHighlight())
2627 boolean iAmProtein = !getAlignment().isNucleotide();
2628 AlignmentI proteinAlignment = iAmProtein ? getAlignment() : complement
2630 if (proteinAlignment == null)
2634 final List<AlignedCodonFrame> mappings = proteinAlignment
2638 * Heuristic: find the first mapped sequence (if any) with a non-gapped
2639 * residue in the middle column of the visible region. Scroll the
2640 * complementary alignment to line up the corresponding residue.
2643 SequenceI sequence = null;
2646 * locate 'middle' column (true middle if an odd number visible, left of
2647 * middle if an even number visible)
2649 int middleColumn = getStartRes() + (getEndRes() - getStartRes()) / 2;
2650 final HiddenSequences hiddenSequences = getAlignment()
2651 .getHiddenSequences();
2654 * searching to the bottom of the alignment gives smoother scrolling across
2655 * all gapped visible regions
2657 int lastSeq = alignment.getHeight() - 1;
2658 for (int seqNo = getStartSeq(); seqNo < lastSeq; seqNo++, seqOffset++)
2660 sequence = getAlignment().getSequenceAt(seqNo);
2661 if (hiddenSequences != null && hiddenSequences.isHidden(sequence))
2665 if (Comparison.isGap(sequence.getCharAt(middleColumn)))
2669 List<AlignedCodonFrame> seqMappings = MappingUtils
2670 .findMappingsForSequence(sequence, mappings);
2671 if (!seqMappings.isEmpty())
2677 if (sequence == null)
2680 * No ungapped mapped sequence in middle column - do nothing
2684 MappingUtils.addSearchResults(sr, sequence,
2685 sequence.findPosition(middleColumn), mappings);
2690 * synthesize a column selection if none exists so it covers the given
2691 * selection group. if wholewidth is false, no column selection is made if the
2692 * selection group covers the whole alignment width.
2697 public void expandColSelection(SequenceGroup sg, boolean wholewidth)
2701 && (sgs = sg.getStartRes()) >= 0
2702 && sg.getStartRes() <= (sge = sg.getEndRes())
2703 && (colSel == null || colSel.getSelected() == null || colSel
2704 .getSelected().size() == 0))
2706 if (!wholewidth && alignment.getWidth() == (1 + sge - sgs))
2713 colSel = new ColumnSelection();
2715 for (int cspos = sg.getStartRes(); cspos <= sg.getEndRes(); cspos++)
2717 colSel.addElement(cspos);