From: TZVanaalten Date: Wed, 26 Jul 2017 12:16:48 +0000 (+0100) Subject: JAL-2629 HMMs now map to reference annotation if exists X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=db0d1ba6a2b5367dfc86256f75383b5cb2672a28;p=jalview.git JAL-2629 HMMs now map to reference annotation if exists --- 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); + } + } + + } + } }