X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FMCview%2FPDBViewer.java;h=5b30043cbdba2fc97308bae432c536b0ef79a367;hb=a8f483d04205bb8273ee311c12968b7e86d205fa;hp=b44dece35d5e86f917524199ce2e3fd50a1587b5;hpb=1419df7e52f4f2fb923eb5d026ecd39ded424519;p=jalview.git diff --git a/src/MCview/PDBViewer.java b/src/MCview/PDBViewer.java index b44dece..5b30043 100755 --- a/src/MCview/PDBViewer.java +++ b/src/MCview/PDBViewer.java @@ -1,83 +1,90 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2) + * Copyright (C) 2014 The Jalview Authors + * + * This file is part of Jalview. + * + * Jalview is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. + * + * Jalview is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with Jalview. If not, see . + * The Jalview Authors are detailed in the 'AUTHORS' file. */ package MCview; import java.io.*; -import java.awt.*; import java.awt.event.*; import javax.swing.*; -import java.util.BitSet; import jalview.datamodel.*; import jalview.gui.*; import jalview.io.*; import jalview.schemes.*; +import jalview.util.MessageManager; +import jalview.ws.ebi.EBIFetchClient; -import org.jmol.api.*; -import org.jmol.adapter.smarter.SmarterJmolAdapter; -import org.jmol.util.Logger; -import org.jmol.popup.*; - -public class PDBViewer - extends JInternalFrame implements Runnable +public class PDBViewer extends JInternalFrame implements Runnable { - PDBEntry pdb; + /** * The associated sequence in an alignment */ - Sequence sequence; PDBCanvas pdbcanvas; + + PDBEntry pdbentry; + + SequenceI[] seq; + + String[] chains; + + AlignmentPanel ap; + + String protocol; + String tmpPDBFile; - public PDBViewer(PDBEntry entry, - Sequence seq, - SeqCanvas seqcanvas) + public PDBViewer(PDBEntry pdbentry, SequenceI[] seq, String[] chains, + AlignmentPanel ap, String protocol) { - /* try + this.pdbentry = pdbentry; + this.seq = seq; + this.chains = chains; + this.ap = ap; + this.protocol = protocol; + + try { jbInit(); - } - catch (Exception ex) + } catch (Exception ex) { ex.printStackTrace(); } - if (entry == null) - { - return; - } - pdb = entry; - sequence = seq; - pdbcanvas = new PDBCanvas(seqcanvas, sequence); + StringBuffer title = new StringBuffer(seq[0].getName() + ":" + + pdbentry.getFile()); + + pdbcanvas = new PDBCanvas(); - if (pdb.getFile() != null) + setContentPane(pdbcanvas); + + if (pdbentry.getFile() != null) { try { - tmpPDBFile = pdb.getFile(); + tmpPDBFile = pdbentry.getFile(); PDBfile pdbfile = new PDBfile(tmpPDBFile, - jalview.io.AppletFormatAdapter.FILE); - pdbcanvas.setPDBFile(pdbfile); + jalview.io.AppletFormatAdapter.FILE); - } - catch (java.io.IOException ex) + pdbcanvas.init(pdbentry, seq, chains, ap, protocol); + + } catch (java.io.IOException ex) { ex.printStackTrace(); } @@ -88,282 +95,41 @@ public class PDBViewer worker.start(); } - public void run() - { - try - { - EBIFetchClient ebi = new EBIFetchClient(); - String query = "pdb:" + pdb.getId(); - tmpPDBFile = ebi.fetchDataAsFile(query, "default", "raw").getAbsolutePath(); - if (tmpPDBFile != null) - { - PDBfile pdbfile = new PDBfile(tmpPDBFile, - jalview.io.AppletFormatAdapter.FILE); - pdbcanvas.setPDBFile(pdbfile); - } - else - { - throw new Exception("Empty result for WSDbFetch Query: " + query); - } - } - catch (Exception ex) - { - ex.printStackTrace(); - showErrorMessage("Failed to retrieve PDB structure."); -// this.dispose(); - } - } - - - setContentPane(pdbcanvas); - StringBuffer title = new StringBuffer(sequence.getName() + ":" + pdb.getId()); - if (pdb.getProperty() != null) + if (pdbentry.getProperty() != null) { - if (pdb.getProperty().get("method") != null) + if (pdbentry.getProperty().get("method") != null) { title.append(" Method: "); - title.append(pdb.getProperty().get("method")); + title.append(pdbentry.getProperty().get("method")); } - if (pdb.getProperty().get("chains") != null) + if (pdbentry.getProperty().get("chains") != null) { title.append(" Chain:"); - title.append(pdb.getProperty().get("chains")); - } - } - */ - - Container contentPane = getContentPane(); - JmolPanel jmolPanel = new JmolPanel(); - contentPane.add(jmolPanel); - - JmolViewer viewer = jmolPanel.viewer; - - - System.out.println(entry.getFile()+" "+entry.getId()); - viewer.openFile(entry.getFile()); - - - StringBuffer string = new StringBuffer(); - - for(int i=0; i") > -1 || data.indexOf("") > -1) - ) + if (!(data.indexOf("
") > -1 || data.indexOf("
") > -1)) { out.println(data); } } out.close(); - } - catch (Exception ex) + in.close(); + } catch (Exception ex) { ex.printStackTrace(); }