From 2574bf4ab96840e3e064a0e4de521973fd299edc Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 14 Dec 2018 15:09:22 +0000 Subject: [PATCH] =?utf8?q?JAL-3171=20resolve=20dataset=20for=20imported=20pr?= =?utf8?q?ojects=20via=20the=20alignment=E2=80=99s=20SequenceSetId?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/jalview/gui/Jalview2XML.java | 53 ++++++++++++++++++++++++++++------ src/jalview/project/Jalview2XML.java | 53 ++++++++++++++++++++++++++++------ 2 files changed, 88 insertions(+), 18 deletions(-) diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index edadf75..5cd8f9a 100644 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -169,6 +169,12 @@ public class Jalview2XML private static final String UTF_8 = "UTF-8"; + /** + * prefix for recovering datasets for alignments with multiple views where + * non-existent dataset IDs were written for some views + */ + private static final String UNIQSEQSETID = "uniqueSeqSetId."; + // use this with nextCounter() to make unique names for entities private int counter = 0; @@ -2868,6 +2874,28 @@ public class Jalview2XML : null; // //////////////////////////////// + // INITIALISE ALIGNMENT SEQUENCESETID AND VIEWID + // + // + // If we just load in the same jar file again, the sequenceSetId + // will be the same, and we end up with multiple references + // to the same sequenceSet. We must modify this id on load + // so that each load of the file gives a unique id + + /** + * used to resolve correct alignment dataset for alignments with multiple + * views + */ + String uniqueSeqSetId = null; + String viewId = null; + if (view != null) + { + uniqueSeqSetId = view.getSequenceSetId() + uniqueSetSuffix; + viewId = (view.getId() == null ? null + : view.getId() + uniqueSetSuffix); + } + + // //////////////////////////////// // LOAD SEQUENCES List hiddenSeqs = null; @@ -2985,7 +3013,7 @@ public class Jalview2XML // finally, verify all data in vamsasSet is actually present in al // passing on flag indicating if it is actually a stored dataset - recoverDatasetFor(vamsasSet, al, isdsal); + recoverDatasetFor(vamsasSet, al, isdsal, uniqueSeqSetId); } if (referenceseqForView != null) @@ -3533,13 +3561,6 @@ public class Jalview2XML // /////////////////////////////// // LOAD VIEWPORT - // If we just load in the same jar file again, the sequenceSetId - // will be the same, and we end up with multiple references - // to the same sequenceSet. We must modify this id on load - // so that each load of the file gives a unique id - String uniqueSeqSetId = view.getSequenceSetId() + uniqueSetSuffix; - String viewId = (view.getId() == null ? null - : view.getId() + uniqueSetSuffix); AlignFrame af = null; AlignViewport av = null; // now check to see if we really need to create a new viewport. @@ -5083,13 +5104,25 @@ public class Jalview2XML } private void recoverDatasetFor(SequenceSet vamsasSet, AlignmentI al, - boolean ignoreUnrefed) + boolean ignoreUnrefed, String uniqueSeqSetId) { jalview.datamodel.AlignmentI ds = getDatasetFor( vamsasSet.getDatasetId()); Vector dseqs = null; if (ds == null) { + if (!ignoreUnrefed) + { + // try to resolve the dataset via uniqueSeqSetId + ds = getDatasetFor(UNIQSEQSETID + uniqueSeqSetId); + if (ds != null) + { + addDatasetRef(vamsasSet.getDatasetId(), ds); + } + } + } + if (ds == null) + { // create a list of new dataset sequences dseqs = new Vector(); } @@ -5112,6 +5145,8 @@ public class Jalview2XML if (al.getDataset() == null && !ignoreUnrefed) { al.setDataset(ds); + // register dataset for the alignment's uniqueSeqSetId for legacy projects + addDatasetRef(UNIQSEQSETID + uniqueSeqSetId, ds); } } diff --git a/src/jalview/project/Jalview2XML.java b/src/jalview/project/Jalview2XML.java index c461210..8c3175f 100644 --- a/src/jalview/project/Jalview2XML.java +++ b/src/jalview/project/Jalview2XML.java @@ -192,6 +192,12 @@ public class Jalview2XML private static final String UTF_8 = "UTF-8"; + /** + * prefix for recovering datasets for alignments with multiple views where + * non-existent dataset IDs were written for some views + */ + private static final String UNIQSEQSETID = "uniqueSeqSetId."; + // use this with nextCounter() to make unique names for entities private int counter = 0; @@ -3030,6 +3036,28 @@ public class Jalview2XML : null; // //////////////////////////////// + // INITIALISE ALIGNMENT SEQUENCESETID AND VIEWID + // + // + // If we just load in the same jar file again, the sequenceSetId + // will be the same, and we end up with multiple references + // to the same sequenceSet. We must modify this id on load + // so that each load of the file gives a unique id + + /** + * used to resolve correct alignment dataset for alignments with multiple + * views + */ + String uniqueSeqSetId = null; + String viewId = null; + if (view != null) + { + uniqueSeqSetId = view.getSequenceSetId() + uniqueSetSuffix; + viewId = (view.getId() == null ? null + : view.getId() + uniqueSetSuffix); + } + + // //////////////////////////////// // LOAD SEQUENCES List hiddenSeqs = null; @@ -3150,7 +3178,7 @@ public class Jalview2XML // finally, verify all data in vamsasSet is actually present in al // passing on flag indicating if it is actually a stored dataset - recoverDatasetFor(vamsasSet, al, isdsal); + recoverDatasetFor(vamsasSet, al, isdsal, uniqueSeqSetId); } if (referenceseqForView != null) @@ -3690,13 +3718,6 @@ public class Jalview2XML // /////////////////////////////// // LOAD VIEWPORT - // If we just load in the same jar file again, the sequenceSetId - // will be the same, and we end up with multiple references - // to the same sequenceSet. We must modify this id on load - // so that each load of the file gives a unique id - String uniqueSeqSetId = view.getSequenceSetId() + uniqueSetSuffix; - String viewId = (view.getId() == null ? null - : view.getId() + uniqueSetSuffix); AlignFrame af = null; AlignViewport av = null; // now check to see if we really need to create a new viewport. @@ -5195,13 +5216,25 @@ public class Jalview2XML } private void recoverDatasetFor(SequenceSet vamsasSet, AlignmentI al, - boolean ignoreUnrefed) + boolean ignoreUnrefed, String uniqueSeqSetId) { jalview.datamodel.AlignmentI ds = getDatasetFor( vamsasSet.getDatasetId()); Vector dseqs = null; if (ds == null) { + if (!ignoreUnrefed) + { + // try to resolve the dataset via uniqueSeqSetId + ds = getDatasetFor(UNIQSEQSETID + uniqueSeqSetId); + if (ds != null) + { + addDatasetRef(vamsasSet.getDatasetId(), ds); + } + } + } + if (ds == null) + { // create a list of new dataset sequences dseqs = new Vector(); } @@ -5224,6 +5257,8 @@ public class Jalview2XML if (al.getDataset() == null && !ignoreUnrefed) { al.setDataset(ds); + // register dataset for the alignment's uniqueSeqSetId for legacy projects + addDatasetRef(UNIQSEQSETID + uniqueSeqSetId, ds); } } -- 1.7.10.2