import jalview.util.StringUtils;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import java.util.Vector;
protected void initSeqFrom(SequenceI seq,
AlignmentAnnotation[] alAnnotation)
{
- initSeqAndName(seq.getName(), seq.getSequence(), seq.getStart(),
+ {
+ char[] oseq = seq.getSequence();
+ initSeqAndName(seq.getName(), Arrays.copyOf(oseq, oseq.length),
+ seq.getStart(),
seq.getEnd());
+ }
description = seq.getDescription();
- sourceDBRef = seq.getSourceDBRef();
+ sourceDBRef = seq.getSourceDBRef() == null ? null : new DBRefEntry(
+ seq.getSourceDBRef());
if (seq.getSequenceFeatures() != null)
{
SequenceFeature[] sf = seq.getSequenceFeatures();
@Override
public Vector<PDBEntry> getAllPDBEntries()
{
- return pdbIds;
+ return pdbIds == null ? new Vector<PDBEntry>() : pdbIds;
}
/**
}
/**
- * DOCUMENT ME!
- *
- * @param i
- * DOCUMENT ME!
+ * Returns the character of the aligned sequence at the given position (base
+ * zero), or space if the position is not within the sequence's bounds
*
- * @return DOCUMENT ME!
+ * @return
*/
@Override
public char getCharAt(int i)
{
- if (i < sequence.length)
+ if (i >= 0 && i < sequence.length)
{
return sequence[i];
}
{
if (datasetSequence == null)
{
- datasetSequence = new Sequence(getName(), AlignSeq.extractGaps(
+ Sequence dsseq = new Sequence(getName(), AlignSeq.extractGaps(
jalview.util.Comparison.GapChars, getSequenceAsString()),
getStart(), getEnd());
- datasetSequence.setSequenceFeatures(getSequenceFeatures());
- datasetSequence.setDescription(getDescription());
- setSequenceFeatures(null);
- // move database references onto dataset sequence
- datasetSequence.setDBRefs(getDBRefs());
- setDBRefs(null);
- datasetSequence.setPDBId(getAllPDBEntries());
- setPDBId(null);
+
+ datasetSequence = dsseq;
+
+ dsseq.setDescription(description);
+ // move features and database references onto dataset sequence
+ dsseq.sequenceFeatures = sequenceFeatures;
+ sequenceFeatures=null;
+ dsseq.dbrefs = dbrefs;
+ dbrefs=null;
+ // TODO: search and replace any references to this sequence with
+ // references to the dataset sequence in Mappings on dbref
+ dsseq.pdbIds = pdbIds;
+ pdbIds = null;
datasetSequence.updatePDBIds();
if (annotation != null)
{
+ // annotation is cloned rather than moved, to preserve what's currently
+ // on the alignment
for (AlignmentAnnotation aa : annotation)
{
AlignmentAnnotation _aa = new AlignmentAnnotation(aa);