ProfilesI getHmmProfiles();
/**
- * Updates all information annotations.
+ * Registers and starts a worker thread to calculate Information Content
+ * annotation, if it is not already registered
*
* @param ap
*/
- void updateInformation(AlignmentViewPanel ap);
+ void initInformationWorker(AlignmentViewPanel ap);
boolean isInfoLetterHeight();
alignPanel);
viewport.updateConservation(alignPanel);
viewport.updateConsensus(alignPanel);
- viewport.updateInformation(alignPanel);
+ viewport.initInformationWorker(alignPanel);
displayNonconservedMenuItem.setState(viewport.getShowUnconserved());
followMouseOverFlag.setState(viewport.isFollowHighlight());
// this is called after loading new annotation onto alignment
if (alignFrame.getSize().height == 0)
{
- System.out.println(
- "adjustAnnotationHeight frame size zero NEEDS FIXING");
+ // panel not laid out yet?
+ return;
}
fontChanged();
validateAnnotationDimensions(true);
ap.av.updateConservation(ap);
ap.av.updateConsensus(ap);
ap.av.updateStrucConsensus(ap);
- ap.av.updateInformation(ap);
+ ap.av.initInformationWorker(ap);
}
}
@Override
public void actionPerformed(ActionEvent e)
{
- av.updateInformation(ap);
av.setShowHMMSequenceLogo(cprof.getState());
ap.repaint();
}
import jalview.datamodel.SequenceI;
import jalview.gui.AlignFrame;
import jalview.gui.AlignViewport;
-import jalview.gui.AlignmentPanel;
import jalview.gui.JvOptionPane;
import jalview.io.DataSourceType;
import jalview.io.FileParse;
af.setProgressBar(MessageManager.getString("status.running_hmmbuild"),
msgID);
- AlignViewportI viewport = af.getViewport();
+ AlignViewport viewport = af.getViewport();
try
{
/*
}
} finally
{
- viewport.updateInformation(af.alignPanel);
- af.buildColourMenu(); // to enable HMMER colour schemes
af.setProgressBar("", msgID);
+ viewport.alignmentChanged(af.alignPanel);
+ af.buildColourMenu(); // to enable HMMER colour schemes
}
}
alignment.setHmmConsensus(hmmSeq);
}
- AlignViewport viewport = af.getViewport();
- if (viewport != null)
+ if (af.getSelectedHMM() == null)
{
- AlignmentPanel alignPanel = viewport.getAlignPanel();
- viewport.alignmentChanged(alignPanel);
- alignPanel.adjustAnnotationHeight();
- viewport.updateSequenceIdColours();
-
- if (alignPanel.alignFrame.getSelectedHMM() == null)
- {
- alignPanel.alignFrame.setSelectedHMMSequence(hmmSeq);
- }
+ af.setSelectedHMMSequence(hmmSeq);
}
}
}
}
}
- /**
- * 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
ignoreGapsInConsensusCalculation = b;
if (ap != null)
{
- updateConsensus(ap);
if (residueShading != null)
{
residueShading.setThreshold(residueShading.getThreshold(),
public void setIgnoreBelowBackground(boolean b, AlignmentViewPanel ap)
{
- boolean was = ignoreBelowBackGroundFrequencyCalculation;
ignoreBelowBackGroundFrequencyCalculation = b;
- if (ap != null && was != b)
- {
- updateInformation(ap);
- }
}
public void setInfoLetterHeight(boolean b, AlignmentViewPanel ap)
{
- boolean was = infoLetterHeight;
infoLetterHeight = b;
- if (ap != null && was != b)
- {
- updateInformation(ap);
- }
}
private long sgrouphash = -1, colselhash = -1;
{
alignment.padGaps();
}
- if (autoCalculateConsensus)
- {
- updateConsensus(ap);
- }
- if (consensusProfiles != null && autoCalculateConsensus)
- {
- updateConservation(ap);
- }
- if (autoCalculateStrucConsensus)
- {
- updateStrucConsensus(ap);
- }
- // initInformation();
- updateInformation(ap);
+ // if (autoCalculateConsensus)
+ // {
+ // updateConsensus(ap);
+ // }
+ // if (consensusProfiles != null && autoCalculateConsensus)
+ // {
+ // updateConservation(ap);
+ // }
+ // if (autoCalculateStrucConsensus)
+ // {
+ // updateStrucConsensus(ap);
+ // }
+ //
+ // updateInformation(ap);
// Reset endRes of groups if beyond alignment width
int alWidth = alignment.getWidth();
updateAllColourSchemes();
calculator.restartWorkers();
- // alignment.adjustSequenceAnnotations();
}
/**
import jalview.datamodel.SequenceI;
import jalview.util.MessageManager;
+import java.util.ArrayList;
import java.util.List;
/**
{
public static final String HMM_CALC_ID = "HMM";
- private float max = 0f;
-
/**
* Constructor
*
abortAndDestroy();
return;
}
- AlignmentI alignment = alignViewport.getAlignment();
+ AlignmentI alignment = alignViewport.getAlignment();
int aWidth = alignment == null ? -1 : alignment.getWidth();
-
if (aWidth < 0)
{
calcMan.workerComplete(this);
return;
}
+ /*
+ * compute information profiles for any HMM consensus sequences
+ * for the alignment or sub-groups
+ */
computeProfiles(alignment);
+
+ /*
+ * construct the corresponding annotations
+ */
updateAnnotation();
if (ap != null)
{
AlignmentI alignment = alignViewport.getAlignment();
- this.max = 0f;
+ float maxInformation = 0f;
+ List<AlignmentAnnotation> infos = new ArrayList<>();
/*
* annotation for alignment HMM consensus if present
*/
SequenceI hmmSeq = alignment.getHmmConsensus();
ProfilesI profile = alignViewport.getHmmProfiles();
- updateInformationAnnotation(hmmSeq, profile, null);
+ float m = updateInformationAnnotation(hmmSeq, profile, null, infos);
+ maxInformation = Math.max(maxInformation, m);
/*
* annotation for group HMM consensus if present
{
hmmSeq = group.getHmmConsensus();
ProfilesI profiles = group.getHmmProfiles();
- updateInformationAnnotation(hmmSeq, profiles, group);
+ m = updateInformationAnnotation(hmmSeq, profiles, group, infos);
+ maxInformation = Math.max(maxInformation, m);
}
/*
- * todo: this.max is not used, but acquires the maximum value of
- * information in any of the annotations; set this as graphMax in all
- * annotations to have them all scaled the same
+ * maxInformation holds the maximum value of information score;
+ * set this as graphMax in all annotations to scale them all the same
*/
+ for (AlignmentAnnotation ann : infos)
+ {
+ ann.graphMax = maxInformation;
+ }
}
/**
* Updates (and first constructs if necessary) an HMM Profile information
* content annotation for a sequence. The <code>group</code> argument is null
- * for the whole alignment annotation, not null for a subgroup annotation.
+ * for the whole alignment annotation, not null for a subgroup annotation. The
+ * updated annotation is added to the <code>infos</code> list. Answers the
+ * maximum information content value of any annotation (for use as a scaling
+ * factor for display).
*
* @param seq
* @param profile
* @param group
+ * @param infos
* @return
*/
- protected AlignmentAnnotation updateInformationAnnotation(SequenceI seq,
- ProfilesI profile, SequenceGroup group)
+ protected float updateInformationAnnotation(SequenceI seq,
+ ProfilesI profile, SequenceGroup group,
+ List<AlignmentAnnotation> infos)
{
if (seq == null || profile == null)
{
- return null;
+ return 0f;
}
AlignmentAnnotation ann = findOrCreateAnnotation(seq, group);
seq.addAlignmentAnnotation(ann);
+ infos.add(ann);
- max = AAFrequency.completeInformation(ann, profile,
+ float max = AAFrequency.completeInformation(ann, profile,
profile.getStartColumn(), profile.getEndColumn() + 1);
- return ann;
+ return max;
}
/**
{
info = ann;
info.setSequenceRef(seq);
+ info.label = seq.getName(); // in case group name changed!
break;
}
}