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;
}
}