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.LinkedHashMap;
27 import java.util.List;
30 import ext.edu.ucsf.rbvi.strucviz2.ChimeraManager;
31 import ext.edu.ucsf.rbvi.strucviz2.ChimeraModel;
32 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
33 import ext.edu.ucsf.rbvi.strucviz2.StructureManager.ModelType;
35 import jalview.api.AlignmentViewPanel;
36 import jalview.api.FeatureRenderer;
37 import jalview.api.SequenceRenderer;
38 import jalview.bin.Cache;
39 import jalview.datamodel.AlignmentI;
40 import jalview.datamodel.ColumnSelection;
41 import jalview.datamodel.PDBEntry;
42 import jalview.datamodel.SequenceI;
43 import jalview.schemes.ColourSchemeI;
44 import jalview.schemes.ResidueProperties;
45 import jalview.structure.AtomSpec;
46 import jalview.structure.StructureMapping;
47 import jalview.structure.StructureMappingcommandSet;
48 import jalview.structure.StructureSelectionManager;
49 import jalview.structures.models.AAStructureBindingModel;
50 import jalview.util.Comparison;
51 import jalview.util.MessageManager;
53 public abstract class JalviewChimeraBinding extends AAStructureBindingModel
56 private static final boolean debug = false;
58 private static final String PHOSPHORUS = "P";
60 private static final String ALPHACARBON = "CA";
62 private StructureManager csm;
65 * Object through which we talk to Chimera
67 private ChimeraManager viewer;
70 * Object which listens to Chimera notifications
72 private ChimeraListener chimeraListener;
75 * set if chimera state is being restored from some source - instructs binding
76 * not to apply default display style when structure set is updated for first
79 private boolean loadingFromArchive = false;
82 * flag to indicate if the Chimera viewer should ignore sequence colouring
83 * events from the structure manager because the GUI is still setting up
85 private boolean loadingFinished = true;
88 * state flag used to check if the Chimera viewer's paint method can be called
90 private boolean finishedInit = false;
92 private List<String> atomsPicked = new ArrayList<String>();
94 private List<String> chainNames;
96 private Map<String, String> chainFile;
98 public String fileLoadingError;
101 * Map of ChimeraModel objects keyed by PDB full local file name
103 private Map<String, List<ChimeraModel>> chimeraMaps = new LinkedHashMap<String, List<ChimeraModel>>();
106 * the default or current model displayed if the model cannot be identified
107 * from the selection message
109 private int frameNo = 0;
111 private String lastCommand;
113 private boolean loadedInline;
116 * current set of model filenames loaded
118 String[] modelFileNames = null;
120 String lastMousedOverAtomSpec;
122 private List<String> lastReply;
125 * incremented every time a load notification is successfully handled -
126 * lightweight mechanism for other threads to detect when they can start
127 * referring to new structures.
129 private long loadNotifiesHandled = 0;
132 * Open a PDB structure file in Chimera and set up mappings from Jalview.
134 * We check if the PDB model id is already loaded in Chimera, if so don't
135 * reopen it. This is the case if Chimera has opened a saved session file.
140 public boolean openFile(PDBEntry pe)
142 String file = pe.getFile();
145 List<ChimeraModel> modelsToMap = new ArrayList<ChimeraModel>();
146 List<ChimeraModel> oldList = viewer.getModelList();
147 boolean alreadyOpen = false;
150 * If Chimera already has this model, don't reopen it, but do remap it.
152 for (ChimeraModel open : oldList)
154 if (open.getModelName().equals(pe.getId()))
157 modelsToMap.add(open);
162 * If Chimera doesn't yet have this model, ask it to open it, and retrieve
163 * the model name(s) added by Chimera.
167 viewer.openModel(file, pe.getId(), ModelType.PDB_MODEL);
168 List<ChimeraModel> newList = viewer.getModelList();
169 // JAL-1728 newList.removeAll(oldList) does not work
170 for (ChimeraModel cm : newList)
172 if (cm.getModelName().equals(pe.getId()))
179 chimeraMaps.put(file, modelsToMap);
181 if (getSsm() != null)
183 getSsm().addStructureViewerListener(this);
184 // ssm.addSelectionListener(this);
185 FeatureRenderer fr = getFeatureRenderer(null);
193 } catch (Exception q)
195 log("Exception when trying to open model " + file + "\n"
211 public JalviewChimeraBinding(StructureSelectionManager ssm,
212 PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
215 super(ssm, pdbentry, sequenceIs, chains, protocol);
216 viewer = new ChimeraManager(
217 csm = new ext.edu.ucsf.rbvi.strucviz2.StructureManager(true));
221 * Start a dedicated HttpServer to listen for Chimera notifications, and tell
222 * it to start listening
224 public void startChimeraListener()
228 chimeraListener = new ChimeraListener(this);
229 viewer.startListening(chimeraListener.getUri());
230 } catch (BindException e)
232 System.err.println("Failed to start Chimera listener: "
243 public JalviewChimeraBinding(StructureSelectionManager ssm,
244 ChimeraManager theViewer)
248 csm = viewer.getStructureManager();
252 * Construct a title string for the viewer window based on the data Jalview
258 public String getViewerTitle(boolean verbose)
260 return getViewerTitle("Chimera", verbose);
264 * prepare the view for a given set of models/chains. chainList contains
265 * strings of the form 'pdbfilename:Chaincode'
268 * list of chains to make visible
270 public void centerViewer(List<String> toshow)
272 StringBuilder cmd = new StringBuilder(64);
274 for (String lbl : toshow)
280 mlength = lbl.indexOf(":", p);
281 } while (p < mlength && mlength < (lbl.length() - 2));
282 // TODO: lookup each pdb id and recover proper model number for it.
283 cmd.append("#" + getModelNum(chainFile.get(lbl)) + "."
284 + lbl.substring(mlength + 1) + " or ");
286 if (cmd.length() > 0)
288 cmd.setLength(cmd.length() - 4);
290 String cmdstring = cmd.toString();
291 evalStateCommand("~display #*; ~ribbon #*; ribbon " + cmdstring
292 + ";focus " + cmdstring, false);
296 * Close down the Jalview viewer and listener, and (optionally) the associated
299 public void closeViewer(boolean closeChimera)
301 getSsm().removeStructureViewerListener(this, this.getPdbFile());
304 viewer.exitChimera();
306 if (this.chimeraListener != null)
308 chimeraListener.shutdown();
309 chimeraListener = null;
314 releaseUIResources();
317 public void colourByChain()
319 colourBySequence = false;
320 evalStateCommand("rainbow chain", false);
323 public void colourByCharge()
325 colourBySequence = false;
327 "color white;color red ::ASP;color red ::GLU;color blue ::LYS;color blue ::ARG;color yellow ::CYS",
332 * superpose the structures associated with sequences in the alignment
333 * according to their corresponding positions.
335 public void superposeStructures(AlignmentI alignment)
337 superposeStructures(alignment, -1, null);
341 * superpose the structures associated with sequences in the alignment
342 * according to their corresponding positions. ded)
344 * @param refStructure
345 * - select which pdb file to use as reference (default is -1 - the
346 * first structure in the alignment)
348 public void superposeStructures(AlignmentI alignment, int refStructure)
350 superposeStructures(alignment, refStructure, null);
354 * superpose the structures associated with sequences in the alignment
355 * according to their corresponding positions. ded)
357 * @param refStructure
358 * - select which pdb file to use as reference (default is -1 - the
359 * first structure in the alignment)
363 public void superposeStructures(AlignmentI alignment, int refStructure,
364 ColumnSelection hiddenCols)
366 superposeStructures(new AlignmentI[]
367 { alignment }, new int[]
368 { refStructure }, new ColumnSelection[]
372 public void superposeStructures(AlignmentI[] _alignment,
373 int[] _refStructure, ColumnSelection[] _hiddenCols)
375 assert (_alignment.length == _refStructure.length && _alignment.length != _hiddenCols.length);
376 StringBuilder allComs = new StringBuilder(128); // Chimera superposition cmd
377 String[] files = getPdbFile();
378 // check to see if we are still waiting for Chimera files
379 long starttime = System.currentTimeMillis();
380 boolean waiting = true;
384 for (String file : files)
388 // HACK - in Jalview 2.8 this call may not be threadsafe so we catch
389 // every possible exception
390 StructureMapping[] sm = getSsm().getMapping(file);
391 if (sm == null || sm.length == 0)
395 } catch (Exception x)
403 // we wait around for a reasonable time before we give up
405 && System.currentTimeMillis() < (10000 + 1000 * files.length + starttime));
409 .println("RUNTIME PROBLEM: Chimera seems to be taking a long time to process all the structures.");
413 StringBuffer selectioncom = new StringBuffer();
414 for (int a = 0; a < _alignment.length; a++)
416 int refStructure = _refStructure[a];
417 AlignmentI alignment = _alignment[a];
418 ColumnSelection hiddenCols = _hiddenCols[a];
420 && selectioncom.length() > 0
421 && !selectioncom.substring(selectioncom.length() - 1).equals(
424 selectioncom.append(" ");
426 // process this alignment
427 if (refStructure >= files.length)
429 System.err.println("Invalid reference structure value "
433 if (refStructure < -1)
438 boolean matched[] = new boolean[alignment.getWidth()];
439 for (int m = 0; m < matched.length; m++)
442 matched[m] = (hiddenCols != null) ? hiddenCols.isVisible(m) : true;
445 int commonrpositions[][] = new int[files.length][alignment.getWidth()];
446 String isel[] = new String[files.length];
447 String[] targetC = new String[files.length];
448 String[] chainNames = new String[files.length];
449 String[] atomSpec = new String[files.length];
450 for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
452 StructureMapping[] mapping = getSsm().getMapping(files[pdbfnum]);
453 // RACE CONDITION - getMapping only returns Jmol loaded filenames once
454 // Jmol callback has completed.
455 if (mapping == null || mapping.length < 1)
457 throw new Error(MessageManager.getString("error.implementation_error_chimera_getting_data"));
460 final int seqCountForPdbFile = getSequence()[pdbfnum].length;
461 for (int s = 0; s < seqCountForPdbFile; s++)
463 for (int sp, m = 0; m < mapping.length; m++)
465 final SequenceI theSequence = getSequence()[pdbfnum][s];
466 if (mapping[m].getSequence() == theSequence
467 && (sp = alignment.findIndex(theSequence)) > -1)
469 if (refStructure == -1)
471 refStructure = pdbfnum;
473 SequenceI asp = alignment.getSequenceAt(sp);
474 for (int r = 0; r < matched.length; r++)
480 matched[r] = false; // assume this is not a good site
481 if (r >= asp.getLength())
486 if (Comparison.isGap(asp.getCharAt(r)))
488 // no mapping to gaps in sequence
491 int t = asp.findPosition(r); // sequence position
492 int apos = mapping[m].getAtomNum(t);
493 int pos = mapping[m].getPDBResNum(t);
495 if (pos < 1 || pos == lastPos)
497 // can't align unmapped sequence
500 matched[r] = true; // this is a good ite
502 // just record this residue position
503 commonrpositions[pdbfnum][r] = pos;
505 // create model selection suffix
506 isel[pdbfnum] = "#" + pdbfnum;
507 if (mapping[m].getChain() == null
508 || mapping[m].getChain().trim().length() == 0)
510 targetC[pdbfnum] = "";
514 targetC[pdbfnum] = "." + mapping[m].getChain();
516 chainNames[pdbfnum] = mapping[m].getPdbId()
518 atomSpec[pdbfnum] = asp.getRNA() != null ? PHOSPHORUS : ALPHACARBON;
519 // move on to next pdb file
520 s = seqCountForPdbFile;
527 // TODO: consider bailing if nmatched less than 4 because superposition
530 // TODO: refactor superposable position search (above) from jmol selection
531 // construction (below)
533 String[] selcom = new String[files.length];
536 // generate select statements to select regions to superimpose structures
538 for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
540 String chainCd = targetC[pdbfnum];
543 StringBuffer molsel = new StringBuffer();
544 for (int r = 0; r < matched.length; r++)
552 if (lpos != commonrpositions[pdbfnum][r] - 1)
557 molsel.append((run ? "" : ":") + lpos);
558 molsel.append(chainCd);
564 // continuous run - and lpos >-1
567 // at the beginning, so add dash
568 molsel.append(":" + lpos);
573 lpos = commonrpositions[pdbfnum][r];
574 // molsel.append(lpos);
577 // add final selection phrase
580 molsel.append((run ? "" : ":") + lpos);
581 molsel.append(chainCd);
582 // molsel.append("");
584 if (molsel.length() > 1)
586 selcom[pdbfnum] = molsel.toString();
587 selectioncom.append("#" + pdbfnum);
588 selectioncom.append(selcom[pdbfnum]);
589 selectioncom.append(" ");
590 if (pdbfnum < files.length - 1)
592 selectioncom.append("| ");
597 selcom[pdbfnum] = null;
601 StringBuilder command = new StringBuilder(256);
602 for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
604 if (pdbfnum == refStructure || selcom[pdbfnum] == null
605 || selcom[refStructure] == null)
609 if (command.length() > 0)
615 * Form Chimera match command, from the 'new' structure to the
616 * 'reference' structure e.g. (residues 1-91, chain B/A, alphacarbons):
618 * match #1:1-91.B@CA #0:1-91.A@CA
621 * https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/match.html
623 command.append("match #" + pdbfnum /* +".1" */);
624 // TODO: handle sub-models
625 command.append(selcom[pdbfnum]);
626 command.append("@" + atomSpec[pdbfnum]);
627 command.append(" #" + refStructure /* +".1" */);
628 command.append(selcom[refStructure]);
629 command.append("@" + atomSpec[refStructure]);
631 if (selectioncom.length() > 0)
635 System.out.println("Select regions:\n" + selectioncom.toString());
636 System.out.println("Superimpose command(s):\n"
637 + command.toString());
639 allComs.append("~display all; chain @CA|P; ribbon "
640 + selectioncom.toString() + ";"+command.toString());
641 // selcom.append("; ribbons; ");
644 if (selectioncom.length() > 0)
645 {// finally, mark all regions that were superposed.
646 if (selectioncom.substring(selectioncom.length() - 1).equals("|"))
648 selectioncom.setLength(selectioncom.length() - 1);
652 System.out.println("Select regions:\n" + selectioncom.toString());
654 allComs.append("; ~display all; chain @CA|P; ribbon "
655 + selectioncom.toString() + "; focus");
656 // evalStateCommand("select *; backbone; select "+selcom.toString()+"; cartoons; center "+selcom.toString());
657 evalStateCommand(allComs.toString(), true /* false */);
662 private void checkLaunched()
664 if (!viewer.isChimeraLaunched())
666 viewer.launchChimera(StructureManager.getChimeraPaths());
668 if (!viewer.isChimeraLaunched())
670 log("Failed to launch Chimera!");
675 * Answers true if the Chimera process is still running, false if ended or not
680 public boolean isChimeraRunning()
682 return viewer.isChimeraLaunched();
686 * Send a command to Chimera, launching it first if necessary, and optionally
692 public void evalStateCommand(final String command, boolean logResponse)
694 viewerCommandHistory(false);
696 if (lastCommand == null || !lastCommand.equals(command))
698 // trim command or it may never find a match in the replyLog!!
699 lastReply = viewer.sendChimeraCommand(command.trim(), logResponse);
700 if (debug && logResponse)
702 log("Response from command ('" + command + "') was:\n" + lastReply);
705 viewerCommandHistory(true);
706 lastCommand = command;
710 * colour any structures associated with sequences in the given alignment
711 * using the getFeatureRenderer() and getSequenceRenderer() renderers but only
712 * if colourBySequence is enabled.
714 public void colourBySequence(boolean showFeatures,
715 jalview.api.AlignmentViewPanel alignmentv)
717 if (!colourBySequence || !loadingFinished)
721 if (getSsm() == null)
725 String[] files = getPdbFile();
727 SequenceRenderer sr = getSequenceRenderer(alignmentv);
729 FeatureRenderer fr = null;
732 fr = getFeatureRenderer(alignmentv);
734 AlignmentI alignment = alignmentv.getAlignment();
736 for (jalview.structure.StructureMappingcommandSet cpdbbyseq : getColourBySequenceCommands(
737 files, sr, fr, alignment))
739 for (String command : cpdbbyseq.commands)
741 executeWhenReady(command);
753 protected StructureMappingcommandSet[] getColourBySequenceCommands(
754 String[] files, SequenceRenderer sr, FeatureRenderer fr,
755 AlignmentI alignment)
757 return ChimeraCommands.getColourBySequenceCommand(getSsm(), files,
758 getSequence(), sr, fr, alignment);
764 protected void executeWhenReady(String command)
767 evalStateCommand(command, false);
771 private void waitForChimera()
773 while (viewer != null && viewer.isBusy())
777 } catch (InterruptedException q)
784 // End StructureListener
785 // //////////////////////////
787 public Color getColour(int atomIndex, int pdbResNum, String chain,
790 if (getModelNum(pdbfile) < 0)
794 log("get model / residue colour attribute unimplemented");
799 * returns the current featureRenderer that should be used to colour the
806 public abstract FeatureRenderer getFeatureRenderer(
807 AlignmentViewPanel alignment);
810 * instruct the Jalview binding to update the pdbentries vector if necessary
811 * prior to matching the jmol view's contents to the list of structure files
812 * Jalview knows about.
814 public abstract void refreshPdbEntries();
816 private int getModelNum(String modelFileName)
818 String[] mfn = getPdbFile();
823 for (int i = 0; i < mfn.length; i++)
825 if (mfn[i].equalsIgnoreCase(modelFileName))
834 * map between index of model filename returned from getPdbFile and the first
835 * index of models from this file in the viewer. Note - this is not trimmed -
836 * use getPdbFile to get number of unique models.
838 private int _modelFileNameMap[];
840 // ////////////////////////////////
841 // /StructureListener
842 public synchronized String[] getPdbFile()
846 return new String[0];
848 // if (modelFileNames == null)
850 // Collection<ChimeraModel> chimodels = viewer.getChimeraModels();
851 // _modelFileNameMap = new int[chimodels.size()];
853 // for (ChimeraModel chimodel : chimodels)
855 // String mdlName = chimodel.getModelName();
857 // modelFileNames = new String[j];
858 // // System.arraycopy(mset, 0, modelFileNames, 0, j);
861 return chimeraMaps.keySet().toArray(
862 modelFileNames = new String[chimeraMaps.size()]);
866 * map from string to applet
868 public Map getRegistryInfo()
870 // TODO Auto-generated method stub
875 * returns the current sequenceRenderer that should be used to colour the
882 public abstract SequenceRenderer getSequenceRenderer(
883 AlignmentViewPanel alignment);
886 * Construct and send a command to highlight an atom.
889 * Done by generating a command like (to 'highlight' position 44)
890 * ~show #0:43.C;show #0:44.C
891 * Note this removes the highlight from the previous position.
894 public void highlightAtom(int atomIndex, int pdbResNum, String chain,
897 List<ChimeraModel> cms = chimeraMaps.get(pdbfile);
900 StringBuilder sb = new StringBuilder();
901 sb.append(" #" + cms.get(0).getModelNumber());
902 sb.append(":" + pdbResNum);
903 if (!chain.equals(" "))
905 sb.append("." + chain);
907 String atomSpec = sb.toString();
909 StringBuilder command = new StringBuilder(32);
910 if (lastMousedOverAtomSpec != null)
912 command.append("~show " + lastMousedOverAtomSpec + ";");
914 viewerCommandHistory(false);
915 command.append("show ").append(atomSpec);
916 String cmd = command.toString();
917 if (cmd.length() > 0)
919 viewer.stopListening(chimeraListener.getUri());
920 viewer.sendChimeraCommand(cmd, false);
921 viewer.startListening(chimeraListener.getUri());
923 viewerCommandHistory(true);
924 this.lastMousedOverAtomSpec = atomSpec;
929 * Query Chimera for its current selection, and highlight it on the alignment
931 public void highlightChimeraSelection()
934 * Ask Chimera for its current selection
936 List<String> selection = viewer.getSelectedResidueSpecs();
939 * Parse model number, residue and chain for each selected position,
940 * formatted as #0:123.A or #1.2:87.B (#model.submodel:residue.chain)
942 List<AtomSpec> atomSpecs = new ArrayList<AtomSpec>();
943 for (String atomSpec : selection)
945 int colonPos = atomSpec.indexOf(":");
948 continue; // malformed
951 int hashPos = atomSpec.indexOf("#");
952 String modelSubmodel = atomSpec.substring(hashPos + 1, colonPos);
953 int dotPos = modelSubmodel.indexOf(".");
956 modelId = Integer.valueOf(dotPos == -1 ? modelSubmodel
957 : modelSubmodel.substring(0, dotPos));
958 } catch (NumberFormatException e) {
959 // ignore, default to model 0
962 String residueChain = atomSpec.substring(colonPos + 1);
963 dotPos = residueChain.indexOf(".");
964 int pdbResNum = Integer.parseInt(dotPos == -1 ? residueChain
965 : residueChain.substring(0, dotPos));
967 String chainId = dotPos == -1 ? "" : residueChain
968 .substring(dotPos + 1);
971 * Work out the pdbfilename from the model number
973 String pdbfilename = modelFileNames[frameNo];
974 findfileloop: for (String pdbfile : this.chimeraMaps.keySet())
976 for (ChimeraModel cm : chimeraMaps.get(pdbfile))
978 if (cm.getModelNumber() == modelId)
980 pdbfilename = pdbfile;
985 atomSpecs.add(new AtomSpec(pdbfilename, chainId, pdbResNum, 0));
989 * Broadcast the selection (which may be empty, if the user just cleared all
992 getSsm().mouseOverStructure(atomSpecs);
995 private void log(String message)
997 System.err.println("## Chimera log: " + message);
1000 private void viewerCommandHistory(boolean enable)
1002 // log("(Not yet implemented) History "
1003 // + ((debug || enable) ? "on" : "off"));
1006 public long getLoadNotifiesHandled()
1008 return loadNotifiesHandled;
1011 public void setJalviewColourScheme(ColourSchemeI cs)
1013 colourBySequence = false;
1022 // Chimera expects RBG values in the range 0-1
1023 final double normalise = 255D;
1024 viewerCommandHistory(false);
1025 // TODO: Switch between nucleotide or aa selection expressions
1026 StringBuilder command = new StringBuilder(128);
1027 command.append("color white;");
1028 for (String res : ResidueProperties.aa3Hash.keySet())
1030 index = ResidueProperties.aa3Hash.get(res).intValue();
1036 col = cs.findColour(ResidueProperties.aa[index].charAt(0));
1037 command.append("color " + col.getRed() / normalise + ","
1038 + col.getGreen() / normalise + "," + col.getBlue()
1039 / normalise + " ::" + res + ";");
1042 evalStateCommand(command.toString(),false);
1043 viewerCommandHistory(true);
1047 * called when the binding thinks the UI needs to be refreshed after a Chimera
1048 * state change. this could be because structures were loaded, or because an
1049 * error has occurred.
1051 public abstract void refreshGUI();
1053 public void setLoadingFromArchive(boolean loadingFromArchive)
1055 this.loadingFromArchive = loadingFromArchive;
1060 * @return true if Chimeral is still restoring state or loading is still going
1061 * on (see setFinsihedLoadingFromArchive)
1063 public boolean isLoadingFromArchive()
1065 return loadingFromArchive && !loadingFinished;
1069 * modify flag which controls if sequence colouring events are honoured by the
1070 * binding. Should be true for normal operation
1072 * @param finishedLoading
1074 public void setFinishedLoadingFromArchive(boolean finishedLoading)
1076 loadingFinished = finishedLoading;
1080 * Send the Chimera 'background solid <color>" command.
1083 * ://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/background
1087 public void setBackgroundColour(Color col)
1089 viewerCommandHistory(false);
1090 double normalise = 255D;
1091 final String command = "background solid " + col.getRed() / normalise + ","
1092 + col.getGreen() / normalise + "," + col.getBlue()
1094 viewer.sendChimeraCommand(command, false);
1095 viewerCommandHistory(true);
1101 * @return text report of alignment between pdbfile and any associated
1102 * alignment sequences
1104 public String printMapping(String pdbfile)
1106 return getSsm().printMapping(pdbfile);
1110 * Ask Chimera to save its session to the given file. Returns true if
1111 * successful, else false.
1116 public boolean saveSession(String filepath)
1118 if (isChimeraRunning())
1120 List<String> reply = viewer.sendChimeraCommand("save " + filepath,
1122 if (reply.contains("Session written"))
1129 .error("Error saving Chimera session: " + reply.toString());
1136 * Ask Chimera to open a session file. Returns true if successful, else false.
1137 * The filename must have a .py extension for this command to work.
1142 public boolean openSession(String filepath)
1144 evalStateCommand("open " + filepath, true);
1145 // todo: test for failure - how?
1149 public boolean isFinishedInit()
1151 return finishedInit;
1154 public void setFinishedInit(boolean finishedInit)
1156 this.finishedInit = finishedInit;
1159 public List<String> getChainNames()