}
}
- /**
- * DOCUMENT ME!
- *
- * @param v
- * DOCUMENT ME!
- */
+
@Override
public void setSequenceFeatures(SequenceFeature[] features)
{
- sequenceFeatures = features;
+ if (datasetSequence == null)
+ {
+ sequenceFeatures = features;
+ }
+ else
+ {
+ if (datasetSequence.getSequenceFeatures() != features
+ && datasetSequence.getSequenceFeatures() != null
+ && datasetSequence.getSequenceFeatures().length > 0)
+ {
+ new Exception(
+ "Warning: JAL-2046 side effect ? Possible implementation error: overwriting dataset sequence features by setting sequence features on alignment")
+ .printStackTrace();
+ }
+ datasetSequence.setSequenceFeatures(features);
+ }
}
@Override
public synchronized void addSequenceFeature(SequenceFeature sf)
{
- // TODO add to dataset sequence instead if there is one?
+ if (sequenceFeatures==null && datasetSequence != null)
+ {
+ datasetSequence.addSequenceFeature(sf);
+ return;
+ }
if (sequenceFeatures == null)
{
sequenceFeatures = new SequenceFeature[0];
{
if (sequenceFeatures == null)
{
+ if (datasetSequence!=null) {
+ datasetSequence.deleteFeature(sf);
+ }
return;
}
dbrefs = new DBRefEntry[0];
}
- int i, iSize = dbrefs.length;
-
- for (i = 0; i < iSize; i++)
+ for (DBRefEntryI dbr : dbrefs)
{
- if (dbrefs[i].equalRef(entry))
+ if (dbr.updateFrom(entry))
{
- if (entry.getMap() != null)
- {
- if (dbrefs[i].getMap() == null)
- {
- // overwrite with 'superior' entry that contains a mapping.
- dbrefs[i] = entry;
- }
- }
+ /*
+ * found a dbref that either matched, or could be
+ * updated from, the new entry - no need to add it
+ */
return;
}
}
- DBRefEntry[] temp = new DBRefEntry[iSize + 1];
- System.arraycopy(dbrefs, 0, temp, 0, iSize);
+ /*
+ * extend the array to make room for one more
+ */
+ // TODO use an ArrayList instead
+ int j = dbrefs.length;
+ DBRefEntry[] temp = new DBRefEntry[j + 1];
+ System.arraycopy(dbrefs, 0, temp, 0, j);
temp[temp.length - 1] = entry;
dbrefs = temp;
@Override
public SequenceI deriveSequence()
{
- SequenceI seq = new Sequence(this);
- if (datasetSequence != null)
- {
- // duplicate current sequence with same dataset
- seq.setDatasetSequence(datasetSequence);
- }
- else
+ Sequence seq=null;
+ if (datasetSequence == null)
{
if (isValidDatasetSequence())
{
// Use this as dataset sequence
+ seq = new Sequence(getName(), "", 1, -1);
seq.setDatasetSequence(this);
+ seq.initSeqFrom(this, getAnnotation());
+ return seq;
}
else
{
// Create a new, valid dataset sequence
- SequenceI ds = seq;
- ds.setSequence(AlignSeq.extractGaps(
- jalview.util.Comparison.GapChars, new String(sequence)));
- setDatasetSequence(ds);
- ds.setSequenceFeatures(getSequenceFeatures());
- seq = this; // and return this sequence as the derived sequence.
+ createDatasetSequence();
}
}
- return seq;
+ return new Sequence(this);
}
+ private boolean _isNa;
+
+ private long _seqhash = 0;
+
+ @Override
+ public boolean isProtein()
+ {
+ if (datasetSequence != null)
+ {
+ return datasetSequence.isProtein();
+ }
+ if (_seqhash != sequence.hashCode())
+ {
+ _seqhash = sequence.hashCode();
+ _isNa=jalview.util.Comparison.isNucleotide(new SequenceI[] { this });
+ }
+ return !_isNa;
+ };
+
/*
* (non-Javadoc)
*