import jalview.datamodel.ColumnSelection;
import jalview.datamodel.HiddenColumns;
import jalview.datamodel.HiddenSequences;
-import jalview.datamodel.ProfileI;
-import jalview.datamodel.Profiles;
import jalview.datamodel.ProfilesI;
import jalview.datamodel.SearchResultsI;
import jalview.datamodel.Sequence;
import java.util.Deque;
import java.util.HashMap;
import java.util.Hashtable;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
protected Deque<CommandI> redoList = new ArrayDeque<>();
-
/**
* alignment displayed in the viewport. Please use get/setter
*/
protected AlignmentI alignment;
+
+ /*
+ * probably unused indicator that view is of a dataset rather than an
+ * alignment
+ */
+
+ protected boolean ignoreBelowBackGroundFrequencyCalculation = false;
+
+ protected boolean infoLetterHeight = false;
+
+ protected AlignmentAnnotation occupancy;
+
+ /**
+ * results of alignment consensus analysis for visible portion of view
+ */
+ protected ProfilesI consensusProfiles;
+
+ /**
+ * HMM profile for the alignment
+ */
+ protected ProfilesI hmmProfiles;
public AlignmentViewport(AlignmentI al)
{
* alignment
*/
protected boolean isDataset = false;
-
+
public void setDataset(boolean b)
{
isDataset = b;
public boolean autoCalculateConsensus = true;
- public boolean autoCalculateInformation = true;
-
protected boolean autoCalculateStrucConsensus = true;
protected boolean ignoreGapsInConsensusCalculation = false;
- protected boolean ignoreBelowBackGroundFrequencyCalculation = false;
-
- protected boolean infoLetterHeight = false;
-
protected ResidueShaderI residueShading = new ResidueShader();
-
+
@Override
public void setGlobalColourScheme(ColourSchemeI cs)
{
* 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,
{
return residueShading;
}
-
+
protected AlignmentAnnotation consensus;
protected AlignmentAnnotation complementConsensus;
protected AlignmentAnnotation[] groupConservation;
- protected List<AlignmentAnnotation> groupInformation = new ArrayList<>();
-
- protected List<AlignmentAnnotation> information = new ArrayList<>();
-
/**
* results of alignment consensus analysis for visible portion of view
*/
protected ProfilesI hconsensus = null;
/**
- * results of information annotation analysis for the visible portion of view
- */
- protected List<ProfilesI> hinformation = new ArrayList<>();
-
- /**
* results of cDNA complement consensus visible portion of view
*/
protected Hashtable[] hcomplementConsensus = null;
protected Hashtable[] hStrucConsensus = null;
protected Conservation hconservation = null;
-
+
@Override
public void setConservation(Conservation cons)
{
}
@Override
- public void setSequenceInformationHashes(List<ProfilesI> info)
- {
- hinformation = info;
- }
-
- @Override
- public void setSequenceInformationHash(ProfilesI info, int index)
- {
- if (hinformation.size() < index + 1)
- {
- return;
- }
- hinformation.set(index, info);
- }
-
- @Override
- public List<ProfilesI> getSequenceInformationHashes()
+ public void setHmmProfiles(ProfilesI info)
{
- return hinformation;
+ hmmProfiles = info;
}
@Override
- public ProfilesI getSequenceInformationHash(int index)
+ public ProfilesI getHmmProfiles()
{
- return hinformation.get(index);
+ return hmmProfiles;
}
@Override
}
@Override
- public List<AlignmentAnnotation> getInformationAnnotations()
- {
- return information;
- }
-
- @Override
- public AlignmentAnnotation getInformationAnnotation(int index)
- {
- return information.get(index);
- }
-
- @Override
public AlignmentAnnotation getAlignmentGapAnnotation()
{
return gapcounts;
}
}
- /**
- * trigger update of information annotation
- */
@Override
- public void updateInformation(final AlignmentViewPanel ap)
+ public void initInformationWorker(final AlignmentViewPanel ap)
{
if (calculator
.getRegisteredWorkersOfClass(InformationThread.class) == null)
{
calculator.registerWorker(new InformationThread(this, ap));
}
-
}
// --------START Structure Conservation
strucConsensus = null;
conservation = null;
quality = null;
+ consensusProfiles = null;
groupConsensus = null;
groupConservation = null;
hconsensus = null;
/**
* should hmm profile be rendered by default
*/
- protected boolean showHMMSequenceLogo = false;
+ protected boolean hmmShowSequenceLogo = false;
/**
* should hmm profile be rendered normalised to row height
*/
- protected boolean normaliseHMMSequenceLogo = false;
+ protected boolean hmmNormaliseSequenceLogo = false;
/**
* should information histograms be rendered by default
*/
- protected boolean showInformationHistogram = true;
+ protected boolean hmmShowHistogram = true;
/**
* @return the showConsensusProfile
@Override
public boolean isShowHMMSequenceLogo()
{
- return showHMMSequenceLogo;
+ return hmmShowSequenceLogo;
}
/**
public void setShowHMMSequenceLogo(boolean showHMMSequenceLogo)
{
- if (showHMMSequenceLogo != this.showHMMSequenceLogo)
+ if (showHMMSequenceLogo != this.hmmShowSequenceLogo)
{
- this.showHMMSequenceLogo = showHMMSequenceLogo;
- calculator.updateAnnotationFor(InformationThread.class);
+ this.hmmShowSequenceLogo = showHMMSequenceLogo;
+ // TODO: updateAnnotation if description (tooltip) will show
+ // profile in place of information content?
+ // calculator.updateAnnotationFor(InformationThread.class);
}
- this.showHMMSequenceLogo = showHMMSequenceLogo;
+ this.hmmShowSequenceLogo = showHMMSequenceLogo;
}
/**
/**
* @param showInformationHistogram
- * the showInformationHistogram to set
*/
public void setShowInformationHistogram(boolean showInformationHistogram)
{
- this.showInformationHistogram = showInformationHistogram;
+ this.hmmShowHistogram = showInformationHistogram;
}
/**
@Override
public boolean isShowInformationHistogram()
{
- return this.showInformationHistogram;
+ return this.hmmShowHistogram;
}
/**
ignoreGapsInConsensusCalculation);
}
}
-
}
public void setIgnoreBelowBackground(boolean b, AlignmentViewPanel ap)
{
ignoreBelowBackGroundFrequencyCalculation = b;
- if (ap != null)
- {
- updateInformation(ap);
- }
-
}
public void setInfoLetterHeight(boolean b, AlignmentViewPanel ap)
{
infoLetterHeight = b;
- if (ap != null)
- {
- updateInformation(ap);
- }
-
}
private long sgrouphash = -1, colselhash = -1;
public void invertColumnSelection()
{
colSel.invertColumnSelection(0, alignment.getWidth(), alignment);
+ isColSelChanged(true);
}
@Override
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);
}
{
updateStrucConsensus(ap);
}
- initInformation();
- updateInformation(ap);
-
- List<SequenceI> hmmSequences;
- hmmSequences = alignment.getHMMConsensusSequences(false);
-
- for (SequenceI seq : hmmSequences)
- {
- seq.updateHMMMapping();
- }
// Reset endRes of groups if beyond alignment width
int alWidth = alignment.getWidth();
updateAllColourSchemes();
calculator.restartWorkers();
- // alignment.adjustSequenceAnnotations();
}
/**
}
}
- @Override
- public void initInformation()
- {
- for (SequenceI seq : alignment.getHMMConsensusSequences(false))
- {
- if (!seq.hasHMMAnnotation())
- {
- AlignmentAnnotation information;
- information = new AlignmentAnnotation(seq.getName(),
- MessageManager.getString("label.information_description"),
- new Annotation[1], 0f, 6.52f,
- AlignmentAnnotation.BAR_GRAPH);
- information.hasText = true;
- information.autoCalculated = true;
- information.hasText = true;
- information.autoCalculated = false;
- information.sequenceRef = seq;
- information.setCalcId("HMM");
- this.information.add(information);
- hinformation.add(new Profiles(new ProfileI[1]));
- alignment.addAnnotation(information);
- seq.updateHMMMapping();
- seq.setHasInfo(true);
- seq.addAlignmentAnnotation(information);
- }
- }
-
- }
-
// these should be extracted from the view model - style and settings for
// derived annotation
private void initGapCounts()
sg.setshowSequenceLogo(showprf);
sg.setShowConsensusHistogram(showConsHist);
sg.setNormaliseSequenceLogo(normLogo);
- sg.setshowHMMSequenceLogo(showHMMPrf);
+ sg.setShowHMMSequenceLogo(showHMMPrf);
sg.setShowInformationHistogram(showInfoHist);
sg.setNormaliseHMMSequenceLogo(normHMMLogo);
}
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))
{
return currentTree;
}
+
+ @Override
+ public boolean isNormaliseSequenceLogo()
+ {
+ return normaliseSequenceLogo;
+ }
+
+ public void setNormaliseSequenceLogo(boolean state)
+ {
+ normaliseSequenceLogo = state;
+ }
+
+ @Override
+ public boolean isNormaliseHMMSequenceLogo()
+ {
+ return hmmNormaliseSequenceLogo;
+ }
+
+ public void setNormaliseHMMSequenceLogo(boolean state)
+ {
+ hmmNormaliseSequenceLogo = state;
+ }
+
+ /**
+ * 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);
+ }
+ }
+
+ /**
+ * Filters out sequences with an eValue higher than the specified value. The
+ * filtered sequences are hidden or deleted. Sequences with no eValues are also
+ * filtered out.
+ *
+ * @param eValue
+ * @param delete
+ */
+ public void filterByEvalue(double eValue)
+ {
+ for (SequenceI seq : alignment.getSequencesArray())
+ {
+ if ((seq.getAnnotation("Search Scores") == null
+ || seq.getAnnotation("Search Scores")[0].getEValue() > eValue)
+ && seq.getHMM() == null)
+ {
+ hideSequence(new SequenceI[] { seq });
+ }
+ }
+ }
+
+ /**
+ * Filters out sequences with an score lower than the specified value. The
+ * filtered sequences are hidden or deleted.
+ *
+ * @param score
+ * @param delete
+ */
+ public void filterByScore(double score)
+ {
+ for (SequenceI seq : alignment.getSequencesArray())
+ {
+ if ((seq.getAnnotation("Search Scores") == null
+ || seq.getAnnotation("Search Scores")[0]
+ .getBitScore() < score)
+ && seq.getHMM() == null)
+ {
+ hideSequence(new SequenceI[] { seq });
+ }
+ }
+ }
}