1 package compbio.data.sequence;
\r
3 import java.util.EnumMap;
\r
4 import java.util.List;
\r
5 import java.util.Map;
\r
7 import compbio.util.annotation.NotThreadSafe;
\r
18 public class MultiAnnotatedSequence<T extends Enum<T>> {
\r
20 private final Map<T, List<Float>> annotations;
\r
22 public MultiAnnotatedSequence(Class<T> enumeration) {
\r
23 this.annotations = new EnumMap<T, List<Float>>(enumeration);
\r
26 public void addAnnotation(T type, List<Float> annotation) {
\r
27 assert type != null : "Type is expected";
\r
28 assert annotation != null : "Not empty value is expected!";
\r
29 if (!annotations.isEmpty()) {
\r
30 assert annotations.values().iterator().next().size() == annotation
\r
31 .size() : "Annotations must contain the same number of elements!";
\r
33 this.annotations.put(type, annotation);
\r
36 public Map<T, List<Float>> getAnnotations() {
\r
37 return new EnumMap<T, List<Float>>(this.annotations);
\r
41 public int hashCode() {
\r
42 final int prime = 31;
\r
44 result = prime * result
\r
45 + ((annotations == null) ? 0 : annotations.hashCode());
\r
50 public boolean equals(Object obj) {
\r
55 if (getClass() != obj.getClass())
\r
57 MultiAnnotatedSequence other = (MultiAnnotatedSequence) obj;
\r
58 if (annotations == null) {
\r
59 if (other.annotations != null)
\r
61 } else if (!annotations.equals(other.annotations))
\r
67 public String toString() {
\r
69 for (Map.Entry<T, List<Float>> annt : annotations.entrySet()) {
\r
70 value += annt.getKey() + " ";
\r
71 value += annt.getValue() + "\n";
\r
76 public JalviewAnnotation toJalviewAnnotation() {
\r
77 // TODO Auto-generated method stub
\r