*really* make sure database references are stored and recovered for all sequences
authorjprocter <Jim Procter>
Thu, 30 Aug 2007 22:44:17 +0000 (22:44 +0000)
committerjprocter <Jim Procter>
Thu, 30 Aug 2007 22:44:17 +0000 (22:44 +0000)
src/jalview/gui/Jalview2XML.java

index 62a05df..aab41ca 100755 (executable)
@@ -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" : ""));
     }
   }