+
+ /**
+ * remove docseqs from the given alignment marking provenance appropriately
+ * and removing any references to the sequences.
+ *
+ * @param alignment
+ * @param docseqs
+ */
+ private void removeValignmentSequences(Alignment alignment, Vector docseqs)
+ {
+ // delete these from document. This really needs to be a generic document
+ // API function derived by CASTOR.
+ Enumeration en = docseqs.elements();
+ while (en.hasMoreElements())
+ {
+ alignment.removeAlignmentSequence((AlignmentSequence) en
+ .nextElement());
+ }
+ Entry pe = addProvenance(alignment.getProvenance(), "Removed "
+ + docseqs.size() + " sequences");
+ en = alignment.enumerateAlignmentAnnotation();
+ Vector toremove = new Vector();
+ while (en.hasMoreElements())
+ {
+ uk.ac.vamsas.objects.core.AlignmentAnnotation alan = (uk.ac.vamsas.objects.core.AlignmentAnnotation) en
+ .nextElement();
+ if (alan.getSeqrefsCount() > 0)
+ {
+ int p = 0;
+ Vector storem = new Vector();
+ Enumeration sr = alan.enumerateSeqrefs();
+ while (sr.hasMoreElements())
+ {
+ Object alsr = sr.nextElement();
+ if (docseqs.contains(alsr))
+ {
+ storem.addElement(alsr);
+ }
+ }
+ // remove references to the deleted sequences
+ sr = storem.elements();
+ while (sr.hasMoreElements())
+ {
+ alan.removeSeqrefs(sr.nextElement());
+ }
+
+ if (alan.getSeqrefsCount() == 0)
+ {
+ // should then delete alan from dataset
+ toremove.addElement(alan);
+ }
+ }
+ }
+ // remove any annotation that used to be associated to a specific bunch of
+ // sequences
+ en = toremove.elements();
+ while (en.hasMoreElements())
+ {
+ alignment
+ .removeAlignmentAnnotation((uk.ac.vamsas.objects.core.AlignmentAnnotation) en
+ .nextElement());
+ }
+ // TODO: search through alignment annotations to remove any references to
+ // this alignment sequence
+ }
+