Merge remote-tracking branch 'origin/tasks/JAL-3070_wsinterfaces' into alpha/JAL...
[jalview.git] / src / jalview / datamodel / HMMNode.java
index 93fa49e..b646eee 100644 (file)
@@ -18,7 +18,7 @@ public class HMMNode
   double[] stateTransitions;
   
   //annotations
-  Integer alignmentColumn = null;
+  int residueNumber;
   char consensusResidue;
   char referenceAnnotation;
   char maskValue;
@@ -36,7 +36,7 @@ public class HMMNode
     return matchEmissions;
   }
 
-  public double getMatchEmission(int symbolIndex)
+  double getMatchEmission(int symbolIndex)
   {
     return matchEmissions[symbolIndex];
   }
@@ -51,7 +51,7 @@ public class HMMNode
     return insertEmissions;
   }
 
-  public double getInsertEmission(int symbolIndex)
+  double getInsertEmission(int symbolIndex)
   {
     return insertEmissions[symbolIndex];
   }
@@ -66,7 +66,7 @@ public class HMMNode
     return stateTransitions;
   }
 
-  public double getStateTransition(int transition)
+  double getStateTransition(int transition)
   {
     return stateTransitions[transition];
   }
@@ -76,15 +76,16 @@ public class HMMNode
     this.stateTransitions = stateTransitionsM;
   }
 
-  public Integer getAlignmentColumn()
+  int getResidueNumber()
   {
-    return alignmentColumn;
+    return residueNumber;
   }
-  public void setAlignmentColumn(int alignmentColumn)
+  public void setResidueNumber(int resNo)
   {
-    this.alignmentColumn = alignmentColumn;
+    this.residueNumber = resNo;
   }
-  public char getConsensusResidue()
+
+  char getConsensusResidue()
   {
     return consensusResidue;
   }
@@ -92,7 +93,8 @@ public class HMMNode
   {
     this.consensusResidue = consensusResidue;
   }
-  public char getReferenceAnnotation()
+
+  char getReferenceAnnotation()
   {
     return referenceAnnotation;
   }
@@ -100,7 +102,8 @@ public class HMMNode
   {
     this.referenceAnnotation = referenceAnnotation;
   }
-  public char getMaskValue()
+
+  char getMaskValue()
   {
     return maskValue;
   }
@@ -108,7 +111,8 @@ public class HMMNode
   {
     this.maskValue = maskValue;
   }
-  public char getConsensusStructure()
+
+  char getConsensusStructure()
   {
     return consensusStructure;
   }
@@ -116,6 +120,29 @@ public class HMMNode
   {
     this.consensusStructure = consensusStructure;
   }
+
+  /**
+   * Answers the symbol index of the symbol with the highest match emission
+   * probability (first symbol in case of a tie). Note this object stores
+   * probabilities, not the negative logarithms as in the HMM file.
+   * 
+   * @return
+   */
+  int getMaxMatchEmissionIndex()
+  {
+    int maxIndex = 0;
+    double max = 0D;
+
+    for (int i = 0; i < matchEmissions.length; i++)
+    {
+      if (matchEmissions[i] > max)
+      {
+        max = matchEmissions[i];
+        maxIndex = i;
+      }
+    }
+    return maxIndex;
+  }
 }