1 package compbio.data.sequence;
\r
3 import java.util.Arrays;
\r
5 public class AnnotatedSequence extends FastaSequence {
\r
7 private float[] annotation;
\r
9 private AnnotatedSequence() {
\r
11 // JAXB default constructor
\r
14 public AnnotatedSequence(String id, String sequence, float[] annotation) {
\r
15 super(id, sequence);
\r
16 this.annotation = annotation;
\r
17 if (annotation == null || annotation.length != sequence.length()) {
\r
18 throw new IllegalArgumentException("The length of the annotation ("
\r
19 + ((annotation != null) ? annotation.length : "0")
\r
20 + ") does not match the length of the sequence ("
\r
21 + sequence.length() + ")!");
\r
25 public AnnotatedSequence(FastaSequence fsequence, float[] annotation) {
\r
26 this(fsequence.getId(), fsequence.getSequence(), annotation);
\r
29 public float[] getAnnotation() {
\r
34 public int hashCode() {
\r
35 final int prime = 7;
\r
36 int result = super.hashCode();
\r
37 result = prime * result + Arrays.hashCode(annotation);
\r
42 public boolean equals(Object obj) {
\r
45 if (!super.equals(obj))
\r
47 if (getClass() != obj.getClass())
\r
49 AnnotatedSequence other = (AnnotatedSequence) obj;
\r
50 if (!Arrays.equals(annotation, other.annotation))
\r
56 public String toString() {
\r
57 return super.toString() + "Annotation:\n "
\r
58 + Arrays.toString(annotation) + "\n";
\r