1 package compbio.data.sequence;
\r
3 import java.util.Arrays;
\r
5 public class AnnotatedSequence extends FastaSequence {
\r
7 private final float[] annotation;
\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
20 public AnnotatedSequence(FastaSequence fsequence, float[] annotation) {
\r
21 this(fsequence.getId(), fsequence.getSequence(), annotation);
\r
24 public float[] getAnnotation() {
\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
37 public boolean equals(Object obj) {
\r
40 if (!super.equals(obj))
\r
42 if (getClass() != obj.getClass())
\r
44 AnnotatedSequence other = (AnnotatedSequence) obj;
\r
45 if (!Arrays.equals(annotation, other.annotation))
\r
51 public String toString() {
\r
52 return super.toString() + "Annotation:\n "
\r
53 + Arrays.toString(annotation) + "\n";
\r