Add JRonn runner, tester, methods to parse jronn output files.
[jabaws.git] / datamodel / compbio / data / sequence / AnnotatedSequence.java
1 package compbio.data.sequence;\r
2 \r
3 import java.util.Arrays;\r
4 \r
5 public class AnnotatedSequence extends FastaSequence {\r
6 \r
7     private final float[] annotation;\r
8 \r
9     public AnnotatedSequence(String id, String sequence, float[] annotation) {\r
10         super(id, sequence);\r
11         this.annotation = annotation;\r
12         if (annotation == null || annotation.length != sequence.length()) {\r
13             throw new IllegalArgumentException("The length of the annotation ("\r
14                     + ((annotation != null) ? annotation.length : "0")\r
15                     + ") does not match the length of the sequence ("\r
16                     + sequence.length() + ")!");\r
17         }\r
18     }\r
19 \r
20     public AnnotatedSequence(FastaSequence fsequence, float[] annotation) {\r
21         this(fsequence.getId(), fsequence.getSequence(), annotation);\r
22     }\r
23 \r
24     public float[] getAnnotation() {\r
25         return annotation;\r
26     }\r
27 \r
28     @Override\r
29     public int hashCode() {\r
30         final int prime = 7;\r
31         int result = super.hashCode();\r
32         result = prime * result + Arrays.hashCode(annotation);\r
33         return result;\r
34     }\r
35 \r
36     @Override\r
37     public boolean equals(Object obj) {\r
38         if (this == obj)\r
39             return true;\r
40         if (!super.equals(obj))\r
41             return false;\r
42         if (getClass() != obj.getClass())\r
43             return false;\r
44         AnnotatedSequence other = (AnnotatedSequence) obj;\r
45         if (!Arrays.equals(annotation, other.annotation))\r
46             return false;\r
47         return true;\r
48     }\r
49 \r
50     @Override\r
51     public String toString() {\r
52         return super.toString() + "Annotation:\n "\r
53                 + Arrays.toString(annotation) + "\n";\r
54     }\r
55 \r
56 }\r