{
jalview.datamodel.AlignmentI ds = getDatasetFor(
vamsasSet.getDatasetId());
+ AlignmentI xtant_ds = ds;
+ if (xtant_ds == null)
+ {
+ // good chance we are about to create a new dataset, but check if we've
+ // seen some of the dataset sequence IDs before.
+ // TODO: skip this check if we are working with project generated by
+ // version 2.11 or later
+ xtant_ds = checkIfHasDataset(vamsasSet.getSequence());
+ if (xtant_ds != null)
+ {
+ ds = xtant_ds;
+ addDatasetRef(vamsasSet.getDatasetId(), ds);
+ }
+ }
Vector dseqs = null;
if (!ignoreUnrefed)
{
{
warn("JAL-3171 regression: Overwriting a dataset reference for an alignment"
+ " - CDS/Protein crossreference data may be lost");
+ if (xtant_ds != null)
+ {
+ // This can only happen if the unique sequence set ID was bound to a
+ // dataset that did not contain any of the sequences in the view
+ // currently being restored.
+ warn("JAL-3171 SERIOUS! TOTAL CONFUSION - please consider contacting the Jalview Development team so they can investigate why your project caused this message to be displayed.");
+ }
}
ds = seqSetDS;
addDatasetRef(vamsasSet.getDatasetId(), ds);
}
if (ds == null)
{
+ // try even harder to restore dataset
+ AlignmentI xtantDS = checkIfHasDataset(vamsasSet.getSequence());
// create a list of new dataset sequences
dseqs = new Vector();
}
// register dataset for the alignment's uniqueSeqSetId for legacy projects
addDatasetRef(UNIQSEQSETID + uniqueSeqSetId, ds);
}
+ updateSeqDatasetBinding(vamsasSet.getSequence(), ds);
+ }
+
+ /**
+ * XML dataset sequence ID to materialised dataset reference
+ */
+ HashMap<String, AlignmentI> seqToDataset = new HashMap<>();
+
+ /**
+ * @return the first materialised dataset reference containing a dataset
+ * sequence referenced in the given view
+ * @param list
+ * - sequences from the view
+ */
+ AlignmentI checkIfHasDataset(List<Sequence> list)
+ {
+ for (Sequence restoredSeq : list)
+ {
+ AlignmentI datasetFor = seqToDataset.get(restoredSeq.getDsseqid());
+ if (datasetFor != null)
+ {
+ return datasetFor;
+ }
+ }
+ return null;
}
/**
+ * Register ds as the containing dataset for the dataset sequences referenced
+ * by sequences in list
+ *
+ * @param list
+ * - sequences in a view
+ * @param ds
+ */
+ void updateSeqDatasetBinding(List<Sequence> list, AlignmentI ds)
+ {
+ for (Sequence restoredSeq : list)
+ {
+ AlignmentI prevDS = seqToDataset.put(restoredSeq.getDsseqid(), ds);
+ if (prevDS != null && prevDS != ds)
+ {
+ warn("Dataset sequence appears in many datasets: "
+ + restoredSeq.getDsseqid());
+ // TODO: try to merge!
+ }
+ }
+ }
+ /**
*
* @param vamsasSeq
* sequence definition to create/merge dataset sequence for