import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
import jalview.analysis.Conservation;
+import jalview.analysis.TreeModel;
import jalview.api.AlignCalcManagerI;
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
import jalview.datamodel.Annotation;
-import jalview.datamodel.CigarArray;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.HiddenSequences;
import java.util.Deque;
import java.util.HashMap;
import java.util.Hashtable;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
public abstract class AlignmentViewport
implements AlignViewportI, CommandListener, VamsasSource
{
- final protected ViewportRanges ranges;
+ protected ViewportRanges ranges;
protected ViewStyleI viewStyle = new ViewStyle();
* retain any colour thresholds per group while
* changing choice of colour scheme (JAL-2386)
*/
- sg.setColourScheme(cs);
+ sg.setColourScheme(
+ cs == null ? null : cs.getInstance(this, sg));
if (cs != null)
{
sg.getGroupColourScheme().alignmentChanged(sg,
groupConsensus = null;
groupConservation = null;
hconsensus = null;
+ hconservation = null;
hcomplementConsensus = null;
- // colour scheme may hold reference to consensus
- residueShading = null;
- // TODO remove listeners from changeSupport?
+ gapcounts = null;
+ calculator = null;
+ residueShading = null; // may hold a reference to Consensus
changeSupport = null;
+ ranges = null;
+ currentTree = null;
+ selectionGroup = null;
setAlignment(null);
}
public void removePropertyChangeListener(
java.beans.PropertyChangeListener listener)
{
- changeSupport.removePropertyChangeListener(listener);
+ if (changeSupport != null)
+ {
+ changeSupport.removePropertyChangeListener(listener);
+ }
}
/**
public void invertColumnSelection()
{
colSel.invertColumnSelection(0, alignment.getWidth(), alignment);
+ isColSelChanged(true);
}
@Override
}
@Override
- public CigarArray getViewAsCigars(boolean selectedRegionOnly)
- {
- return new CigarArray(alignment, alignment.getHiddenColumns(),
- (selectedRegionOnly ? selectionGroup : null));
- }
-
- @Override
public jalview.datamodel.AlignmentView getAlignmentView(
boolean selectedOnly)
{
if (alignment.getHiddenColumns() != null
&& alignment.getHiddenColumns().hasHiddenColumns())
{
- selection = alignment.getHiddenColumns()
- .getVisibleSequenceStrings(start, end, seqs);
+ for (i = 0; i < iSize; i++)
+ {
+ Iterator<int[]> blocks = alignment.getHiddenColumns()
+ .getVisContigsIterator(start, end + 1, false);
+ selection[i] = seqs[i].getSequenceStringFromIterator(blocks);
+ }
}
else
{
{
if (start == 0)
{
- start = hidden.adjustForHiddenColumns(start);
+ start = hidden.visibleToAbsoluteColumn(start);
}
- end = hidden.getHiddenBoundaryRight(start);
+ end = hidden.getNextHiddenBoundary(false, start);
if (start == end)
{
end = max;
if (hidden != null && hidden.hasHiddenColumns())
{
- start = hidden.adjustForHiddenColumns(end);
- start = hidden.getHiddenBoundaryLeft(start) + 1;
+ start = hidden.visibleToAbsoluteColumn(end);
+ start = hidden.getNextHiddenBoundary(true, start) + 1;
}
} while (end < max);
AlignmentAnnotation clone = new AlignmentAnnotation(annot);
if (selectedOnly && selectionGroup != null)
{
- alignment.getHiddenColumns().makeVisibleAnnotation(
+ clone.makeVisibleAnnotation(
selectionGroup.getStartRes(), selectionGroup.getEndRes(),
- clone);
+ alignment.getHiddenColumns());
}
else
{
- alignment.getHiddenColumns().makeVisibleAnnotation(clone);
+ clone.makeVisibleAnnotation(alignment.getHiddenColumns());
}
ala.add(clone);
}
{
if (!alignment.isNucleotide())
{
- initConservation();
- initQuality();
+ if (showConservation && conservation == null)
+ {
+ initConservation();
+ }
+ if (showQuality && quality == null)
+ {
+ initQuality();
+ }
}
else
{
- initRNAStructure();
+ if (showConsensus && alignment.hasRNAStructure()
+ && strucConsensus == null)
+ {
+ initRNAStructure();
+ }
+ }
+ if (showConsensus)
+ {
+ initConsensus();
+ }
+ if (showOccupancy)
+ {
+ initOccupancy();
}
- consensus = new AlignmentAnnotation("Consensus",
- MessageManager.getString("label.consensus_descr"),
- new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
- initConsensus(consensus);
- initGapCounts();
initComplementConsensus();
}
.getString("label.complement_consensus_descr"),
new Annotation[1], 0f, 100f,
AlignmentAnnotation.BAR_GRAPH);
- initConsensus(complementConsensus);
+ complementConsensus.hasText = true;
+ complementConsensus.autoCalculated = true;
+ alignment.addAnnotation(complementConsensus);
return true;
}
}
return false;
}
- private void initConsensus(AlignmentAnnotation aa)
+ @Override
+ public void initConsensus()
{
- aa.hasText = true;
- aa.autoCalculated = true;
-
- if (showConsensus)
- {
- alignment.addAnnotation(aa);
- }
+ consensus = new AlignmentAnnotation("Consensus",
+ MessageManager.getString("label.consensus_descr"),
+ new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
+ consensus.hasText = true;
+ consensus.autoCalculated = true;
+ alignment.addAnnotation(consensus);
}
- // these should be extracted from the view model - style and settings for
- // derived annotation
- private void initGapCounts()
+ @Override
+ public void initOccupancy()
{
- if (showOccupancy)
- {
- gapcounts = new AlignmentAnnotation("Occupancy",
- MessageManager.getString("label.occupancy_descr"),
- new Annotation[1], 0f, alignment.getHeight(),
- AlignmentAnnotation.BAR_GRAPH);
- gapcounts.hasText = true;
- gapcounts.autoCalculated = true;
- gapcounts.scaleColLabel = true;
- gapcounts.graph = AlignmentAnnotation.BAR_GRAPH;
+ gapcounts = new AlignmentAnnotation("Occupancy",
+ MessageManager.getString("label.occupancy_descr"),
+ new Annotation[1], 0f, alignment.getHeight(),
+ AlignmentAnnotation.BAR_GRAPH);
+ gapcounts.hasText = true;
+ gapcounts.autoCalculated = true;
+ gapcounts.scaleColLabel = true;
+ gapcounts.graph = AlignmentAnnotation.BAR_GRAPH;
- alignment.addAnnotation(gapcounts);
- }
+ alignment.addAnnotation(gapcounts);
}
- private void initConservation()
+ @Override
+ public void initConservation()
{
- if (showConservation)
- {
- if (conservation == null)
- {
- conservation = new AlignmentAnnotation("Conservation",
- MessageManager.formatMessage("label.conservation_descr",
- getConsPercGaps()),
- new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
- conservation.hasText = true;
- conservation.autoCalculated = true;
- alignment.addAnnotation(conservation);
- }
- }
+ conservation = new AlignmentAnnotation("Conservation",
+ MessageManager.formatMessage("label.conservation_descr",
+ getConsPercGaps()),
+ new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
+ conservation.hasText = true;
+ conservation.autoCalculated = true;
+ alignment.addAnnotation(conservation);
}
- private void initQuality()
+ @Override
+ public void initQuality()
{
- if (showQuality)
- {
- if (quality == null)
- {
- quality = new AlignmentAnnotation("Quality",
- MessageManager.getString("label.quality_descr"),
- new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
- quality.hasText = true;
- quality.autoCalculated = true;
- alignment.addAnnotation(quality);
- }
- }
+ quality = new AlignmentAnnotation("Quality",
+ MessageManager.getString("label.quality_descr"),
+ new Annotation[1], 0f, 11f, AlignmentAnnotation.BAR_GRAPH);
+ quality.hasText = true;
+ quality.autoCalculated = true;
+ alignment.addAnnotation(quality);
}
- private void initRNAStructure()
+ @Override
+ public void initRNAStructure()
{
- if (alignment.hasRNAStructure() && strucConsensus == null)
- {
- strucConsensus = new AlignmentAnnotation("StrucConsensus",
- MessageManager.getString("label.strucconsensus_descr"),
- new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
- strucConsensus.hasText = true;
- strucConsensus.autoCalculated = true;
-
- if (showConsensus)
- {
- alignment.addAnnotation(strucConsensus);
- }
- }
+ strucConsensus = new AlignmentAnnotation("StrucConsensus",
+ MessageManager.getString("label.strucconsensus_descr"),
+ new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
+ strucConsensus.hasText = true;
+ strucConsensus.autoCalculated = true;
+ alignment.addAnnotation(strucConsensus);
}
/*
viewStyle.setProteinFontAsCdna(b);
}
+ @Override
+ public void setShowComplementFeatures(boolean b)
+ {
+ viewStyle.setShowComplementFeatures(b);
+ }
+
+ @Override
+ public boolean isShowComplementFeatures()
+ {
+ return viewStyle.isShowComplementFeatures();
+ }
+
+ @Override
+ public void setShowComplementFeaturesOnTop(boolean b)
+ {
+ viewStyle.setShowComplementFeaturesOnTop(b);
+ }
+
+ @Override
+ public boolean isShowComplementFeaturesOnTop()
+ {
+ return viewStyle.isShowComplementFeaturesOnTop();
+ }
+
/**
* @return true if view should scroll to show the highlighted region of a
* sequence
int lastSeq = alignment.getHeight() - 1;
List<AlignedCodonFrame> seqMappings = null;
for (int seqNo = ranges
- .getStartSeq(); seqNo < lastSeq; seqNo++, seqOffset++)
+ .getStartSeq(); seqNo <= lastSeq; seqNo++, seqOffset++)
{
sequence = getAlignment().getSequenceAt(seqNo);
if (hiddenSequences != null && hiddenSequences.isHidden(sequence))
*/
private SearchResultsI searchResults = null;
+ protected TreeModel currentTree = null;
+
@Override
public boolean hasSearchResults()
{
+ ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
return sq;
}
+
+ @Override
+ public void setCurrentTree(TreeModel tree)
+ {
+ currentTree = tree;
+ }
+
+ @Override
+ public TreeModel getCurrentTree()
+ {
+ return currentTree;
+ }
+
+ /**
+ * flag set to indicate if structure views might be out of sync with sequences
+ * in the alignment
+ */
+
+ private boolean needToUpdateStructureViews = false;
+
+ @Override
+ public boolean isUpdateStructures()
+ {
+ return needToUpdateStructureViews;
+ }
+
+ @Override
+ public void setUpdateStructures(boolean update)
+ {
+ needToUpdateStructureViews = update;
+ }
+
+ @Override
+ public boolean needToUpdateStructureViews()
+ {
+ boolean update = needToUpdateStructureViews;
+ needToUpdateStructureViews = false;
+ return update;
+ }
+
+ @Override
+ public void addSequenceGroup(SequenceGroup sequenceGroup)
+ {
+ alignment.addGroup(sequenceGroup);
+
+ Color col = sequenceGroup.idColour;
+ if (col != null)
+ {
+ col = col.brighter();
+
+ for (SequenceI sq : sequenceGroup.getSequences())
+ {
+ setSequenceColour(sq, col);
+ }
+ }
+
+ if (codingComplement != null)
+ {
+ SequenceGroup mappedGroup = MappingUtils
+ .mapSequenceGroup(sequenceGroup, this, codingComplement);
+ if (mappedGroup.getSequences().size() > 0)
+ {
+ codingComplement.getAlignment().addGroup(mappedGroup);
+
+ if (col != null)
+ {
+ for (SequenceI seq : mappedGroup.getSequences())
+ {
+ codingComplement.setSequenceColour(seq, col);
+ }
+ }
+ }
+ // propagate the structure view update flag according to our own setting
+ codingComplement.setUpdateStructures(needToUpdateStructureViews);
+ }
+ }
}