From 2dc9a48f09149e6df2a09f7cfb07155bd4429be8 Mon Sep 17 00:00:00 2001 From: jprocter Date: Tue, 13 Oct 2009 15:13:03 +0000 Subject: [PATCH] use Pdb database source for fetching and warn user if PDB reference did not resolve to a record. --- src/jalview/gui/AppJmol.java | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index 2137a80..3b94bf4 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -76,8 +76,10 @@ public class AppJmol extends GStructureViewer implements StructureListener, { this(file, id, seq, ap, loadStatus, bounds, null); } + public AppJmol(String file, String id, SequenceI[] seq, - AlignmentPanel ap, String loadStatus, Rectangle bounds, String viewid) + AlignmentPanel ap, String loadStatus, Rectangle bounds, + String viewid) { loadingFromArchive = true; pdbentry = new PDBEntry(); @@ -315,11 +317,25 @@ public class AppJmol extends GStructureViewer implements StructureListener, { try { - EBIFetchClient ebi = new EBIFetchClient(); - String query = "pdb:" + pdbentry.getId(); - pdbentry.setFile(ebi.fetchDataAsFile(query, "default", "raw") - .getAbsolutePath()); - initJmol("load " + pdbentry.getFile()); + // TODO: replace with reference fetching/transfer code (validate PDBentry as a DBRef?) + jalview.ws.dbsources.Pdb pdbclient = new jalview.ws.dbsources.Pdb(); + AlignmentI pdbseq; + if ((pdbseq=pdbclient.getSequenceRecords(pdbentry.getId())) != null) + { + // just transfer the file name from the first seuqence's first PDBEntry + pdbentry.setFile(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId().elementAt(0)).getFile()); + initJmol("load " + pdbentry.getFile()); + } + else + { + JOptionPane + .showInternalMessageDialog( + Desktop.desktop, + pdbentry.getId() + + " could not be retrieved. Please try downloading the file manually.", + "Couldn't load file", JOptionPane.ERROR_MESSAGE); + + } } catch (OutOfMemoryError oomerror) { new OOMWarning("Retrieving PDB id " + pdbentry.getId() + " from MSD", @@ -379,7 +395,7 @@ public class AppJmol extends GStructureViewer implements StructureListener, * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ public void eps_actionPerformed(ActionEvent e) { @@ -390,7 +406,7 @@ public class AppJmol extends GStructureViewer implements StructureListener, * DOCUMENT ME! * * @param e - * DOCUMENT ME! + * DOCUMENT ME! */ public void png_actionPerformed(ActionEvent e) { @@ -973,12 +989,14 @@ public class AppJmol extends GStructureViewer implements StructureListener, } } } - String viewId=null; + + String viewId = null; + public String getViewId() { - if (viewId==null) + if (viewId == null) { - viewId=System.currentTimeMillis()+"."+this.hashCode(); + viewId = System.currentTimeMillis() + "." + this.hashCode(); } return viewId; } -- 1.7.10.2