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 jalview.api.AlignmentViewPanel;
24 import jalview.api.structures.JalviewStructureDisplayI;
25 import jalview.bin.Cache;
26 import jalview.datamodel.AlignmentI;
27 import jalview.datamodel.HiddenColumns;
28 import jalview.datamodel.PDBEntry;
29 import jalview.datamodel.SearchResultMatchI;
30 import jalview.datamodel.SearchResultsI;
31 import jalview.datamodel.SequenceFeature;
32 import jalview.datamodel.SequenceI;
33 import jalview.gui.Preferences;
34 import jalview.gui.StructureViewer.ViewerType;
35 import jalview.httpserver.AbstractRequestHandler;
36 import jalview.io.DataSourceType;
37 import jalview.structure.AtomSpec;
38 import jalview.structure.StructureMappingcommandSet;
39 import jalview.structure.StructureSelectionManager;
40 import jalview.structures.models.AAStructureBindingModel;
41 import jalview.util.MessageManager;
44 import java.io.FileOutputStream;
45 import java.io.IOException;
46 import java.io.PrintWriter;
47 import java.net.BindException;
48 import java.util.ArrayList;
49 import java.util.BitSet;
50 import java.util.Collections;
51 import java.util.Iterator;
52 import java.util.LinkedHashMap;
53 import java.util.List;
56 import ext.edu.ucsf.rbvi.strucviz2.ChimeraManager;
57 import ext.edu.ucsf.rbvi.strucviz2.ChimeraModel;
58 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
59 import ext.edu.ucsf.rbvi.strucviz2.StructureManager.ModelType;
61 public abstract class JalviewChimeraBinding extends AAStructureBindingModel
63 public static final String CHIMERA_FEATURE_GROUP = "Chimera";
65 // Chimera clause to exclude alternate locations in atom selection
66 private static final String NO_ALTLOCS = "&~@.B-Z&~@.2-9";
68 private static final boolean debug = false;
70 private static final String PHOSPHORUS = "P";
72 private static final String ALPHACARBON = "CA";
75 * Object through which we talk to Chimera
77 private ChimeraManager chimeraManager;
80 * Object which listens to Chimera notifications
82 private AbstractRequestHandler chimeraListener;
85 * Map of ChimeraModel objects keyed by PDB full local file name
87 private Map<String, List<ChimeraModel>> chimeraMaps = new LinkedHashMap<>();
89 String lastHighlightCommand;
91 private Thread chimeraMonitor;
94 * Open a PDB structure file in Chimera and set up mappings from Jalview.
96 * We check if the PDB model id is already loaded in Chimera, if so don't reopen
97 * it. This is the case if Chimera has opened a saved session file.
102 public boolean openFile(PDBEntry pe)
104 String file = pe.getFile();
107 List<ChimeraModel> modelsToMap = new ArrayList<>();
108 List<ChimeraModel> oldList = chimeraManager.getModelList();
109 boolean alreadyOpen = false;
112 * If Chimera already has this model, don't reopen it, but do remap it.
114 for (ChimeraModel open : oldList)
116 if (open.getModelName().equals(pe.getId()))
119 modelsToMap.add(open);
124 * If Chimera doesn't yet have this model, ask it to open it, and retrieve
125 * the model name(s) added by Chimera.
129 chimeraManager.openModel(file, pe.getId(), ModelType.PDB_MODEL);
130 if (chimeraManager.isChimeraX())
133 * ChimeraX hack: force chimera model name to pdbId
135 int modelNumber = chimeraMaps.size() + 1;
136 String command = "setattr #" + modelNumber + " models name "
138 executeCommand(command, false);
139 modelsToMap.add(new ChimeraModel(pe.getId(), ModelType.PDB_MODEL,
145 * Chimera: query for actual models and find the one with
146 * matching model name - set in viewer.openModel()
148 List<ChimeraModel> newList = chimeraManager.getModelList();
149 // JAL-1728 newList.removeAll(oldList) does not work
150 for (ChimeraModel cm : newList)
152 if (cm.getModelName().equals(pe.getId()))
160 chimeraMaps.put(file, modelsToMap);
162 if (getSsm() != null)
164 getSsm().addStructureViewerListener(this);
167 } catch (Exception q)
169 log("Exception when trying to open model " + file + "\n"
184 public JalviewChimeraBinding(StructureSelectionManager ssm,
185 PDBEntry[] pdbentry, SequenceI[][] sequenceIs,
186 DataSourceType protocol)
188 super(ssm, pdbentry, sequenceIs, protocol);
189 chimeraManager = new ChimeraManager(new StructureManager(true));
190 String viewerType = Cache.getProperty(Preferences.STRUCTURE_DISPLAY);
191 chimeraManager.setChimeraX(ViewerType.CHIMERAX.name().equals(viewerType));
192 setStructureCommands(new ChimeraCommands());
196 * Starts a thread that waits for the Chimera process to finish, so that we can
197 * then close the associated resources. This avoids leaving orphaned Chimera
198 * viewer panels in Jalview if the user closes Chimera.
200 protected void startChimeraProcessMonitor()
202 final Process p = chimeraManager.getChimeraProcess();
203 chimeraMonitor = new Thread(new Runnable()
212 JalviewStructureDisplayI display = getViewer();
215 display.closeViewer(false);
217 } catch (InterruptedException e)
219 // exit thread if Chimera Viewer is closed in Jalview
223 chimeraMonitor.start();
227 * Start a dedicated HttpServer to listen for Chimera notifications, and tell it
230 public void startChimeraListener()
234 chimeraListener = new ChimeraListener(this);
235 chimeraManager.startListening(chimeraListener.getUri());
236 } catch (BindException e)
239 "Failed to start Chimera listener: " + e.getMessage());
244 * Close down the Jalview viewer and listener, and (optionally) the associated
247 public void closeViewer(boolean closeChimera)
249 getSsm().removeStructureViewerListener(this, this.getStructureFiles());
252 chimeraManager.exitChimera();
254 if (this.chimeraListener != null)
256 chimeraListener.shutdown();
257 chimeraListener = null;
259 chimeraManager = null;
261 if (chimeraMonitor != null)
263 chimeraMonitor.interrupt();
265 releaseUIResources();
272 public String superposeStructures(AlignmentI[] _alignment,
273 int[] _refStructure, HiddenColumns[] _hiddenCols)
275 StringBuilder allComs = new StringBuilder(128);
276 String[] files = getStructureFiles();
278 if (!waitForFileLoad(files))
284 StringBuilder selectioncom = new StringBuilder(256);
285 boolean chimeraX = chimeraManager.isChimeraX();
286 for (int a = 0; a < _alignment.length; a++)
288 int refStructure = _refStructure[a];
289 AlignmentI alignment = _alignment[a];
290 HiddenColumns hiddenCols = _hiddenCols[a];
292 if (refStructure >= files.length)
294 System.err.println("Ignoring invalid reference structure value "
300 * 'matched' bit i will be set for visible alignment columns i where
301 * all sequences have a residue with a mapping to the PDB structure
303 BitSet matched = new BitSet();
304 for (int m = 0; m < alignment.getWidth(); m++)
306 if (hiddenCols == null || hiddenCols.isVisible(m))
312 SuperposeData[] structures = new SuperposeData[files.length];
313 for (int f = 0; f < files.length; f++)
315 structures[f] = new SuperposeData(alignment.getWidth());
319 * Calculate the superposable alignment columns ('matched'), and the
320 * corresponding structure residue positions (structures.pdbResNo)
322 int candidateRefStructure = findSuperposableResidues(alignment,
323 matched, structures);
324 if (refStructure < 0)
327 * If no reference structure was specified, pick the first one that has
328 * a mapping in the alignment
330 refStructure = candidateRefStructure;
333 int nmatched = matched.cardinality();
336 return MessageManager.formatMessage("label.insufficient_residues",
341 * Generate select statements to select regions to superimpose structures
343 String[] selcom = new String[files.length];
344 for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
346 final int modelNo = pdbfnum + (chimeraX ? 1 : 0);
347 // todo correct resolution to model number
348 String chainCd = "." + structures[pdbfnum].chain;
351 StringBuilder molsel = new StringBuilder();
354 molsel.append("/" + structures[pdbfnum].chain + ":");
357 int nextColumnMatch = matched.nextSetBit(0);
358 while (nextColumnMatch != -1)
360 int pdbResNum = structures[pdbfnum].pdbResNo[nextColumnMatch];
361 if (lpos != pdbResNum - 1)
364 * discontiguous - append last residue now
368 molsel.append(String.valueOf(lpos));
371 molsel.append(chainCd);
380 * extending a contiguous run
385 * start the range selection
387 molsel.append(String.valueOf(lpos));
393 nextColumnMatch = matched.nextSetBit(nextColumnMatch + 1);
397 * and terminate final selection
401 molsel.append(String.valueOf(lpos));
404 molsel.append(chainCd);
407 if (molsel.length() > 1)
409 selcom[pdbfnum] = molsel.toString();
410 selectioncom.append("#").append(String.valueOf(modelNo));
413 selectioncom.append(":");
415 selectioncom.append(selcom[pdbfnum]);
416 // selectioncom.append(" ");
417 if (pdbfnum < files.length - 1)
419 selectioncom.append("|");
424 selcom[pdbfnum] = null;
428 StringBuilder command = new StringBuilder(256);
429 for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
431 final int modelNo = pdbfnum + (chimeraX ? 1 : 0);
432 if (pdbfnum == refStructure || selcom[pdbfnum] == null
433 || selcom[refStructure] == null)
437 if (command.length() > 0)
443 * Form Chimera match command, from the 'new' structure to the
444 * 'reference' structure e.g. (50 residues, chain B/A, alphacarbons):
446 * match #1:1-30.B,81-100.B@CA #0:21-40.A,61-90.A@CA
449 * https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/match.html
451 command.append(chimeraX ? "align " : "match ");
452 command.append(getModelSpec(modelNo));
457 command.append(selcom[pdbfnum]);
458 command.append("@").append(
459 structures[pdbfnum].isRna ? PHOSPHORUS : ALPHACARBON);
460 // JAL-1757 exclude alternate CA locations - ChimeraX syntax tbd
463 command.append(NO_ALTLOCS);
465 command.append(chimeraX ? " toAtoms " : " ")
466 .append(getModelSpec(refStructure + (chimeraX ? 1 : 0)));
471 command.append(selcom[refStructure]);
472 command.append("@").append(
473 structures[refStructure].isRna ? PHOSPHORUS : ALPHACARBON);
476 command.append(NO_ALTLOCS);
479 if (selectioncom.length() > 0)
483 System.out.println("Select regions:\n" + selectioncom.toString());
485 "Superimpose command(s):\n" + command.toString());
487 // allComs.append("~display all; ");
490 // allComs.append("show ").append(selectioncom.toString())
491 // .append(" pbonds");
495 // allComs.append("chain @CA|P; ribbon ");
496 // allComs.append(selectioncom.toString());
498 if (allComs.length() > 0) {
501 allComs.append(command.toString());
506 if (selectioncom.length() > 0)
508 // TODO: visually distinguish regions that were superposed
509 if (selectioncom.substring(selectioncom.length() - 1).equals("|"))
511 selectioncom.setLength(selectioncom.length() - 1);
515 System.out.println("Select regions:\n" + selectioncom.toString());
517 allComs.append(";~display all; ");
520 allComs.append("show @CA|P pbonds; show ")
521 .append(selectioncom.toString()).append(" ribbons; view");
525 allComs.append("chain @CA|P; ribbon ; focus");
526 allComs.append(selectioncom.toString());
528 // allComs.append("; ~display all; chain @CA|P; ribbon ")
529 // .append(selectioncom.toString()).append("; focus");
530 List<String> chimeraReplies = executeCommand(allComs.toString(),
532 for (String reply : chimeraReplies)
534 if (reply.toLowerCase().contains("unequal numbers of atoms"))
544 * Helper method to construct model spec in Chimera format:
546 * <li>#0 (#1 etc) for a PDB file with no sub-models</li>
547 * <li>#0.1 (#1.1 etc) for a PDB file with sub-models</li>
549 * Note for now we only ever choose the first of multiple models. This
550 * corresponds to the hard-coded Jmol equivalent (compare {1.1}). Refactor in
551 * future if there is a need to select specific sub-models.
556 protected String getModelSpec(int pdbfnum)
558 if (pdbfnum < 0 || pdbfnum >= getPdbCount())
560 return "#" + pdbfnum; // temp hack for ChimeraX
564 * For now, the test for having sub-models is whether multiple Chimera
565 * models are mapped for the PDB file; the models are returned as a response
566 * to the Chimera command 'list models type molecule', see
567 * ChimeraManager.getModelList().
569 List<ChimeraModel> maps = chimeraMaps.get(getStructureFiles()[pdbfnum]);
570 boolean hasSubModels = maps != null && maps.size() > 1;
571 return "#" + String.valueOf(pdbfnum) + (hasSubModels ? ".1" : "");
575 * Launch Chimera, unless an instance linked to this object is already
576 * running. Returns true if Chimera is successfully launched, or already
577 * running, else false.
581 public boolean launchChimera()
583 if (chimeraManager.isChimeraLaunched())
588 boolean launched = chimeraManager.launchChimera(
589 StructureManager.getChimeraPaths(chimeraManager.isChimeraX()));
592 startChimeraProcessMonitor();
596 log("Failed to launch Chimera!");
602 * Answers true if the Chimera process is still running, false if ended or not
607 public boolean isChimeraRunning()
609 return chimeraManager.isChimeraLaunched();
613 * Send a command to Chimera, and optionally log and return any responses.
619 public List<String> executeCommand(final String command,
622 if (chimeraManager == null || command == null)
624 // ? thread running after viewer shut down
627 List<String> reply = null;
628 // trim command or it may never find a match in the replyLog!!
629 List<String> lastReply = chimeraManager
630 .sendChimeraCommand(command.trim(), getResponse);
636 log("Response from command ('" + command + "') was:\n" + lastReply);
644 * Send a Chimera command asynchronously in a new thread. If the progress
645 * message is not null, display this message while the command is executing.
650 protected abstract void sendAsynchronousCommand(String command,
656 protected void executeWhenReady(String command)
659 executeCommand(command, false);
663 private void waitForChimera()
665 while (chimeraManager != null && chimeraManager.isBusy())
670 } catch (InterruptedException q)
676 // End StructureListener
677 // //////////////////////////
680 * map between index of model filename returned from getPdbFile and the first
681 * index of models from this file in the viewer. Note - this is not trimmed -
682 * use getPdbFile to get number of unique models.
684 private int _modelFileNameMap[];
686 // ////////////////////////////////
687 // /StructureListener
689 public synchronized String[] getStructureFiles()
691 if (chimeraManager == null)
693 return new String[0];
696 return chimeraMaps.keySet()
697 .toArray(modelFileNames = new String[chimeraMaps.size()]);
701 * Construct and send a command to highlight zero, one or more atoms. We do this
702 * by sending an "rlabel" command to show the residue label at that position.
705 public void highlightAtoms(List<AtomSpec> atoms)
707 if (atoms == null || atoms.size() == 0)
712 boolean forChimeraX = chimeraManager.isChimeraX();
713 StringBuilder cmd = new StringBuilder(128);
714 boolean first = true;
715 boolean found = false;
717 for (AtomSpec atom : atoms)
719 int pdbResNum = atom.getPdbResNum();
720 String chain = atom.getChain();
721 String pdbfile = atom.getPdbFile();
722 List<ChimeraModel> cms = chimeraMaps.get(pdbfile);
723 if (cms != null && !cms.isEmpty())
727 cmd.append(forChimeraX ? "label #" : "rlabel #");
736 cmd.append(cms.get(0).getModelNumber())
737 .append("/").append(chain).append(":").append(pdbResNum);
741 cmd.append(cms.get(0).getModelNumber())
742 .append(":").append(pdbResNum);
743 if (!chain.equals(" ") && !forChimeraX)
745 cmd.append(".").append(chain);
751 String command = cmd.toString();
754 * avoid repeated commands for the same residue
756 if (command.equals(lastHighlightCommand))
762 * unshow the label for the previous residue
764 if (lastHighlightCommand != null)
766 chimeraManager.sendChimeraCommand("~" + lastHighlightCommand, false);
770 chimeraManager.sendChimeraCommand(command, false);
772 this.lastHighlightCommand = command;
776 * Query Chimera for its current selection, and highlight it on the alignment
778 public void highlightChimeraSelection()
781 * Ask Chimera for its current selection
783 List<String> selection = chimeraManager.getSelectedResidueSpecs();
786 * Parse model number, residue and chain for each selected position,
787 * formatted as #0:123.A or #1.2:87.B (#model.submodel:residue.chain)
789 List<AtomSpec> atomSpecs = convertStructureResiduesToAlignment(
793 * Broadcast the selection (which may be empty, if the user just cleared all
796 getSsm().mouseOverStructure(atomSpecs);
800 * Converts a list of Chimera atomspecs to a list of AtomSpec representing the
801 * corresponding residues (if any) in Jalview
803 * @param structureSelection
806 protected List<AtomSpec> convertStructureResiduesToAlignment(
807 List<String> structureSelection)
809 boolean chimeraX = chimeraManager.isChimeraX();
810 List<AtomSpec> atomSpecs = new ArrayList<>();
811 for (String atomSpec : structureSelection)
815 AtomSpec spec = AtomSpec.fromChimeraAtomspec(atomSpec, chimeraX);
816 String pdbfilename = getPdbFileForModel(spec.getModelNumber());
817 spec.setPdbFile(pdbfilename);
819 } catch (IllegalArgumentException e)
821 System.err.println("Failed to parse atomspec: " + atomSpec);
831 protected String getPdbFileForModel(int modelId)
834 * Work out the pdbfilename from the model number
836 String pdbfilename = modelFileNames[0];
837 findfileloop: for (String pdbfile : this.chimeraMaps.keySet())
839 for (ChimeraModel cm : chimeraMaps.get(pdbfile))
841 if (cm.getModelNumber() == modelId)
843 pdbfilename = pdbfile;
851 private void log(String message)
853 System.err.println("## Chimera log: " + message);
857 * Ask Chimera to save its session to the given file. Returns true if
858 * successful, else false.
863 public boolean saveSession(String filepath)
865 if (isChimeraRunning())
868 * Chimera: https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/save.html
869 * ChimeraX: https://www.cgl.ucsf.edu/chimerax/docs/user/commands/save.html
871 String command = isChimeraX() ? "save session " : "save ";
872 List<String> reply = chimeraManager.sendChimeraCommand(command + filepath,
874 if (reply.contains("Session written"))
881 .error("Error saving Chimera session: " + reply.toString());
888 * Ask Chimera to open a session file. Returns true if successful, else false.
889 * The filename must have a .py (Chimera) or .cxs (ChimeraX) extension for
890 * this command to work.
895 public boolean openSession(String filepath)
898 * Chimera: https://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/open.html
899 * ChimeraX: https://www.cgl.ucsf.edu/chimerax/docs/user/commands/open.html
901 executeCommand("open " + filepath, true);
902 // todo: test for failure - how?
907 * Send a 'show' command for all atoms in the currently selected columns
909 * TODO: pull up to abstract structure viewer interface
913 public void highlightSelection(AlignmentViewPanel vp)
915 List<Integer> cols = vp.getAlignViewport().getColumnSelection()
917 AlignmentI alignment = vp.getAlignment();
918 StructureSelectionManager sm = getSsm();
919 for (SequenceI seq : alignment.getSequences())
922 * convert selected columns into sequence positions
924 int[] positions = new int[cols.size()];
926 for (Integer col : cols)
928 positions[i++] = seq.findPosition(col);
930 sm.highlightStructure(this, seq, positions);
935 * Constructs and send commands to Chimera to set attributes on residues for
936 * features visible in Jalview
941 public int sendFeaturesToViewer(AlignmentViewPanel avp)
943 // TODO refactor as required to pull up to an interface
944 AlignmentI alignment = avp.getAlignment();
946 String[] files = getStructureFiles();
952 StructureMappingcommandSet commandSet = ChimeraCommands
953 .getSetAttributeCommandsForFeatures(getSsm(), files,
954 getSequence(), avp, chimeraManager.isChimeraX());
955 String[] commands = commandSet.commands;
956 if (commands.length > 10)
958 sendCommandsByFile(commands);
962 for (String command : commands)
964 sendAsynchronousCommand(command, null);
967 return commands.length;
971 * Write commands to a temporary file, and send a command to Chimera to open the
972 * file as a commands script. For use when sending a large number of separate
973 * commands would overload the REST interface mechanism.
977 protected void sendCommandsByFile(String[] commands)
979 boolean toChimeraX = chimeraManager.isChimeraX();
982 File tmp = File.createTempFile("chim", toChimeraX ? ".cxc" : ".com");
984 PrintWriter out = new PrintWriter(new FileOutputStream(tmp));
985 for (String command : commands)
987 out.println(command);
991 String path = tmp.getAbsolutePath();
992 String command = "open " + (toChimeraX ? "" : "cmd:") + path;
993 sendAsynchronousCommand(command, null);
994 } catch (IOException e)
996 System.err.println("Sending commands to Chimera via file failed with "
1002 * Get Chimera residues which have the named attribute, find the mapped
1003 * positions in the Jalview sequence(s), and set as sequence features
1006 * @param alignmentPanel
1008 public void copyStructureAttributesToFeatures(String attName,
1009 AlignmentViewPanel alignmentPanel)
1011 // todo pull up to AAStructureBindingModel (and interface?)
1014 * ask Chimera to list residues with the attribute, reporting its value
1016 // this alternative command
1017 // list residues spec ':*/attName' attr attName
1018 // doesn't report 'None' values (which is good), but
1019 // fails for 'average.bfactor' (which is bad):
1021 String cmd = "list residues attr '" + attName + "'";
1022 List<String> residues = executeCommand(cmd, true);
1024 boolean featureAdded = createFeaturesForAttributes(attName, residues);
1027 alignmentPanel.getFeatureRenderer().featuresAdded();
1032 * Create features in Jalview for the given attribute name and structure
1036 * The residue list should be 0, 1 or more reply lines of the format:
1037 * residue id #0:5.A isHelix -155.000836316 index 5
1039 * residue id #0:6.A isHelix None
1046 protected boolean createFeaturesForAttributes(String attName,
1047 List<String> residues)
1049 boolean featureAdded = false;
1050 String featureGroup = getViewerFeatureGroup();
1051 boolean chimeraX = chimeraManager.isChimeraX();
1053 for (String residue : residues)
1055 AtomSpec spec = null;
1056 String[] tokens = residue.split(" ");
1057 if (tokens.length < 5)
1061 String atomSpec = tokens[2];
1062 String attValue = tokens[4];
1065 * ignore 'None' (e.g. for phi) or 'False' (e.g. for isHelix)
1067 if ("None".equalsIgnoreCase(attValue)
1068 || "False".equalsIgnoreCase(attValue))
1075 spec = AtomSpec.fromChimeraAtomspec(atomSpec, chimeraX);
1076 } catch (IllegalArgumentException e)
1078 System.err.println("Problem parsing atomspec " + atomSpec);
1082 String chainId = spec.getChain();
1083 String description = attValue;
1084 float score = Float.NaN;
1087 score = Float.valueOf(attValue);
1088 description = chainId;
1089 } catch (NumberFormatException e)
1091 // was not a float value
1094 String pdbFile = getPdbFileForModel(spec.getModelNumber());
1095 spec.setPdbFile(pdbFile);
1097 List<AtomSpec> atoms = Collections.singletonList(spec);
1100 * locate the mapped position in the alignment (if any)
1102 SearchResultsI sr = getSsm()
1103 .findAlignmentPositionsForStructurePositions(atoms);
1106 * expect one matched alignment position, or none
1107 * (if the structure position is not mapped)
1109 for (SearchResultMatchI m : sr.getResults())
1111 SequenceI seq = m.getSequence();
1112 int start = m.getStart();
1113 int end = m.getEnd();
1114 SequenceFeature sf = new SequenceFeature(attName, description,
1115 start, end, score, featureGroup);
1116 // todo: should SequenceFeature have an explicit property for chain?
1117 // note: repeating the action shouldn't duplicate features
1118 featureAdded |= seq.addSequenceFeature(sf);
1121 return featureAdded;
1125 * Answers the feature group name to apply to features created in Jalview from
1126 * Chimera attributes
1130 protected String getViewerFeatureGroup()
1132 // todo pull up to interface
1133 return CHIMERA_FEATURE_GROUP;
1137 public int getModelNoForFile(String pdbFile)
1139 List<ChimeraModel> foundModels = chimeraMaps.get(pdbFile);
1140 if (foundModels != null && !foundModels.isEmpty())
1142 return foundModels.get(0).getModelNumber();
1148 * Answers a (possibly empty) list of attribute names in Chimera[X], excluding
1149 * any which were added from Jalview
1153 public List<String> getChimeraAttributes()
1155 List<String> atts = chimeraManager.getAttrList();
1156 Iterator<String> it = atts.iterator();
1157 while (it.hasNext())
1159 if (it.next().startsWith(ChimeraCommands.NAMESPACE_PREFIX))
1162 * attribute added from Jalview - exclude it
1170 public boolean isChimeraX()
1172 return chimeraManager.isChimeraX();