X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2FMCview%2FPDBViewer.java;h=e16241bdc222c1d389a08a9336b37b480fdecc42;hb=ab43013b7e357b84b4abade0dba949668dfb2a0e;hp=b44dece35d5e86f917524199ce2e3fd50a1587b5;hpb=1419df7e52f4f2fb923eb5d026ecd39ded424519;p=jalview.git diff --git a/src/MCview/PDBViewer.java b/src/MCview/PDBViewer.java index b44dece..e16241b 100755 --- a/src/MCview/PDBViewer.java +++ b/src/MCview/PDBViewer.java @@ -1,83 +1,124 @@ /* - * 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 + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1) + * 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. - * - * 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. - * + * + * 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 this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + * 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 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 +import jalview.datamodel.PDBEntry; +import jalview.datamodel.SequenceI; +import jalview.gui.AlignmentPanel; +import jalview.gui.Desktop; +import jalview.gui.OOMWarning; +import jalview.gui.UserDefinedColours; +import jalview.io.JalviewFileChooser; +import jalview.io.JalviewFileView; +import jalview.schemes.BuriedColourScheme; +import jalview.schemes.HelixColourScheme; +import jalview.schemes.HydrophobicColourScheme; +import jalview.schemes.StrandColourScheme; +import jalview.schemes.TaylorColourScheme; +import jalview.schemes.TurnColourScheme; +import jalview.schemes.UserColourScheme; +import jalview.schemes.ZappoColourScheme; +import jalview.util.MessageManager; +import jalview.ws.ebi.EBIFetchClient; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.BufferedReader; +import java.io.File; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.PrintWriter; + +import javax.swing.ButtonGroup; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JColorChooser; +import javax.swing.JInternalFrame; +import javax.swing.JMenu; +import javax.swing.JMenuBar; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JRadioButtonMenuItem; +import javax.swing.SwingUtilities; + +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(); + + setContentPane(pdbcanvas); - if (pdb.getFile() != null) + if (pdbentry.getFile() != null) { try { - tmpPDBFile = pdb.getFile(); - PDBfile pdbfile = new PDBfile(tmpPDBFile, - jalview.io.AppletFormatAdapter.FILE); - pdbcanvas.setPDBFile(pdbfile); + tmpPDBFile = pdbentry.getFile(); + PDBfile pdbfile = new PDBfile(false, false, false, tmpPDBFile, + 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 +129,43 @@ 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(); }