From 2ed25b9d62b190d26c2ec68c60d3cf96c5cc1c7c Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Tue, 14 Sep 2021 17:14:23 +0100 Subject: [PATCH] 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 --- src/jalview/gui/StructureViewerBase.java | 21 +++++++++++++++++++- .../ThreeDBStructureChooserQuerySource.java | 5 ++++- 2 files changed, 24 insertions(+), 2 deletions(-) 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); -- 1.7.10.2