X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fext%2Fjmol%2FJalviewJmolBinding.java;h=8cecf6eba5f3d47abb24fbe2590fd6c5003df90f;hb=6bf5604d306cbcd55289639967411ddbafcac682;hp=216c09ee70fd01d35f1670f6e8021101db8b39c2;hpb=0f8e8fef1abe7837642706ee5b5f97d3e1eda9db;p=jalview.git
diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java
index 216c09e..8cecf6e 100644
--- a/src/jalview/ext/jmol/JalviewJmolBinding.java
+++ b/src/jalview/ext/jmol/JalviewJmolBinding.java
@@ -1,37 +1,42 @@
/*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
- * Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
*
* This file is part of Jalview.
*
* Jalview is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
*
* Jalview is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
- * You should have received a copy of the GNU General Public License along with Jalview. If not, see .
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
*/
package jalview.ext.jmol;
+import jalview.api.AlignViewportI;
import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureRenderer;
-import jalview.api.SequenceRenderer;
-import jalview.api.SequenceStructureBinding;
-import jalview.api.StructureSelectionManagerProvider;
import jalview.datamodel.AlignmentI;
-import jalview.datamodel.ColumnSelection;
+import jalview.datamodel.HiddenColumns;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
-import jalview.io.AppletFormatAdapter;
+import jalview.ext.rbvi.chimera.AtomSpecModel;
+import jalview.gui.IProgressIndicator;
+import jalview.io.DataSourceType;
+import jalview.io.StructureFile;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ResidueProperties;
-import jalview.structure.StructureListener;
-import jalview.structure.StructureMapping;
+import jalview.structure.AtomSpec;
import jalview.structure.StructureSelectionManager;
+import jalview.structures.models.AAStructureBindingModel;
+import jalview.util.MessageManager;
import java.awt.Color;
import java.awt.Container;
@@ -39,9 +44,10 @@ import java.awt.event.ComponentEvent;
import java.awt.event.ComponentListener;
import java.io.File;
import java.net.URL;
-import java.security.AccessControlException;
-import java.util.Enumeration;
+import java.util.ArrayList;
+import java.util.BitSet;
import java.util.Hashtable;
+import java.util.List;
import java.util.Map;
import java.util.Vector;
@@ -50,75 +56,35 @@ import org.jmol.api.JmolAppConsoleInterface;
import org.jmol.api.JmolSelectionListener;
import org.jmol.api.JmolStatusListener;
import org.jmol.api.JmolViewer;
-import org.jmol.constant.EnumCallback;
-import org.jmol.popup.JmolPopup;
-
-public abstract class JalviewJmolBinding implements StructureListener,
- JmolStatusListener, SequenceStructureBinding,
- JmolSelectionListener, ComponentListener,
- StructureSelectionManagerProvider
+import org.jmol.c.CBK;
+import org.jmol.script.T;
+import org.jmol.viewer.Viewer;
+public abstract class JalviewJmolBinding extends AAStructureBindingModel
+ implements JmolStatusListener, JmolSelectionListener,
+ ComponentListener
{
- /**
- * set if Jmol state is being restored from some source - instructs binding
- * not to apply default display style when structure set is updated for first
- * time.
- */
- private boolean loadingFromArchive = false;
-
- /**
- * second flag to indicate if the jmol viewer should ignore sequence colouring
- * events from the structure manager because the GUI is still setting up
- */
- private boolean loadingFinished = true;
-
- /**
- * state flag used to check if the Jmol viewer's paint method can be called
- */
- private boolean finishedInit = false;
-
- public boolean isFinishedInit()
- {
- return finishedInit;
- }
-
- public void setFinishedInit(boolean finishedInit)
- {
- this.finishedInit = finishedInit;
- }
-
boolean allChainsSelected = false;
- /**
+ /*
* when true, try to search the associated datamodel for sequences that are
* associated with any unknown structures in the Jmol view.
*/
private boolean associateNewStructs = false;
- Vector atomsPicked = new Vector();
-
- public Vector chainNames;
-
- Hashtable chainFile;
-
- /**
- * array of target chains for seuqences - tied to pdbentry and sequence[]
- */
- protected String[][] chains;
+ Vector atomsPicked = new Vector<>();
- boolean colourBySequence = true;
+ private List chainNames;
- StringBuffer eval = new StringBuffer();
+ Hashtable chainFile;
- public String fileLoadingError;
-
- /**
+ /*
* the default or current model displayed if the model cannot be identified
* from the selection message
*/
int frameNo = 0;
- protected JmolPopup jmolpopup;
+ // protected JmolGenericPopup jmolpopup; // not used - remove?
String lastCommand;
@@ -126,42 +92,15 @@ public abstract class JalviewJmolBinding implements StructureListener,
boolean loadedInline;
- /**
- * current set of model filenames loaded in the Jmol instance
- */
- String[] modelFileNames = null;
-
- public PDBEntry[] pdbentry;
-
- /**
- * datasource protocol for access to PDBEntrylatest
- */
- String protocol = null;
-
StringBuffer resetLastRes = new StringBuffer();
- /**
- * sequences mapped to each pdbentry
- */
- public SequenceI[][] sequence;
-
- public StructureSelectionManager ssm;
-
- public JmolViewer viewer;
+ public Viewer viewer;
public JalviewJmolBinding(StructureSelectionManager ssm,
- PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
- String protocol)
+ PDBEntry[] pdbentry, SequenceI[][] sequenceIs,
+ DataSourceType protocol)
{
- this.ssm = ssm;
- this.sequence = sequenceIs;
- this.chains = chains;
- this.pdbentry = pdbentry;
- this.protocol = protocol;
- if (chains == null)
- {
- this.chains = new String[pdbentry.length][];
- }
+ super(ssm, pdbentry, sequenceIs, protocol);
/*
* viewer = JmolViewer.allocateViewer(renderPanel, new SmarterJmolAdapter(),
* "jalviewJmol", ap.av.applet .getDocumentBase(),
@@ -172,10 +111,11 @@ public abstract class JalviewJmolBinding implements StructureListener,
}
public JalviewJmolBinding(StructureSelectionManager ssm,
- JmolViewer viewer2)
+ SequenceI[][] seqs, Viewer theViewer)
{
- this.ssm = ssm;
- viewer = viewer2;
+ super(ssm, seqs);
+
+ viewer = theViewer;
viewer.setJmolStatusListener(this);
viewer.addSelectionListener(this);
}
@@ -188,48 +128,20 @@ public abstract class JalviewJmolBinding implements StructureListener,
*/
public String getViewerTitle()
{
- if (sequence == null || pdbentry == null || sequence.length < 1
- || pdbentry.length < 1 || sequence[0].length < 1)
- {
- return ("Jalview Jmol Window");
- }
- // TODO: give a more informative title when multiple structures are
- // displayed.
- StringBuffer title = new StringBuffer(sequence[0][0].getName() + ":"
- + pdbentry[0].getId());
-
- if (pdbentry[0].getProperty() != null)
- {
- if (pdbentry[0].getProperty().get("method") != null)
- {
- title.append(" Method: ");
- title.append(pdbentry[0].getProperty().get("method"));
- }
- if (pdbentry[0].getProperty().get("chains") != null)
- {
- title.append(" Chain:");
- title.append(pdbentry[0].getProperty().get("chains"));
- }
- }
- return title.toString();
+ return getViewerTitle("Jmol", true);
}
/**
* prepare the view for a given set of models/chains. chainList contains
* strings of the form 'pdbfilename:Chaincode'
- *
- * @param chainList
- * list of chains to make visible
*/
- public void centerViewer(Vector chainList)
+ public void centerViewer()
{
- StringBuffer cmd = new StringBuffer();
- String lbl;
+ StringBuilder cmd = new StringBuilder(128);
int mlength, p;
- for (int i = 0, iSize = chainList.size(); i < iSize; i++)
+ for (String lbl : chainsToShow)
{
mlength = 0;
- lbl = (String) chainList.elementAt(i);
do
{
p = mlength;
@@ -237,32 +149,27 @@ public abstract class JalviewJmolBinding implements StructureListener,
} while (p < mlength && mlength < (lbl.length() - 2));
// TODO: lookup each pdb id and recover proper model number for it.
cmd.append(":" + lbl.substring(mlength + 1) + " /"
- + (1 + getModelNum((String) chainFile.get(lbl))) + " or ");
+ + (1 + getModelNum(chainFile.get(lbl))) + " or ");
}
if (cmd.length() > 0)
+ {
cmd.setLength(cmd.length() - 4);
- evalStateCommand("select *;restrict " + cmd + ";cartoon;center " + cmd);
+ }
+ String command = "select *;restrict " + cmd + ";cartoon;center " + cmd;
+ evalStateCommand(command);
}
public void closeViewer()
{
- viewer.setModeMouse(org.jmol.viewer.JmolConstants.MOUSE_NONE);
// remove listeners for all structures in viewer
- ssm.removeStructureViewerListener(this, this.getPdbFile());
- // and shut down jmol
- viewer.evalStringQuiet("zap");
- viewer.setJmolStatusListener(null);
+ getSsm().removeStructureViewerListener(this, this.getStructureFiles());
+ viewer.dispose();
lastCommand = null;
viewer = null;
releaseUIResources();
}
- /**
- * called by JalviewJmolbinding after closeViewer is called - release any
- * resources and references so they can be garbage collected.
- */
- protected abstract void releaseUIResources();
-
+ @Override
public void colourByChain()
{
colourBySequence = false;
@@ -272,6 +179,7 @@ public abstract class JalviewJmolBinding implements StructureListener,
evalStateCommand("select *;color chain");
}
+ @Override
public void colourByCharge()
{
colourBySequence = false;
@@ -312,234 +220,233 @@ public abstract class JalviewJmolBinding implements StructureListener,
* TODO
*/
public void superposeStructures(AlignmentI alignment, int refStructure,
- ColumnSelection hiddenCols)
+ HiddenColumns hiddenCols)
{
- superposeStructures(new AlignmentI[]
- { alignment }, new int[]
- { refStructure }, new ColumnSelection[]
- { hiddenCols });
+ superposeStructures(new AlignmentI[] { alignment },
+ new int[]
+ { refStructure }, new HiddenColumns[] { hiddenCols });
}
- public void superposeStructures(AlignmentI[] _alignment,
- int[] _refStructure, ColumnSelection[] _hiddenCols)
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public String superposeStructures(AlignmentI[] _alignment,
+ int[] _refStructure, HiddenColumns[] _hiddenCols)
{
- assert (_alignment.length == _refStructure.length && _alignment.length != _hiddenCols.length);
+ while (viewer.isScriptExecuting())
+ {
+ try
+ {
+ Thread.sleep(10);
+ } catch (InterruptedException i)
+ {
+ }
+ }
- String[] files = getPdbFile();
- StringBuffer selectioncom = new StringBuffer();
+ /*
+ * get the distinct structure files modelled
+ * (a file with multiple chains may map to multiple sequences)
+ */
+ String[] files = getStructureFiles();
+ if (!waitForFileLoad(files))
+ {
+ return null;
+ }
+
+ StringBuilder selectioncom = new StringBuilder(256);
+ // In principle - nSeconds specifies the speed of animation for each
+ // superposition - but is seems to behave weirdly, so we don't specify it.
+ String nSeconds = " ";
+ if (files.length > 10)
+ {
+ nSeconds = " 0.005 ";
+ }
+ else
+ {
+ nSeconds = " " + (2.0 / files.length) + " ";
+ // if (nSeconds).substring(0,5)+" ";
+ }
+
+ // see JAL-1345 - should really automatically turn off the animation for
+ // large numbers of structures, but Jmol doesn't seem to allow that.
+ // nSeconds = " ";
// union of all aligned positions are collected together.
for (int a = 0; a < _alignment.length; a++)
{
int refStructure = _refStructure[a];
AlignmentI alignment = _alignment[a];
- ColumnSelection hiddenCols = _hiddenCols[a];
- if (a > 0
- && selectioncom.length() > 0
- && !selectioncom.substring(selectioncom.length() - 1).equals(
- "|"))
+ HiddenColumns hiddenCols = _hiddenCols[a];
+ if (a > 0 && selectioncom.length() > 0 && !selectioncom
+ .substring(selectioncom.length() - 1).equals("|"))
{
selectioncom.append("|");
}
// process this alignment
if (refStructure >= files.length)
{
- System.err.println("Invalid reference structure value "
- + refStructure);
+ System.err.println(
+ "Invalid reference structure value " + refStructure);
refStructure = -1;
}
- if (refStructure < -1)
+
+ /*
+ * 'matched' bit j will be set for visible alignment columns j where
+ * all sequences have a residue with a mapping to the PDB structure
+ */
+ BitSet matched = new BitSet();
+ for (int m = 0; m < alignment.getWidth(); m++)
{
- refStructure = -1;
+ if (hiddenCols == null || hiddenCols.isVisible(m))
+ {
+ matched.set(m);
+ }
}
- StringBuffer command = new StringBuffer();
- boolean matched[] = new boolean[alignment.getWidth()];
- for (int m = 0; m < matched.length; m++)
+ SuperposeData[] structures = new SuperposeData[files.length];
+ for (int f = 0; f < files.length; f++)
{
-
- matched[m] = (hiddenCols != null) ? hiddenCols.isVisible(m) : true;
+ structures[f] = new SuperposeData(alignment.getWidth());
}
- int commonrpositions[][] = new int[files.length][alignment.getWidth()];
- String isel[] = new String[files.length];
- // reference structure - all others are superposed in it
- String[] targetC = new String[files.length];
- String[] chainNames = new String[files.length];
- for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
+ /*
+ * Calculate the superposable alignment columns ('matched'), and the
+ * corresponding structure residue positions (structures.pdbResNo)
+ */
+ int candidateRefStructure = findSuperposableResidues(alignment,
+ matched, structures);
+ if (refStructure < 0)
{
- StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]);
- // RACE CONDITION - getMapping only returns Jmol loaded filenames once
- // Jmol callback has completed.
- if (mapping == null || mapping.length < 1)
- continue;
-
- int lastPos = -1;
- for (int s = 0; s < sequence[pdbfnum].length; s++)
- {
- for (int sp, m = 0; m < mapping.length; m++)
- {
- if (mapping[m].getSequence() == sequence[pdbfnum][s]
- && (sp = alignment.findIndex(sequence[pdbfnum][s])) > -1)
- {
- if (refStructure == -1)
- {
- refStructure = pdbfnum;
- }
- SequenceI asp = alignment.getSequenceAt(sp);
- for (int r = 0; r < matched.length; r++)
- {
- if (!matched[r])
- {
- continue;
- }
- matched[r] = false; // assume this is not a good site
- if (r >= asp.getLength())
- {
- continue;
- }
-
- if (jalview.util.Comparison.isGap(asp.getCharAt(r)))
- {
- // no mapping to gaps in sequence
- continue;
- }
- int t = asp.findPosition(r); // sequence position
- int apos = mapping[m].getAtomNum(t);
- int pos = mapping[m].getPDBResNum(t);
-
- if (pos < 1 || pos == lastPos)
- {
- // can't align unmapped sequence
- continue;
- }
- matched[r] = true; // this is a good ite
- lastPos = pos;
- // just record this residue position
- commonrpositions[pdbfnum][r] = pos;
- }
- // create model selection suffix
- isel[pdbfnum] = "/" + (pdbfnum + 1) + ".1";
- if (mapping[m].getChain() == null
- || mapping[m].getChain().trim().length() == 0)
- {
- targetC[pdbfnum] = "";
- }
- else
- {
- targetC[pdbfnum] = ":" + mapping[m].getChain();
- }
- chainNames[pdbfnum] = mapping[m].getPdbId()
- + targetC[pdbfnum];
- // move on to next pdb file
- s = sequence[pdbfnum].length;
- break;
- }
- }
- }
+ /*
+ * If no reference structure was specified, pick the first one that has
+ * a mapping in the alignment
+ */
+ refStructure = candidateRefStructure;
}
+
String[] selcom = new String[files.length];
- int nmatched = 0;
- // generate select statements to select regions to superimpose structures
+ int nmatched = matched.cardinality();
+ if (nmatched < 4)
{
+ return (MessageManager.formatMessage("label.insufficient_residues",
+ nmatched));
+ }
+
+ /*
+ * generate select statements to select regions to superimpose structures
+ */
+ {
+ // TODO extract method to construct selection statements
for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
{
- String chainCd = targetC[pdbfnum];
+ String chainCd = ":" + structures[pdbfnum].chain;
int lpos = -1;
boolean run = false;
- StringBuffer molsel = new StringBuffer();
+ StringBuilder molsel = new StringBuilder();
molsel.append("{");
- for (int r = 0; r < matched.length; r++)
+
+ int nextColumnMatch = matched.nextSetBit(0);
+ while (nextColumnMatch != -1)
{
- if (matched[r])
+ int pdbResNo = structures[pdbfnum].pdbResNo[nextColumnMatch];
+ if (lpos != pdbResNo - 1)
{
- if (pdbfnum == 0)
+ // discontinuity
+ if (lpos != -1)
{
- nmatched++;
+ molsel.append(lpos);
+ molsel.append(chainCd);
+ molsel.append("|");
}
- if (lpos != commonrpositions[pdbfnum][r] - 1)
- {
- // discontinuity
- if (lpos != -1)
- {
- molsel.append(lpos);
- molsel.append(chainCd);
- // molsel.append("} {");
- molsel.append("|");
- }
- }
- else
+ run = false;
+ }
+ else
+ {
+ // continuous run - and lpos >-1
+ if (!run)
{
- // continuous run - and lpos >-1
- if (!run)
- {
- // at the beginning, so add dash
- molsel.append(lpos);
- molsel.append("-");
- }
- run = true;
+ // at the beginning, so add dash
+ molsel.append(lpos);
+ molsel.append("-");
}
- lpos = commonrpositions[pdbfnum][r];
- // molsel.append(lpos);
+ run = true;
}
+ lpos = pdbResNo;
+ nextColumnMatch = matched.nextSetBit(nextColumnMatch + 1);
}
- // add final selection phrase
+ /*
+ * add final selection phrase
+ */
if (lpos != -1)
{
molsel.append(lpos);
molsel.append(chainCd);
molsel.append("}");
}
- selcom[pdbfnum] = molsel.toString();
- selectioncom.append("((");
- selectioncom.append(selcom[pdbfnum].substring(1,
- selcom[pdbfnum].length() - 1));
- selectioncom.append(" )& ");
- selectioncom.append(pdbfnum + 1);
- selectioncom.append(".1)");
- if (pdbfnum < files.length - 1)
+ if (molsel.length() > 1)
{
- selectioncom.append("|");
+ selcom[pdbfnum] = molsel.toString();
+ selectioncom.append("((");
+ selectioncom.append(selcom[pdbfnum].substring(1,
+ selcom[pdbfnum].length() - 1));
+ selectioncom.append(" )& ");
+ selectioncom.append(pdbfnum + 1);
+ selectioncom.append(".1)");
+ if (pdbfnum < files.length - 1)
+ {
+ selectioncom.append("|");
+ }
+ }
+ else
+ {
+ selcom[pdbfnum] = null;
}
}
}
- // TODO: consider bailing if nmatched less than 4 because superposition
- // not
- // well defined.
- // TODO: refactor superposable position search (above) from jmol selection
- // construction (below)
+ StringBuilder command = new StringBuilder(256);
+ // command.append("set spinFps 10;\n");
+
for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
{
- if (pdbfnum == refStructure)
+ if (pdbfnum == refStructure || selcom[pdbfnum] == null
+ || selcom[refStructure] == null)
{
continue;
}
command.append("echo ");
command.append("\"Superposing (");
- command.append(chainNames[pdbfnum]);
+ command.append(structures[pdbfnum].pdbId);
command.append(") against reference (");
- command.append(chainNames[refStructure]);
- command.append(")\";\ncompare ");
+ command.append(structures[refStructure].pdbId);
+ command.append(")\";\ncompare " + nSeconds);
command.append("{");
- command.append(1 + pdbfnum);
+ command.append(Integer.toString(1 + pdbfnum));
command.append(".1} {");
- command.append(1 + refStructure);
- command.append(".1} SUBSET {*.CA | *.P} ATOMS ");
-
- // form the matched pair strings
- String sep = "";
- for (int s = 0; s < 2; s++)
- {
- command.append(selcom[(s == 0 ? pdbfnum : refStructure)]);
- }
+ command.append(Integer.toString(1 + refStructure));
+ // conformation=1 excludes alternate locations for CA (JAL-1757)
+ command.append(
+ ".1} SUBSET {(*.CA | *.P) and conformation=1} ATOMS ");
+
+ // for (int s = 0; s < 2; s++)
+ // {
+ // command.append(selcom[(s == 0 ? pdbfnum : refStructure)]);
+ // }
+ command.append(selcom[pdbfnum]);
+ command.append(selcom[refStructure]);
command.append(" ROTATE TRANSLATE;\n");
}
- System.out.println("Select regions:\n" + selectioncom.toString());
- evalStateCommand("select *; cartoons off; backbone; select ("
- + selectioncom.toString() + "); cartoons; ");
- // selcom.append("; ribbons; ");
- System.out.println("Superimpose command(s):\n" + command.toString());
-
- evalStateCommand(command.toString());
+ if (selectioncom.length() > 0)
+ {
+ // TODO is performing selectioncom redundant here? is done later on
+ // System.out.println("Select regions:\n" + selectioncom.toString());
+ evalStateCommand("select *; cartoons off; backbone; select ("
+ + selectioncom.toString() + "); cartoons; ");
+ // selcom.append("; ribbons; ");
+ String cmdString = command.toString();
+ // System.out.println("Superimpose command(s):\n" + cmdString);
+
+ evalStateCommand(cmdString);
+ }
}
if (selectioncom.length() > 0)
{// finally, mark all regions that were superposed.
@@ -547,11 +454,14 @@ public abstract class JalviewJmolBinding implements StructureListener,
{
selectioncom.setLength(selectioncom.length() - 1);
}
- System.out.println("Select regions:\n" + selectioncom.toString());
+ // System.out.println("Select regions:\n" + selectioncom.toString());
evalStateCommand("select *; cartoons off; backbone; select ("
+ selectioncom.toString() + "); cartoons; ");
- // evalStateCommand("select *; backbone; select "+selcom.toString()+"; cartoons; center "+selcom.toString());
+ // evalStateCommand("select *; backbone; select "+selcom.toString()+";
+ // cartoons; center "+selcom.toString());
}
+
+ return null;
}
public void evalStateCommand(String command)
@@ -565,48 +475,55 @@ public abstract class JalviewJmolBinding implements StructureListener,
lastCommand = command;
}
+ Thread colourby = null;
+
/**
- * colour any structures associated with sequences in the given alignment
- * using the getFeatureRenderer() and getSequenceRenderer() renderers but only
- * if colourBySequence is enabled.
+ * Sends a set of colour commands to the structure viewer
+ *
+ * @param commands
*/
- public void colourBySequence(boolean showFeatures,
- jalview.api.AlignmentViewPanel alignmentv)
+ @Override
+ protected void colourBySequence(final String[] commands)
{
- if (!colourBySequence || !loadingFinished)
- return;
- if (ssm == null)
+ if (colourby != null)
{
- return;
+ colourby.interrupt();
+ colourby = null;
}
- String[] files = getPdbFile();
-
- SequenceRenderer sr = getSequenceRenderer(alignmentv);
-
- FeatureRenderer fr = null;
- if (showFeatures)
+ colourby = new Thread(new Runnable()
{
- fr = getFeatureRenderer(alignmentv);
- }
- AlignmentI alignment = alignmentv.getAlignment();
-
- for (jalview.structure.StructureMappingcommandSet cpdbbyseq : JmolCommands
- .getColourBySequenceCommand(ssm, files, sequence, sr, fr,
- alignment))
- for (String cbyseq : cpdbbyseq.commands)
+ @Override
+ public void run()
{
- evalStateCommand(cbyseq);
+ for (String cmd : commands)
+ {
+ executeWhenReady(cmd);
+ }
}
+ });
+ colourby.start();
}
- public boolean isColourBySequence()
+ /**
+ * @param files
+ * @param viewPanel
+ * @return
+ */
+ @Override
+ protected String[] getColourBySequenceCommands(
+ String[] files, AlignmentViewPanel viewPanel)
{
- return colourBySequence;
+ Map