JAL-3855 JAL-3829 better checks on PDB or mmCIF file based on URL path (though should...
[jalview.git] / src / jalview / gui / StructureViewerBase.java
index 11bf50f..021e2f6 100644 (file)
@@ -65,6 +65,7 @@ import jalview.util.BrowserLauncher;
 import jalview.util.MessageManager;
 import jalview.ws.dbsources.EBIAlfaFold;
 import jalview.ws.dbsources.Pdb;
+import jalview.ws.utils.UrlDownloadClient;
 
 /**
  * Base class with common functionality for JMol, Chimera or other structure
@@ -1153,7 +1154,25 @@ public abstract class StructureViewerBase extends GStructureViewer
       {
         pdbseq = afclient.getSequenceRecords(pdbid);
       } else {
-        pdbseq = pdbclient.getSequenceRecords(pdbid);
+          if (processingEntry.hasRetrievalUrl())
+          {
+            // retrieve from URL to new local tmpfile
+            File tmpFile = File.createTempFile(pdbid,
+                    "." + (PDBEntry.Type.MMCIF.toString().equals(
+                            processingEntry.getType().toString()) ? "cif"
+                                    : "pdb"));
+            String fromUrl = processingEntry.getRetrievalUrl();
+            UrlDownloadClient.download(fromUrl, tmpFile);
+            
+            // may not need this check ?
+            String file = tmpFile.getAbsolutePath();
+            if (file != null)
+            {
+              pdbseq = EBIAlfaFold.importDownloadedStructureFromUrl(fromUrl,tmpFile,pdbid,null,null,null);
+            }
+          } else {
+            pdbseq = pdbclient.getSequenceRecords(pdbid);
+          }
       }
     } catch (Exception e)
     {