package compbio.data.sequence; import java.util.Arrays; public class AnnotatedSequence extends FastaSequence { private final float[] annotation; public AnnotatedSequence(String id, String sequence, float[] annotation) { super(id, sequence); this.annotation = annotation; if (annotation == null || annotation.length != sequence.length()) { throw new IllegalArgumentException("The length of the annotation (" + ((annotation != null) ? annotation.length : "0") + ") does not match the length of the sequence (" + sequence.length() + ")!"); } } public AnnotatedSequence(FastaSequence fsequence, float[] annotation) { this(fsequence.getId(), fsequence.getSequence(), annotation); } public float[] getAnnotation() { return annotation; } @Override public int hashCode() { final int prime = 7; int result = super.hashCode(); result = prime * result + Arrays.hashCode(annotation); return result; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (!super.equals(obj)) return false; if (getClass() != obj.getClass()) return false; AnnotatedSequence other = (AnnotatedSequence) obj; if (!Arrays.equals(annotation, other.annotation)) return false; return true; } @Override public String toString() { return super.toString() + "Annotation:\n " + Arrays.toString(annotation) + "\n"; } }