import jalview.workers.AlignCalcManager;
import jalview.workers.ComplementConsensusThread;
import jalview.workers.ConsensusThread;
+import jalview.workers.SecondaryStructureConsensusThread;
import jalview.workers.StrucConsensusThread;
/**
}
protected AlignmentAnnotation consensus;
+
+ protected AlignmentAnnotation secondaryStructureConsensus;
protected AlignmentAnnotation complementConsensus;
protected AlignmentAnnotation quality;
protected AlignmentAnnotation[] groupConsensus;
+
+ protected AlignmentAnnotation[] groupSSConsensus;
protected AlignmentAnnotation[] groupConservation;
* results of alignment consensus analysis for visible portion of view
*/
protected ProfilesI hconsensus = null;
+
+ protected ProfilesI hSSConsensus = null;
+
+
/**
* results of cDNA complement consensus visible portion of view
{
this.hconsensus = hconsensus;
}
-
+
+ @Override
+ public void setSequenceSSConsensusHash(ProfilesI hSSConsensus)
+ {
+ this.hSSConsensus = hSSConsensus;
+ }
+
@Override
public void setComplementConsensusHash(
Hashtable<String, Object>[] hconsensus)
{
return hconsensus;
}
+
+ @Override
+ public ProfilesI getSequenceSSConsensusHash()
+ {
+ return hSSConsensus;
+ }
@Override
public Hashtable<String, Object>[] getComplementConsensusHash()
return consensus;
}
+
+ @Override
+ public AlignmentAnnotation getAlignmentSecondaryStructureConsensusAnnotation()
+ {
+ return secondaryStructureConsensus;
+ }
+
+
@Override
public AlignmentAnnotation getAlignmentGapAnnotation()
{
}
}
}
+
+
+
+
+ /**
+ * trigger update of consensus annotation
+ */
+ public void updateSecondaryStructureConsensus(final AlignmentViewPanel ap)
+ {
+ // see note in mantis : issue number 8585
+ if (secondaryStructureConsensus == null || !autoCalculateConsensus)
+ {
+ return;
+ }
+ if (calculator
+ .getRegisteredWorkersOfClass(SecondaryStructureConsensusThread.class) == null)
+ {
+ calculator.registerWorker(new SecondaryStructureConsensusThread(this, ap));
+ }
+ }
// --------START Structure Conservation
public void updateStrucConsensus(final AlignmentViewPanel ap)
consensus = null;
complementConsensus = null;
strucConsensus = null;
+ secondaryStructureConsensus = null;
conservation = null;
quality = null;
groupConsensus = null;
* should consensus profile be rendered by default
*/
protected boolean showSequenceLogo = false;
+
+ protected boolean showSequenceSSLogo = false;
/**
* should consensus profile be rendered normalised to row height
* should consensus histograms be rendered by default
*/
protected boolean showConsensusHistogram = true;
+
+ protected boolean showSSConsensusHistogram = true;
+
+ public void setShowSSConsensusHistogram(boolean showSSConsensusHistogram)
+ {
+ this.showSSConsensusHistogram = showSSConsensusHistogram;
+ }
/**
* @return the showConsensusProfile
{
return showSequenceLogo;
}
+
+ @Override
+ public boolean isShowSequenceSSLogo()
+ {
+ return showSequenceSSLogo;
+ }
/**
* @param showSequenceLogo
}
this.showSequenceLogo = showSequenceLogo;
}
+
+ public void setShowSequenceSSLogo(boolean showSequenceSSLogo)
+ {
+ if (showSequenceSSLogo != this.showSequenceSSLogo)
+ {
+ // TODO: decouple settings setting from calculation when refactoring
+ // annotation update method from alignframe to viewport
+ this.showSequenceSSLogo = showSequenceSSLogo;
+ calculator.updateAnnotationFor(SecondaryStructureConsensusThread.class);
+ }
+ this.showSequenceSSLogo = showSequenceSSLogo;
+ }
/**
* @param showConsensusHistogram
{
return this.showConsensusHistogram;
}
+
+ @Override
+ public boolean isShowSSConsensusHistogram()
+ {
+ return this.showSSConsensusHistogram;
+ }
/**
* when set, updateAlignment will always ensure sequences are of equal length
if (ap != null)
{
updateConsensus(ap);
+ updateSecondaryStructureConsensus(ap);
if (residueShading != null)
{
residueShading.setThreshold(residueShading.getThreshold(),
if (autoCalculateConsensus)
{
updateConsensus(ap);
+ updateSecondaryStructureConsensus(ap);
}
if (hconsensus != null && autoCalculateConsensus)
{
consensus = new AlignmentAnnotation("Consensus",
MessageManager.getString("label.consensus_descr"),
new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
+
+ secondaryStructureConsensus = new AlignmentAnnotation("SecondaryStructureConsensus",
+ MessageManager.getString("label.ssconsensus_descr"),
+ new Annotation[1], 0f, 100f, AlignmentAnnotation.BAR_GRAPH);
+
initConsensus(consensus);
+ initSSConsensus(secondaryStructureConsensus);
initGapCounts();
-
initComplementConsensus();
}
}
+
/**
* If this is a protein alignment and there are mappings to cDNA, adds the
* cDNA consensus annotation and returns true, else returns false.
alignment.addAnnotation(aa);
}
}
+
+ private void initSSConsensus(AlignmentAnnotation aa)
+ {
+ aa.hasText = true;
+ aa.autoCalculated = true;
+
+ if (showConsensus)
+ {
+ alignment.addAnnotation(aa);
+ }
+ }
// these should be extracted from the view model - style and settings for
// derived annotation
boolean conv = isShowGroupConservation();
boolean cons = isShowGroupConsensus();
boolean showprf = isShowSequenceLogo();
+ boolean showSSprf = isShowSequenceSSLogo();
boolean showConsHist = isShowConsensusHistogram();
+ boolean showSSConsHist = isShowSSConsensusHistogram();
boolean normLogo = isNormaliseSequenceLogo();
/**
{
// set defaults for this group's conservation/consensus
sg.setshowSequenceLogo(showprf);
+ sg.setshowSequenceSSLogo(showSSprf);
sg.setShowConsensusHistogram(showConsHist);
+ sg.setShowSSConsensusHistogram(showSSConsHist);
sg.setNormaliseSequenceLogo(normLogo);
}
if (conv)
{
updateCalcs = true;
alignment.addAnnotation(sg.getConsensus(), 0);
+ alignment.addAnnotation(sg.getSSConsensus(), 0);
}
// refresh the annotation rows
if (updateCalcs)
+ ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
return sq;
}
+
+ public SequenceI getSSConsensusSeq()
+ {
+ if (secondaryStructureConsensus == null)
+ {
+ updateSecondaryStructureConsensus(null);
+ }
+ if (secondaryStructureConsensus == null)
+ {
+ return null;
+ }
+ StringBuffer seqs = new StringBuffer();
+ for (int i = 0; i < secondaryStructureConsensus.annotations.length; i++)
+ {
+ Annotation annotation = secondaryStructureConsensus.annotations[i];
+ if (annotation != null)
+ {
+ String description = annotation.description;
+ if (description != null && description.startsWith("["))
+ {
+ // consensus is a tie - just pick the first one
+ seqs.append(description.charAt(1));
+ }
+ else
+ {
+ seqs.append(annotation.displayCharacter);
+ }
+ }
+ }
+
+ SequenceI sq = new Sequence("Sec Str Consensus", seqs.toString());
+ sq.setDescription("Percentage Identity Sec Str Consensus "
+ + ((ignoreGapsInConsensusCalculation) ? " without gaps" : ""));
+ return sq;
+ }
@Override
public void setCurrentTree(TreeModel tree)