+ public void mapToReferenceAnnotation(AlignmentAnnotation reference,
+ SequenceI seq)
+ {
+ HiddenMarkovModel hmm = seq.getHMM();
+ Annotation[] annots = reference.annotations;
+ {
+ int nodeIndex = 0;
+ for (int col = 0; col < annots.length; col++)
+ {
+ String character = annots[col].displayCharacter;
+ if ("x".equals(character) || "X".equals(character))
+ {
+ nodeIndex++;
+ if (nodeIndex < hmm.getNodes().size())
+ {
+ HMMNode node = hmm.getNode(nodeIndex);
+ int alignPos = getNodeAlignmentColumn(nodeIndex);
+ char seqCharacter = seq.getCharAt(alignPos);
+ if (alignPos >= seq.getLength() || col >= seq.getLength())
+ {
+ seq.insertCharAt(seq.getLength(),
+ (alignPos + 1) - seq.getLength(),
+ '-');
+ }
+ seq.getSequence()[alignPos] = '-';
+ seq.getSequence()[col] = seqCharacter;
+ node.setAlignmentColumn(col);
+ hmm.nodeLookup.put(col, nodeIndex);
+ }
+ else
+ {
+ System.out.println(
+ "The reference annotation contains more consensus columns than the hidden Markov model");
+ break;
+ }
+ }
+ else
+ {
+ hmm.nodeLookup.remove(col);
+ }
+ }
+
+ }
+
+ }
+