+ * Derive the information annotations to be added to the alignment for
+ * display. This does not recompute the raw data, but may be called on a
+ * change in display options, such as 'ignore below background frequency',
+ * which may in turn result in a change in the derived values.
+ *
+ * @param information
+ * the annotation row to add annotations to
+ * @param profiles
+ * the source information data
+ * @param startCol
+ * start column (inclusive)
+ * @param endCol
+ * end column (exclusive)
+ * @param ignoreGaps
+ * if true, normalise residue percentages
+ * @param showSequenceLogo
+ * if true include all information symbols, else just show modal
+ * residue
+ */
+ public static float completeInformation(AlignmentAnnotation information,
+ ProfilesI profiles, int startCol, int endCol)
+ {
+ // long now = System.currentTimeMillis();
+ if (information == null || information.annotations == null)
+ {
+ /*
+ * called with a bad alignment annotation row
+ * wait for it to be initialised properly
+ */
+ return 0;
+ }
+
+ float max = 0f;
+ SequenceI hmmSeq = information.sequenceRef;
+
+ int seqLength = hmmSeq.getLength();
+ if (information.annotations.length < seqLength)
+ {
+ return 0;
+ }
+
+ HiddenMarkovModel hmm = hmmSeq.getHMM();
+
+ for (int column = startCol; column < endCol; column++)
+ {
+ if (column >= seqLength)
+ {
+ // hmm consensus sequence is shorter than the alignment
+ break;
+ }
+
+ float value = hmm.getInformationContent(column);
+ boolean isNaN = Float.isNaN(value);
+ if (!isNaN)
+ {
+ max = Math.max(max, value);
+ }
+
+ String description = isNaN ? null
+ : String.format("%.4f bits", value);
+ information.annotations[column] = new Annotation(
+ Character.toString(
+ Character.toUpperCase(hmmSeq.getCharAt(column))),
+ description, ' ', value);
+ }
+
+ information.graphMax = max;
+ return max;
+ }
+
+ /**
+ * Derive the occupancy count annotation