From: Jim Procter Date: Tue, 14 Sep 2021 16:14:23 +0000 (+0100) Subject: JAL-3855 JAL-3829 better checks on PDB or mmCIF file based on URL path (though should... X-Git-Tag: Release_2_11_2_0~37^2^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2ed25b9d62b190d26c2ec68c60d3cf96c5cc1c7c;p=jalview.git JAL-3855 JAL-3829 better checks on PDB or mmCIF file based on URL path (though should really determine when processing via jmolData now we have mechanism) - ChimeraX in particular cares about file endings --- diff --git a/src/jalview/gui/StructureViewerBase.java b/src/jalview/gui/StructureViewerBase.java index 11bf50f..021e2f6 100644 --- a/src/jalview/gui/StructureViewerBase.java +++ b/src/jalview/gui/StructureViewerBase.java @@ -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) { diff --git a/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java b/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java index 78dca3f..ff414dd 100644 --- a/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java +++ b/src/jalview/gui/structurechooser/ThreeDBStructureChooserQuerySource.java @@ -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);