package compbio.data.sequence;\r
\r
+import java.util.ArrayList;\r
import java.util.EnumMap;\r
import java.util.List;\r
+import java.util.Map;\r
+\r
+import compbio.util.annotation.NotThreadSafe;\r
\r
/**\r
* TODO complete\r
* @param <T>\r
* enum type\r
*/\r
+@NotThreadSafe\r
+// @XmlAccessorType(XmlAccessType.FIELD)\r
public class MultiAnnotatedSequence<T extends Enum<T>> {\r
\r
- private final EnumMap<T, List<Float>> annotation;\r
+ private EnumMap<T, ArrayList<Float>> annotations;\r
+\r
+ MultiAnnotatedSequence() {\r
+ // default constructor for JAXB\r
+ }\r
+\r
+ public MultiAnnotatedSequence(Class<T> enumeration) {\r
+ this.annotations = new EnumMap<T, ArrayList<Float>>(enumeration);\r
+ }\r
+\r
+ public void addAnnotation(T type, ArrayList<Float> annotation) {\r
+ assert type != null : "Type is expected";\r
+ assert annotation != null : "Not empty value is expected!";\r
+ if (!annotations.isEmpty()) {\r
+ assert annotations.values().iterator().next().size() == annotation\r
+ .size() : "Annotations must contain the same number of elements!";\r
+ }\r
+ this.annotations.put(type, annotation);\r
+ }\r
+\r
+ public Map<T, List<Float>> getAnnotations() {\r
+ return new EnumMap<T, List<Float>>(this.annotations);\r
+ }\r
\r
- private MultiAnnotatedSequence(Class<T> type) {\r
- this.annotation = new EnumMap<T, List<Float>>(type);\r
- }\r
+ @Override\r
+ public int hashCode() {\r
+ final int prime = 31;\r
+ int result = 1;\r
+ result = prime * result\r
+ + ((annotations == null) ? 0 : annotations.hashCode());\r
+ return result;\r
+ }\r
\r
- // public MultiAnnotatedSequence getFloatInstance(FastaSequence fsequence) {\r
- // return null;\r
- //}\r
+ @Override\r
+ public boolean equals(Object obj) {\r
+ if (this == obj)\r
+ return true;\r
+ if (obj == null)\r
+ return false;\r
+ if (getClass() != obj.getClass())\r
+ return false;\r
+ MultiAnnotatedSequence other = (MultiAnnotatedSequence) obj;\r
+ if (annotations == null) {\r
+ if (other.annotations != null)\r
+ return false;\r
+ } else if (!annotations.equals(other.annotations))\r
+ return false;\r
+ return true;\r
+ }\r
\r
- public EnumMap<T, List<Integer>> getIntegerInstance(Class<T> enumeration) {\r
- return new EnumMap<T, List<Integer>>(enumeration);\r
- }\r
+ @Override\r
+ public String toString() {\r
+ String value = "";\r
+ for (Map.Entry<T, ArrayList<Float>> annt : annotations.entrySet()) {\r
+ value += annt.getKey() + " ";\r
+ value += annt.getValue() + "\n";\r
+ }\r
+ return value;\r
+ }\r
\r
- public EnumMap<T, List<Float>> getFloatInstance(Class<T> enumeration) {\r
- return new EnumMap<T, List<Float>>(enumeration);\r
- }\r
+ public JalviewAnnotation toJalviewAnnotation() {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
}\r