+ endRes++;
+ }
+ }
+ if (endRes > 0)
+ {
+ endRes += start - 1;
+ }
+
+ if (end<endRes) {
+ end = endRes;
+ }
+ }
+
+ }
+
+ /**
+ * Creates a new Sequence object.
+ *
+ * @param name
+ * DOCUMENT ME!
+ * @param sequence
+ * DOCUMENT ME!
+ */
+ public Sequence(String name, String sequence)
+ {
+ this(name, sequence, 1, -1);
+ }
+
+ /**
+ * Creates a new Sequence object with new features, DBRefEntries,
+ * AlignmentAnnotations, and PDBIds but inherits any existing dataset sequence
+ * reference.
+ *
+ * @param seq
+ * DOCUMENT ME!
+ */
+ 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());
+ description = seq.getDescription();
+ if (seq.getSequenceFeatures() != null)
+ {
+ SequenceFeature[] sf = seq.getSequenceFeatures();
+ for (int i = 0; i < sf.length; i++)
+ {
+ addSequenceFeature(new SequenceFeature(sf[i]));
+ }
+ }
+ setDatasetSequence(seq.getDatasetSequence());
+ if (datasetSequence == null && seq.getDBRef() != null)
+ {
+ // only copy DBRefs if we really are a dataset sequence
+ DBRefEntry[] dbr = seq.getDBRef();
+ for (int i = 0; i < dbr.length; i++)
+ {
+ addDBRef(new DBRefEntry(dbr[i]));
+ }
+ }
+ if (seq.getAnnotation() != null)
+ {
+ AlignmentAnnotation[] sqann = seq.getAnnotation();
+ for (int i = 0; i < sqann.length; i++)
+ {
+ if (sqann[i] == null)
+ {
+ continue;
+ }
+ boolean found = (alAnnotation == null);
+ if (!found)
+ {
+ for (int apos = 0; !found && apos < alAnnotation.length; apos++)