import jalview.analysis.Conservation;
import jalview.analysis.TreeModel;
import jalview.api.AlignCalcManagerI;
+import jalview.api.AlignCalcManagerI2;
+import jalview.api.AlignCalcWorkerI;
+import jalview.api.AlignExportSettingsI;
import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.api.FeaturesDisplayedI;
import jalview.commands.CommandI;
import jalview.datamodel.AlignedCodonFrame;
import jalview.datamodel.AlignmentAnnotation;
+import jalview.datamodel.AlignmentExportData;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.AlignmentView;
import jalview.datamodel.Annotation;
import jalview.util.MessageManager;
import jalview.viewmodel.styles.ViewStyle;
import jalview.workers.AlignCalcManager;
+import jalview.workers.AlignCalcManager2;
import jalview.workers.ComplementConsensusThread;
import jalview.workers.ConsensusThread;
import jalview.workers.InformationThread;
protected Deque<CommandI> redoList = new ArrayDeque<>();
- protected String sequenceSetID;
-
+ /**
+ * 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 isDataset = false;
-
- private Map<SequenceI, SequenceCollectionI> hiddenRepSequences;
-
- protected ColumnSelection colSel = new ColumnSelection();
-
- public boolean autoCalculateConsensus = true;
-
- protected boolean autoCalculateStrucConsensus = true;
-
- protected boolean ignoreGapsInConsensusCalculation = false;
protected boolean ignoreBelowBackGroundFrequencyCalculation = false;
protected boolean infoLetterHeight = false;
- protected ResidueShaderI residueShading = new ResidueShader();
-
- protected AlignmentAnnotation consensus;
-
- protected AlignmentAnnotation complementConsensus;
-
protected AlignmentAnnotation occupancy;
-
- protected AlignmentAnnotation strucConsensus;
-
- protected AlignmentAnnotation conservation;
-
- protected AlignmentAnnotation quality;
-
- /**
- * alignment displayed in the viewport
- */
- private AlignmentI alignment;
-
+
/**
* results of alignment consensus analysis for visible portion of view
*/
*/
protected ProfilesI hmmProfiles;
- /**
- * results of cDNA complement consensus visible portion of view
- */
- protected Hashtable[] hcomplementConsensus;
-
- /**
- * results of secondary structure base pair consensus for visible portion of
- * view
- */
- protected Hashtable[] hStrucConsensus;
-
- protected Conservation hconservation;
-
public AlignmentViewport(AlignmentI al)
{
setAlignment(al);
return alignment.getGapCharacter();
}
+ protected String sequenceSetID;
+
+ /**
+ * probably unused indicator that view is of a dataset rather than an
+ * alignment
+ */
+ protected boolean isDataset = false;
+
public void setDataset(boolean b)
{
isDataset = b;
return isDataset;
}
+ private Map<SequenceI, SequenceCollectionI> hiddenRepSequences;
+
+ protected ColumnSelection colSel = new ColumnSelection();
+
+ public boolean autoCalculateConsensus = true;
+
+ protected boolean autoCalculateStrucConsensus = true;
+
+ protected boolean ignoreGapsInConsensusCalculation = 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 gapcounts;
+
+ protected AlignmentAnnotation strucConsensus;
+
+ protected AlignmentAnnotation conservation;
+
+ protected AlignmentAnnotation quality;
+
+ protected AlignmentAnnotation[] groupConsensus;
+
+ protected AlignmentAnnotation[] groupConservation;
+
+ /**
+ * results of alignment consensus analysis for visible portion of view
+ */
+ protected ProfilesI hconsensus = null;
+
+ /**
+ * results of cDNA complement consensus visible portion of view
+ */
+ protected Hashtable<String, Object>[] hcomplementConsensus = null;
+
+ /**
+ * results of secondary structure base pair consensus for visible portion of
+ * view
+ */
+ protected Hashtable<String, Object>[] hStrucConsensus = null;
+
+ protected Conservation hconservation = null;
+
@Override
public void setConservation(Conservation cons)
{
}
@Override
- public void setConsensusProfiles(ProfilesI hconsensus)
+ public void setSequenceConsensusHash(ProfilesI hconsensus)
{
- this.consensusProfiles = hconsensus;
+ this.hconsensus = hconsensus;
}
@Override
- public void setComplementConsensusHash(Hashtable[] hconsensus)
+ public void setComplementConsensusHash(
+ Hashtable<String, Object>[] hconsensus)
{
this.hcomplementConsensus = hconsensus;
}
@Override
- public ProfilesI getConsensusProfiles()
+ public ProfilesI getSequenceConsensusHash()
{
- return consensusProfiles;
+ return hconsensus;
}
@Override
}
@Override
- public Hashtable[] getComplementConsensusHash()
+ public Hashtable<String, Object>[] getComplementConsensusHash()
{
return hcomplementConsensus;
}
@Override
- public Hashtable[] getRnaStructureConsensusHash()
+ public Hashtable<String, Object>[] getRnaStructureConsensusHash()
{
return hStrucConsensus;
}
@Override
- public void setRnaStructureConsensusHash(Hashtable[] hStrucConsensus)
+ public void setRnaStructureConsensusHash(
+ Hashtable<String, Object>[] hStrucConsensus)
{
this.hStrucConsensus = hStrucConsensus;
}
@Override
- public AlignmentAnnotation getOccupancyAnnotation()
+ public AlignmentAnnotation getAlignmentGapAnnotation()
{
- return occupancy;
+ return gapcounts;
}
@Override
return strucConsensus;
}
- protected AlignCalcManagerI calculator = new AlignCalcManager();
+ protected AlignCalcManagerI2 calculator = new AlignCalcManager2();
/**
* trigger update of conservation annotation
{
return;
}
- if (calculator.getRegisteredWorkersOfClass(
- jalview.workers.ConservationThread.class) == null)
+ if (calculator.getWorkersOfClass(
+ jalview.workers.ConservationThread.class).isEmpty())
{
calculator.registerWorker(
new jalview.workers.ConservationThread(this, ap));
{
return;
}
- if (calculator
- .getRegisteredWorkersOfClass(ConsensusThread.class) == null)
+ if (calculator.getWorkersOfClass(ConsensusThread.class).isEmpty())
{
calculator.registerWorker(new ConsensusThread(this, ap));
}
}
if (doConsensus)
{
- if (calculator.getRegisteredWorkersOfClass(
- ComplementConsensusThread.class) == null)
+ if (calculator.getWorkersOfClass(ComplementConsensusThread.class).isEmpty())
{
- calculator
- .registerWorker(new ComplementConsensusThread(this, ap));
+ calculator.registerWorker(new ComplementConsensusThread(this, ap));
}
}
}
@Override
public void initInformationWorker(final AlignmentViewPanel ap)
{
- if (calculator
- .getRegisteredWorkersOfClass(InformationThread.class) == null)
+ if (calculator.getWorkersOfClass(InformationThread.class).isEmpty())
{
calculator.registerWorker(new InformationThread(this, ap));
}
{
return;
}
- if (calculator.getRegisteredWorkersOfClass(
- StrucConsensusThread.class) == null)
+ if (calculator.getWorkersOfClass(StrucConsensusThread.class).isEmpty())
{
calculator.registerWorker(new StrucConsensusThread(this, ap));
}
{
return false;
}
- if (calculator.workingInvolvedWith(alignmentAnnotation))
+ if (calculator.isWorkingWithAnnotation(alignmentAnnotation))
{
// System.err.println("grey out ("+alignmentAnnotation.label+")");
return true;
conservation = null;
quality = null;
consensusProfiles = null;
+ groupConsensus = null;
+ groupConservation = null;
+ hconsensus = null;
hconservation = null;
hcomplementConsensus = null;
- occupancy = null;
+ gapcounts = null;
+ calculator.shutdown();
calculator = null;
residueShading = null; // may hold a reference to Consensus
changeSupport = null;
}
@Override
- public AlignCalcManagerI getCalcManager()
+ public AlignCalcManagerI2 getCalcManager()
{
return calculator;
}
// TODO: decouple settings setting from calculation when refactoring
// annotation update method from alignframe to viewport
this.showSequenceLogo = showSequenceLogo;
- calculator.updateAnnotationFor(ConsensusThread.class);
- calculator.updateAnnotationFor(ComplementConsensusThread.class);
- calculator.updateAnnotationFor(StrucConsensusThread.class);
+ for (AlignCalcWorkerI worker : calculator.getWorkers())
+ {
+ if (worker.getClass().equals(ConsensusThread.class) ||
+ worker.getClass().equals(ComplementConsensusThread.class) ||
+ worker.getClass().equals(StrucConsensusThread.class))
+ {
+ worker.updateAnnotation();
+ }
+ }
}
this.showSequenceLogo = showSequenceLogo;
}
ignoreGapsInConsensusCalculation = b;
if (ap != null)
{
+ updateConsensus(ap);
if (residueShading != null)
{
residueShading.setThreshold(residueShading.getThreshold(),
public void invertColumnSelection()
{
colSel.invertColumnSelection(0, alignment.getWidth(), alignment);
+ isColSelChanged(true);
}
@Override
}
else
{
- sequences = selectionGroup.getSelectionAsNewSequences(alignment,
- true);
+ sequences = selectionGroup.getSelectionAsNewSequences(alignment);
}
return sequences;
}
} while (end < max);
- int[][] startEnd = new int[regions.size()][2];
+ // int[][] startEnd = new int[regions.size()][2];
return regions;
}
{
alignment.padGaps();
}
+ if (autoCalculateConsensus)
+ {
+ updateConsensus(ap);
+ }
+ if (hconsensus != null && autoCalculateConsensus)
+ {
+ updateConservation(ap);
+ }
+ if (autoCalculateStrucConsensus)
+ {
+ updateStrucConsensus(ap);
+ }
// Reset endRes of groups if beyond alignment width
int alWidth = alignment.getWidth();
{
rs.alignmentChanged(alignment, hiddenRepSequences);
- rs.setConsensus(consensusProfiles);
+ rs.setConsensus(hconsensus);
if (rs.conservationApplied())
{
rs.setConservation(Conservation.calculateConservation("All",
// depending on if the user wants to see the annotation or not in a
// specific alignment
- if (consensusProfiles == null && !isDataset)
+ if (hconsensus == null && !isDataset)
{
if (!alignment.isNucleotide())
{
new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
initConsensus(consensus);
- initOccupancy();
+ initGapCounts();
initComplementConsensus();
}
// these should be extracted from the view model - style and settings for
// derived annotation
- private void initOccupancy()
+ private void initGapCounts()
{
if (showOccupancy)
{
- occupancy = new AlignmentAnnotation("Occupancy",
+ gapcounts = new AlignmentAnnotation("Occupancy",
MessageManager.getString("label.occupancy_descr"),
new Annotation[1], 0f, alignment.getHeight(),
AlignmentAnnotation.BAR_GRAPH);
- occupancy.hasText = true;
- occupancy.autoCalculated = true;
- occupancy.scaleColLabel = true;
- occupancy.graph = AlignmentAnnotation.BAR_GRAPH;
+ gapcounts.hasText = true;
+ gapcounts.autoCalculated = true;
+ gapcounts.scaleColLabel = true;
+ gapcounts.graph = AlignmentAnnotation.BAR_GRAPH;
- alignment.addAnnotation(occupancy);
+ alignment.addAnnotation(gapcounts);
}
}
* TODO reorder the annotation rows according to group/sequence ordering on
* alignment
*/
- boolean sortg = true;
+ // boolean sortg = true;
// remove old automatic annotation
// add any new annotation
public void clearSequenceColours()
{
sequenceColours.clear();
- };
+ }
@Override
public AlignViewportI getCodingComplement()
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
}
@Override
+ public AlignmentExportData getAlignExportData(AlignExportSettingsI options)
+ {
+ AlignmentI alignmentToExport = null;
+ String[] omitHidden = null;
+ alignmentToExport = null;
+
+ if (hasHiddenColumns() && !options.isExportHiddenColumns())
+ {
+ omitHidden = getViewAsString(false,
+ options.isExportHiddenSequences());
+ }
+
+ int[] alignmentStartEnd = new int[2];
+ if (hasHiddenRows() && options.isExportHiddenSequences())
+ {
+ alignmentToExport = getAlignment().getHiddenSequences()
+ .getFullAlignment();
+ }
+ else
+ {
+ alignmentToExport = getAlignment();
+ }
+ alignmentStartEnd = getAlignment().getHiddenColumns()
+ .getVisibleStartAndEndIndex(alignmentToExport.getWidth());
+ AlignmentExportData ed = new AlignmentExportData(alignmentToExport,
+ omitHidden, alignmentStartEnd);
+ return ed;
+ }
+
+ @Override
public boolean isNormaliseSequenceLogo()
{
return normaliseSequenceLogo;
{
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 });
+ }
+ }
+ }
}