2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
23 import java.awt.event.ActionEvent;
24 import java.awt.event.ActionListener;
25 import java.awt.event.ItemEvent;
26 import java.awt.event.ItemListener;
27 import java.io.BufferedReader;
29 import java.io.FileOutputStream;
30 import java.io.FileReader;
31 import java.io.IOException;
32 import java.io.PrintWriter;
33 import java.util.ArrayList;
34 import java.util.List;
35 import java.util.Vector;
37 import javax.swing.JCheckBoxMenuItem;
38 import javax.swing.JColorChooser;
39 import javax.swing.JInternalFrame;
40 import javax.swing.JMenu;
41 import javax.swing.JMenuItem;
42 import javax.swing.JOptionPane;
43 import javax.swing.event.InternalFrameAdapter;
44 import javax.swing.event.InternalFrameEvent;
45 import javax.swing.event.MenuEvent;
46 import javax.swing.event.MenuListener;
48 import jalview.bin.Cache;
49 import jalview.datamodel.Alignment;
50 import jalview.datamodel.AlignmentI;
51 import jalview.datamodel.ColumnSelection;
52 import jalview.datamodel.PDBEntry;
53 import jalview.datamodel.SequenceI;
54 import jalview.ext.rbvi.chimera.JalviewChimeraBinding;
55 import jalview.io.AppletFormatAdapter;
56 import jalview.io.JalviewFileChooser;
57 import jalview.io.JalviewFileView;
58 import jalview.schemes.BuriedColourScheme;
59 import jalview.schemes.ColourSchemeI;
60 import jalview.schemes.HelixColourScheme;
61 import jalview.schemes.HydrophobicColourScheme;
62 import jalview.schemes.PurinePyrimidineColourScheme;
63 import jalview.schemes.StrandColourScheme;
64 import jalview.schemes.TaylorColourScheme;
65 import jalview.schemes.TurnColourScheme;
66 import jalview.schemes.ZappoColourScheme;
67 import jalview.structures.models.AAStructureBindingModel;
68 import jalview.util.MessageManager;
69 import jalview.util.Platform;
70 import jalview.ws.dbsources.Pdb;
73 * GUI elements for handlnig an external chimera display
78 public class ChimeraViewFrame extends StructureViewerBase
80 private JalviewChimeraBinding jmb;
82 private boolean allChainsSelected = false;
84 private boolean alignAddedStructures = false;
87 * state flag for PDB retrieval thread
89 private boolean _started = false;
91 private boolean addingStructures = false;
93 private IProgressIndicator progressBar = null;
96 * pdb retrieval thread.
98 private Thread worker = null;
101 * Path to Chimera session file. This is set when an open Jalview/Chimera
102 * session is saved, or on restore from a Jalview project (if it holds the
103 * filename of any saved Chimera sessions).
105 private String chimeraSessionFile = null;
108 * Initialise menu options.
110 private void initMenus()
112 viewerActionMenu.setText(MessageManager.getString("label.chimera"));
113 viewerColour.setText(MessageManager
114 .getString("label.colour_with_chimera"));
115 viewerColour.setToolTipText(MessageManager
116 .getString("label.let_chimera_manage_structure_colours"));
117 helpItem.setText(MessageManager.getString("label.chimera_help"));
118 seqColour.setSelected(jmb.isColourBySequence());
119 viewerColour.setSelected(!jmb.isColourBySequence());
120 if (_colourwith == null)
122 _colourwith = new Vector<AlignmentPanel>();
124 if (_alignwith == null)
126 _alignwith = new Vector<AlignmentPanel>();
129 // save As not yet implemented
130 savemenu.setVisible(false);
132 ViewSelectionMenu seqColourBy = new ViewSelectionMenu(
133 MessageManager.getString("label.colour_by"), this, _colourwith,
137 public void itemStateChanged(ItemEvent e)
139 if (!seqColour.isSelected())
145 // update the Chimera display now.
146 seqColour_actionPerformed(null);
150 viewMenu.add(seqColourBy);
151 final ItemListener handler;
152 JMenu alpanels = new ViewSelectionMenu(
153 MessageManager.getString("label.superpose_with"), this,
154 _alignwith, handler = new ItemListener()
157 public void itemStateChanged(ItemEvent e)
159 alignStructs.setEnabled(_alignwith.size() > 0);
160 alignStructs.setToolTipText(MessageManager
162 "label.align_structures_using_linked_alignment_views",
164 { new Integer(_alignwith.size()).toString() }));
167 handler.itemStateChanged(null);
168 viewerActionMenu.add(alpanels);
169 viewerActionMenu.addMenuListener(new MenuListener()
173 public void menuSelected(MenuEvent e)
175 handler.itemStateChanged(null);
179 public void menuDeselected(MenuEvent e)
181 // TODO Auto-generated method stub
185 public void menuCanceled(MenuEvent e)
187 // TODO Auto-generated method stub
193 * add a single PDB structure to a new or existing Chimera view
200 public ChimeraViewFrame(PDBEntry pdbentry, SequenceI[] seq,
201 String[] chains, final AlignmentPanel ap)
204 progressBar = ap.alignFrame;
205 // ////////////////////////////////
206 // Is the pdb file already loaded?
207 String alreadyMapped = ap.getStructureSelectionManager()
208 .alreadyMappedToFile(pdbentry.getId());
210 if (alreadyMapped != null)
212 int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
213 MessageManager.formatMessage(
214 "label.pdb_entry_is_already_displayed", new Object[]
215 { pdbentry.getId() }), MessageManager.formatMessage(
216 "label.map_sequences_to_visible_window", new Object[]
217 { pdbentry.getId() }),
218 JOptionPane.YES_NO_CANCEL_OPTION);
220 if (option == JOptionPane.CANCEL_OPTION)
224 if (option == JOptionPane.YES_OPTION)
226 // TODO : Fix multiple seq to one chain issue here.
227 ap.getStructureSelectionManager().setMapping(seq, chains,
228 alreadyMapped, AppletFormatAdapter.FILE);
229 if (ap.getSeqPanel().seqCanvas.fr != null)
231 ap.getSeqPanel().seqCanvas.fr.featuresAdded();
232 ap.paintAlignment(true);
235 // Now this ChimeraViewFrame is mapped to new sequences. We must add
236 // them to the existing array
237 JInternalFrame[] frames = Desktop.instance.getAllFrames();
239 for (JInternalFrame frame : frames)
241 if (frame instanceof ChimeraViewFrame)
243 final ChimeraViewFrame topView = ((ChimeraViewFrame) frame);
244 // JBPNOTE: this looks like a binding routine, rather than a gui
246 for (int pe = 0; pe < topView.jmb.getPdbCount(); pe++)
248 if (topView.jmb.getPdbEntry(pe).getFile()
252 topView.jmb.addSequence(pe, seq);
253 topView.addAlignmentPanel(ap);
254 // add it to the set used for colouring
255 topView.useAlignmentPanelForColourbyseq(ap);
256 topView.buildActionMenu();
257 ap.getStructureSelectionManager()
258 .sequenceColoursChanged(ap);
268 // /////////////////////////////////
269 // Check if there are other Chimera views involving this alignment
270 // and prompt user about adding this molecule to one of them
271 List<ChimeraViewFrame> existingViews = getChimeraWindowsFor(ap);
272 for (ChimeraViewFrame topView : existingViews)
274 // TODO: highlight topView in view somehow
275 int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
276 MessageManager.formatMessage("label.add_pdbentry_to_view",
278 { pdbentry.getId(), topView.getTitle() }),
280 .getString("label.align_to_existing_structure_view"),
281 JOptionPane.YES_NO_CANCEL_OPTION);
282 if (option == JOptionPane.CANCEL_OPTION)
286 if (option == JOptionPane.YES_OPTION)
288 topView.useAlignmentPanelForSuperposition(ap);
289 topView.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
293 // /////////////////////////////////
294 openNewChimera(ap, new PDBEntry[]
295 { pdbentry }, new SequenceI[][]
299 private void openNewChimera(AlignmentPanel ap, PDBEntry[] pdbentrys,
302 progressBar = ap.alignFrame;
303 jmb = new JalviewChimeraBindingModel(this,
304 ap.getStructureSelectionManager(), pdbentrys, seqs, null, null);
305 addAlignmentPanel(ap);
306 useAlignmentPanelForColourbyseq(ap);
307 if (pdbentrys.length > 1)
309 alignAddedStructures = true;
310 useAlignmentPanelForSuperposition(ap);
312 jmb.setColourBySequence(true);
313 setSize(400, 400); // probably should be a configurable/dynamic default here
316 addingStructures = false;
317 worker = new Thread(this);
320 this.addInternalFrameListener(new InternalFrameAdapter()
322 public void internalFrameClosing(InternalFrameEvent internalFrameEvent)
331 * create a new viewer containing several structures superimposed using the
338 public ChimeraViewFrame(AlignmentPanel ap, PDBEntry[] pe,
342 openNewChimera(ap, pe, seqs);
346 * Create a new viewer from saved session state data including Chimera session
349 * @param chimeraSession
354 * @param colourByChimera
355 * @param colourBySequence
357 public ChimeraViewFrame(String chimeraSession, AlignmentPanel alignPanel,
359 SequenceI[][] seqsArray, boolean colourByChimera,
360 boolean colourBySequence)
363 this.chimeraSessionFile = chimeraSession;
364 openNewChimera(alignPanel, pdbArray, seqsArray);
367 jmb.setColourBySequence(false);
368 seqColour.setSelected(false);
369 viewerColour.setSelected(true);
371 else if (colourBySequence)
373 jmb.setColourBySequence(true);
374 seqColour.setSelected(true);
375 viewerColour.setSelected(false);
380 * add a new structure (with associated sequences and chains) to this viewer,
381 * retrieving it if necessary first.
388 * if true, new structure(s) will be align using associated alignment
390 private void addStructure(final PDBEntry pdbentry, final SequenceI[] seq,
391 final String[] chains, final boolean b,
392 final IProgressIndicator alignFrame)
394 if (pdbentry.getFile() == null)
396 if (worker != null && worker.isAlive())
398 // a retrieval is in progress, wait around and add ourselves to the
400 new Thread(new Runnable()
404 while (worker != null && worker.isAlive() && _started)
408 Thread.sleep(100 + ((int) Math.random() * 100));
410 } catch (Exception e)
415 // and call ourselves again.
416 addStructure(pdbentry, seq, chains, b, alignFrame);
422 // otherwise, start adding the structure.
423 jmb.addSequenceAndChain(new PDBEntry[]
424 { pdbentry }, new SequenceI[][]
425 { seq }, new String[][]
427 addingStructures = true;
429 alignAddedStructures = b;
430 progressBar = alignFrame; // visual indication happens on caller frame.
431 (worker = new Thread(this)).start();
435 private List<ChimeraViewFrame> getChimeraWindowsFor(AlignmentPanel apanel)
437 List<ChimeraViewFrame> result = new ArrayList<ChimeraViewFrame>();
438 JInternalFrame[] frames = Desktop.instance.getAllFrames();
440 for (JInternalFrame frame : frames)
442 if (frame instanceof ChimeraViewFrame)
444 if (((StructureViewerBase) frame).isLinkedWith(apanel))
446 result.add((ChimeraViewFrame) frame);
454 * Launch Chimera. If we have a chimera session file name, send Chimera the
455 * command to open its saved session file.
459 jmb.setFinishedInit(false);
460 jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle("Chimera", true),
461 getBounds().width, getBounds().height);
464 * Pass an empty 'command' to launch Chimera
466 jmb.evalStateCommand("", false);
468 if (this.chimeraSessionFile != null)
470 boolean opened = jmb.openSession(chimeraSessionFile);
474 .println("An error occurred opening Chimera session file "
475 + chimeraSessionFile);
478 jmb.setFinishedInit(true);
481 void setChainMenuItems(List<String> chainNames)
483 chainMenu.removeAll();
484 if (chainNames == null)
488 JMenuItem menuItem = new JMenuItem(
489 MessageManager.getString("label.all"));
490 menuItem.addActionListener(new ActionListener()
492 public void actionPerformed(ActionEvent evt)
494 allChainsSelected = true;
495 for (int i = 0; i < chainMenu.getItemCount(); i++)
497 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
499 ((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
503 allChainsSelected = false;
507 chainMenu.add(menuItem);
509 for (String chainName : chainNames)
511 menuItem = new JCheckBoxMenuItem(chainName, true);
512 menuItem.addItemListener(new ItemListener()
514 public void itemStateChanged(ItemEvent evt)
516 if (!allChainsSelected)
523 chainMenu.add(menuItem);
529 List<String> toshow = new ArrayList<String>();
530 for (int i = 0; i < chainMenu.getItemCount(); i++)
532 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
534 JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
535 if (item.isSelected())
537 toshow.add(item.getText());
541 jmb.centerViewer(toshow);
545 * Close down this instance of Jalview's Chimera viewer, giving the user the
546 * option to close the associated Chimera window (process). They may wish to
547 * keep it open until they have had an opportunity to save any work.
549 * @param closeChimera
550 * if true, close any linked Chimera process; if false, prompt first
552 public void closeViewer(boolean closeChimera)
554 if (jmb.isChimeraRunning())
558 String prompt = MessageManager.formatMessage(
559 "label.confirm_close_chimera", new Object[]
560 { jmb.getViewerTitle("Chimera", false) });
561 prompt = JvSwingUtils.wrapTooltip(true, prompt);
562 int confirm = JOptionPane.showConfirmDialog(this, prompt,
563 MessageManager.getString("label.close_viewer"),
564 JOptionPane.YES_NO_OPTION);
565 closeChimera = confirm == JOptionPane.YES_OPTION;
567 jmb.closeViewer(closeChimera);
569 setAlignmentPanel(null);
573 // TODO: check for memory leaks where instance isn't finalised because jmb
574 // holds a reference to the window
579 * Open any newly added PDB structures in Chimera, having first fetched data
580 * from PDB (if not already saved).
585 // todo - record which pdbids were successfully imported.
586 StringBuilder errormsgs = new StringBuilder(128);
587 StringBuilder files = new StringBuilder(128);
588 List<PDBEntry> filePDB = new ArrayList<PDBEntry>();
589 List<Integer> filePDBpos = new ArrayList<Integer>();
590 PDBEntry thePdbEntry = null;
593 String[] curfiles = jmb.getPdbFile(); // files currently in viewer
594 // TODO: replace with reference fetching/transfer code (validate PDBentry
596 for (int pi = 0; pi < jmb.getPdbCount(); pi++)
599 thePdbEntry = jmb.getPdbEntry(pi);
600 if (thePdbEntry.getFile() == null)
603 * Retrieve PDB data, save to file, attach to PDBEntry
605 file = fetchPdbFile(thePdbEntry);
608 errormsgs.append("'" + thePdbEntry.getId() + "' ");
614 * Got file already - ignore if already loaded in Chimera.
616 file = new File(thePdbEntry.getFile()).getAbsoluteFile()
618 if (curfiles != null && curfiles.length > 0)
620 addingStructures = true; // already files loaded.
621 for (int c = 0; c < curfiles.length; c++)
623 if (curfiles[c].equals(file))
633 filePDB.add(thePdbEntry);
634 filePDBpos.add(Integer.valueOf(pi));
635 files.append(" \"" + Platform.escapeString(file) + "\"");
638 } catch (OutOfMemoryError oomerror)
640 new OOMWarning("Retrieving PDB files: " + thePdbEntry.getId(),
642 } catch (Exception ex)
644 ex.printStackTrace();
645 errormsgs.append("When retrieving pdbfiles for '"
646 + thePdbEntry.getId() + "'");
648 if (errormsgs.length() > 0)
651 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
652 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
654 { errormsgs.toString() }), MessageManager
655 .getString("label.couldnt_load_file"),
656 JOptionPane.ERROR_MESSAGE);
659 if (files.length() > 0)
661 if (!addingStructures)
666 } catch (Exception ex)
668 Cache.log.error("Couldn't open Chimera viewer!", ex);
672 for (PDBEntry pe : filePDB)
675 if (pe.getFile() != null)
679 int pos = filePDBpos.get(num).intValue();
681 jmb.addSequence(pos, jmb.getSequence()[pos]);
682 File fl = new File(pe.getFile());
683 String protocol = AppletFormatAdapter.URL;
688 protocol = AppletFormatAdapter.FILE;
690 } catch (Throwable e)
693 // Explicitly map to the filename used by Chimera ;
694 // TODO: use pe.getId() instead of pe.getFile() ?
695 jmb.getSsm().setMapping(jmb.getSequence()[pos], null,
698 } catch (OutOfMemoryError oomerror)
701 "When trying to open and map structures from Chimera!",
703 } catch (Exception ex)
705 Cache.log.error("Couldn't open " + pe.getFile()
706 + " in Chimera viewer!", ex);
709 Cache.log.debug("File locations are " + files);
713 jmb.setFinishedInit(true);
714 jmb.setLoadingFromArchive(false);
716 // refresh the sequence colours for the new structure(s)
717 for (AlignmentPanel ap : _colourwith)
719 jmb.updateColours(ap);
721 // do superposition if asked to
722 if (alignAddedStructures)
724 new Thread(new Runnable()
728 alignStructs_withAllAlignPanels();
731 alignAddedStructures = false;
733 addingStructures = false;
740 * Fetch PDB data and save to a local file. Returns the full path to the file,
741 * or null if fetch fails.
743 * @param processingEntry
747 private String fetchPdbFile(PDBEntry processingEntry) throws Exception
749 String filePath = null;
750 Pdb pdbclient = new Pdb();
751 AlignmentI pdbseq = null;
752 String pdbid = processingEntry.getId();
753 long hdl = pdbid.hashCode() - System.currentTimeMillis();
754 if (progressBar != null)
756 progressBar.setProgressBar(MessageManager.formatMessage(
757 "status.fetching_pdb", new Object[]
762 pdbseq = pdbclient.getSequenceRecords(pdbid);
763 } catch (OutOfMemoryError oomerror)
765 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
768 if (progressBar != null)
775 .getString("label.state_completed"),
780 * If PDB data were saved and are not invalid (empty alignment), return the
783 if (pdbseq != null && pdbseq.getHeight() > 0)
785 // just use the file name from the first sequence's first PDBEntry
786 filePath = new File(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId()
787 .elementAt(0)).getFile()).getAbsolutePath();
788 processingEntry.setFile(filePath);
794 public void pdbFile_actionPerformed(ActionEvent actionEvent)
796 JalviewFileChooser chooser = new JalviewFileChooser(
797 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
799 chooser.setFileView(new JalviewFileView());
800 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
801 chooser.setToolTipText(MessageManager.getString("action.save"));
803 int value = chooser.showSaveDialog(this);
805 if (value == JalviewFileChooser.APPROVE_OPTION)
807 BufferedReader in = null;
810 // TODO: cope with multiple PDB files in view
811 in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
812 File outFile = chooser.getSelectedFile();
814 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
816 while ((data = in.readLine()) != null)
818 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
824 } catch (Exception ex)
826 ex.printStackTrace();
834 } catch (IOException e)
844 public void viewMapping_actionPerformed(ActionEvent actionEvent)
846 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
849 for (int pdbe = 0; pdbe < jmb.getPdbCount(); pdbe++)
851 cap.appendText(jmb.printMapping(jmb.getPdbEntry(pdbe).getFile()));
852 cap.appendText("\n");
854 } catch (OutOfMemoryError e)
857 "composing sequence-structure alignments for display in text box.",
862 jalview.gui.Desktop.addInternalFrame(cap,
863 MessageManager.getString("label.pdb_sequence_mapping"), 550,
868 public void eps_actionPerformed(ActionEvent e)
872 .getString("error.eps_generation_not_implemented"));
876 public void png_actionPerformed(ActionEvent e)
880 .getString("error.png_generation_not_implemented"));
884 public void viewerColour_actionPerformed(ActionEvent actionEvent)
886 if (viewerColour.isSelected())
888 // disable automatic sequence colouring.
889 jmb.setColourBySequence(false);
894 public void seqColour_actionPerformed(ActionEvent actionEvent)
896 jmb.setColourBySequence(seqColour.isSelected());
897 if (_colourwith == null)
899 _colourwith = new Vector<AlignmentPanel>();
901 if (jmb.isColourBySequence())
903 if (!jmb.isLoadingFromArchive())
905 if (_colourwith.size() == 0 && getAlignmentPanel() != null)
907 // Make the currently displayed alignment panel the associated view
908 _colourwith.add(getAlignmentPanel().alignFrame.alignPanel);
911 // Set the colour using the current view for the associated alignframe
912 for (AlignmentPanel ap : _colourwith)
914 jmb.colourBySequence(ap.av.isShowSequenceFeatures(), ap);
920 public void chainColour_actionPerformed(ActionEvent actionEvent)
922 chainColour.setSelected(true);
927 public void chargeColour_actionPerformed(ActionEvent actionEvent)
929 chargeColour.setSelected(true);
930 jmb.colourByCharge();
934 public void zappoColour_actionPerformed(ActionEvent actionEvent)
936 zappoColour.setSelected(true);
937 jmb.setJalviewColourScheme(new ZappoColourScheme());
941 public void taylorColour_actionPerformed(ActionEvent actionEvent)
943 taylorColour.setSelected(true);
944 jmb.setJalviewColourScheme(new TaylorColourScheme());
948 public void hydroColour_actionPerformed(ActionEvent actionEvent)
950 hydroColour.setSelected(true);
951 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
955 public void helixColour_actionPerformed(ActionEvent actionEvent)
957 helixColour.setSelected(true);
958 jmb.setJalviewColourScheme(new HelixColourScheme());
962 public void strandColour_actionPerformed(ActionEvent actionEvent)
964 strandColour.setSelected(true);
965 jmb.setJalviewColourScheme(new StrandColourScheme());
969 public void turnColour_actionPerformed(ActionEvent actionEvent)
971 turnColour.setSelected(true);
972 jmb.setJalviewColourScheme(new TurnColourScheme());
976 public void buriedColour_actionPerformed(ActionEvent actionEvent)
978 buriedColour.setSelected(true);
979 jmb.setJalviewColourScheme(new BuriedColourScheme());
983 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
985 setJalviewColourScheme(new PurinePyrimidineColourScheme());
989 public void userColour_actionPerformed(ActionEvent actionEvent)
991 userColour.setSelected(true);
992 new UserDefinedColours(this, null);
996 public void backGround_actionPerformed(ActionEvent actionEvent)
998 java.awt.Color col = JColorChooser
999 .showDialog(this, MessageManager
1000 .getString("label.select_backgroud_colour"), null);
1003 jmb.setBackgroundColour(col);
1008 public void showHelp_actionPerformed(ActionEvent actionEvent)
1012 jalview.util.BrowserLauncher
1013 .openURL("https://www.cgl.ucsf.edu/chimera/docs/UsersGuide");
1014 } catch (Exception ex)
1019 public void updateTitleAndMenus()
1021 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
1026 setChainMenuItems(jmb.getChainNames());
1028 this.setTitle(jmb.getViewerTitle("Chimera", true));
1029 if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
1031 viewerActionMenu.setVisible(true);
1033 if (!jmb.isLoadingFromArchive())
1035 seqColour_actionPerformed(null);
1043 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
1047 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
1049 alignStructs_withAllAlignPanels();
1052 private void alignStructs_withAllAlignPanels()
1054 if (getAlignmentPanel() == null)
1059 if (_alignwith.size() == 0)
1061 _alignwith.add(getAlignmentPanel());
1066 AlignmentI[] als = new Alignment[_alignwith.size()];
1067 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
1068 int[] alm = new int[_alignwith.size()];
1071 for (AlignmentPanel ap : _alignwith)
1073 als[a] = ap.av.getAlignment();
1075 alc[a++] = ap.av.getColumnSelection();
1077 jmb.superposeStructures(als, alm, alc);
1078 } catch (Exception e)
1080 StringBuffer sp = new StringBuffer();
1081 for (AlignmentPanel ap : _alignwith)
1083 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1085 Cache.log.info("Couldn't align structures with the " + sp.toString()
1086 + "associated alignment panels.", e);
1092 public void setJalviewColourScheme(ColourSchemeI ucs)
1094 jmb.setJalviewColourScheme(ucs);
1101 * @return first alignment panel displaying given alignment, or the default
1104 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1106 for (AlignmentPanel ap : getAllAlignmentPanels())
1108 if (ap.av.getAlignment() == alignment)
1113 return getAlignmentPanel();
1117 public AAStructureBindingModel getBinding()
1123 * Ask Chimera to save its session to the designated file path. Returns true
1124 * if successful, else false.
1129 public boolean saveSession(String filepath)
1131 boolean result = jmb.saveSession(filepath);
1134 this.chimeraSessionFile = filepath;
1140 * Returns the file path of the Chimera session file the last time it was
1141 * saved. If it was never saved, returns an empty string. There is no
1142 * guarantee that the Chimera session has not changed since it was saved.
1145 public String getStateInfo()
1147 return this.chimeraSessionFile;