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.
21 package jalview.ext.rbvi.chimera;
23 import java.awt.Color;
24 import java.net.BindException;
25 import java.util.ArrayList;
26 import java.util.HashMap;
27 import java.util.LinkedHashMap;
28 import java.util.List;
31 import ext.edu.ucsf.rbvi.strucviz2.ChimeraManager;
32 import ext.edu.ucsf.rbvi.strucviz2.ChimeraModel;
33 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
34 import ext.edu.ucsf.rbvi.strucviz2.StructureManager.ModelType;
36 import jalview.api.AlignmentViewPanel;
37 import jalview.api.FeatureRenderer;
38 import jalview.api.SequenceRenderer;
39 import jalview.bin.Cache;
40 import jalview.datamodel.AlignmentI;
41 import jalview.datamodel.ColumnSelection;
42 import jalview.datamodel.PDBEntry;
43 import jalview.datamodel.SequenceI;
44 import jalview.schemes.ColourSchemeI;
45 import jalview.schemes.ResidueProperties;
46 import jalview.structure.AtomSpec;
47 import jalview.structure.StructureMapping;
48 import jalview.structure.StructureMappingcommandSet;
49 import jalview.structure.StructureSelectionManager;
50 import jalview.structures.models.AAStructureBindingModel;
51 import jalview.util.Comparison;
52 import jalview.util.MessageManager;
54 public abstract class JalviewChimeraBinding extends AAStructureBindingModel
57 private static final boolean debug = false;
59 private static final String PHOSPHORUS = "P";
61 private static final String ALPHACARBON = "CA";
63 private StructureManager csm;
66 * Object through which we talk to Chimera
68 private ChimeraManager viewer;
71 * Object which listens to Chimera notifications
73 private ChimeraListener chimeraListener;
76 * set if chimera state is being restored from some source - instructs binding
77 * not to apply default display style when structure set is updated for first
80 private boolean loadingFromArchive = false;
83 * flag to indicate if the Chimera viewer should ignore sequence colouring
84 * events from the structure manager because the GUI is still setting up
86 private boolean loadingFinished = true;
89 * state flag used to check if the Chimera viewer's paint method can be called
91 private boolean finishedInit = false;
93 private List<String> atomsPicked = new ArrayList<String>();
95 private List<String> chainNames;
97 private Map<String, String> chainFile;
99 public String fileLoadingError;
102 * Map of ChimeraModel objects keyed by PDB full local file name
104 private Map<String, List<ChimeraModel>> chimeraMaps = new LinkedHashMap<String, List<ChimeraModel>>();
107 * the default or current model displayed if the model cannot be identified
108 * from the selection message
110 private int frameNo = 0;
112 private String lastCommand;
114 private boolean loadedInline;
117 * current set of model filenames loaded
119 String[] modelFileNames = null;
121 String lastMousedOverAtomSpec;
123 private List<String> lastReply;
126 * incremented every time a load notification is successfully handled -
127 * lightweight mechanism for other threads to detect when they can start
128 * referring to new structures.
130 private long loadNotifiesHandled = 0;
133 * Open a PDB structure file in Chimera and set up mappings from Jalview.
135 * We check if the PDB model id is already loaded in Chimera, if so don't
136 * reopen it. This is the case if Chimera has opened a saved session file.
141 public boolean openFile(PDBEntry pe)
143 String file = pe.getFile();
146 List<ChimeraModel> modelsToMap = new ArrayList<ChimeraModel>();
147 List<ChimeraModel> oldList = viewer.getModelList();
148 boolean alreadyOpen = false;
151 * If Chimera already has this model, don't reopen it, but do remap it.
153 for (ChimeraModel open : oldList)
155 if (open.getModelName().equals(pe.getId()))
158 modelsToMap.add(open);
163 * If Chimera doesn't yet have this model, ask it to open it, and retrieve
164 * the model name(s) added by Chimera.
168 viewer.openModel(file, pe.getId(), ModelType.PDB_MODEL);
169 List<ChimeraModel> newList = viewer.getModelList();
170 // JAL-1728 newList.removeAll(oldList) does not work
171 for (ChimeraModel cm : newList)
173 if (cm.getModelName().equals(pe.getId()))
180 chimeraMaps.put(file, modelsToMap);
182 if (getSsm() != null)
184 getSsm().addStructureViewerListener(this);
185 // ssm.addSelectionListener(this);
186 FeatureRenderer fr = getFeatureRenderer(null);
194 } catch (Exception q)
196 log("Exception when trying to open model " + file + "\n"
212 public JalviewChimeraBinding(StructureSelectionManager ssm,
213 PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
216 super(ssm, pdbentry, sequenceIs, chains, protocol);
217 viewer = new ChimeraManager(
218 csm = new ext.edu.ucsf.rbvi.strucviz2.StructureManager(true));
222 * Start a dedicated HttpServer to listen for Chimera notifications, and tell
223 * it to start listening
225 public void startChimeraListener()
229 chimeraListener = new ChimeraListener(this);
230 viewer.startListening(chimeraListener.getUri());
231 } catch (BindException e)
233 System.err.println("Failed to start Chimera listener: "
244 public JalviewChimeraBinding(StructureSelectionManager ssm,
245 ChimeraManager theViewer)
249 csm = viewer.getStructureManager();
253 * Construct a title string for the viewer window based on the data Jalview
259 public String getViewerTitle(boolean verbose)
261 return getViewerTitle("Chimera", verbose);
265 * prepare the view for a given set of models/chains. chainList contains
266 * strings of the form 'pdbfilename:Chaincode'
269 * list of chains to make visible
271 public void centerViewer(List<String> toshow)
273 StringBuilder cmd = new StringBuilder(64);
275 for (String lbl : toshow)
281 mlength = lbl.indexOf(":", p);
282 } while (p < mlength && mlength < (lbl.length() - 2));
283 // TODO: lookup each pdb id and recover proper model number for it.
284 cmd.append("#" + getModelNum(chainFile.get(lbl)) + "."
285 + lbl.substring(mlength + 1) + " or ");
287 if (cmd.length() > 0)
289 cmd.setLength(cmd.length() - 4);
291 String cmdstring = cmd.toString();
292 evalStateCommand("~display #*; ~ribbon #*; ribbon " + cmdstring
293 + ";focus " + cmdstring, false);
297 * Close down the Jalview viewer and listener, and (optionally) the associated
300 public void closeViewer(boolean closeChimera)
302 getSsm().removeStructureViewerListener(this, this.getPdbFile());
305 viewer.exitChimera();
307 if (this.chimeraListener != null)
309 chimeraListener.shutdown();
310 chimeraListener = null;
315 releaseUIResources();
318 public void colourByChain()
320 colourBySequence = false;
321 evalStateCommand("rainbow chain", false);
324 public void colourByCharge()
326 colourBySequence = false;
328 "color white;color red ::ASP;color red ::GLU;color blue ::LYS;color blue ::ARG;color yellow ::CYS",
333 * superpose the structures associated with sequences in the alignment
334 * according to their corresponding positions.
336 public void superposeStructures(AlignmentI alignment)
338 superposeStructures(alignment, -1, null);
342 * superpose the structures associated with sequences in the alignment
343 * according to their corresponding positions. ded)
345 * @param refStructure
346 * - select which pdb file to use as reference (default is -1 - the
347 * first structure in the alignment)
349 public void superposeStructures(AlignmentI alignment, int refStructure)
351 superposeStructures(alignment, refStructure, null);
355 * superpose the structures associated with sequences in the alignment
356 * according to their corresponding positions. ded)
358 * @param refStructure
359 * - select which pdb file to use as reference (default is -1 - the
360 * first structure in the alignment)
364 public void superposeStructures(AlignmentI alignment, int refStructure,
365 ColumnSelection hiddenCols)
367 superposeStructures(new AlignmentI[]
368 { alignment }, new int[]
369 { refStructure }, new ColumnSelection[]
373 public void superposeStructures(AlignmentI[] _alignment,
374 int[] _refStructure, ColumnSelection[] _hiddenCols)
376 assert (_alignment.length == _refStructure.length && _alignment.length != _hiddenCols.length);
377 StringBuilder allComs = new StringBuilder(128); // Chimera superposition cmd
378 String[] files = getPdbFile();
379 // check to see if we are still waiting for Chimera files
380 long starttime = System.currentTimeMillis();
381 boolean waiting = true;
385 for (String file : files)
389 // HACK - in Jalview 2.8 this call may not be threadsafe so we catch
390 // every possible exception
391 StructureMapping[] sm = getSsm().getMapping(file);
392 if (sm == null || sm.length == 0)
396 } catch (Exception x)
404 // we wait around for a reasonable time before we give up
406 && System.currentTimeMillis() < (10000 + 1000 * files.length + starttime));
410 .println("RUNTIME PROBLEM: Chimera seems to be taking a long time to process all the structures.");
414 StringBuffer selectioncom = new StringBuffer();
415 for (int a = 0; a < _alignment.length; a++)
417 int refStructure = _refStructure[a];
418 AlignmentI alignment = _alignment[a];
419 ColumnSelection hiddenCols = _hiddenCols[a];
421 && selectioncom.length() > 0
422 && !selectioncom.substring(selectioncom.length() - 1).equals(
425 selectioncom.append(" ");
427 // process this alignment
428 if (refStructure >= files.length)
430 System.err.println("Invalid reference structure value "
434 if (refStructure < -1)
439 boolean matched[] = new boolean[alignment.getWidth()];
440 for (int m = 0; m < matched.length; m++)
443 matched[m] = (hiddenCols != null) ? hiddenCols.isVisible(m) : true;
446 int commonrpositions[][] = new int[files.length][alignment.getWidth()];
447 String isel[] = new String[files.length];
448 String[] targetC = new String[files.length];
449 String[] chainNames = new String[files.length];
450 String[] atomSpec = new String[files.length];
451 for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
453 StructureMapping[] mapping = getSsm().getMapping(files[pdbfnum]);
454 // RACE CONDITION - getMapping only returns Jmol loaded filenames once
455 // Jmol callback has completed.
456 if (mapping == null || mapping.length < 1)
458 throw new Error(MessageManager.getString("error.implementation_error_chimera_getting_data"));
461 final int seqCountForPdbFile = getSequence()[pdbfnum].length;
462 for (int s = 0; s < seqCountForPdbFile; s++)
464 for (int sp, m = 0; m < mapping.length; m++)
466 final SequenceI theSequence = getSequence()[pdbfnum][s];
467 if (mapping[m].getSequence() == theSequence
468 && (sp = alignment.findIndex(theSequence)) > -1)
470 if (refStructure == -1)
472 refStructure = pdbfnum;
474 SequenceI asp = alignment.getSequenceAt(sp);
475 for (int r = 0; r < matched.length; r++)
481 matched[r] = false; // assume this is not a good site
482 if (r >= asp.getLength())
487 if (Comparison.isGap(asp.getCharAt(r)))
489 // no mapping to gaps in sequence
492 int t = asp.findPosition(r); // sequence position
493 int apos = mapping[m].getAtomNum(t);
494 int pos = mapping[m].getPDBResNum(t);
496 if (pos < 1 || pos == lastPos)
498 // can't align unmapped sequence
501 matched[r] = true; // this is a good ite
503 // just record this residue position
504 commonrpositions[pdbfnum][r] = pos;
506 // create model selection suffix
507 isel[pdbfnum] = "#" + pdbfnum;
508 if (mapping[m].getChain() == null
509 || mapping[m].getChain().trim().length() == 0)
511 targetC[pdbfnum] = "";
515 targetC[pdbfnum] = "." + mapping[m].getChain();
517 chainNames[pdbfnum] = mapping[m].getPdbId()
519 atomSpec[pdbfnum] = asp.getRNA() != null ? PHOSPHORUS : ALPHACARBON;
520 // move on to next pdb file
521 s = seqCountForPdbFile;
528 // TODO: consider bailing if nmatched less than 4 because superposition
531 // TODO: refactor superposable position search (above) from jmol selection
532 // construction (below)
534 String[] selcom = new String[files.length];
537 // generate select statements to select regions to superimpose structures
539 for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
541 String chainCd = targetC[pdbfnum];
544 StringBuffer molsel = new StringBuffer();
545 for (int r = 0; r < matched.length; r++)
553 if (lpos != commonrpositions[pdbfnum][r] - 1)
558 molsel.append((run ? "" : ":") + lpos);
559 molsel.append(chainCd);
565 // continuous run - and lpos >-1
568 // at the beginning, so add dash
569 molsel.append(":" + lpos);
574 lpos = commonrpositions[pdbfnum][r];
575 // molsel.append(lpos);
578 // add final selection phrase
581 molsel.append((run ? "" : ":") + lpos);
582 molsel.append(chainCd);
583 // molsel.append("");
585 if (molsel.length() > 1)
587 selcom[pdbfnum] = molsel.toString();
588 selectioncom.append("#" + pdbfnum);
589 selectioncom.append(selcom[pdbfnum]);
590 selectioncom.append(" ");
591 if (pdbfnum < files.length - 1)
593 selectioncom.append("| ");
598 selcom[pdbfnum] = null;
602 StringBuilder command = new StringBuilder(256);
603 for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
605 if (pdbfnum == refStructure || selcom[pdbfnum] == null
606 || selcom[refStructure] == null)
610 if (command.length() > 0)
616 * Form Chimera match command, from the 'new' structure to the
617 * 'reference' structure e.g. (residues 1-91, chain B/A, alphacarbons):
619 * match #1:1-91.B@CA #0:1-91.A@CA
622 * https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/match.html
624 command.append("match #" + pdbfnum /* +".1" */);
625 // TODO: handle sub-models
626 command.append(selcom[pdbfnum]);
627 command.append("@" + atomSpec[pdbfnum]);
628 command.append(" #" + refStructure /* +".1" */);
629 command.append(selcom[refStructure]);
630 command.append("@" + atomSpec[refStructure]);
632 if (selectioncom.length() > 0)
636 System.out.println("Select regions:\n" + selectioncom.toString());
637 System.out.println("Superimpose command(s):\n"
638 + command.toString());
640 allComs.append("~display all; chain @CA|P; ribbon "
641 + selectioncom.toString() + ";"+command.toString());
642 // selcom.append("; ribbons; ");
645 if (selectioncom.length() > 0)
646 {// finally, mark all regions that were superposed.
647 if (selectioncom.substring(selectioncom.length() - 1).equals("|"))
649 selectioncom.setLength(selectioncom.length() - 1);
653 System.out.println("Select regions:\n" + selectioncom.toString());
655 allComs.append("; ~display all; chain @CA|P; ribbon "
656 + selectioncom.toString() + "; focus");
657 // evalStateCommand("select *; backbone; select "+selcom.toString()+"; cartoons; center "+selcom.toString());
658 evalStateCommand(allComs.toString(), true /* false */);
663 private void checkLaunched()
665 if (!viewer.isChimeraLaunched())
667 viewer.launchChimera(StructureManager.getChimeraPaths());
669 if (!viewer.isChimeraLaunched())
671 log("Failed to launch Chimera!");
676 * Answers true if the Chimera process is still running, false if ended or not
681 public boolean isChimeraRunning()
683 return viewer.isChimeraLaunched();
687 * Send a command to Chimera, launching it first if necessary, and optionally
693 public void evalStateCommand(final String command, boolean logResponse)
695 viewerCommandHistory(false);
697 if (lastCommand == null || !lastCommand.equals(command))
699 // trim command or it may never find a match in the replyLog!!
700 lastReply = viewer.sendChimeraCommand(command.trim(), logResponse);
701 if (debug && logResponse)
703 log("Response from command ('" + command + "') was:\n" + lastReply);
706 viewerCommandHistory(true);
707 lastCommand = command;
711 * colour any structures associated with sequences in the given alignment
712 * using the getFeatureRenderer() and getSequenceRenderer() renderers but only
713 * if colourBySequence is enabled.
715 public void colourBySequence(boolean showFeatures,
716 jalview.api.AlignmentViewPanel alignmentv)
718 if (!colourBySequence || !loadingFinished)
722 if (getSsm() == null)
726 String[] files = getPdbFile();
728 SequenceRenderer sr = getSequenceRenderer(alignmentv);
730 FeatureRenderer fr = null;
733 fr = getFeatureRenderer(alignmentv);
735 AlignmentI alignment = alignmentv.getAlignment();
737 for (jalview.structure.StructureMappingcommandSet cpdbbyseq : getColourBySequenceCommands(
738 files, sr, fr, alignment))
740 for (String command : cpdbbyseq.commands)
742 executeWhenReady(command);
754 protected StructureMappingcommandSet[] getColourBySequenceCommands(
755 String[] files, SequenceRenderer sr, FeatureRenderer fr,
756 AlignmentI alignment)
758 return ChimeraCommands.getColourBySequenceCommand(getSsm(), files,
759 getSequence(), sr, fr, alignment);
765 protected void executeWhenReady(String command)
768 evalStateCommand(command, false);
772 private void waitForChimera()
774 while (viewer != null && viewer.isBusy())
778 } catch (InterruptedException q)
785 // End StructureListener
786 // //////////////////////////
788 public Color getColour(int atomIndex, int pdbResNum, String chain,
791 if (getModelNum(pdbfile) < 0)
795 log("get model / residue colour attribute unimplemented");
800 * returns the current featureRenderer that should be used to colour the
807 public abstract FeatureRenderer getFeatureRenderer(
808 AlignmentViewPanel alignment);
811 * instruct the Jalview binding to update the pdbentries vector if necessary
812 * prior to matching the jmol view's contents to the list of structure files
813 * Jalview knows about.
815 public abstract void refreshPdbEntries();
817 private int getModelNum(String modelFileName)
819 String[] mfn = getPdbFile();
824 for (int i = 0; i < mfn.length; i++)
826 if (mfn[i].equalsIgnoreCase(modelFileName))
835 * map between index of model filename returned from getPdbFile and the first
836 * index of models from this file in the viewer. Note - this is not trimmed -
837 * use getPdbFile to get number of unique models.
839 private int _modelFileNameMap[];
841 // ////////////////////////////////
842 // /StructureListener
843 public synchronized String[] getPdbFile()
847 return new String[0];
849 // if (modelFileNames == null)
851 // Collection<ChimeraModel> chimodels = viewer.getChimeraModels();
852 // _modelFileNameMap = new int[chimodels.size()];
854 // for (ChimeraModel chimodel : chimodels)
856 // String mdlName = chimodel.getModelName();
858 // modelFileNames = new String[j];
859 // // System.arraycopy(mset, 0, modelFileNames, 0, j);
862 return chimeraMaps.keySet().toArray(
863 modelFileNames = new String[chimeraMaps.size()]);
867 * map from string to applet
869 public Map getRegistryInfo()
871 // TODO Auto-generated method stub
876 * returns the current sequenceRenderer that should be used to colour the
883 public abstract SequenceRenderer getSequenceRenderer(
884 AlignmentViewPanel alignment);
887 * Construct and send a command to highlight an atom.
890 * Done by generating a command like (to 'highlight' position 44)
891 * ~show #0:43.C;show #0:44.C
892 * Note this removes the highlight from the previous position.
895 public void highlightAtom(int atomIndex, int pdbResNum, String chain,
898 List<ChimeraModel> cms = chimeraMaps.get(pdbfile);
901 StringBuilder sb = new StringBuilder();
902 sb.append(" #" + cms.get(0).getModelNumber());
903 sb.append(":" + pdbResNum);
904 if (!chain.equals(" "))
906 sb.append("." + chain);
908 String atomSpec = sb.toString();
910 StringBuilder command = new StringBuilder(32);
911 if (lastMousedOverAtomSpec != null)
913 command.append("~show " + lastMousedOverAtomSpec + ";");
915 viewerCommandHistory(false);
916 command.append("show ").append(atomSpec);
917 String cmd = command.toString();
918 if (cmd.length() > 0)
920 viewer.stopListening(chimeraListener.getUri());
921 viewer.sendChimeraCommand(cmd, false);
922 viewer.startListening(chimeraListener.getUri());
924 viewerCommandHistory(true);
925 this.lastMousedOverAtomSpec = atomSpec;
930 * Query Chimera for its current selection, and highlight it on the alignment
932 public void highlightChimeraSelection()
934 List<String> selection = viewer.getSelectedResidueSpecs();
935 // System.out.println("Chimera selection: " + selection.toString());
937 // TODO handle more than one!!
938 if (selection.size() > 0)
940 highlightChimeraSelection(selection);
944 private void log(String message)
946 System.err.println("## Chimera log: " + message);
949 private void viewerCommandHistory(boolean enable)
951 // log("(Not yet implemented) History "
952 // + ((debug || enable) ? "on" : "off"));
956 * Propagate atom selections from Chimera
959 * for example "#0:70.A" (model/residue/chain)
961 public void highlightChimeraSelection(List<String> atoms)
963 List<AtomSpec> atomSpecs = new ArrayList<AtomSpec>();
964 for (String atomSpec : atoms)
966 int hashPos = atomSpec.indexOf("#");
967 int colonPos = atomSpec.indexOf(":");
968 int dotPos = atomSpec.indexOf(".");
972 continue; // malformed
974 int pdbResNum = Integer.parseInt(dotPos == -1 ? atomSpec
975 .substring(colonPos) : atomSpec.substring(colonPos + 1,
978 String chainId = dotPos == -1 ? "" : atomSpec.substring(dotPos + 1);
981 modelId = Integer.valueOf(atomSpec.substring(hashPos + 1, colonPos));
982 } catch (NumberFormatException e) {
983 // ignore, default to model 0
987 * Work out the pdbfilename from the model number
989 String pdbfilename = modelFileNames[frameNo];
990 findfileloop: for (String pdbfile : this.chimeraMaps.keySet())
992 for (ChimeraModel cm : chimeraMaps.get(pdbfile))
994 if (cm.getModelNumber() == modelId)
996 pdbfilename = pdbfile;
1001 atomSpecs.add(new AtomSpec(pdbfilename, chainId, pdbResNum, 0));
1003 if (!atomSpecs.isEmpty())
1005 getSsm().mouseOverStructure(atomSpecs);
1009 public long getLoadNotifiesHandled()
1011 return loadNotifiesHandled;
1014 public void setJalviewColourScheme(ColourSchemeI cs)
1016 colourBySequence = false;
1025 // Chimera expects RBG values in the range 0-1
1026 final double normalise = 255D;
1027 viewerCommandHistory(false);
1028 // TODO: Switch between nucleotide or aa selection expressions
1029 StringBuilder command = new StringBuilder(128);
1030 command.append("color white;");
1031 for (String res : ResidueProperties.aa3Hash.keySet())
1033 index = ResidueProperties.aa3Hash.get(res).intValue();
1039 col = cs.findColour(ResidueProperties.aa[index].charAt(0));
1040 command.append("color " + col.getRed() / normalise + ","
1041 + col.getGreen() / normalise + "," + col.getBlue()
1042 / normalise + " ::" + res + ";");
1045 evalStateCommand(command.toString(),false);
1046 viewerCommandHistory(true);
1050 * called when the binding thinks the UI needs to be refreshed after a Chimera
1051 * state change. this could be because structures were loaded, or because an
1052 * error has occurred.
1054 public abstract void refreshGUI();
1056 public void setLoadingFromArchive(boolean loadingFromArchive)
1058 this.loadingFromArchive = loadingFromArchive;
1063 * @return true if Chimeral is still restoring state or loading is still going
1064 * on (see setFinsihedLoadingFromArchive)
1066 public boolean isLoadingFromArchive()
1068 return loadingFromArchive && !loadingFinished;
1072 * modify flag which controls if sequence colouring events are honoured by the
1073 * binding. Should be true for normal operation
1075 * @param finishedLoading
1077 public void setFinishedLoadingFromArchive(boolean finishedLoading)
1079 loadingFinished = finishedLoading;
1083 * Send the Chimera 'background solid <color>" command.
1086 * ://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/background
1090 public void setBackgroundColour(Color col)
1092 viewerCommandHistory(false);
1093 double normalise = 255D;
1094 final String command = "background solid " + col.getRed() / normalise + ","
1095 + col.getGreen() / normalise + "," + col.getBlue()
1097 viewer.sendChimeraCommand(command, false);
1098 viewerCommandHistory(true);
1104 * @return text report of alignment between pdbfile and any associated
1105 * alignment sequences
1107 public String printMapping(String pdbfile)
1109 return getSsm().printMapping(pdbfile);
1113 * Ask Chimera to save its session to the given file. Returns true if
1114 * successful, else false.
1119 public boolean saveSession(String filepath)
1121 if (isChimeraRunning())
1123 List<String> reply = viewer.sendChimeraCommand("save " + filepath,
1125 if (reply.contains("Session written"))
1132 .error("Error saving Chimera session: " + reply.toString());
1139 * Ask Chimera to open a session file. Returns true if successful, else false.
1140 * The filename must have a .py extension for this command to work.
1145 public boolean openSession(String filepath)
1147 evalStateCommand("open " + filepath, true);
1148 // todo: test for failure - how?
1152 public boolean isFinishedInit()
1154 return finishedInit;
1157 public void setFinishedInit(boolean finishedInit)
1159 this.finishedInit = finishedInit;
1162 public List<String> getChainNames()