2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 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 jalview.bin.Cache;
24 import jalview.datamodel.Alignment;
25 import jalview.datamodel.AlignmentI;
26 import jalview.datamodel.ColumnSelection;
27 import jalview.datamodel.PDBEntry;
28 import jalview.datamodel.SequenceI;
29 import jalview.ext.rbvi.chimera.JalviewChimeraBinding;
30 import jalview.gui.Jalview2XML.ViewerData;
31 import jalview.io.AppletFormatAdapter;
32 import jalview.io.JalviewFileChooser;
33 import jalview.io.JalviewFileView;
34 import jalview.schemes.BuriedColourScheme;
35 import jalview.schemes.ColourSchemeI;
36 import jalview.schemes.HelixColourScheme;
37 import jalview.schemes.HydrophobicColourScheme;
38 import jalview.schemes.PurinePyrimidineColourScheme;
39 import jalview.schemes.StrandColourScheme;
40 import jalview.schemes.TaylorColourScheme;
41 import jalview.schemes.TurnColourScheme;
42 import jalview.schemes.ZappoColourScheme;
43 import jalview.structures.models.AAStructureBindingModel;
44 import jalview.util.MessageManager;
45 import jalview.util.Platform;
46 import jalview.ws.dbsources.Pdb;
48 import java.awt.event.ActionEvent;
49 import java.awt.event.ActionListener;
50 import java.awt.event.ItemEvent;
51 import java.awt.event.ItemListener;
52 import java.io.BufferedReader;
54 import java.io.FileOutputStream;
55 import java.io.FileReader;
56 import java.io.IOException;
57 import java.io.PrintWriter;
58 import java.util.ArrayList;
59 import java.util.List;
60 import java.util.Vector;
62 import javax.swing.JCheckBoxMenuItem;
63 import javax.swing.JColorChooser;
64 import javax.swing.JInternalFrame;
65 import javax.swing.JMenu;
66 import javax.swing.JMenuItem;
67 import javax.swing.JOptionPane;
68 import javax.swing.event.InternalFrameAdapter;
69 import javax.swing.event.InternalFrameEvent;
70 import javax.swing.event.MenuEvent;
71 import javax.swing.event.MenuListener;
74 * GUI elements for handlnig an external chimera display
79 public class ChimeraViewFrame extends StructureViewerBase
81 private JalviewChimeraBinding jmb;
83 private boolean allChainsSelected = false;
85 private boolean alignAddedStructures = false;
88 * state flag for PDB retrieval thread
90 private boolean _started = false;
92 private boolean addingStructures = false;
94 private IProgressIndicator progressBar = null;
97 * pdb retrieval thread.
99 private Thread worker = null;
102 * Path to Chimera session file - set in saveSession()
104 private String chimeraSessionFile = "";
107 * Initialise menu options.
109 private void initMenus()
111 viewerActionMenu.setText(MessageManager.getString("label.chimera"));
112 viewerColour.setText(MessageManager
113 .getString("label.colour_with_chimera"));
114 viewerColour.setToolTipText(MessageManager
115 .getString("label.let_chimera_manage_structure_colours"));
116 helpItem.setText(MessageManager.getString("label.chimera_help"));
117 seqColour.setSelected(jmb.isColourBySequence());
118 viewerColour.setSelected(!jmb.isColourBySequence());
119 if (_colourwith == null)
121 _colourwith = new Vector<AlignmentPanel>();
123 if (_alignwith == null)
125 _alignwith = new Vector<AlignmentPanel>();
128 // save As not yet implemented
129 savemenu.setVisible(false);
131 ViewSelectionMenu seqColourBy = new ViewSelectionMenu(
132 MessageManager.getString("label.colour_by"), this, _colourwith,
136 public void itemStateChanged(ItemEvent e)
138 if (!seqColour.isSelected())
144 // update the Chimera display now.
145 seqColour_actionPerformed(null);
149 viewMenu.add(seqColourBy);
150 final ItemListener handler;
151 JMenu alpanels = new ViewSelectionMenu(
152 MessageManager.getString("label.superpose_with"), this,
153 _alignwith, handler = new ItemListener()
156 public void itemStateChanged(ItemEvent e)
158 alignStructs.setEnabled(_alignwith.size() > 0);
159 alignStructs.setToolTipText(MessageManager
161 "label.align_structures_using_linked_alignment_views",
163 { new Integer(_alignwith.size()).toString() }));
166 handler.itemStateChanged(null);
167 viewerActionMenu.add(alpanels);
168 viewerActionMenu.addMenuListener(new MenuListener()
172 public void menuSelected(MenuEvent e)
174 handler.itemStateChanged(null);
178 public void menuDeselected(MenuEvent e)
180 // TODO Auto-generated method stub
184 public void menuCanceled(MenuEvent e)
186 // TODO Auto-generated method stub
192 * add a single PDB structure to a new or existing Chimera view
199 public ChimeraViewFrame(PDBEntry pdbentry, SequenceI[] seq,
200 String[] chains, final AlignmentPanel ap)
203 progressBar = ap.alignFrame;
204 // ////////////////////////////////
205 // Is the pdb file already loaded?
206 String alreadyMapped = ap.getStructureSelectionManager()
207 .alreadyMappedToFile(pdbentry.getId());
209 if (alreadyMapped != null)
211 int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
212 MessageManager.formatMessage(
213 "label.pdb_entry_is_already_displayed", new Object[]
214 { pdbentry.getId() }), MessageManager.formatMessage(
215 "label.map_sequences_to_visible_window", new Object[]
216 { pdbentry.getId() }),
217 JOptionPane.YES_NO_CANCEL_OPTION);
219 if (option == JOptionPane.CANCEL_OPTION)
223 if (option == JOptionPane.YES_OPTION)
225 // TODO : Fix multiple seq to one chain issue here.
226 ap.getStructureSelectionManager().setMapping(seq, chains,
227 alreadyMapped, AppletFormatAdapter.FILE);
228 if (ap.getSeqPanel().seqCanvas.fr != null)
230 ap.getSeqPanel().seqCanvas.fr.featuresAdded();
231 ap.paintAlignment(true);
234 // Now this ChimeraViewFrame is mapped to new sequences. We must add
235 // them to the existing array
236 JInternalFrame[] frames = Desktop.instance.getAllFrames();
238 for (JInternalFrame frame : frames)
240 if (frame instanceof ChimeraViewFrame)
242 final ChimeraViewFrame topView = ((ChimeraViewFrame) frame);
243 // JBPNOTE: this looks like a binding routine, rather than a gui
245 for (int pe = 0; pe < topView.jmb.getPdbCount(); pe++)
247 if (topView.jmb.getPdbEntry(pe).getFile()
251 topView.jmb.addSequence(pe, seq);
252 topView.addAlignmentPanel(ap);
253 // add it to the set used for colouring
254 topView.useAlignmentPanelForColourbyseq(ap);
255 topView.buildActionMenu();
256 ap.getStructureSelectionManager()
257 .sequenceColoursChanged(ap);
267 // /////////////////////////////////
268 // Check if there are other Chimera views involving this alignment
269 // and prompt user about adding this molecule to one of them
270 List<ChimeraViewFrame> existingViews = getChimeraWindowsFor(ap);
271 for (ChimeraViewFrame topView : existingViews)
273 // TODO: highlight topView in view somehow
274 int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
275 MessageManager.formatMessage("label.add_pdbentry_to_view",
277 { pdbentry.getId(), topView.getTitle() }),
279 .getString("label.align_to_existing_structure_view"),
280 JOptionPane.YES_NO_CANCEL_OPTION);
281 if (option == JOptionPane.CANCEL_OPTION)
285 if (option == JOptionPane.YES_OPTION)
287 topView.useAlignmentPanelForSuperposition(ap);
288 topView.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
292 // /////////////////////////////////
293 openNewChimera(ap, new PDBEntry[]
294 { pdbentry }, new SequenceI[][]
298 private void openNewChimera(AlignmentPanel ap, PDBEntry[] pdbentrys,
301 progressBar = ap.alignFrame;
302 jmb = new JalviewChimeraBindingModel(this,
303 ap.getStructureSelectionManager(), pdbentrys, seqs, null, null);
304 addAlignmentPanel(ap);
305 useAlignmentPanelForColourbyseq(ap);
306 if (pdbentrys.length > 1)
308 alignAddedStructures = true;
309 useAlignmentPanelForSuperposition(ap);
311 jmb.setColourBySequence(true);
312 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.
351 public ChimeraViewFrame(ViewerData viewerData, AlignFrame af)
354 String chimeraSessionFile = viewerData.stateData;
355 openNewChimera(af.alignPanel, new PDBEntry[]
356 {}, new SequenceI[][]
358 initChimera("open " + chimeraSessionFile);
359 // TODO restore mappings
363 * add a new structure (with associated sequences and chains) to this viewer,
364 * retrieving it if necessary first.
371 * if true, new structure(s) will be align using associated alignment
373 private void addStructure(final PDBEntry pdbentry, final SequenceI[] seq,
374 final String[] chains, final boolean b,
375 final IProgressIndicator alignFrame)
377 if (pdbentry.getFile() == null)
379 if (worker != null && worker.isAlive())
381 // a retrieval is in progress, wait around and add ourselves to the
383 new Thread(new Runnable()
387 while (worker != null && worker.isAlive() && _started)
391 Thread.sleep(100 + ((int) Math.random() * 100));
393 } catch (Exception e)
398 // and call ourselves again.
399 addStructure(pdbentry, seq, chains, b, alignFrame);
405 // otherwise, start adding the structure.
406 jmb.addSequenceAndChain(new PDBEntry[]
407 { pdbentry }, new SequenceI[][]
408 { seq }, new String[][]
410 addingStructures = true;
412 alignAddedStructures = b;
413 progressBar = alignFrame; // visual indication happens on caller frame.
414 (worker = new Thread(this)).start();
418 private List<ChimeraViewFrame> getChimeraWindowsFor(AlignmentPanel apanel)
420 List<ChimeraViewFrame> result = new ArrayList<ChimeraViewFrame>();
421 JInternalFrame[] frames = Desktop.instance.getAllFrames();
423 for (JInternalFrame frame : frames)
425 if (frame instanceof ChimeraViewFrame)
427 if (((StructureViewerBase) frame).isLinkedWith(apanel))
429 result.add((ChimeraViewFrame) frame);
436 void initChimera(String command)
438 jmb.setFinishedInit(false);
439 // TODO: consider waiting until the structure/view is fully loaded before
441 jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle("Chimera", true),
442 getBounds().width, getBounds().height);
447 jmb.evalStateCommand(command, false);
448 jmb.setFinishedInit(true);
451 void setChainMenuItems(List<String> chainNames)
453 chainMenu.removeAll();
454 if (chainNames == null)
458 JMenuItem menuItem = new JMenuItem(
459 MessageManager.getString("label.all"));
460 menuItem.addActionListener(new ActionListener()
462 public void actionPerformed(ActionEvent evt)
464 allChainsSelected = true;
465 for (int i = 0; i < chainMenu.getItemCount(); i++)
467 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
469 ((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
473 allChainsSelected = false;
477 chainMenu.add(menuItem);
479 for (String chainName : chainNames)
481 menuItem = new JCheckBoxMenuItem(chainName, true);
482 menuItem.addItemListener(new ItemListener()
484 public void itemStateChanged(ItemEvent evt)
486 if (!allChainsSelected)
493 chainMenu.add(menuItem);
499 List<String> toshow = new ArrayList<String>();
500 for (int i = 0; i < chainMenu.getItemCount(); i++)
502 if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
504 JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
505 if (item.isSelected())
507 toshow.add(item.getText());
511 jmb.centerViewer(toshow);
515 * Close down this instance of Jalview's Chimera viewer, giving the user the
516 * option to close the associated Chimera window (process). They may wish to
517 * keep it open until they have had an opportunity to save any work.
519 public void closeViewer()
521 if (jmb.isChimeraRunning())
523 String prompt = MessageManager
524 .formatMessage("label.confirm_close_chimera", new Object[]
525 { jmb.getViewerTitle("Chimera", false) });
526 prompt = JvSwingUtils.wrapTooltip(true, prompt);
527 int confirm = JOptionPane.showConfirmDialog(this, prompt,
528 MessageManager.getString("label.close_viewer"),
529 JOptionPane.YES_NO_OPTION);
530 jmb.closeViewer(confirm == JOptionPane.YES_OPTION);
532 setAlignmentPanel(null);
536 // TODO: check for memory leaks where instance isn't finalised because jmb
537 // holds a reference to the window
542 * Open any newly added PDB structures in Chimera, having first fetched data
543 * from PDB (if not already saved).
548 // todo - record which pdbids were successfully imported.
549 StringBuilder errormsgs = new StringBuilder(128);
550 StringBuilder files = new StringBuilder(128);
551 List<PDBEntry> filePDB = new ArrayList<PDBEntry>();
552 List<Integer> filePDBpos = new ArrayList<Integer>();
553 PDBEntry thePdbEntry = null;
556 String[] curfiles = jmb.getPdbFile(); // files currently in viewer
557 // TODO: replace with reference fetching/transfer code (validate PDBentry
559 for (int pi = 0; pi < jmb.getPdbCount(); pi++)
562 thePdbEntry = jmb.getPdbEntry(pi);
563 if (thePdbEntry.getFile() == null)
566 * Retrieve PDB data, save to file, attach to PDBEntry
568 file = fetchPdbFile(thePdbEntry);
571 errormsgs.append("'" + thePdbEntry.getId() + "' ");
577 * Got file already - ignore if already loaded in Chimera.
579 file = new File(thePdbEntry.getFile()).getAbsoluteFile()
581 if (curfiles != null && curfiles.length > 0)
583 addingStructures = true; // already files loaded.
584 for (int c = 0; c < curfiles.length; c++)
586 if (curfiles[c].equals(file))
596 filePDB.add(thePdbEntry);
597 filePDBpos.add(Integer.valueOf(pi));
598 files.append(" \"" + Platform.escapeString(file) + "\"");
601 } catch (OutOfMemoryError oomerror)
603 new OOMWarning("Retrieving PDB files: " + thePdbEntry.getId(),
605 } catch (Exception ex)
607 ex.printStackTrace();
608 errormsgs.append("When retrieving pdbfiles for '"
609 + thePdbEntry.getId() + "'");
611 if (errormsgs.length() > 0)
614 JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
615 .formatMessage("label.pdb_entries_couldnt_be_retrieved",
617 { errormsgs.toString() }), MessageManager
618 .getString("label.couldnt_load_file"),
619 JOptionPane.ERROR_MESSAGE);
622 if (files.length() > 0)
624 if (!addingStructures)
629 } catch (Exception ex)
631 Cache.log.error("Couldn't open Chimera viewer!", ex);
635 for (PDBEntry pe : filePDB)
638 if (pe.getFile() != null)
642 int pos = filePDBpos.get(num).intValue();
644 jmb.addSequence(pos, jmb.getSequence()[pos]);
645 File fl = new File(pe.getFile());
646 String protocol = AppletFormatAdapter.URL;
651 protocol = AppletFormatAdapter.FILE;
653 } catch (Throwable e)
656 // Explicitly map to the filename used by Chimera ;
657 // TODO: use pe.getId() instead of pe.getFile() ?
658 jmb.getSsm().setMapping(jmb.getSequence()[pos], null,
661 } catch (OutOfMemoryError oomerror)
664 "When trying to open and map structures from Chimera!",
666 } catch (Exception ex)
668 Cache.log.error("Couldn't open " + pe.getFile()
669 + " in Chimera viewer!", ex);
672 Cache.log.debug("File locations are " + files);
676 jmb.setFinishedInit(true);
677 jmb.setLoadingFromArchive(false);
679 // refresh the sequence colours for the new structure(s)
680 for (AlignmentPanel ap : _colourwith)
682 jmb.updateColours(ap);
684 // do superposition if asked to
685 if (alignAddedStructures)
687 new Thread(new Runnable()
691 alignStructs_withAllAlignPanels();
694 alignAddedStructures = false;
696 addingStructures = false;
703 * Fetch PDB data and save to a local file. Returns the full path to the file,
704 * or null if fetch fails.
706 * @param processingEntry
710 private String fetchPdbFile(PDBEntry processingEntry) throws Exception
712 String filePath = null;
713 Pdb pdbclient = new Pdb();
714 AlignmentI pdbseq = null;
715 String pdbid = processingEntry.getId();
716 long hdl = pdbid.hashCode() - System.currentTimeMillis();
717 if (progressBar != null)
719 progressBar.setProgressBar(MessageManager.formatMessage(
720 "status.fetching_pdb", new Object[]
725 pdbseq = pdbclient.getSequenceRecords(pdbid);
726 } catch (OutOfMemoryError oomerror)
728 new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
731 if (progressBar != null)
738 .getString("label.state_completed"),
743 * If PDB data were saved and are not invalid (empty alignment), return the
746 if (pdbseq != null && pdbseq.getHeight() > 0)
748 // just use the file name from the first sequence's first PDBEntry
749 filePath = new File(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId()
750 .elementAt(0)).getFile()).getAbsolutePath();
751 processingEntry.setFile(filePath);
757 public void pdbFile_actionPerformed(ActionEvent actionEvent)
759 JalviewFileChooser chooser = new JalviewFileChooser(
760 jalview.bin.Cache.getProperty("LAST_DIRECTORY"));
762 chooser.setFileView(new JalviewFileView());
763 chooser.setDialogTitle(MessageManager.getString("label.save_pdb_file"));
764 chooser.setToolTipText(MessageManager.getString("action.save"));
766 int value = chooser.showSaveDialog(this);
768 if (value == JalviewFileChooser.APPROVE_OPTION)
770 BufferedReader in = null;
773 // TODO: cope with multiple PDB files in view
774 in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
775 File outFile = chooser.getSelectedFile();
777 PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
779 while ((data = in.readLine()) != null)
781 if (!(data.indexOf("<PRE>") > -1 || data.indexOf("</PRE>") > -1))
787 } catch (Exception ex)
789 ex.printStackTrace();
797 } catch (IOException e)
807 public void viewMapping_actionPerformed(ActionEvent actionEvent)
809 jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
812 for (int pdbe = 0; pdbe < jmb.getPdbCount(); pdbe++)
814 cap.appendText(jmb.printMapping(jmb.getPdbEntry(pdbe).getFile()));
815 cap.appendText("\n");
817 } catch (OutOfMemoryError e)
820 "composing sequence-structure alignments for display in text box.",
825 jalview.gui.Desktop.addInternalFrame(cap,
826 MessageManager.getString("label.pdb_sequence_mapping"), 550,
831 public void eps_actionPerformed(ActionEvent e)
835 .getString("error.eps_generation_not_implemented"));
839 public void png_actionPerformed(ActionEvent e)
843 .getString("error.png_generation_not_implemented"));
847 public void viewerColour_actionPerformed(ActionEvent actionEvent)
849 if (viewerColour.isSelected())
851 // disable automatic sequence colouring.
852 jmb.setColourBySequence(false);
857 public void seqColour_actionPerformed(ActionEvent actionEvent)
859 jmb.setColourBySequence(seqColour.isSelected());
860 if (_colourwith == null)
862 _colourwith = new Vector<AlignmentPanel>();
864 if (jmb.isColourBySequence())
866 if (!jmb.isLoadingFromArchive())
868 if (_colourwith.size() == 0 && getAlignmentPanel() != null)
870 // Make the currently displayed alignment panel the associated view
871 _colourwith.add(getAlignmentPanel().alignFrame.alignPanel);
874 // Set the colour using the current view for the associated alignframe
875 for (AlignmentPanel ap : _colourwith)
877 jmb.colourBySequence(ap.av.showSequenceFeatures, ap);
883 public void chainColour_actionPerformed(ActionEvent actionEvent)
885 chainColour.setSelected(true);
890 public void chargeColour_actionPerformed(ActionEvent actionEvent)
892 chargeColour.setSelected(true);
893 jmb.colourByCharge();
897 public void zappoColour_actionPerformed(ActionEvent actionEvent)
899 zappoColour.setSelected(true);
900 jmb.setJalviewColourScheme(new ZappoColourScheme());
904 public void taylorColour_actionPerformed(ActionEvent actionEvent)
906 taylorColour.setSelected(true);
907 jmb.setJalviewColourScheme(new TaylorColourScheme());
911 public void hydroColour_actionPerformed(ActionEvent actionEvent)
913 hydroColour.setSelected(true);
914 jmb.setJalviewColourScheme(new HydrophobicColourScheme());
918 public void helixColour_actionPerformed(ActionEvent actionEvent)
920 helixColour.setSelected(true);
921 jmb.setJalviewColourScheme(new HelixColourScheme());
925 public void strandColour_actionPerformed(ActionEvent actionEvent)
927 strandColour.setSelected(true);
928 jmb.setJalviewColourScheme(new StrandColourScheme());
932 public void turnColour_actionPerformed(ActionEvent actionEvent)
934 turnColour.setSelected(true);
935 jmb.setJalviewColourScheme(new TurnColourScheme());
939 public void buriedColour_actionPerformed(ActionEvent actionEvent)
941 buriedColour.setSelected(true);
942 jmb.setJalviewColourScheme(new BuriedColourScheme());
946 public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
948 setJalviewColourScheme(new PurinePyrimidineColourScheme());
952 public void userColour_actionPerformed(ActionEvent actionEvent)
954 userColour.setSelected(true);
955 new UserDefinedColours(this, null);
959 public void backGround_actionPerformed(ActionEvent actionEvent)
961 java.awt.Color col = JColorChooser
962 .showDialog(this, MessageManager
963 .getString("label.select_backgroud_colour"), null);
966 jmb.setBackgroundColour(col);
971 public void showHelp_actionPerformed(ActionEvent actionEvent)
975 jalview.util.BrowserLauncher
976 .openURL("https://www.cgl.ucsf.edu/chimera/docs/UsersGuide");
977 } catch (Exception ex)
982 public void updateTitleAndMenus()
984 if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
989 setChainMenuItems(jmb.chainNames);
991 this.setTitle(jmb.getViewerTitle("Chimera", true));
992 if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
994 viewerActionMenu.setVisible(true);
996 if (!jmb.isLoadingFromArchive())
998 seqColour_actionPerformed(null);
1006 * jalview.jbgui.GStructureViewer#alignStructs_actionPerformed(java.awt.event
1010 protected void alignStructs_actionPerformed(ActionEvent actionEvent)
1012 alignStructs_withAllAlignPanels();
1015 private void alignStructs_withAllAlignPanels()
1017 if (getAlignmentPanel() == null)
1022 if (_alignwith.size() == 0)
1024 _alignwith.add(getAlignmentPanel());
1029 AlignmentI[] als = new Alignment[_alignwith.size()];
1030 ColumnSelection[] alc = new ColumnSelection[_alignwith.size()];
1031 int[] alm = new int[_alignwith.size()];
1034 for (AlignmentPanel ap : _alignwith)
1036 als[a] = ap.av.getAlignment();
1038 alc[a++] = ap.av.getColumnSelection();
1040 jmb.superposeStructures(als, alm, alc);
1041 } catch (Exception e)
1043 StringBuffer sp = new StringBuffer();
1044 for (AlignmentPanel ap : _alignwith)
1046 sp.append("'" + ap.alignFrame.getTitle() + "' ");
1048 Cache.log.info("Couldn't align structures with the " + sp.toString()
1049 + "associated alignment panels.", e);
1055 public void setJalviewColourScheme(ColourSchemeI ucs)
1057 jmb.setJalviewColourScheme(ucs);
1064 * @return first alignment panel displaying given alignment, or the default
1067 public AlignmentPanel getAlignmentPanelFor(AlignmentI alignment)
1069 for (AlignmentPanel ap : getAllAlignmentPanels())
1071 if (ap.av.getAlignment() == alignment)
1076 return getAlignmentPanel();
1080 public AAStructureBindingModel getBinding()
1086 * Ask Chimera to save its session to the designated file path. Returns true
1087 * if successful, else false.
1092 public boolean saveSession(String filepath)
1094 boolean result = jmb.saveSession(filepath);
1097 this.chimeraSessionFile = filepath;
1103 * Returns the file path of the Chimera session file the last time it was
1104 * saved. If it was never saved, returns an empty string. There is no
1105 * guarantee that the Chimera session has not changed since it was saved.
1108 public String getStateInfo()
1110 return this.chimeraSessionFile;