1 package compbio.data.sequence;
\r
3 import java.util.ArrayList;
\r
4 import java.util.EnumMap;
\r
5 import java.util.List;
\r
6 import java.util.Map;
\r
8 import javax.xml.bind.annotation.XmlAccessType;
\r
9 import javax.xml.bind.annotation.XmlAccessorType;
\r
11 import compbio.util.annotation.NotThreadSafe;
\r
22 @XmlAccessorType(XmlAccessType.FIELD)
\r
23 public class MultiAnnotatedSequence<T extends Enum<T>> {
\r
25 private EnumMap<T, ArrayList<Float>> annotations;
\r
27 MultiAnnotatedSequence() {
\r
28 // default constructor for JAXB
\r
31 public MultiAnnotatedSequence(Class<T> enumeration) {
\r
32 this.annotations = new EnumMap<T, ArrayList<Float>>(enumeration);
\r
35 public void addAnnotation(T type, ArrayList<Float> annotation) {
\r
36 assert type != null : "Type is expected";
\r
37 assert annotation != null : "Not empty value is expected!";
\r
38 if (!annotations.isEmpty()) {
\r
39 assert annotations.values().iterator().next().size() == annotation
\r
40 .size() : "Annotations must contain the same number of elements!";
\r
42 this.annotations.put(type, annotation);
\r
45 public Map<T, List<Float>> getAnnotations() {
\r
46 return new EnumMap<T, List<Float>>(this.annotations);
\r
50 public int hashCode() {
\r
51 final int prime = 31;
\r
53 result = prime * result
\r
54 + ((annotations == null) ? 0 : annotations.hashCode());
\r
59 public boolean equals(Object obj) {
\r
64 if (getClass() != obj.getClass())
\r
66 MultiAnnotatedSequence other = (MultiAnnotatedSequence) obj;
\r
67 if (annotations == null) {
\r
68 if (other.annotations != null)
\r
70 } else if (!annotations.equals(other.annotations))
\r
76 public String toString() {
\r
78 for (Map.Entry<T, ArrayList<Float>> annt : annotations.entrySet()) {
\r
79 value += annt.getKey() + " ";
\r
80 value += annt.getValue() + "\n";
\r
85 public JalviewAnnotation toJalviewAnnotation() {
\r
86 // TODO Auto-generated method stub
\r