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.httpserver.AbstractRequestHandler;
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
56 // Chimera clause to exclude alternate locations in atom selection
57 private static final String NO_ALTLOCS = "&~@.B-Z&~@.2-9";
59 private static final boolean debug = false;
61 private static final String PHOSPHORUS = "P";
63 private static final String ALPHACARBON = "CA";
65 private StructureManager csm;
68 * Object through which we talk to Chimera
70 private ChimeraManager viewer;
73 * Object which listens to Chimera notifications
75 private AbstractRequestHandler chimeraListener;
78 * set if chimera state is being restored from some source - instructs binding
79 * not to apply default display style when structure set is updated for first
82 private boolean loadingFromArchive = false;
85 * flag to indicate if the Chimera viewer should ignore sequence colouring
86 * events from the structure manager because the GUI is still setting up
88 private boolean loadingFinished = true;
91 * state flag used to check if the Chimera viewer's paint method can be called
93 private boolean finishedInit = false;
95 private List<String> atomsPicked = new ArrayList<String>();
97 private List<String> chainNames;
99 private Map<String, String> chainFile;
101 public String fileLoadingError;
104 * Map of ChimeraModel objects keyed by PDB full local file name
106 private Map<String, List<ChimeraModel>> chimeraMaps = new LinkedHashMap<String, List<ChimeraModel>>();
109 * the default or current model displayed if the model cannot be identified
110 * from the selection message
112 private int frameNo = 0;
114 private String lastCommand;
116 private boolean loadedInline;
119 * current set of model filenames loaded
121 String[] modelFileNames = null;
123 String lastMousedOverAtomSpec;
125 private List<String> lastReply;
128 * incremented every time a load notification is successfully handled -
129 * lightweight mechanism for other threads to detect when they can start
130 * referring to new structures.
132 private long loadNotifiesHandled = 0;
135 * Open a PDB structure file in Chimera and set up mappings from Jalview.
137 * We check if the PDB model id is already loaded in Chimera, if so don't
138 * reopen it. This is the case if Chimera has opened a saved session file.
143 public boolean openFile(PDBEntry pe)
145 String file = pe.getFile();
148 List<ChimeraModel> modelsToMap = new ArrayList<ChimeraModel>();
149 List<ChimeraModel> oldList = viewer.getModelList();
150 boolean alreadyOpen = false;
153 * If Chimera already has this model, don't reopen it, but do remap it.
155 for (ChimeraModel open : oldList)
157 if (open.getModelName().equals(pe.getId()))
160 modelsToMap.add(open);
165 * If Chimera doesn't yet have this model, ask it to open it, and retrieve
166 * the model name(s) added by Chimera.
170 viewer.openModel(file, pe.getId(), ModelType.PDB_MODEL);
171 List<ChimeraModel> newList = viewer.getModelList();
172 // JAL-1728 newList.removeAll(oldList) does not work
173 for (ChimeraModel cm : newList)
175 if (cm.getModelName().equals(pe.getId()))
182 chimeraMaps.put(file, modelsToMap);
184 if (getSsm() != null)
186 getSsm().addStructureViewerListener(this);
187 // ssm.addSelectionListener(this);
188 FeatureRenderer fr = getFeatureRenderer(null);
196 } catch (Exception q)
198 log("Exception when trying to open model " + file + "\n"
214 public JalviewChimeraBinding(StructureSelectionManager ssm,
215 PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
218 super(ssm, pdbentry, sequenceIs, chains, protocol);
219 viewer = new ChimeraManager(
220 csm = new ext.edu.ucsf.rbvi.strucviz2.StructureManager(true));
224 * Start a dedicated HttpServer to listen for Chimera notifications, and tell
225 * it to start listening
227 public void startChimeraListener()
231 chimeraListener = new ChimeraListener(this);
232 viewer.startListening(chimeraListener.getUri());
233 } catch (BindException e)
235 System.err.println("Failed to start Chimera listener: "
246 public JalviewChimeraBinding(StructureSelectionManager ssm,
247 ChimeraManager theViewer)
251 csm = viewer.getStructureManager();
255 * Construct a title string for the viewer window based on the data Jalview
261 public String getViewerTitle(boolean verbose)
263 return getViewerTitle("Chimera", verbose);
267 * prepare the view for a given set of models/chains. chainList contains
268 * strings of the form 'pdbfilename:Chaincode'
271 * list of chains to make visible
273 public void centerViewer(List<String> toshow)
275 StringBuilder cmd = new StringBuilder(64);
277 for (String lbl : toshow)
283 mlength = lbl.indexOf(":", p);
284 } while (p < mlength && mlength < (lbl.length() - 2));
285 // TODO: lookup each pdb id and recover proper model number for it.
286 cmd.append("#" + getModelNum(chainFile.get(lbl)) + "."
287 + lbl.substring(mlength + 1) + " or ");
289 if (cmd.length() > 0)
291 cmd.setLength(cmd.length() - 4);
293 String cmdstring = cmd.toString();
294 evalStateCommand("~display #*; ~ribbon #*; ribbon " + cmdstring, false);
298 * Close down the Jalview viewer and listener, and (optionally) the associated
301 public void closeViewer(boolean closeChimera)
303 getSsm().removeStructureViewerListener(this, this.getPdbFile());
306 viewer.exitChimera();
308 if (this.chimeraListener != null)
310 chimeraListener.shutdown();
311 chimeraListener = null;
316 releaseUIResources();
319 public void colourByChain()
321 colourBySequence = false;
322 evalStateCommand("rainbow chain", false);
325 public void colourByCharge()
327 colourBySequence = false;
329 "color white;color red ::ASP;color red ::GLU;color blue ::LYS;color blue ::ARG;color yellow ::CYS",
334 * superpose the structures associated with sequences in the alignment
335 * according to their corresponding positions.
337 public void superposeStructures(AlignmentI alignment)
339 superposeStructures(alignment, -1, null);
343 * superpose the structures associated with sequences in the alignment
344 * according to their corresponding positions. ded)
346 * @param refStructure
347 * - select which pdb file to use as reference (default is -1 - the
348 * first structure in the alignment)
350 public void superposeStructures(AlignmentI alignment, int refStructure)
352 superposeStructures(alignment, refStructure, null);
356 * superpose the structures associated with sequences in the alignment
357 * according to their corresponding positions. ded)
359 * @param refStructure
360 * - select which pdb file to use as reference (default is -1 - the
361 * first structure in the alignment)
365 public void superposeStructures(AlignmentI alignment, int refStructure,
366 ColumnSelection hiddenCols)
368 superposeStructures(new AlignmentI[]
369 { alignment }, new int[]
370 { refStructure }, new ColumnSelection[]
374 public void superposeStructures(AlignmentI[] _alignment,
375 int[] _refStructure, ColumnSelection[] _hiddenCols)
377 assert (_alignment.length == _refStructure.length && _alignment.length != _hiddenCols.length);
378 StringBuilder allComs = new StringBuilder(128); // Chimera superposition cmd
379 String[] files = getPdbFile();
380 // check to see if we are still waiting for Chimera files
381 long starttime = System.currentTimeMillis();
382 boolean waiting = true;
386 for (String file : files)
390 // HACK - in Jalview 2.8 this call may not be threadsafe so we catch
391 // every possible exception
392 StructureMapping[] sm = getSsm().getMapping(file);
393 if (sm == null || sm.length == 0)
397 } catch (Exception x)
405 // we wait around for a reasonable time before we give up
407 && System.currentTimeMillis() < (10000 + 1000 * files.length + starttime));
411 .println("RUNTIME PROBLEM: Chimera seems to be taking a long time to process all the structures.");
415 StringBuffer selectioncom = new StringBuffer();
416 for (int a = 0; a < _alignment.length; a++)
418 int refStructure = _refStructure[a];
419 AlignmentI alignment = _alignment[a];
420 ColumnSelection hiddenCols = _hiddenCols[a];
422 && selectioncom.length() > 0
423 && !selectioncom.substring(selectioncom.length() - 1).equals(
426 selectioncom.append(" ");
428 // process this alignment
429 if (refStructure >= files.length)
431 System.err.println("Invalid reference structure value "
435 if (refStructure < -1)
440 boolean matched[] = new boolean[alignment.getWidth()];
441 for (int m = 0; m < matched.length; m++)
444 matched[m] = (hiddenCols != null) ? hiddenCols.isVisible(m) : true;
447 int commonrpositions[][] = new int[files.length][alignment.getWidth()];
448 String isel[] = new String[files.length];
449 String[] targetC = new String[files.length];
450 String[] chainNames = new String[files.length];
451 String[] atomSpec = new String[files.length];
452 for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
454 StructureMapping[] mapping = getSsm().getMapping(files[pdbfnum]);
455 // RACE CONDITION - getMapping only returns Jmol loaded filenames once
456 // Jmol callback has completed.
457 if (mapping == null || mapping.length < 1)
459 throw new Error(MessageManager.getString("error.implementation_error_chimera_getting_data"));
462 final int seqCountForPdbFile = getSequence()[pdbfnum].length;
463 for (int s = 0; s < seqCountForPdbFile; s++)
465 for (int sp, m = 0; m < mapping.length; m++)
467 final SequenceI theSequence = getSequence()[pdbfnum][s];
468 if (mapping[m].getSequence() == theSequence
469 && (sp = alignment.findIndex(theSequence)) > -1)
471 if (refStructure == -1)
473 refStructure = pdbfnum;
475 SequenceI asp = alignment.getSequenceAt(sp);
476 for (int r = 0; r < matched.length; r++)
482 matched[r] = false; // assume this is not a good site
483 if (r >= asp.getLength())
488 if (Comparison.isGap(asp.getCharAt(r)))
490 // no mapping to gaps in sequence
493 int t = asp.findPosition(r); // sequence position
494 int apos = mapping[m].getAtomNum(t);
495 int pos = mapping[m].getPDBResNum(t);
497 if (pos < 1 || pos == lastPos)
499 // can't align unmapped sequence
502 matched[r] = true; // this is a good ite
504 // just record this residue position
505 commonrpositions[pdbfnum][r] = pos;
507 // create model selection suffix
508 isel[pdbfnum] = "#" + pdbfnum;
509 if (mapping[m].getChain() == null
510 || mapping[m].getChain().trim().length() == 0)
512 targetC[pdbfnum] = "";
516 targetC[pdbfnum] = "." + mapping[m].getChain();
518 chainNames[pdbfnum] = mapping[m].getPdbId()
520 atomSpec[pdbfnum] = asp.getRNA() != null ? PHOSPHORUS : ALPHACARBON;
521 // move on to next pdb file
522 s = seqCountForPdbFile;
529 // TODO: consider bailing if nmatched less than 4 because superposition
532 // TODO: refactor superposable position search (above) from jmol selection
533 // construction (below)
535 String[] selcom = new String[files.length];
538 // generate select statements to select regions to superimpose structures
540 for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
542 String chainCd = targetC[pdbfnum];
545 StringBuffer molsel = new StringBuffer();
546 for (int r = 0; r < matched.length; r++)
554 if (lpos != commonrpositions[pdbfnum][r] - 1)
559 molsel.append((run ? "" : ":") + lpos);
560 molsel.append(chainCd);
566 // continuous run - and lpos >-1
569 // at the beginning, so add dash
570 molsel.append(":" + lpos);
575 lpos = commonrpositions[pdbfnum][r];
576 // molsel.append(lpos);
579 // add final selection phrase
582 molsel.append((run ? "" : ":") + lpos);
583 molsel.append(chainCd);
584 // molsel.append("");
586 if (molsel.length() > 1)
588 selcom[pdbfnum] = molsel.toString();
589 selectioncom.append("#" + pdbfnum);
590 selectioncom.append(selcom[pdbfnum]);
591 selectioncom.append(" ");
592 if (pdbfnum < files.length - 1)
594 selectioncom.append("| ");
599 selcom[pdbfnum] = null;
603 StringBuilder command = new StringBuilder(256);
604 for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
606 if (pdbfnum == refStructure || selcom[pdbfnum] == null
607 || selcom[refStructure] == null)
611 if (command.length() > 0)
617 * Form Chimera match command, from the 'new' structure to the
618 * 'reference' structure e.g. (residues 1-91, chain B/A, alphacarbons):
620 * match #1:1-91.B@CA #0:1-91.A@CA
623 * https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/match.html
625 command.append("match #" + pdbfnum /* +".1" */);
626 // TODO: handle sub-models
627 command.append(selcom[pdbfnum]);
628 command.append("@" + atomSpec[pdbfnum]);
629 // JAL-1757 exclude alternative CA locations
630 command.append(NO_ALTLOCS);
631 command.append(" #" + refStructure /* +".1" */);
632 command.append(selcom[refStructure]);
633 command.append("@" + atomSpec[refStructure]);
634 command.append(NO_ALTLOCS);
636 if (selectioncom.length() > 0)
640 System.out.println("Select regions:\n" + selectioncom.toString());
641 System.out.println("Superimpose command(s):\n"
642 + command.toString());
644 allComs.append("~display all; chain @CA|P; ribbon "
645 + selectioncom.toString() + ";"+command.toString());
646 // selcom.append("; ribbons; ");
649 if (selectioncom.length() > 0)
650 {// finally, mark all regions that were superposed.
651 if (selectioncom.substring(selectioncom.length() - 1).equals("|"))
653 selectioncom.setLength(selectioncom.length() - 1);
657 System.out.println("Select regions:\n" + selectioncom.toString());
659 allComs.append("; ~display all; chain @CA|P; ribbon "
660 + selectioncom.toString() + "; focus");
661 // evalStateCommand("select *; backbone; select "+selcom.toString()+"; cartoons; center "+selcom.toString());
662 evalStateCommand(allComs.toString(), true /* false */);
667 private void checkLaunched()
669 if (!viewer.isChimeraLaunched())
671 viewer.launchChimera(StructureManager.getChimeraPaths());
673 if (!viewer.isChimeraLaunched())
675 log("Failed to launch Chimera!");
680 * Answers true if the Chimera process is still running, false if ended or not
685 public boolean isChimeraRunning()
687 return viewer.isChimeraLaunched();
691 * Send a command to Chimera, launching it first if necessary, and optionally
697 public void evalStateCommand(final String command, boolean logResponse)
699 viewerCommandHistory(false);
701 if (lastCommand == null || !lastCommand.equals(command))
703 // trim command or it may never find a match in the replyLog!!
704 lastReply = viewer.sendChimeraCommand(command.trim(), logResponse);
705 if (debug && logResponse)
707 log("Response from command ('" + command + "') was:\n" + lastReply);
710 viewerCommandHistory(true);
711 lastCommand = command;
715 * colour any structures associated with sequences in the given alignment
716 * using the getFeatureRenderer() and getSequenceRenderer() renderers but only
717 * if colourBySequence is enabled.
719 public void colourBySequence(boolean showFeatures,
720 jalview.api.AlignmentViewPanel alignmentv)
722 if (!colourBySequence || !loadingFinished)
726 if (getSsm() == null)
730 String[] files = getPdbFile();
732 SequenceRenderer sr = getSequenceRenderer(alignmentv);
734 FeatureRenderer fr = null;
737 fr = getFeatureRenderer(alignmentv);
739 AlignmentI alignment = alignmentv.getAlignment();
741 for (jalview.structure.StructureMappingcommandSet cpdbbyseq : getColourBySequenceCommands(
742 files, sr, fr, alignment))
744 for (String command : cpdbbyseq.commands)
746 executeWhenReady(command);
758 protected StructureMappingcommandSet[] getColourBySequenceCommands(
759 String[] files, SequenceRenderer sr, FeatureRenderer fr,
760 AlignmentI alignment)
762 return ChimeraCommands.getColourBySequenceCommand(getSsm(), files,
763 getSequence(), sr, fr, alignment);
769 protected void executeWhenReady(String command)
772 evalStateCommand(command, false);
776 private void waitForChimera()
778 while (viewer != null && viewer.isBusy())
782 } catch (InterruptedException q)
789 // End StructureListener
790 // //////////////////////////
792 public Color getColour(int atomIndex, int pdbResNum, String chain,
795 if (getModelNum(pdbfile) < 0)
799 log("get model / residue colour attribute unimplemented");
804 * returns the current featureRenderer that should be used to colour the
811 public abstract FeatureRenderer getFeatureRenderer(
812 AlignmentViewPanel alignment);
815 * instruct the Jalview binding to update the pdbentries vector if necessary
816 * prior to matching the jmol view's contents to the list of structure files
817 * Jalview knows about.
819 public abstract void refreshPdbEntries();
821 private int getModelNum(String modelFileName)
823 String[] mfn = getPdbFile();
828 for (int i = 0; i < mfn.length; i++)
830 if (mfn[i].equalsIgnoreCase(modelFileName))
839 * map between index of model filename returned from getPdbFile and the first
840 * index of models from this file in the viewer. Note - this is not trimmed -
841 * use getPdbFile to get number of unique models.
843 private int _modelFileNameMap[];
845 // ////////////////////////////////
846 // /StructureListener
847 public synchronized String[] getPdbFile()
851 return new String[0];
853 // if (modelFileNames == null)
855 // Collection<ChimeraModel> chimodels = viewer.getChimeraModels();
856 // _modelFileNameMap = new int[chimodels.size()];
858 // for (ChimeraModel chimodel : chimodels)
860 // String mdlName = chimodel.getModelName();
862 // modelFileNames = new String[j];
863 // // System.arraycopy(mset, 0, modelFileNames, 0, j);
866 return chimeraMaps.keySet().toArray(
867 modelFileNames = new String[chimeraMaps.size()]);
871 * map from string to applet
873 public Map getRegistryInfo()
875 // TODO Auto-generated method stub
880 * returns the current sequenceRenderer that should be used to colour the
887 public abstract SequenceRenderer getSequenceRenderer(
888 AlignmentViewPanel alignment);
891 * Construct and send a command to highlight an atom.
894 * Done by generating a command like (to 'highlight' position 44)
895 * ~show #0:43.C;show #0:44.C
896 * Note this removes the highlight from the previous position.
899 public void highlightAtom(int atomIndex, int pdbResNum, String chain,
902 List<ChimeraModel> cms = chimeraMaps.get(pdbfile);
905 StringBuilder sb = new StringBuilder();
906 sb.append(" #" + cms.get(0).getModelNumber());
907 sb.append(":" + pdbResNum);
908 if (!chain.equals(" "))
910 sb.append("." + chain);
912 String atomSpec = sb.toString();
914 StringBuilder command = new StringBuilder(32);
915 if (lastMousedOverAtomSpec != null)
917 command.append("~show " + lastMousedOverAtomSpec + ";");
919 viewerCommandHistory(false);
920 command.append("show ").append(atomSpec);
921 String cmd = command.toString();
922 if (cmd.length() > 0)
924 viewer.stopListening(chimeraListener.getUri());
925 viewer.sendChimeraCommand(cmd, false);
926 viewer.startListening(chimeraListener.getUri());
928 viewerCommandHistory(true);
929 this.lastMousedOverAtomSpec = atomSpec;
934 * Query Chimera for its current selection, and highlight it on the alignment
936 public void highlightChimeraSelection()
939 * Ask Chimera for its current selection
941 List<String> selection = viewer.getSelectedResidueSpecs();
944 * Parse model number, residue and chain for each selected position,
945 * formatted as #0:123.A or #1.2:87.B (#model.submodel:residue.chain)
947 List<AtomSpec> atomSpecs = new ArrayList<AtomSpec>();
948 for (String atomSpec : selection)
950 int colonPos = atomSpec.indexOf(":");
953 continue; // malformed
956 int hashPos = atomSpec.indexOf("#");
957 String modelSubmodel = atomSpec.substring(hashPos + 1, colonPos);
958 int dotPos = modelSubmodel.indexOf(".");
961 modelId = Integer.valueOf(dotPos == -1 ? modelSubmodel
962 : modelSubmodel.substring(0, dotPos));
963 } catch (NumberFormatException e) {
964 // ignore, default to model 0
967 String residueChain = atomSpec.substring(colonPos + 1);
968 dotPos = residueChain.indexOf(".");
969 int pdbResNum = Integer.parseInt(dotPos == -1 ? residueChain
970 : residueChain.substring(0, dotPos));
972 String chainId = dotPos == -1 ? "" : residueChain
973 .substring(dotPos + 1);
976 * Work out the pdbfilename from the model number
978 String pdbfilename = modelFileNames[frameNo];
979 findfileloop: for (String pdbfile : this.chimeraMaps.keySet())
981 for (ChimeraModel cm : chimeraMaps.get(pdbfile))
983 if (cm.getModelNumber() == modelId)
985 pdbfilename = pdbfile;
990 atomSpecs.add(new AtomSpec(pdbfilename, chainId, pdbResNum, 0));
994 * Broadcast the selection (which may be empty, if the user just cleared all
997 getSsm().mouseOverStructure(atomSpecs);
1000 private void log(String message)
1002 System.err.println("## Chimera log: " + message);
1005 private void viewerCommandHistory(boolean enable)
1007 // log("(Not yet implemented) History "
1008 // + ((debug || enable) ? "on" : "off"));
1011 public long getLoadNotifiesHandled()
1013 return loadNotifiesHandled;
1016 public void setJalviewColourScheme(ColourSchemeI cs)
1018 colourBySequence = false;
1025 // Chimera expects RBG values in the range 0-1
1026 final double normalise = 255D;
1027 viewerCommandHistory(false);
1028 StringBuilder command = new StringBuilder(128);
1030 List<String> residueSet = ResidueProperties.getResidues(isNucleotide(),
1032 for (String res : residueSet)
1034 Color col = cs.findColour(res.charAt(0));
1035 command.append("color " + col.getRed() / normalise + ","
1036 + col.getGreen() / normalise + "," + col.getBlue()
1037 / normalise + " ::" + res + ";");
1040 evalStateCommand(command.toString(),false);
1041 viewerCommandHistory(true);
1045 * called when the binding thinks the UI needs to be refreshed after a Chimera
1046 * state change. this could be because structures were loaded, or because an
1047 * error has occurred.
1049 public abstract void refreshGUI();
1051 public void setLoadingFromArchive(boolean loadingFromArchive)
1053 this.loadingFromArchive = loadingFromArchive;
1058 * @return true if Chimeral is still restoring state or loading is still going
1059 * on (see setFinsihedLoadingFromArchive)
1061 public boolean isLoadingFromArchive()
1063 return loadingFromArchive && !loadingFinished;
1067 * modify flag which controls if sequence colouring events are honoured by the
1068 * binding. Should be true for normal operation
1070 * @param finishedLoading
1072 public void setFinishedLoadingFromArchive(boolean finishedLoading)
1074 loadingFinished = finishedLoading;
1078 * Send the Chimera 'background solid <color>" command.
1081 * ://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/background
1085 public void setBackgroundColour(Color col)
1087 viewerCommandHistory(false);
1088 double normalise = 255D;
1089 final String command = "background solid " + col.getRed() / normalise + ","
1090 + col.getGreen() / normalise + "," + col.getBlue()
1092 viewer.sendChimeraCommand(command, false);
1093 viewerCommandHistory(true);
1099 * @return text report of alignment between pdbfile and any associated
1100 * alignment sequences
1102 public String printMapping(String pdbfile)
1104 return getSsm().printMapping(pdbfile);
1108 * Ask Chimera to save its session to the given file. Returns true if
1109 * successful, else false.
1114 public boolean saveSession(String filepath)
1116 if (isChimeraRunning())
1118 List<String> reply = viewer.sendChimeraCommand("save " + filepath,
1120 if (reply.contains("Session written"))
1127 .error("Error saving Chimera session: " + reply.toString());
1134 * Ask Chimera to open a session file. Returns true if successful, else false.
1135 * The filename must have a .py extension for this command to work.
1140 public boolean openSession(String filepath)
1142 evalStateCommand("open " + filepath, true);
1143 // todo: test for failure - how?
1147 public boolean isFinishedInit()
1149 return finishedInit;
1152 public void setFinishedInit(boolean finishedInit)
1154 this.finishedInit = finishedInit;
1157 public List<String> getChainNames()