*/
public Sequence(SequenceI seq)
{
+ this(seq, seq.getAnnotation());
+ }
+ /**
+ * Create a new sequence object with new features, DBRefEntries, and PDBIds
+ * but inherits any existing dataset sequence reference, and duplicate of
+ * any annotation that is present in the given annotation array.
+ * @param seq the sequence to be copied
+ * @param alAnnotation an array of annotation including some associated with seq
+ */
+ public Sequence(SequenceI seq, AlignmentAnnotation[] alAnnotation)
+ {
this(seq.getName(),
- seq.getSequence(),
- seq.getStart(),
- seq.getEnd());
+ seq.getSequence(),
+ seq.getStart(),
+ seq.getEnd());
description = seq.getDescription();
if (seq.getSequenceFeatures()!=null) {
SequenceFeature[] sf = seq.getSequenceFeatures();
}
}
setDatasetSequence(seq.getDatasetSequence());
- if (seq.getAnnotation()!=null) {
+ if (seq.getAnnotation()!=null && alAnnotation!=null) {
AlignmentAnnotation[] sqann = seq.getAnnotation();
for (int i=0;i<sqann.length; i++)
{
+ boolean found = sqann == alAnnotation;
+ if (!found)
+ {
+ for (int apos = 0; !found && apos<alAnnotation.length; apos++)
+ {
+ found = (alAnnotation[apos] == sqann[i]);
+ }
+ }
AlignmentAnnotation newann = new AlignmentAnnotation(sqann[i]);
addAlignmentAnnotation(newann);
}
}
}
-
/**
* DOCUMENT ME!
*
*/
public char [] getSequence(int start, int end)
{
+ if (start<0)
+ start=0;
// JBPNote - left to user to pad the result here (TODO:Decide on this policy)
if (start >= sequence.length)
{
}
}
+ /* (non-Javadoc)
+ * @see jalview.datamodel.SequenceI#getAnnotation(java.lang.String)
+ */
+ public AlignmentAnnotation[] getAnnotation(String label)
+ {
+ if (annotation==null || annotation.size()==0)
+ {
+ return null;
+ }
+
+ Vector subset = new Vector();
+ Enumeration e = annotation.elements();
+ while (e.hasMoreElements())
+ {
+ AlignmentAnnotation ann = (AlignmentAnnotation) e.nextElement();
+ if (ann.label!=null && ann.label.equals(label))
+ {
+ subset.addElement(ann);
+ }
+ }
+ if (subset.size()==0)
+ {
+ return null;
+ }
+ AlignmentAnnotation[] anns = new AlignmentAnnotation[subset.size()];
+ int i=0;
+ e = subset.elements();
+ while (e.hasMoreElements())
+ {
+ anns[i++] = (AlignmentAnnotation) e.nextElement();
+ }
+ subset.removeAllElements();
+ return anns;
+ }
+
}