beginning of fix for embl/cds/highlighting IO in https://mantis.lifesci.dundee.ac...
authorjprocter <Jim Procter>
Tue, 19 Aug 2008 13:36:34 +0000 (13:36 +0000)
committerjprocter <Jim Procter>
Tue, 19 Aug 2008 13:36:34 +0000 (13:36 +0000)
src/jalview/gui/Jalview2XML.java

index 97dfefd..ebf7aba 100755 (executable)
@@ -122,15 +122,40 @@ public class Jalview2XML
             }
             else
             {
-              System.err
-                      .println("IMPLEMENTATION ERROR: Unimplemented forward sequence references for "
-                              + ref[1].getClass() + " type objects.");
+              if (ref[1] instanceof jalview.datamodel.AlignedCodonFrame)
+              {
+                SequenceI seq = (SequenceI) seqRefIds.get(sref);
+                while (seq.getDatasetSequence() != null)
+                {
+                  seq = seq.getDatasetSequence();
+                }
+                if (ref[2] != null
+                        && ref[2] instanceof jalview.datamodel.Mapping)
+                {
+                  jalview.datamodel.Mapping mp = (jalview.datamodel.Mapping) ref[2];
+                  ((jalview.datamodel.AlignedCodonFrame) ref[1]).addMap(
+                          seq, mp.getTo(), mp.getMap());
+                }
+                else
+                {
+                  System.err
+                          .println("IMPLEMENTATION ERROR: Unimplemented forward sequence references for AlcodonFrames involving "
+                                  + ref[2].getClass() + " type objects.");
+                }
+              }
+              else
+              {
+                System.err
+                        .println("IMPLEMENTATION ERROR: Unimplemented forward sequence references for "
+                                + ref[1].getClass() + " type objects.");
+              }
+              frefedSequence.remove(r);
+              rSize--;
             }
-            frefedSequence.remove(r);
-            rSize--;
           }
           else
           {
+            System.err.println("IMPLEMENTATION WARNING: Unresolved forward reference for hash string "+ref[0]+" with objecttype "+ref[1].getClass());
             r++;
           }
         }
@@ -1575,15 +1600,19 @@ public class Jalview2XML
             SequenceI dnaseq = (SequenceI) seqRefIds
                     .get(maps[m].getDnasq());
             // Load Mapping
+            jalview.datamodel.Mapping mapping = null;
             // attach to dna sequence reference.
+            if (maps[m].getMapping() != null)
+            {
+              mapping = addMapping(maps[m]
+                      .getMapping());
+            }
             if (dnaseq != null)
             {
-              if (maps[m].getMapping() != null)
-              {
-                jalview.datamodel.Mapping mapping = addMapping(maps[m]
-                        .getMapping());
                 cf.addMap(dnaseq, mapping.getTo(), mapping.getMap());
-              }
+            } else {
+              // defer to later
+              frefedSequence.add(new Object[] { maps[m].getDnasq(), cf, mapping});
             }
           }
         }
@@ -2259,6 +2288,7 @@ public class Jalview2XML
    */
   private void ensureJalviewDatasetSequence(Sequence vamsasSeq, AlignmentI ds, Vector dseqs)
   {
+    // JBP TODO: Check this is called for AlCodonFrames to support recovery of xRef Codon Maps
     jalview.datamodel.Sequence sq = (jalview.datamodel.Sequence) seqRefIds.get(vamsasSeq.getId());
     jalview.datamodel.SequenceI dsq = null;
     if (sq!=null && sq.getDatasetSequence()!=null)