+ synchronized (sequences)
+ {
+ SeqCigar alseqs[] = new SeqCigar[sequences.size()];
+ int i = 0;
+ for (SequenceI seq : sequences)
+ {
+ alseqs[i++] = new SeqCigar(seq);
+ }
+ CigarArray cal = new CigarArray(alseqs);
+ cal.addOperation(CigarArray.M, getWidth());
+ return cal;
+ }
+ }
+
+ @Override
+ public void setProperty(Object key, Object value)
+ {
+ if (alignmentProperties == null)
+ {
+ alignmentProperties = new Hashtable();
+ }
+
+ alignmentProperties.put(key, value);
+ }
+
+ @Override
+ public Object getProperty(Object key)
+ {
+ if (alignmentProperties != null)
+ {
+ return alignmentProperties.get(key);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ @Override
+ public Hashtable getProperties()
+ {
+ return alignmentProperties;
+ }
+
+ AlignedCodonFrame[] codonFrameList = null;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.datamodel.AlignmentI#addCodonFrame(jalview.datamodel.AlignedCodonFrame
+ * )
+ */
+ @Override
+ public void addCodonFrame(AlignedCodonFrame codons)
+ {
+ if (codons == null)
+ {
+ return;
+ }
+ if (codonFrameList == null)
+ {
+ codonFrameList = new AlignedCodonFrame[]
+ { codons };
+ return;
+ }
+ AlignedCodonFrame[] t = new AlignedCodonFrame[codonFrameList.length + 1];
+ System.arraycopy(codonFrameList, 0, t, 0, codonFrameList.length);
+ t[codonFrameList.length] = codons;
+ codonFrameList = t;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see jalview.datamodel.AlignmentI#getCodonFrame(int)
+ */
+ @Override
+ public AlignedCodonFrame getCodonFrame(int index)
+ {
+ return codonFrameList[index];
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * jalview.datamodel.AlignmentI#getCodonFrame(jalview.datamodel.SequenceI)
+ */
+ @Override
+ public AlignedCodonFrame[] getCodonFrame(SequenceI seq)
+ {
+ if (seq == null || codonFrameList == null)
+ {
+ return null;
+ }
+ Vector cframes = new Vector();
+ for (int f = 0; f < codonFrameList.length; f++)
+ {
+ if (codonFrameList[f].involvesSequence(seq))
+ {
+ cframes.addElement(codonFrameList[f]);
+ }
+ }
+ if (cframes.size() == 0)
+ {
+ return null;
+ }
+ AlignedCodonFrame[] cfr = new AlignedCodonFrame[cframes.size()];
+ cframes.copyInto(cfr);
+ return cfr;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see jalview.datamodel.AlignmentI#getCodonFrames()
+ */
+ @Override
+ public AlignedCodonFrame[] getCodonFrames()
+ {
+ return codonFrameList;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seejalview.datamodel.AlignmentI#removeCodonFrame(jalview.datamodel.
+ * AlignedCodonFrame)
+ */
+ @Override
+ public boolean removeCodonFrame(AlignedCodonFrame codons)
+ {
+ if (codons == null || codonFrameList == null)
+ {
+ return false;
+ }
+ boolean removed = false;
+ int i = 0, iSize = codonFrameList.length;
+ while (i < iSize)
+ {
+ if (codonFrameList[i] == codons)
+ {
+ removed = true;
+ if (i + 1 < iSize)
+ {
+ System.arraycopy(codonFrameList, i + 1, codonFrameList, i, iSize
+ - i - 1);
+ }
+ iSize--;
+ }
+ else
+ {
+ i++;
+ }
+ }
+ return removed;
+ }
+
+ @Override
+ public void append(AlignmentI toappend)
+ {
+ if (toappend == this)
+ {
+ System.err.println("Self append may cause a deadlock.");
+ }
+ // TODO test this method for a future 2.5 release
+ // currently tested for use in jalview.gui.SequenceFetcher
+ boolean samegap = toappend.getGapCharacter() == getGapCharacter();
+ char oldc = toappend.getGapCharacter();
+ boolean hashidden = toappend.getHiddenSequences() != null
+ && toappend.getHiddenSequences().hiddenSequences != null;
+ // get all sequences including any hidden ones
+ List<SequenceI> sqs = (hashidden) ? toappend.getHiddenSequences()
+ .getFullAlignment().getSequences() : toappend.getSequences();
+ if (sqs != null)
+ {
+ synchronized (sqs)
+ {
+ for (SequenceI addedsq : sqs)
+ {
+ if (!samegap)
+ {
+ char[] oldseq = addedsq.getSequence();
+ for (int c = 0; c < oldseq.length; c++)
+ {
+ if (oldseq[c] == oldc)
+ {
+ oldseq[c] = gapCharacter;
+ }
+ }
+ }
+ addSequence(addedsq);
+ }
+ }
+ }
+ AlignmentAnnotation[] alan = toappend.getAlignmentAnnotation();
+ for (int a = 0; alan != null && a < alan.length; a++)
+ {
+ addAnnotation(alan[a]);
+ }
+ AlignedCodonFrame[] acod = toappend.getCodonFrames();
+ for (int a = 0; acod != null && a < acod.length; a++)