From db0d1ba6a2b5367dfc86256f75383b5cb2672a28 Mon Sep 17 00:00:00 2001 From: TZVanaalten Date: Wed, 26 Jul 2017 13:16:48 +0100 Subject: [PATCH] JAL-2629 HMMs now map to reference annotation if exists --- src/jalview/datamodel/HiddenMarkovModel.java | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/jalview/datamodel/HiddenMarkovModel.java b/src/jalview/datamodel/HiddenMarkovModel.java index 879968f..40f106e 100644 --- a/src/jalview/datamodel/HiddenMarkovModel.java +++ b/src/jalview/datamodel/HiddenMarkovModel.java @@ -1054,5 +1054,40 @@ public class HiddenMarkovModel } return mostLikely; } + + /** + * Maps the nodes of the hidden Markov model to the reference annotation. + */ + public void mapToReferenceAnnotation(AlignmentAnnotation alAnnotation) + { + Annotation[] annots = alAnnotation.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 <= nodes.size()) + { + nodes.get(nodeIndex).setAlignmentColumn(col + 1); + nodeLookup.put(col + 1, nodeIndex); + } + else + { + System.out.println( + "The reference annotation contains more consensus columns than the hidden Markov model"); + break; + } + } + else + { + nodeLookup.remove(col + 1); + } + } + + } + } } -- 1.7.10.2