package jalview.datamodel;
import jalview.analysis.AlignSeq;
+import jalview.api.DBRefEntryI;
import jalview.util.StringUtils;
import java.util.ArrayList;
String vamsasId;
+ DBRefEntryI sourceDBRef;
+
DBRefEntry[] dbrefs;
RNA rna;
initSeqAndName(seq.getName(), seq.getSequence(), seq.getStart(),
seq.getEnd());
description = seq.getDescription();
+ sourceDBRef = seq.getSourceDBRef() == null ? null : new DBRefEntry(
+ seq.getSourceDBRef());
if (seq.getSequenceFeatures() != null)
{
SequenceFeature[] sf = seq.getSequenceFeatures();
}
}
setDatasetSequence(seq.getDatasetSequence());
- if (datasetSequence == null && seq.getDBRef() != null)
+ if (datasetSequence == null && seq.getDBRefs() != null)
{
// only copy DBRefs if we really are a dataset sequence
- DBRefEntry[] dbr = seq.getDBRef();
+ DBRefEntry[] dbr = seq.getDBRefs();
for (int i = 0; i < dbr.length; i++)
{
addDBRef(new DBRefEntry(dbr[i]));
@Override
public synchronized void addSequenceFeature(SequenceFeature sf)
{
+ // TODO add to dataset sequence instead if there is one?
if (sequenceFeatures == null)
{
sequenceFeatures = new SequenceFeature[0];
@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];
}
}
@Override
- public void setDBRef(DBRefEntry[] dbref)
+ public void setDBRefs(DBRefEntry[] dbref)
{
dbrefs = dbref;
}
@Override
- public DBRefEntry[] getDBRef()
+ public DBRefEntry[] getDBRefs()
{
if (dbrefs == null && datasetSequence != null
&& this != datasetSequence)
{
- return datasetSequence.getDBRef();
+ return datasetSequence.getDBRefs();
}
return dbrefs;
}
@Override
public void addDBRef(DBRefEntry entry)
{
+ // TODO add to dataset sequence instead if there is one?
if (dbrefs == null)
{
dbrefs = new DBRefEntry[0];
{
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.setDBRef(getDBRef());
- setDBRef(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);
}
}
// transfer database references
- DBRefEntry[] entryRefs = entry.getDBRef();
+ DBRefEntry[] entryRefs = entry.getDBRefs();
if (entryRefs != null)
{
for (int r = 0; r < entryRefs.length; r++)
return null;
}
+ @Override
+ public void setSourceDBRef(DBRefEntryI dbRef)
+ {
+ this.sourceDBRef = dbRef;
+ }
+
+ @Override
+ public DBRefEntryI getSourceDBRef()
+ {
+ return this.sourceDBRef;
+ }
+
}