HiddenSequences hiddenSequences = new HiddenSequences(this);
+ public Hashtable alignmentProperties;
+
private void initAlignment(SequenceI[] seqs)
{
int i = 0;
{
if (dataset != null)
{
+ // maintain dataset integrity
if (snew.getDatasetSequence() != null)
{
getDataset().addSequence(snew.getDatasetSequence());
}
else
{
- Sequence ds = new Sequence(snew.getName(),
- AlignSeq.extractGaps("-. ",
- snew.getSequenceAsString()),
- snew.getStart(),
- snew.getEnd());
-
- snew.setDatasetSequence(ds);
- getDataset().addSequence(ds);
+ // derive new sequence
+ SequenceI adding = snew.deriveSequence();
+ getDataset().addSequence(adding.getDatasetSequence());
+ snew = adding;
}
}
- sequences.addElement(snew);
-
- hiddenSequences.adjustHeightSequenceAdded();
+ if (sequences==null) {
+ initAlignment(new SequenceI[] { snew });
+ } else {
+ sequences.addElement(snew);
+ }
+ if (hiddenSequences!=null)
+ hiddenSequences.adjustHeightSequenceAdded();
}
/** Adds a sequence to the alignment. Recalculates maxLength and size.
return groups;
}
- public void destroyAlignment()
+ public void finalize()
{
if(getDataset()!=null)
- getDataset().destroyAlignment();
+ getDataset().finalize();
dataset = null;
sequences = null;
return true;
}
-
- /**
- * DOCUMENT ME!
- *
- * @param aa DOCUMENT ME!
+ /* (non-Javadoc)
+ * @see jalview.datamodel.AlignmentI#deleteAnnotation(jalview.datamodel.AlignmentAnnotation)
*/
- public void deleteAnnotation(AlignmentAnnotation aa)
+ public boolean deleteAnnotation(AlignmentAnnotation aa)
{
int aSize = 1;
if (aSize < 1)
{
- return;
+ return false;
}
AlignmentAnnotation[] temp = new AlignmentAnnotation[aSize - 1];
+ boolean swap=false;
int tIndex = 0;
- for (int i = 0; i < aSize; i++)
+ for (int i = 0; tIndex<temp.length && i < aSize; i++)
{
if (annotations[i] == aa)
{
+ swap=true;
continue;
}
tIndex++;
}
- annotations = temp;
+ if (swap)
+ {
+ annotations = temp;
+ if(aa.sequenceRef!=null)
+ aa.sequenceRef.removeAlignmentAnnotation(aa);
+ }
+ return swap;
}
/**
return cal;
}
+ public void setProperty(Object key, Object value)
+ {
+ if(alignmentProperties==null)
+ alignmentProperties = new Hashtable();
+
+ alignmentProperties.put(key,value);
+ }
+
+ public Object getProperty(Object key)
+ {
+ if(alignmentProperties!=null)
+ return alignmentProperties.get(key);
+ else
+ return null;
+ }
+
+ public Hashtable getProperties()
+ {
+ return alignmentProperties;
+ }
+
}