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.FeatureRenderer;
25 import jalview.api.SequenceRenderer;
26 import jalview.bin.Cache;
27 import jalview.datamodel.AlignmentI;
28 import jalview.datamodel.ColumnSelection;
29 import jalview.datamodel.PDBEntry;
30 import jalview.datamodel.SequenceI;
31 import jalview.httpserver.AbstractRequestHandler;
32 import jalview.schemes.ColourSchemeI;
33 import jalview.schemes.ResidueProperties;
34 import jalview.structure.AtomSpec;
35 import jalview.structure.StructureMappingcommandSet;
36 import jalview.structure.StructureSelectionManager;
37 import jalview.structures.models.AAStructureBindingModel;
38 import jalview.util.MessageManager;
40 import java.awt.Color;
41 import java.net.BindException;
42 import java.util.ArrayList;
43 import java.util.LinkedHashMap;
44 import java.util.List;
47 import ext.edu.ucsf.rbvi.strucviz2.ChimeraManager;
48 import ext.edu.ucsf.rbvi.strucviz2.ChimeraModel;
49 import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
50 import ext.edu.ucsf.rbvi.strucviz2.StructureManager.ModelType;
52 public abstract class JalviewChimeraBinding extends AAStructureBindingModel
54 // Chimera clause to exclude alternate locations in atom selection
55 private static final String NO_ALTLOCS = "&~@.B-Z&~@.2-9";
57 private static final String COLOURING_CHIMERA = MessageManager
58 .getString("status.colouring_chimera");
60 private static final boolean debug = false;
62 private static final String PHOSPHORUS = "P";
64 private static final String ALPHACARBON = "CA";
67 * Object through which we talk to Chimera
69 private ChimeraManager viewer;
72 * Object which listens to Chimera notifications
74 private AbstractRequestHandler chimeraListener;
77 * set if chimera state is being restored from some source - instructs binding
78 * not to apply default display style when structure set is updated for first
81 private boolean loadingFromArchive = false;
84 * flag to indicate if the Chimera viewer should ignore sequence colouring
85 * events from the structure manager because the GUI is still setting up
87 private boolean loadingFinished = true;
89 public String fileLoadingError;
92 * Map of ChimeraModel objects keyed by PDB full local file name
94 private Map<String, List<ChimeraModel>> chimeraMaps = new LinkedHashMap<String, List<ChimeraModel>>();
97 * the default or current model displayed if the model cannot be identified
98 * from the selection message
100 private int frameNo = 0;
102 private String lastCommand;
104 private boolean loadedInline;
107 * current set of model filenames loaded
109 String[] modelFileNames = null;
111 String lastHighlightCommand;
113 private List<String> lastReply;
116 * incremented every time a load notification is successfully handled -
117 * lightweight mechanism for other threads to detect when they can start
118 * referring to new structures.
120 private long loadNotifiesHandled = 0;
123 * Open a PDB structure file in Chimera and set up mappings from Jalview.
125 * We check if the PDB model id is already loaded in Chimera, if so don't
126 * reopen it. This is the case if Chimera has opened a saved session file.
131 public boolean openFile(PDBEntry pe)
133 String file = pe.getFile();
136 List<ChimeraModel> modelsToMap = new ArrayList<ChimeraModel>();
137 List<ChimeraModel> oldList = viewer.getModelList();
138 boolean alreadyOpen = false;
141 * If Chimera already has this model, don't reopen it, but do remap it.
143 for (ChimeraModel open : oldList)
145 if (open.getModelName().equals(pe.getId()))
148 modelsToMap.add(open);
153 * If Chimera doesn't yet have this model, ask it to open it, and retrieve
154 * the model name(s) added by Chimera.
158 viewer.openModel(file, pe.getId(), ModelType.PDB_MODEL);
159 List<ChimeraModel> newList = viewer.getModelList();
160 // JAL-1728 newList.removeAll(oldList) does not work
161 for (ChimeraModel cm : newList)
163 if (cm.getModelName().equals(pe.getId()))
170 chimeraMaps.put(file, modelsToMap);
172 if (getSsm() != null)
174 getSsm().addStructureViewerListener(this);
175 // ssm.addSelectionListener(this);
176 FeatureRenderer fr = getFeatureRenderer(null);
184 } catch (Exception q)
186 log("Exception when trying to open model " + file + "\n"
202 public JalviewChimeraBinding(StructureSelectionManager ssm,
203 PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
206 super(ssm, pdbentry, sequenceIs, chains, protocol);
207 viewer = new ChimeraManager(
208 new ext.edu.ucsf.rbvi.strucviz2.StructureManager(true));
212 * Start a dedicated HttpServer to listen for Chimera notifications, and tell
213 * it to start listening
215 public void startChimeraListener()
219 chimeraListener = new ChimeraListener(this);
220 viewer.startListening(chimeraListener.getUri());
221 } catch (BindException e)
223 System.err.println("Failed to start Chimera listener: "
229 * Construct a title string for the viewer window based on the data Jalview
235 public String getViewerTitle(boolean verbose)
237 return getViewerTitle("Chimera", verbose);
241 * Tells Chimera to display only the specified chains
245 public void showChains(List<String> toshow)
248 * Construct a chimera command like
250 * ~display #*;~ribbon #*;ribbon :.A,:.B
252 StringBuilder cmd = new StringBuilder(64);
253 boolean first = true;
254 for (String chain : toshow)
260 cmd.append(":.").append(chain);
265 * could append ";focus" to this command to resize the display to fill the
266 * window, but it looks more helpful not to (easier to relate chains to the
269 final String command = "~display #*; ~ribbon #*; ribbon "
271 sendChimeraCommand(command, false);
275 * Close down the Jalview viewer and listener, and (optionally) the associated
278 public void closeViewer(boolean closeChimera)
280 getSsm().removeStructureViewerListener(this, this.getPdbFile());
283 viewer.exitChimera();
285 if (this.chimeraListener != null)
287 chimeraListener.shutdown();
288 chimeraListener = null;
293 releaseUIResources();
296 public void colourByChain()
298 colourBySequence = false;
299 sendAsynchronousCommand("rainbow chain", COLOURING_CHIMERA);
303 * Constructs and sends a Chimera command to colour by charge
305 * <li>Aspartic acid and Glutamic acid (negative charge) red</li>
306 * <li>Lysine and Arginine (positive charge) blue</li>
307 * <li>Cysteine - yellow</li>
308 * <li>all others - white</li>
311 public void colourByCharge()
313 colourBySequence = false;
314 String command = "color white;color red ::ASP;color red ::GLU;color blue ::LYS;color blue ::ARG;color yellow ::CYS";
315 sendAsynchronousCommand(command, COLOURING_CHIMERA);
319 * Construct and send a command to align structures against a reference
320 * structure, based on one or more sequence alignments
323 * an array of alignments to process
324 * @param _refStructure
325 * an array of corresponding reference structures (index into pdb
326 * file array); if a negative value is passed, the first PDB file
327 * mapped to an alignment sequence is used as the reference for
330 * an array of corresponding hidden columns for each alignment
332 public void superposeStructures(AlignmentI[] _alignment,
333 int[] _refStructure, ColumnSelection[] _hiddenCols)
335 StringBuilder allComs = new StringBuilder(128);
336 String[] files = getPdbFile();
338 if (!waitForFileLoad(files))
344 StringBuilder selectioncom = new StringBuilder(256);
345 for (int a = 0; a < _alignment.length; a++)
347 int refStructure = _refStructure[a];
348 AlignmentI alignment = _alignment[a];
349 ColumnSelection hiddenCols = _hiddenCols[a];
351 if (refStructure >= files.length)
353 System.err.println("Ignoring invalid reference structure value "
359 * 'matched' array will hold 'true' for visible alignment columns where
360 * all sequences have a residue with a mapping to the PDB structure
362 boolean matched[] = new boolean[alignment.getWidth()];
363 for (int m = 0; m < matched.length; m++)
365 matched[m] = (hiddenCols != null) ? hiddenCols.isVisible(m) : true;
368 SuperposeData[] structures = new SuperposeData[files.length];
369 for (int f = 0; f < files.length; f++)
371 structures[f] = new SuperposeData(alignment.getWidth());
375 * Calculate the superposable alignment columns ('matched'), and the
376 * corresponding structure residue positions (structures.pdbResNo)
378 int candidateRefStructure = findSuperposableResidues(alignment,
379 matched, structures);
380 if (refStructure < 0)
383 * If no reference structure was specified, pick the first one that has
384 * a mapping in the alignment
386 refStructure = candidateRefStructure;
390 for (boolean b : matched)
399 // TODO: bail out here because superposition illdefined?
403 * Generate select statements to select regions to superimpose structures
405 String[] selcom = new String[files.length];
406 for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
408 String chainCd = "." + structures[pdbfnum].chain;
411 StringBuilder molsel = new StringBuilder();
412 for (int r = 0; r < matched.length; r++)
416 int pdbResNum = structures[pdbfnum].pdbResNo[r];
417 if (lpos != pdbResNum - 1)
420 * discontiguous - append last residue now
424 molsel.append(String.valueOf(lpos));
425 molsel.append(chainCd);
433 * extending a contiguous run
438 * start the range selection
440 molsel.append(String.valueOf(lpos));
450 * and terminate final selection
454 molsel.append(String.valueOf(lpos));
455 molsel.append(chainCd);
457 if (molsel.length() > 1)
459 selcom[pdbfnum] = molsel.toString();
460 selectioncom.append("#").append(String.valueOf(pdbfnum))
462 selectioncom.append(selcom[pdbfnum]);
463 selectioncom.append(" ");
464 if (pdbfnum < files.length - 1)
466 selectioncom.append("| ");
471 selcom[pdbfnum] = null;
475 StringBuilder command = new StringBuilder(256);
476 for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
478 if (pdbfnum == refStructure || selcom[pdbfnum] == null
479 || selcom[refStructure] == null)
483 if (command.length() > 0)
489 * Form Chimera match command, from the 'new' structure to the
490 * 'reference' structure e.g. (50 residues, chain B/A, alphacarbons):
492 * match #1:1-30.B,81-100.B@CA #0:21-40.A,61-90.A@CA
495 * https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/match.html
497 command.append("match ").append(getModelSpec(pdbfnum)).append(":");
498 command.append(selcom[pdbfnum]);
499 command.append("@").append(
500 structures[pdbfnum].isRna ? PHOSPHORUS : ALPHACARBON);
501 // JAL-1757 exclude alternate CA locations
502 command.append(NO_ALTLOCS);
503 command.append(" ").append(getModelSpec(refStructure)).append(":");
504 command.append(selcom[refStructure]);
505 command.append("@").append(
506 structures[refStructure].isRna ? PHOSPHORUS : ALPHACARBON);
507 command.append(NO_ALTLOCS);
509 if (selectioncom.length() > 0)
513 System.out.println("Select regions:\n" + selectioncom.toString());
514 System.out.println("Superimpose command(s):\n"
515 + command.toString());
517 allComs.append("~display all; chain @CA|P; ribbon ")
518 .append(selectioncom.toString())
519 .append(";" + command.toString());
522 if (selectioncom.length() > 0)
524 // TODO: visually distinguish regions that were superposed
525 if (selectioncom.substring(selectioncom.length() - 1).equals("|"))
527 selectioncom.setLength(selectioncom.length() - 1);
531 System.out.println("Select regions:\n" + selectioncom.toString());
533 allComs.append("; ~display all; chain @CA|P; ribbon ")
534 .append(selectioncom.toString()).append("; focus");
535 sendChimeraCommand(allComs.toString(), false);
541 * Helper method to construct model spec in Chimera format:
543 * <li>#0 (#1 etc) for a PDB file with no sub-models</li>
544 * <li>#0.1 (#1.1 etc) for a PDB file with sub-models</li>
546 * Note for now we only ever choose the first of multiple models. This
547 * corresponds to the hard-coded Jmol equivalent (compare {1.1}). Refactor in
548 * future if there is a need to select specific sub-models.
553 protected String getModelSpec(int pdbfnum)
555 if (pdbfnum < 0 || pdbfnum >= getPdbCount())
561 * For now, the test for having sub-models is whether multiple Chimera
562 * models are mapped for the PDB file; the models are returned as a response
563 * to the Chimera command 'list models type molecule', see
564 * ChimeraManager.getModelList().
566 List<ChimeraModel> maps = chimeraMaps.get(getPdbFile()[pdbfnum]);
567 boolean hasSubModels = maps != null && maps.size() > 1;
568 return "#" + String.valueOf(pdbfnum) + (hasSubModels ? ".1" : "");
572 * Launch Chimera, unless an instance linked to this object is already
573 * running. Returns true if chimera is successfully launched, or already
574 * running, else false.
578 public boolean launchChimera()
580 if (!viewer.isChimeraLaunched())
582 return viewer.launchChimera(StructureManager.getChimeraPaths());
584 if (viewer.isChimeraLaunched())
588 log("Failed to launch Chimera!");
593 * Answers true if the Chimera process is still running, false if ended or not
598 public boolean isChimeraRunning()
600 return viewer.isChimeraLaunched();
604 * Send a command to Chimera, and optionally log any responses.
609 public void sendChimeraCommand(final String command, boolean logResponse)
613 // ? thread running after viewer shut down
616 viewerCommandHistory(false);
617 if (lastCommand == null || !lastCommand.equals(command))
619 // trim command or it may never find a match in the replyLog!!
620 lastReply = viewer.sendChimeraCommand(command.trim(), logResponse);
621 if (logResponse && debug)
623 log("Response from command ('" + command + "') was:\n" + lastReply);
626 viewerCommandHistory(true);
627 lastCommand = command;
631 * Send a Chimera command asynchronously in a new thread. If the progress
632 * message is not null, display this message while the command is executing.
637 protected abstract void sendAsynchronousCommand(String command,
641 * colour any structures associated with sequences in the given alignment
642 * using the getFeatureRenderer() and getSequenceRenderer() renderers but only
643 * if colourBySequence is enabled.
645 public void colourBySequence(boolean showFeatures,
646 jalview.api.AlignmentViewPanel alignmentv)
648 if (!colourBySequence || !loadingFinished)
652 if (getSsm() == null)
656 String[] files = getPdbFile();
658 SequenceRenderer sr = getSequenceRenderer(alignmentv);
660 FeatureRenderer fr = null;
663 fr = getFeatureRenderer(alignmentv);
665 AlignmentI alignment = alignmentv.getAlignment();
667 for (jalview.structure.StructureMappingcommandSet cpdbbyseq : getColourBySequenceCommands(
668 files, sr, fr, alignment))
670 for (String command : cpdbbyseq.commands)
672 sendAsynchronousCommand(command, COLOURING_CHIMERA);
684 protected StructureMappingcommandSet[] getColourBySequenceCommands(
685 String[] files, SequenceRenderer sr, FeatureRenderer fr,
686 AlignmentI alignment)
688 return ChimeraCommands.getColourBySequenceCommand(getSsm(), files,
689 getSequence(), sr, fr, alignment);
695 protected void executeWhenReady(String command)
698 sendChimeraCommand(command, false);
702 private void waitForChimera()
704 while (viewer != null && viewer.isBusy())
709 } catch (InterruptedException q)
715 // End StructureListener
716 // //////////////////////////
718 public Color getColour(int atomIndex, int pdbResNum, String chain,
721 if (getModelNum(pdbfile) < 0)
725 log("get model / residue colour attribute unimplemented");
730 * returns the current featureRenderer that should be used to colour the
737 public abstract FeatureRenderer getFeatureRenderer(
738 AlignmentViewPanel alignment);
741 * instruct the Jalview binding to update the pdbentries vector if necessary
742 * prior to matching the viewer's contents to the list of structure files
743 * Jalview knows about.
745 public abstract void refreshPdbEntries();
747 private int getModelNum(String modelFileName)
749 String[] mfn = getPdbFile();
754 for (int i = 0; i < mfn.length; i++)
756 if (mfn[i].equalsIgnoreCase(modelFileName))
765 * map between index of model filename returned from getPdbFile and the first
766 * index of models from this file in the viewer. Note - this is not trimmed -
767 * use getPdbFile to get number of unique models.
769 private int _modelFileNameMap[];
771 // ////////////////////////////////
772 // /StructureListener
774 public synchronized String[] getPdbFile()
778 return new String[0];
780 // if (modelFileNames == null)
782 // Collection<ChimeraModel> chimodels = viewer.getChimeraModels();
783 // _modelFileNameMap = new int[chimodels.size()];
785 // for (ChimeraModel chimodel : chimodels)
787 // String mdlName = chimodel.getModelName();
789 // modelFileNames = new String[j];
790 // // System.arraycopy(mset, 0, modelFileNames, 0, j);
793 return chimeraMaps.keySet().toArray(
794 modelFileNames = new String[chimeraMaps.size()]);
798 * map from string to applet
800 public Map getRegistryInfo()
802 // TODO Auto-generated method stub
807 * returns the current sequenceRenderer that should be used to colour the
814 public abstract SequenceRenderer getSequenceRenderer(
815 AlignmentViewPanel alignment);
818 * Construct and send a command to highlight zero, one or more atoms.
821 * Done by generating a command like (to 'highlight' positions 44 and 46)
826 public void highlightAtoms(List<AtomSpec> atoms)
832 StringBuilder cmd = new StringBuilder(128);
833 boolean first = true;
834 boolean found = false;
836 for (AtomSpec atom : atoms)
838 int pdbResNum = atom.getPdbResNum();
839 String chain = atom.getChain();
840 String pdbfile = atom.getPdbFile();
841 List<ChimeraModel> cms = chimeraMaps.get(pdbfile);
842 if (cms != null && !cms.isEmpty())
846 cmd.append("show #").append(cms.get(0).getModelNumber())
854 cmd.append(cms.get(0).getModelNumber()).append(":");
855 cmd.append(pdbResNum);
856 if (!chain.equals(" "))
858 cmd.append(".").append(chain);
863 String command = cmd.toString();
866 * Avoid repeated commands for the same residue
868 if (command.equals(lastHighlightCommand))
873 viewerCommandHistory(false);
876 viewer.sendChimeraCommand(command.toString(), false);
878 viewerCommandHistory(true);
879 this.lastHighlightCommand = command;
883 * Query Chimera for its current selection, and highlight it on the alignment
885 public void highlightChimeraSelection()
888 * Ask Chimera for its current selection
890 List<String> selection = viewer.getSelectedResidueSpecs();
893 * Parse model number, residue and chain for each selected position,
894 * formatted as #0:123.A or #1.2:87.B (#model.submodel:residue.chain)
896 List<AtomSpec> atomSpecs = new ArrayList<AtomSpec>();
897 for (String atomSpec : selection)
899 int colonPos = atomSpec.indexOf(":");
902 continue; // malformed
905 int hashPos = atomSpec.indexOf("#");
906 String modelSubmodel = atomSpec.substring(hashPos + 1, colonPos);
907 int dotPos = modelSubmodel.indexOf(".");
911 modelId = Integer.valueOf(dotPos == -1 ? modelSubmodel
912 : modelSubmodel.substring(0, dotPos));
913 } catch (NumberFormatException e)
915 // ignore, default to model 0
918 String residueChain = atomSpec.substring(colonPos + 1);
919 dotPos = residueChain.indexOf(".");
920 int pdbResNum = Integer.parseInt(dotPos == -1 ? residueChain
921 : residueChain.substring(0, dotPos));
923 String chainId = dotPos == -1 ? "" : residueChain
924 .substring(dotPos + 1);
927 * Work out the pdbfilename from the model number
929 String pdbfilename = modelFileNames[frameNo];
930 findfileloop: for (String pdbfile : this.chimeraMaps.keySet())
932 for (ChimeraModel cm : chimeraMaps.get(pdbfile))
934 if (cm.getModelNumber() == modelId)
936 pdbfilename = pdbfile;
941 atomSpecs.add(new AtomSpec(pdbfilename, chainId, pdbResNum, 0));
945 * Broadcast the selection (which may be empty, if the user just cleared all
948 getSsm().mouseOverStructure(atomSpecs);
951 private void log(String message)
953 System.err.println("## Chimera log: " + message);
956 private void viewerCommandHistory(boolean enable)
958 // log("(Not yet implemented) History "
959 // + ((debug || enable) ? "on" : "off"));
962 public long getLoadNotifiesHandled()
964 return loadNotifiesHandled;
967 public void setJalviewColourScheme(ColourSchemeI cs)
969 colourBySequence = false;
976 // Chimera expects RBG values in the range 0-1
977 final double normalise = 255D;
978 viewerCommandHistory(false);
979 StringBuilder command = new StringBuilder(128);
981 List<String> residueSet = ResidueProperties.getResidues(isNucleotide(),
983 for (String res : residueSet)
985 Color col = cs.findColour(res.charAt(0));
986 command.append("color " + col.getRed() / normalise + ","
987 + col.getGreen() / normalise + "," + col.getBlue()
988 / normalise + " ::" + res + ";");
991 sendAsynchronousCommand(command.toString(), COLOURING_CHIMERA);
992 viewerCommandHistory(true);
996 * called when the binding thinks the UI needs to be refreshed after a Chimera
997 * state change. this could be because structures were loaded, or because an
998 * error has occurred.
1000 public abstract void refreshGUI();
1003 public void setLoadingFromArchive(boolean loadingFromArchive)
1005 this.loadingFromArchive = loadingFromArchive;
1010 * @return true if Chimeral is still restoring state or loading is still going
1011 * on (see setFinsihedLoadingFromArchive)
1014 public boolean isLoadingFromArchive()
1016 return loadingFromArchive && !loadingFinished;
1020 * modify flag which controls if sequence colouring events are honoured by the
1021 * binding. Should be true for normal operation
1023 * @param finishedLoading
1026 public void setFinishedLoadingFromArchive(boolean finishedLoading)
1028 loadingFinished = finishedLoading;
1032 * Send the Chimera 'background solid <color>" command.
1035 * ://www.cgl.ucsf.edu/chimera/current/docs/UsersGuide/midas/background
1039 public void setBackgroundColour(Color col)
1041 viewerCommandHistory(false);
1042 double normalise = 255D;
1043 final String command = "background solid " + col.getRed() / normalise
1044 + "," + col.getGreen() / normalise + "," + col.getBlue()
1046 viewer.sendChimeraCommand(command, false);
1047 viewerCommandHistory(true);
1051 * Ask Chimera to save its session to the given file. Returns true if
1052 * successful, else false.
1057 public boolean saveSession(String filepath)
1059 if (isChimeraRunning())
1061 List<String> reply = viewer.sendChimeraCommand("save " + filepath,
1063 if (reply.contains("Session written"))
1070 .error("Error saving Chimera session: " + reply.toString());
1077 * Ask Chimera to open a session file. Returns true if successful, else false.
1078 * The filename must have a .py extension for this command to work.
1083 public boolean openSession(String filepath)
1085 sendChimeraCommand("open " + filepath, true);
1086 // todo: test for failure - how?
1091 * Returns a list of chains mapped in this viewer. Note this list is not
1092 * currently scoped per structure.
1096 public List<String> getChainNames()
1098 List<String> names = new ArrayList<String>();
1099 String[][] allNames = getChains();
1100 if (allNames != null)
1102 for (String[] chainsForPdb : allNames)
1104 if (chainsForPdb != null)
1106 for (String chain : chainsForPdb)
1108 if (chain != null && !names.contains(chain))
1120 * Send a 'focus' command to Chimera to recentre the visible display
1122 public void focusView()
1124 sendChimeraCommand("focus", false);
1128 * Send a 'show' command for all atoms in the currently selected columns
1130 * TODO: pull up to abstract structure viewer interface
1134 public void highlightSelection(AlignmentViewPanel vp)
1136 List<Integer> cols = vp.getAlignViewport().getColumnSelection()
1138 AlignmentI alignment = vp.getAlignment();
1139 StructureSelectionManager sm = getSsm();
1140 for (SequenceI seq : alignment.getSequences())
1143 * convert selected columns into sequence positions
1145 int[] positions = new int[cols.size()];
1147 for (Integer col : cols)
1149 positions[i++] = seq.findPosition(col);
1151 sm.highlightStructure(this, seq, positions);