Merge branch 'Jalview-JS/develop' into merge_js_develop
[jalview.git] / src / jalview / datamodel / HMMNode.java
1 package jalview.datamodel;
2
3 /**
4  * stores data for each node in the hmm model
5  * @author TZVanaalten
6  *
7  */
8 public class HMMNode
9 {
10   //contains the match emissions for each symbol 
11   double[] matchEmissions;
12
13   //contains the insert emissions for each symbol 
14   double[] insertEmissions;
15
16   // contains the state transitions for each possible transition. These are mm,
17   // mi, md, im, ii, dm and dd in order
18   double[] stateTransitions;
19   
20   //annotations
21   int residueNumber;
22   char consensusResidue;
23   char referenceAnnotation;
24   char maskValue;
25   char consensusStructure;
26
27   /**
28    * Constructor
29    */
30   public HMMNode()
31   {
32   }
33
34   public double[] getMatchEmissions()
35   {
36     return matchEmissions;
37   }
38
39   double getMatchEmission(int symbolIndex)
40   {
41     return matchEmissions[symbolIndex];
42   }
43
44   public void setMatchEmissions(double[] matches)
45   {
46     this.matchEmissions = matches;
47   }
48
49   public double[] getInsertEmissions()
50   {
51     return insertEmissions;
52   }
53
54   double getInsertEmission(int symbolIndex)
55   {
56     return insertEmissions[symbolIndex];
57   }
58
59   public void setInsertEmissions(double[] insertEmissionsL)
60   {
61     this.insertEmissions = insertEmissionsL;
62   }
63
64   public double[] getStateTransitions()
65   {
66     return stateTransitions;
67   }
68
69   double getStateTransition(int transition)
70   {
71     return stateTransitions[transition];
72   }
73
74   public void setStateTransitions(double[] stateTransitionsM)
75   {
76     this.stateTransitions = stateTransitionsM;
77   }
78
79   int getResidueNumber()
80   {
81     return residueNumber;
82   }
83   public void setResidueNumber(int resNo)
84   {
85     this.residueNumber = resNo;
86   }
87
88   char getConsensusResidue()
89   {
90     return consensusResidue;
91   }
92   public void setConsensusResidue(char consensusResidue)
93   {
94     this.consensusResidue = consensusResidue;
95   }
96
97   char getReferenceAnnotation()
98   {
99     return referenceAnnotation;
100   }
101   public void setReferenceAnnotation(char referenceAnnotation)
102   {
103     this.referenceAnnotation = referenceAnnotation;
104   }
105
106   char getMaskValue()
107   {
108     return maskValue;
109   }
110   public void setMaskValue(char maskValue)
111   {
112     this.maskValue = maskValue;
113   }
114
115   char getConsensusStructure()
116   {
117     return consensusStructure;
118   }
119   public void setConsensusStructure(char consensusStructure)
120   {
121     this.consensusStructure = consensusStructure;
122   }
123
124   /**
125    * Answers the symbol index of the symbol with the highest match emission
126    * probability (first symbol in case of a tie). Note this object stores
127    * probabilities, not the negative logarithms as in the HMM file.
128    * 
129    * @return
130    */
131   int getMaxMatchEmissionIndex()
132   {
133     int maxIndex = 0;
134     double max = 0D;
135
136     for (int i = 0; i < matchEmissions.length; i++)
137     {
138       if (matchEmissions[i] > max)
139       {
140         max = matchEmissions[i];
141         maxIndex = i;
142       }
143     }
144     return maxIndex;
145   }
146 }
147    
148