*/
public char getConsensusAtAlignColumn(int columnIndex)
{
- char value;
+ char mostLikely = '-';
+ if (consensusResidueIsActive())
+ {
+
Integer index = findNodeIndex(columnIndex);
if (index == null)
{
return '-';
}
- value = getNodes().get(index).getConsensusResidue();
- return value;
+ mostLikely = getNodes().get(index).getConsensusResidue();
+ return mostLikely;
+ }
+ else
+ {
+ double highestProb = 0;
+ for (char character : symbols)
+ {
+ Double prob = getMatchEmissionProbability(columnIndex, character);
+ if (prob > highestProb)
+ {
+ highestProb = prob;
+ mostLikely = character;
+ }
+ }
+ return mostLikely;
+ }
+
}
/**
}
Character cons;
+
cons = getConsensusAtAlignColumn(alignPos);
+
cons = Character.toUpperCase(cons);
String description = String.format("%.3f", content);
"The information content of each column, measured in bits",
annotations,
0f, max, AlignmentAnnotation.BAR_GRAPH);
+ annotation.setHMM(this);
return annotation;
}
for (int index = 0; index < length; index++)
{
Character character;
- if (consensusResidueIsActive())
- {
+
character = getConsensusAtAlignColumn(index);
- }
- else
- {
- character = findConsensusCharacter(index);
- }
+
if (character == null || character == '-')
{
sequence[index] = '-';
return seq;
}
- /**
- * Finds the most probable character at a column in an alignment based on the
- * HMM.
- *
- * @param nodeIndex
- * The index of the node.
- * @return
- */
- Character findConsensusCharacter(int column)
- {
- Character mostLikely = null;
- double highestProb = 0;
- for (char character : symbols)
- {
- Double prob = getMatchEmissionProbability(column, character);
- if (prob > highestProb)
- {
- highestProb = prob;
- mostLikely = character;
- }
- }
- return mostLikely;
- }
/**
* Maps the nodes of the hidden Markov model to the reference annotation.
}
}
+
+ public AlignmentI initPlaceholder(AlignmentI alignment)
+ {
+ int length = alignment.getWidth();
+ Sequence consensus = getConsensusSequence(length);
+ consensus.setHMM(this);
+ SequenceI[] consensusArr = new Sequence[] { consensus };
+ AlignmentI newAlignment = new Alignment(consensusArr);
+ newAlignment.append(alignment);
+ return newAlignment;
+ }
+
}