+ 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
+ }
+
+ /**
+ * sync a jalview alignment seuqence into a vamsas alignment assumes all lock
+ * transformation/bindings have been sorted out before hand. creates/syncs the
+ * vamsas alignment sequence for jvalsq and adds it to the alignment if
+ * necessary. unbounddocseq is a duplicate of the vamsas alignment sequences
+ * and these are removed after being processed w.r.t a bound jvalsq
+ *
+ */
+ private boolean syncToAlignmentSequence(SequenceI jvalsq,
+ Alignment alignment, Vector unbounddocseq)
+ {
+ boolean modal = false;
+ // todo: islocked method here
+ boolean up2doc = false;
+ AlignmentSequence alseq = (AlignmentSequence) getjv2vObj(jvalsq);
+ if (alseq == null)
+ {
+ alseq = new AlignmentSequence();
+ up2doc = true;
+ }
+ else
+ {
+ if (unbounddocseq != null)
+ {
+ unbounddocseq.removeElement(alseq);
+ }
+ }
+ // boolean locked = (alignment.getModifiable()==null ||
+ // alignment.getModifiable().length()>0);
+ // TODO: VAMSAS: translate lowercase symbols to annotation ?
+ if (up2doc || !alseq.getSequence().equals(jvalsq.getSequenceAsString()))
+ {
+ alseq.setSequence(jvalsq.getSequenceAsString());
+ alseq.setStart(jvalsq.getStart());
+ alseq.setEnd(jvalsq.getEnd());
+ modal = true;
+ }
+ if (up2doc || !alseq.getName().equals(jvalsq.getName()))
+ {
+ modal = true;
+ alseq.setName(jvalsq.getName());
+ }
+ if (jvalsq.getDescription() != null && (alseq.getDescription() == null
+ || !jvalsq.getDescription().equals(alseq.getDescription())))
+ {
+ modal = true;
+ alseq.setDescription(jvalsq.getDescription());
+ }
+ if (getjv2vObj(jvalsq.getDatasetSequence()) == null)
+ {
+ Cache.log.warn(
+ "Serious Implementation error - Unbound dataset sequence in alignment: "
+ + jvalsq.getDatasetSequence());
+ }
+ alseq.setRefid(getjv2vObj(jvalsq.getDatasetSequence()));
+ if (up2doc)
+ {
+
+ alignment.addAlignmentSequence(alseq);
+ bindjvvobj(jvalsq, alseq);
+ }
+ return up2doc || modal;
+ }
+
+ /**
+ * locally sync a jalview alignment seuqence from a vamsas alignment assumes
+ * all lock transformation/bindings have been sorted out before hand.
+ * creates/syncs the jvalsq from the alignment sequence
+ */
+ private boolean syncFromAlignmentSequence(AlignmentSequence valseq,
+ char valGapchar, char gapChar, List<SequenceI> dsseqs)
+
+ {
+ boolean modal = false;
+ // todo: islocked method here
+ boolean upFromdoc = false;
+ jalview.datamodel.SequenceI alseq = (SequenceI) getvObj2jv(valseq);
+ if (alseq == null)
+ {
+ upFromdoc = true;
+ }
+ if (alseq != null)
+ {
+
+ // boolean locked = (alignment.getModifiable()==null ||
+ // alignment.getModifiable().length()>0);
+ // TODO: VAMSAS: translate lowercase symbols to annotation ?
+ if (upFromdoc
+ || !valseq.getSequence().equals(alseq.getSequenceAsString()))
+ {
+ // this might go *horribly* wrong
+ alseq.setSequence(new String(valseq.getSequence())
+ .replace(valGapchar, gapChar));
+ alseq.setStart((int) valseq.getStart());
+ alseq.setEnd((int) valseq.getEnd());
+ modal = true;
+ }
+ if (!valseq.getName().equals(alseq.getName()))
+ {
+ modal = true;
+ alseq.setName(valseq.getName());
+ }
+ if (alseq.getDescription() == null || (valseq.getDescription() != null
+ && !alseq.getDescription().equals(valseq.getDescription())))
+ {
+ alseq.setDescription(valseq.getDescription());
+ modal = true;
+ }
+ if (modal && Cache.log.isDebugEnabled())
+ {
+ Cache.log.debug(
+ "Updating apparently edited sequence " + alseq.getName());
+ }
+ }
+ else
+ {
+ alseq = new jalview.datamodel.Sequence(valseq.getName(),
+ valseq.getSequence().replace(valGapchar, gapChar),
+ (int) valseq.getStart(), (int) valseq.getEnd());
+
+ Vobject datsetseq = (Vobject) valseq.getRefid();
+ if (datsetseq != null)
+ {
+ alseq.setDatasetSequence((SequenceI) getvObj2jv(datsetseq)); // exceptions
+ if (valseq.getDescription() != null)
+ {
+ alseq.setDescription(valseq.getDescription());
+ }
+ else
+ {
+ // inherit description line from dataset.
+ if (alseq.getDatasetSequence().getDescription() != null)
+ {
+ alseq.setDescription(
+ alseq.getDatasetSequence().getDescription());
+ }
+ }
+ // if
+ // AlignemntSequence
+ // reference
+ // isn't
+ // a
+ // simple
+ // SequenceI
+ }
+ else
+ {
+ Cache.log.error(
+ "Invalid dataset sequence id (null) for alignment sequence "
+ + valseq.getVorbaId());
+ }
+ bindjvvobj(alseq, valseq);
+ alseq.setVamsasId(valseq.getVorbaId().getId());
+ dsseqs.add(alseq);
+ }
+ Vobject datsetseq = (Vobject) valseq.getRefid();
+ if (datsetseq != null)
+ {
+ if (datsetseq != alseq.getDatasetSequence())
+ {
+ modal = true;
+ }
+ alseq.setDatasetSequence((SequenceI) getvObj2jv(datsetseq)); // exceptions
+ }
+ return upFromdoc || modal;