JAL-3855 JAL-3829 better checks on PDB or mmCIF file based on URL path (though should...
authorJim Procter <j.procter@dundee.ac.uk>
Tue, 14 Sep 2021 16:14:23 +0000 (17:14 +0100)
committerJim Procter <j.procter@dundee.ac.uk>
Tue, 14 Sep 2021 16:14:23 +0000 (17:14 +0100)
src/jalview/gui/StructureViewerBase.java
src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.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)
     {
index 78dca3f..ff414dd 100644 (file)
@@ -8,6 +8,7 @@ import java.util.Comparator;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
 import java.util.List;
+import java.util.Locale;
 import java.util.Set;
 
 import javax.swing.JTable;
@@ -384,7 +385,9 @@ public class ThreeDBStructureChooserQuerySource
       {
         pdbEntry = new PDBEntry();
         pdbEntry.setId(pdbIdStr);
-        pdbEntry.setType(PDBEntry.Type.MMCIF);
+        boolean hasCif = urlStr.toLowerCase(Locale.ENGLISH).endsWith("cif");
+        boolean probablyPdb = urlStr.toLowerCase(Locale.ENGLISH).contains("pdb");
+        pdbEntry.setType(hasCif ? PDBEntry.Type.MMCIF : probablyPdb ? PDBEntry.Type.PDB : PDBEntry.Type.FILE);
         if (!"PDBe".equalsIgnoreCase(typeColumn))
         {
           pdbEntry.setRetrievalUrl(urlStr);