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 compbio.util.annotation.NotThreadSafe;
\r
19 // @XmlAccessorType(XmlAccessType.FIELD)
\r
20 public class MultiAnnotatedSequence<T extends Enum<T>> {
\r
22 private EnumMap<T, ArrayList<Float>> annotations;
\r
24 MultiAnnotatedSequence() {
\r
25 // default constructor for JAXB
\r
28 public MultiAnnotatedSequence(Class<T> enumeration) {
\r
29 this.annotations = new EnumMap<T, ArrayList<Float>>(enumeration);
\r
32 public void addAnnotation(T type, ArrayList<Float> annotation) {
\r
33 assert type != null : "Type is expected";
\r
34 assert annotation != null : "Not empty value is expected!";
\r
35 if (!annotations.isEmpty()) {
\r
36 assert annotations.values().iterator().next().size() == annotation
\r
37 .size() : "Annotations must contain the same number of elements!";
\r
39 this.annotations.put(type, annotation);
\r
42 public Map<T, List<Float>> getAnnotations() {
\r
43 return new EnumMap<T, List<Float>>(this.annotations);
\r
47 public int hashCode() {
\r
48 final int prime = 31;
\r
50 result = prime * result
\r
51 + ((annotations == null) ? 0 : annotations.hashCode());
\r
56 public boolean equals(Object obj) {
\r
61 if (getClass() != obj.getClass())
\r
63 MultiAnnotatedSequence other = (MultiAnnotatedSequence) obj;
\r
64 if (annotations == null) {
\r
65 if (other.annotations != null)
\r
67 } else if (!annotations.equals(other.annotations))
\r
73 public String toString() {
\r
75 for (Map.Entry<T, ArrayList<Float>> annt : annotations.entrySet()) {
\r
76 value += annt.getKey() + " ";
\r
77 value += annt.getValue() + "\n";
\r
82 public JalviewAnnotation toJalviewAnnotation() {
\r
83 // TODO Auto-generated method stub
\r