}
/**
+ * Inserts a sequence at a point in the alignment.
+ *
+ * @param i
+ * the index of the position the sequence is to be inserted in.
+ */
+ @Override
+ public void insertSequenceAt(int i, SequenceI snew)
+ {
+ synchronized (sequences)
+ {
+ if (sequences.size() > i)
+ {
+ sequences.add(i, snew);
+ return;
+
+ }
+ else
+ {
+ sequences.add(snew);
+ hiddenSequences.adjustHeightSequenceAdded();
+ }
+ return;
+ }
+ }
+
+ /**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
{
hiddenCols = cols;
}
+
+ /**
+ * Returns all HMM consensus sequences. This will not return real sequences
+ * with HMMs. If remove is set to true, the consensus sequences will be
+ * removed from the alignment.
+ */
+ @Override // TODO make this more efficient.
+ public List<SequenceI> getHMMConsensusSequences(boolean remove)
+ {
+ List<SequenceI> seqs = new ArrayList<>();
+ int position = 0;
+ int seqsRemoved = 0;
+ boolean endReached = false;
+
+ while (!endReached)
+ {
+ SequenceI seq = sequences.get(position);
+ if (seq.isHMMConsensusSequence())
+ {
+ if (remove)
+ {
+ sequences.remove(position);
+ seqsRemoved++;
+ seq.setPreviousPosition(seqsRemoved + position - 1);
+ }
+ else
+ {
+ position++;
+ }
+ seqs.add(seq);
+ }
+ else
+ {
+ position++;
+ }
+
+ if (position >= sequences.size())
+ {
+ endReached = true;
+ }
+ }
+ return seqs;
+ }
}