1e36064196d5f0b6f813984a78733bb61d370325
[jabaws.git] / datamodel / compbio / data / sequence / RNAstruct.java
1 package compbio.data.sequence;
2
3 import java.util.List;
4
5 import javax.xml.bind.annotation.XmlAccessType;
6 import javax.xml.bind.annotation.XmlAccessorType;
7
8 import compbio.util.annotation.Immutable;
9
10 /*
11  * RNA secondary structure
12  */
13
14 @XmlAccessorType(XmlAccessType.FIELD)
15 public final class RNAstruct {
16         
17         private String sequence;
18         private String structure; // needs to be array to deal with all output
19         private Float minEnergy;
20         private Float energySum1; private Float energySum2;
21         
22         
23         public RNAstruct() {
24                 // default JaxB Constructor
25         }
26         
27         public RNAstruct(String sequence, String structure, Float minEnergy
28                         , Float energySum1, Float energySum2) {
29                 this.sequence = sequence;
30                 this.structure = structure;
31                 this.minEnergy = minEnergy;
32                 this.energySum1 = energySum1;
33                 this.energySum2 = energySum2;
34         }
35         
36         public String getSequence() {
37                 return sequence;
38         }
39         
40         public String getStructure() {
41                 return structure;
42         }
43         
44         public Float getEnergy() {
45                 return minEnergy;
46         }
47         
48         
49         @Override
50         public String toString() {
51                 String newLine = System.getProperty("line.separator",".");
52                 return sequence + newLine + structure + " (" + minEnergy.toString() 
53                                 + " = " + energySum1.toString() + " +  " + energySum2.toString()
54                                 + ")"; 
55         }
56         
57         @Override 
58         public boolean equals(Object obj) {
59                 if (obj == null) {
60                         return false;
61                 }
62                 if (!(obj instanceof RNAstruct)) {
63                         return false;
64                 }
65                 RNAstruct st = (RNAstruct) obj;
66                 if (!(this.getSequence() == st.getSequence() &&
67                                 this.getStructure() == st.getStructure() &&
68                                 this.getEnergy() == st.getEnergy())) {
69                         return false;
70                 }
71                 
72                 return true;
73         }
74 }
75
76