package jalview.datamodel;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* stores data for each node in the hmm model
* @author TZVanaalten
public class HMMNode
{
//contains the match emissions for each symbol
- List<Double> matchEmissions = new ArrayList<>();
+ double[] matchEmissions;
+
//contains the insert emissions for each symbol
- List<Double> insertEmissions = new ArrayList<>();
- //contains the state transitions for each possible transition. These are bm, bi, bd, im, ii, dm and dd in order (0th position in
- // the array indicates the probability of a bm transition)
- List<Double> stateTransitions = new ArrayList<>();
+ double[] insertEmissions;
+
+ // contains the state transitions for each possible transition. These are mm,
+ // mi, md, im, ii, dm and dd in order
+ double[] stateTransitions;
//annotations
- Integer alignmentColumn = null;
+ int residueNumber;
char consensusResidue;
char referenceAnnotation;
char maskValue;
char consensusStructure;
+ /**
+ * Constructor
+ */
public HMMNode()
{
}
- public HMMNode(HMMNode node)
+ public double[] getMatchEmissions()
{
- matchEmissions = new ArrayList<>(node.getMatchEmissions());
- insertEmissions = new ArrayList<>(node.getInsertEmissions());
- stateTransitions = new ArrayList<>(node.getStateTransitions());
- alignmentColumn = new Integer(node.getAlignmentColumn());
- consensusResidue = node.getConsensusResidue();
- referenceAnnotation = node.getReferenceAnnotation();
- maskValue = node.getMaskValue();
- consensusStructure = node.getConsensusStructure();
+ return matchEmissions;
}
- public List<Double> getMatchEmissions()
+ double getMatchEmission(int symbolIndex)
{
- return matchEmissions;
+ return matchEmissions[symbolIndex];
}
- public void setMatchEmissions(List<Double> matchEmissionsL)
+ public void setMatchEmissions(double[] matches)
{
- this.matchEmissions = matchEmissionsL;
+ this.matchEmissions = matches;
}
- public List<Double> getInsertEmissions()
+
+ public double[] getInsertEmissions()
{
return insertEmissions;
}
- public void setInsertEmissions(List<Double> insertEmissionsL)
+ double getInsertEmission(int symbolIndex)
+ {
+ return insertEmissions[symbolIndex];
+ }
+
+ public void setInsertEmissions(double[] insertEmissionsL)
{
this.insertEmissions = insertEmissionsL;
}
- public List<Double> getStateTransitions()
+ public double[] getStateTransitions()
{
return stateTransitions;
}
- public void setStateTransitions(List<Double> stateTransitionsM)
+ double getStateTransition(int transition)
+ {
+ return stateTransitions[transition];
+ }
+
+ public void setStateTransitions(double[] stateTransitionsM)
{
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;
}
{
this.consensusResidue = consensusResidue;
}
- public char getReferenceAnnotation()
+
+ char getReferenceAnnotation()
{
return referenceAnnotation;
}
{
this.referenceAnnotation = referenceAnnotation;
}
- public char getMaskValue()
+
+ char getMaskValue()
{
return maskValue;
}
{
this.maskValue = maskValue;
}
- public char getConsensusStructure()
+
+ char getConsensusStructure()
{
return consensusStructure;
}
{
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;
+ }
}