Use id hash to add pdb mappings back to alignment
authoramwaterhouse <Andrew Waterhouse>
Mon, 7 May 2007 13:58:17 +0000 (13:58 +0000)
committeramwaterhouse <Andrew Waterhouse>
Mon, 7 May 2007 13:58:17 +0000 (13:58 +0000)
src/jalview/gui/Jalview2XML.java

index 48ba7f0..9bf6a21 100755 (executable)
@@ -986,6 +986,8 @@ public class Jalview2XML
 
     Hashtable gatherToThisFrame = new Hashtable();
 
+    String errorMessage = null;
+
     try
     {
       //UNMARSHALLER SEEMS TO CLOSE JARINPUTSTREAM, MOST ANNOYING
@@ -1040,22 +1042,19 @@ public class Jalview2XML
       }
       while (jarentry != null);
     }
+    catch(java.io.FileNotFoundException ex)
+    {
+      ex.printStackTrace();
+      errorMessage = "Couldn't locate Jalview XML file : "+file;
+      System.err.println("Exception whilst loading jalview XML file : " +
+                         ex + "\n");
+    }
     catch (java.net.UnknownHostException ex)
     {
       ex.printStackTrace();
-      System.err.println("Couldn't locate Jalview XML file : " +
+      errorMessage = "Couldn't locate Jalview XML file : " +file;
+      System.err.println("Exception whilst loading jalview XML file : " +
                          ex + "\n");
-
-      javax.swing.SwingUtilities.invokeLater(new Runnable()
-      {
-        public void run()
-        {
-          JOptionPane.showInternalMessageDialog(Desktop.desktop,
-                                                "Couldn't locate " + file,
-                                                "URL not found",
-                                                JOptionPane.WARNING_MESSAGE);
-        }
-      });
     }
     catch (Exception ex)
     {
@@ -1071,17 +1070,6 @@ public class Jalview2XML
 
       System.err.println("Exception whilst loading jalview XML file : " +
                          ex + "\n");
-      javax.swing.SwingUtilities.invokeLater(new Runnable()
-      {
-        public void run()
-        {
-
-          JOptionPane.showInternalMessageDialog(Desktop.desktop,
-                                                "Error loading  " + file,
-                                                "Error loading Jalview file",
-                                                JOptionPane.WARNING_MESSAGE);
-        }
-      });
     }
 
     if (Desktop.instance != null)
@@ -1096,6 +1084,21 @@ public class Jalview2XML
           (AlignFrame) en.nextElement());
     }
 
+    if(errorMessage!=null)
+    {
+      final String finalErrorMessage = errorMessage;
+      javax.swing.SwingUtilities.invokeLater(new Runnable()
+      {
+        public void run()
+        {
+          JOptionPane.showInternalMessageDialog(Desktop.desktop,
+                                                finalErrorMessage,
+                                                "Error loading Jalview file",
+                                                JOptionPane.WARNING_MESSAGE);
+        }
+      });
+    }
+
     return af;
   }
 
@@ -1906,9 +1909,11 @@ public class Jalview2XML
 
               String pdbFile = loadPDBFile(file, ids[p].getId());
 
-              jalview.datamodel.SequenceI[] seq = new jalview.datamodel.SequenceI[]
+              jalview.datamodel.SequenceI[] seq = new jalview.datamodel.
+                  SequenceI[]
                   {
-                  al.getSequenceAt(i)};
+                   (jalview.datamodel.SequenceI)
+                  seqRefIds.get(JSEQ[i].getId()+"")};
 
 
               if (comp == null)