From 56dd43fe89054d7e5c18a8145fe9dbc6f6ea7a9f Mon Sep 17 00:00:00 2001 From: jprocter Date: Thu, 30 Aug 2007 22:44:17 +0000 Subject: [PATCH] *really* make sure database references are stored and recovered for all sequences --- src/jalview/gui/Jalview2XML.java | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/jalview/gui/Jalview2XML.java b/src/jalview/gui/Jalview2XML.java index 62a05df..aab41ca 100755 --- a/src/jalview/gui/Jalview2XML.java +++ b/src/jalview/gui/Jalview2XML.java @@ -967,9 +967,10 @@ public class Jalview2XML } else { + vamsasSeq.setDsseqid(id + ""); // so we can tell which sequences really are dataset sequences only dbrefs = jds.getDBRef(); } - if (jds.getDBRef() != null) + if (dbrefs != null) { for (int d = 0; d < dbrefs.length; d++) { @@ -2203,23 +2204,28 @@ public class Jalview2XML ds.addSequence(dsq); } } else { - // make this dataset sequence sq's dataset sequence - sq.setDatasetSequence(dsq); + if (sq!=dsq) + { // make this dataset sequence sq's dataset sequence + sq.setDatasetSequence(dsq); + } } } // TODO: refactor this as a merge dataset sequence function // now check that sq (the dataset sequence) sequence really is the union of all references to it - boolean pre = sq.getStart() < dsq.getStart(); - boolean post = sq.getEnd() > dsq.getEnd(); - if (pre || post) + //boolean pre = sq.getStart() < dsq.getStart(); + //boolean post = sq.getEnd() > dsq.getEnd(); + //if (pre || post) + if (sq!=dsq) { StringBuffer sb = new StringBuffer(); String newres = jalview.analysis.AlignSeq.extractGaps( jalview.util.Comparison.GapChars, sq.getSequenceAsString()); - synchronized (dsq) + if (!newres.equalsIgnoreCase(dsq.getSequenceAsString()) && newres.length()>dsq.getLength()) { - sb.append(dsq.getSequence()); - if (pre) + // Update with the longer sequence. + synchronized (dsq) + { + /*if (pre) { sb.insert(0, newres .substring(0, dsq.getStart() - sq.getStart())); @@ -2231,12 +2237,15 @@ public class Jalview2XML - dsq.getEnd())); dsq.setEnd(sq.getEnd()); } + */ dsq.setSequence(sb.toString()); + } + //TODO: merges will never happen if we 'know' we have the real dataset sequence - this should be detected when id==dssid + System.err + .println("DEBUG Notice: Merged dataset sequence"); // (" + // + (pre ? "prepended" : "") + " " + //+ (post ? "appended" : "")); } - System.err - .println("DEBUG Notice: Merged dataset sequence (" - + (pre ? "prepended" : "") + " " - + (post ? "appended" : "")); } } -- 1.7.10.2