label.edit_sequences = Edit Sequences
label.sequence_details = Sequence Details
label.jmol_help = Jmol Help
+label.chimera_help = Chimera Help
+label.close_viewer = Close Viewer
+label.confirm_close_chimera = Do you want to close the Chimera window?
+label.chimera_help = Chimera Help
label.all = All
label.sort_by = Sort alignment by
label.sort_by_score = Sort by Score
label.display_features_same_type_different_label_using_different_colour = Display features of the same type with a different label using a different colour. (e.g. domain features)
label.select_colour_minimum_value = Select Colour for Minimum Value
label.select_colour_maximum_value = Select Colour for Maximum Value
-label.open_new_jmol_view_with_all_structures_associated_current_selection_superimpose_using_alignment = Open a new Jmol view with all structures associated with the current selection and superimpose them using the alignment.
+label.open_new_jmol_view_with_all_structures_associated_current_selection_superimpose_using_alignment = Open a new structure viewer with all structures associated with the current selection and superimpose them using the alignment.
label.open_url_param = Open URL {0}
label.open_url_seqs_param = Open URL ({0}..) ({1} seqs)
label.load_pdb_file_associate_with_sequence = Load a PDB file and associate it with sequence {0}
label.web_services = Web Services
label.right_click_to_edit_currently_selected_parameter = Right click to edit currently selected parameter.
label.let_jmol_manage_structure_colours = Let Jmol manage structure colours
+label.let_chimera_manage_structure_colours = Let Chimera manage structure colours
label.marks_leaves_tree_not_associated_with_sequence = Marks leaves of tree not associated with a sequence
label.index_web_services_menu_by_host_site = Index web services in menu by the host site
label.option_want_informed_web_service_URL_cannot_be_accessed_jalview_when_starts_up = Check this option if you want to be informed<br>when a web service URL cannot be accessed by Jalview<br>when it starts up
label.view_structure_for = View structure for {0}
label.view_all_structures = View all {0} structures.
label.view_all_representative_structures = View all {0} representative structures.
-label.open_new_jmol_view_with_all_representative_structures_associated_current_selection_superimpose_using_alignment = Opens a new Jmol view with all representative structures\nassociated with the current selection\nsuperimposed with the current alignment.
+label.open_new_jmol_view_with_all_representative_structures_associated_current_selection_superimpose_using_alignment = Opens a new structure viewer with all representative structures\nassociated with the current selection\nsuperimposed with the current alignment.
label.associate_structure_with_sequence = Associate Structure with Sequence
label.from_file = from file
label.enter_pdb_id = Enter PDB Id
label.link_name = Link Name
label.pdb_file = PDB file
label.colour_with_jmol = Colour with Jmol
+label.colour_with_chimera = Colour with Chimera
label.align_structures = Align structures
label.jmol = Jmol
+label.chimera = Chimera
label.sort_alignment_by_tree = Sort Alignment By Tree
label.mark_unlinked_leaves = Mark Unlinked Leaves
label.associate_leaves_with = Associate Leaves With
label.copied_sequences = Copied sequences
label.cut_sequences = Cut Sequences
label.conservation_colour_increment = Conservation Colour Increment ({0})
-label.percentage_identity_thereshold = Percentage Identity Thereshold ({0})
+label.percentage_identity_thereshold = Percentage Identity Threshold ({0})
label.error_unsupported_owwner_user_colour_scheme = Unsupported owner for User Colour scheme dialog
label.save_alignment_to_file = Save Alignment to file
label.save_features_to_file = Save Features to File
label.add_jabaws_url = Add new JABAWS URL
label.news_from_jalview = News from http://www.jalview.org
label.cut_paste_alignmen_file = Cut & Paste Alignment File
-label.enter_redundancy_thereshold = Enter the redundancy thereshold
+label.enter_redundancy_thereshold = Enter the redundancy threshold
label.select_dark_light_set_thereshold = <html><i>Select a dark and light text colour, then set the threshold to<br>switch between colours, based on background colour</i></html>
label.select_feature_colour = Select Feature Colour
label.delete_all = Delete all sequences
public List<ChimeraModel> openModel(String modelPath, ModelType type)
{
+ return openModel(modelPath, getFileNameFromPath(modelPath), type);
+ }
+
+ /**
+ * Overloaded method to allow Jalview to pass in a model name.
+ *
+ * @param modelPath
+ * @param modelName
+ * @param type
+ * @return
+ */
+ public List<ChimeraModel> openModel(String modelPath, String modelName,
+ ModelType type)
+ {
logger.info("chimera open " + modelPath);
stopListening();
List<String> response = null;
{
continue;
}
- String modelName = modelPath;
- // TODO: [Optional] Convert path to name in a better way
- if (modelPath.lastIndexOf(File.separator) > 0)
- {
- modelName = modelPath.substring(modelPath
- .lastIndexOf(File.separator) + 1);
- }
- else if (modelPath.lastIndexOf("/") > 0)
- {
- modelName = modelPath
- .substring(modelPath.lastIndexOf("/") + 1);
- }
ChimeraModel newModel = new ChimeraModel(modelName, type,
modelNumbers[0], modelNumbers[1]);
currentModelsMap.put(modelNumber, newModel);
models.add(newModel);
+ // patch for Jalview - set model name in Chimera
+ sendChimeraCommand("setattr M name " + modelName + " #"
+ + modelNumbers[0], false);
+ // end patch for Jalview
modelNumbers = null;
}
}
return models;
}
+ /**
+ * Refactored method to extract the last (or only) element delimited by file
+ * path separator.
+ *
+ * @param modelPath
+ * @return
+ */
+ private String getFileNameFromPath(String modelPath)
+ {
+ String modelName = modelPath;
+ if (modelPath == null)
+ {
+ return null;
+ }
+ // TODO: [Optional] Convert path to name in a better way
+ if (modelPath.lastIndexOf(File.separator) > 0)
+ {
+ modelName = modelPath.substring(modelPath
+ .lastIndexOf(File.separator) + 1);
+ }
+ else if (modelPath.lastIndexOf("/") > 0)
+ {
+ modelName = modelPath
+ .substring(modelPath.lastIndexOf("/") + 1);
+ }
+ return modelName;
+ }
+
public void closeModel(ChimeraModel model)
{
// int model = structure.modelNumber();
public boolean isChimeraLaunched()
{
- // TODO: [Optional] What is the best way to test if chimera is launched?
-
- // sendChimeraCommand("test", true) !=null
+ boolean launched = false;
if (chimera != null)
{
- return true;
+ try
+ {
+ chimera.exitValue();
+ // if we get here, process has ended
+ } catch (IllegalThreadStateException e)
+ {
+ // ok - not yet terminated
+ launched = true;
+ }
}
- return false;
+ return launched;
}
public boolean launchChimera(List<String> chimeraPaths)
{
return null;
}
- return ChimUtils.parseModelColor((String) colorLines.get(0));
+ return ChimUtils.parseModelColor(colorLines.get(0));
}
/**
{
return null;
}
+ // TODO do we need a maximum wait time before aborting?
while (busy)
{
try
;
}
busy = true;
- chimeraListenerThreads.clearResponse(command);
- String text = command.concat("\n");
- // System.out.println("send command to chimera: " + text);
try
{
- // send the command
- chimera.getOutputStream().write(text.getBytes());
- chimera.getOutputStream().flush();
- } catch (IOException e)
- {
- // logger.info("Unable to execute command: " + text);
- // logger.info("Exiting...");
- logger.warn("Unable to execute command: " + text);
- logger.warn("Exiting...");
- clearOnChimeraExit();
- busy = false;
- return null;
- }
- if (!reply)
+ chimeraListenerThreads.clearResponse(command);
+ String text = command.concat("\n");
+ // System.out.println("send command to chimera: " + text);
+ try
+ {
+ // send the command
+ chimera.getOutputStream().write(text.getBytes());
+ chimera.getOutputStream().flush();
+ } catch (IOException e)
+ {
+ // logger.info("Unable to execute command: " + text);
+ // logger.info("Exiting...");
+ logger.warn("Unable to execute command: " + text);
+ logger.warn("Exiting...");
+ clearOnChimeraExit();
+ // busy = false;
+ return null;
+ }
+ if (!reply)
+ {
+ // busy = false;
+ return null;
+ }
+ List<String> rsp = chimeraListenerThreads.getResponse(command);
+ // busy = false;
+ return rsp;
+ } finally
{
busy = false;
- return null;
}
- List<String> rsp = chimeraListenerThreads.getResponse(command);
- busy = false;
- return rsp;
}
public StructureManager getStructureManager()
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import ext.edu.ucsf.rbvi.strucviz2.*;
+import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
/***************************************************
* Thread Classes *
public List<String> getResponse(String command) {
List<String> reply;
// System.out.println("getResponse: "+command);
+ // TODO do we need a maximum wait time before aborting?
while (!replyLog.containsKey(command)) {
try {
Thread.currentThread().sleep(100);
} catch (InterruptedException e) {
}
if (replyLog.containsKey(command))
- replyLog.remove(command);
+ {
+ replyLog.remove(command);
+ }
return;
}
*/
private void chimeraRead() throws IOException {
if (chimera == null)
- return;
+ {
+ return;
+ }
String line = null;
while ((line = lineReader.readLine()) != null) {
replyLog.put(command, reply);
}
if (updateModels)
- (new ModelUpdater()).start();
+ {
+ (new ModelUpdater()).start();
+ }
if (updateSelection)
- (new SelectionUpdater()).start();
+ {
+ (new SelectionUpdater()).start();
+ }
if (importNetwork) {
(new NetworkUpdater(line)).start();
}
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
-import java.util.Hashtable;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import java.util.Vector;
import ext.edu.ucsf.rbvi.strucviz2.ChimeraManager;
import ext.edu.ucsf.rbvi.strucviz2.ChimeraModel;
SequenceStructureBinding, StructureSelectionManagerProvider
{
+ private static final String PHOSPHORUS = "P";
+
+ private static final String ALPHACARBON = "CA";
+
private StructureManager csm;
private ChimeraManager viewer;
/**
* when true, try to search the associated datamodel for sequences that are
- * associated with any unknown structures in the Jmol view.
+ * associated with any unknown structures in the Chimera view.
*/
private boolean associateNewStructs = false;
- Vector atomsPicked = new Vector();
+ List<String> atomsPicked = new ArrayList<String>();
- public Vector chainNames;
+ public List<String> chainNames;
- Hashtable chainFile;
+ private Map<String, String> chainFile;
/**
- * array of target chains for seuqences - tied to pdbentry and sequence[]
+ * array of target chains for sequences - tied to pdbentry and sequence[]
*/
protected String[][] chains;
public String fileLoadingError;
- private Map<String, List<ChimeraModel>> chimmaps = new HashMap<String, List<ChimeraModel>>();
+ private Map<String, List<ChimeraModel>> chimmaps = new LinkedHashMap<String, List<ChimeraModel>>();
private List<String> mdlToFile = new ArrayList<String>();
try
{
List<ChimeraModel> oldList = viewer.getModelList();
- viewer.openModel(file, ModelType.PDB_MODEL);
+ viewer.openModel(file, pe.getId(), ModelType.PDB_MODEL);
List<ChimeraModel> newList = viewer.getModelList();
if (oldList.size() < newList.size())
{
* prepare the view for a given set of models/chains. chainList contains
* strings of the form 'pdbfilename:Chaincode'
*
- * @param chainList
+ * @param toshow
* list of chains to make visible
*/
- public void centerViewer(Vector chainList)
+ public void centerViewer(List<String> toshow)
{
- StringBuffer cmd = new StringBuffer();
- String lbl;
+ StringBuilder cmd = new StringBuilder(64);
int mlength, p;
- for (int i = 0, iSize = chainList.size(); i < iSize; i++)
+ for (String lbl : toshow)
{
mlength = 0;
- lbl = (String) chainList.elementAt(i);
do
{
p = mlength;
mlength = lbl.indexOf(":", p);
} while (p < mlength && mlength < (lbl.length() - 2));
// TODO: lookup each pdb id and recover proper model number for it.
- cmd.append("#" + getModelNum((String) chainFile.get(lbl)) + "."
+ cmd.append("#" + getModelNum(chainFile.get(lbl)) + "."
+ lbl.substring(mlength + 1) + " or ");
}
if (cmd.length() > 0)
+ {
cmd.setLength(cmd.length() - 4);
- evalStateCommand("~display #*; ~ribbon #*; ribbon " + cmd + ";focus "
- + cmd,false);
+ }
+ String cmdstring = cmd.toString();
+ evalStateCommand("~display #*; ~ribbon #*; ribbon " + cmdstring
+ + ";focus " + cmdstring, false);
}
public void closeViewer()
int[] _refStructure, ColumnSelection[] _hiddenCols)
{
assert (_alignment.length == _refStructure.length && _alignment.length != _hiddenCols.length);
- StringBuffer allComs = new StringBuffer(); // whole shebang for superposition
+ StringBuilder allComs = new StringBuilder(128); // Chimera superposition cmd
String[] files = getPdbFile();
// check to see if we are still waiting for Jmol files
long starttime = System.currentTimeMillis();
if (waiting)
{
System.err
- .println("RUNTIME PROBLEM: Jmol seems to be taking a long time to process all the structures.");
+ .println("RUNTIME PROBLEM: Chimera seems to be taking a long time to process all the structures.");
return;
}
refreshPdbEntries();
{
refStructure = -1;
}
- StringBuffer command = new StringBuffer();
boolean matched[] = new boolean[alignment.getWidth()];
for (int m = 0; m < matched.length; m++)
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];
- String[] atomS = new String[files.length];
+ String[] atomSpec = new String[files.length];
for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
{
StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]);
}
chainNames[pdbfnum] = mapping[m].getPdbId()
+ targetC[pdbfnum];
- atomS[pdbfnum] = asp.getRNA()!=null ? "P" : "CA";
+ atomSpec[pdbfnum] = asp.getRNA() != null ? PHOSPHORUS : ALPHACARBON;
// move on to next pdb file
s = sequence[pdbfnum].length;
break;
}
}
}
+ StringBuilder command = new StringBuilder(256);
for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
{
if (pdbfnum == refStructure || selcom[pdbfnum] == null
{
continue;
}
- if (command.length()>0)
+ if (command.length() > 0)
{
command.append(";");
}
- command.append("match");
- // form the matched pair strings
- for (int s = 0; s < 2; s++)
- {
- command.append(" #"+(s == 0 ? pdbfnum : refStructure)+".1");
- // note - need to select on first model, otherwise it all goes wrong!
- command.append(selcom[(s == 0 ? pdbfnum : refStructure)]);
- command.append("@"+atomS[(s == 0 ? pdbfnum : refStructure)]); // match on backbone alpha/polyphosphate
- }
+ /*
+ * Form Chimera match command, from the 'new' structure to the
+ * 'reference' structure e.g. (residues 1-91, chain B/A, alphacarbons):
+ *
+ * match #1:1-91.B@CA #0:1-91.A@CA
+ *
+ * @see
+ * https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/match.html
+ */
+ command.append("match #" + pdbfnum /* +".1" */);
+ // TODO: handle sub-models
+ command.append(selcom[pdbfnum]);
+ command.append("@" + atomSpec[pdbfnum]);
+ command.append(" #" + refStructure /* +".1" */);
+ command.append(selcom[refStructure]);
+ command.append("@" + atomSpec[refStructure]);
}
if (selectioncom.length() > 0)
{
+ // TODO remove debug output
System.out.println("Select regions:\n" + selectioncom.toString());
System.out
.println("Superimpose command(s):\n" + command.toString());
allComs.append("; ~display all; chain @CA|P; ribbon "
+ selectioncom.toString() + "");
// evalStateCommand("select *; backbone; select "+selcom.toString()+"; cartoons; center "+selcom.toString());
- evalStateCommand(allComs.toString(),false);
+ evalStateCommand(allComs.toString(), true /* false */);
}
}
// @Override
// public void run()
// {
- lastReply = viewer.sendChimeraCommand(command, resp);
- if (debug)
+ // trim command or it may never find a match in the replyLog!!
+ lastReply = viewer.sendChimeraCommand(command.trim(), resp);
+ if (debug && resp)
{
log("Response from command ('" + command + "') was:\n"
+ lastReply);
jalview.api.AlignmentViewPanel alignmentv)
{
if (!colourBySequence || !loadingFinished)
+ {
return;
+ }
if (ssm == null)
{
return;
for (jalview.structure.StructureMappingcommandSet cpdbbyseq : ChimeraCommands
.getColourBySequenceCommand(ssm, files, sequence, sr, fr,
alignment))
+ {
for (String cbyseq : cpdbbyseq.commands)
{
waitForChimera();
evalStateCommand(cbyseq, false);
waitForChimera();
}
+ }
}
private void waitForChimera()
this.colourBySequence = colourBySequence;
}
- public void createImage(String file, String type, int quality)
- {
- System.out.println("JMOL CREATE IMAGE");
- }
-
- public String createImage(String fileName, String type,
- Object textOrBytes, int quality)
- {
- System.out.println("JMOL CREATE IMAGE");
- return null;
- }
-
- public String eval(String strEval)
- {
- // System.out.println(strEval);
- // "# 'eval' is implemented only for the applet.";
- return null;
- }
-
// End StructureListener
// //////////////////////////
String pdbfile)
{
if (getModelNum(pdbfile) < 0)
+ {
return null;
+ }
log("get model / residue colour attribute unimplemented");
return null;
}
for (int i = 0; i < mfn.length; i++)
{
if (mfn[i].equalsIgnoreCase(modelFileName))
+ {
return i;
+ }
}
return -1;
}
String chainId;
if (strInfo.indexOf(":") > -1)
+ {
chainId = strInfo.substring(strInfo.indexOf(":") + 1,
strInfo.indexOf("."));
+ }
else
{
chainId = " ";
;
}
if (lastMessage == null || !lastMessage.equals(strInfo))
+ {
ssm.mouseOverStructure(pdbResNum, chainId, pdbfilename);
+ }
lastMessage = strInfo;
}
int chainSeparator = strInfo.indexOf(":");
int p = 0;
if (chainSeparator == -1)
+ {
chainSeparator = strInfo.indexOf(".");
+ }
String picked = strInfo.substring(strInfo.indexOf("]") + 1,
chainSeparator);
String mdlString = "";
if ((p = strInfo.indexOf(":")) > -1)
+ {
picked += strInfo.substring(p + 1, strInfo.indexOf("."));
+ }
if ((p = strInfo.indexOf("/")) > -1)
{
if (!atomsPicked.contains(picked))
{
viewer.select(picked);
- atomsPicked.addElement(picked);
+ atomsPicked.add(picked);
}
else
{
viewer.select("not " + picked);
- atomsPicked.removeElement(picked);
+ atomsPicked.remove(picked);
}
viewerCommandHistory(true);
// TODO: in application this happens
// incremented every time a load notification is successfully handled -
// lightweight mechanism for other threads to detect when they can start
- // referrring to new structures.
+ // referring to new structures.
private long loadNotifiesHandled = 0;
public long getLoadNotifiesHandled()
fileLoadingError = null;
String[] oldmodels = modelFileNames;
modelFileNames = null;
- chainNames = new Vector();
- chainFile = new Hashtable();
+ chainNames = new ArrayList<String>();
+ chainFile = new HashMap<String, String>();
boolean notifyLoaded = false;
String[] modelfilenames = getPdbFile();
// first check if we've lost any structures
colourBySequence = false;
if (cs == null)
+ {
return;
+ }
String res;
int index;
res = en.nextElement().toString();
index = ((Integer) ResidueProperties.aa3Hash.get(res)).intValue();
if (index > 20)
+ {
continue;
+ }
col = cs.findColour(ResidueProperties.aa[index].charAt(0));
// TODO: need colour string function and res selection here
public synchronized PDBEntry[] addSequenceAndChain(PDBEntry[] pdbe,
SequenceI[][] seq, String[][] chns)
{
- int pe = -1;
- Vector v = new Vector();
- Vector rtn = new Vector();
+ List<PDBEntry> v = new ArrayList<PDBEntry>();
+ List<int[]> rtn = new ArrayList<int[]>();
for (int i = 0; i < pdbentry.length; i++)
{
- v.addElement(pdbentry[i]);
+ v.add(pdbentry[i]);
}
for (int i = 0; i < pdbe.length; i++)
{
int r = v.indexOf(pdbe[i]);
if (r == -1 || r >= pdbentry.length)
{
- rtn.addElement(new int[]
+ rtn.add(new int[]
{ v.size(), i });
- v.addElement(pdbe[i]);
+ v.add(pdbe[i]);
}
else
{
addSequenceAndChain(r, seq[i], chns[i]);
}
}
- pdbe = new PDBEntry[v.size()];
- v.copyInto(pdbe);
+ pdbe = v.toArray(new PDBEntry[v.size()]);
pdbentry = pdbe;
if (rtn.size() > 0)
{
- // expand the tied seuqence[] and string[] arrays
+ // expand the tied sequence[] and string[] arrays
SequenceI[][] sqs = new SequenceI[pdbentry.length][];
String[][] sch = new String[pdbentry.length][];
System.arraycopy(sequence, 0, sqs, 0, sequence.length);
pdbe = new PDBEntry[rtn.size()];
for (int r = 0; r < pdbe.length; r++)
{
- int[] stri = ((int[]) rtn.elementAt(r));
+ int[] stri = (rtn.get(r));
// record the pdb file as a new addition
pdbe[r] = pdbentry[stri[0]];
// and add the new sequence/chain entries
return pdbe;
}
+ /**
+ * Adds sequences to the pe'th pdbentry's sequence set.
+ *
+ * @param pe
+ * @param seq
+ */
public void addSequence(int pe, SequenceI[] seq)
{
- // add sequences to the pe'th pdbentry's seuqence set.
addSequenceAndChain(pe, seq, null);
}
{
if (pe < 0 || pe >= pdbentry.length)
{
- throw new Error(MessageManager.formatMessage("error.implementation_error_no_pdbentry_from_index", new String[]{Integer.valueOf(pe).toString()}));
+ throw new Error(MessageManager.formatMessage(
+ "error.implementation_error_no_pdbentry_from_index",
+ new Object[]
+ { Integer.valueOf(pe).toString() }));
}
final String nullChain = "TheNullChain";
- Vector s = new Vector();
- Vector c = new Vector();
+ List<SequenceI> s = new ArrayList<SequenceI>();
+ List<String> c = new ArrayList<String>();
if (chains == null)
{
chains = new String[pdbentry.length][];
{
for (int i = 0; i < sequence[pe].length; i++)
{
- s.addElement(sequence[pe][i]);
+ s.add(sequence[pe][i]);
if (chains[pe] != null)
{
if (i < chains[pe].length)
{
- c.addElement(chains[pe][i]);
+ c.add(chains[pe][i]);
}
else
{
- c.addElement(nullChain);
+ c.add(nullChain);
}
}
else
{
if (tchain != null && tchain.length > 0)
{
- c.addElement(nullChain);
+ c.add(nullChain);
}
}
}
{
if (!s.contains(seq[i]))
{
- s.addElement(seq[i]);
+ s.add(seq[i]);
if (tchain != null && i < tchain.length)
{
- c.addElement(tchain[i] == null ? nullChain : tchain[i]);
+ c.add(tchain[i] == null ? nullChain : tchain[i]);
}
}
}
- SequenceI[] tmp = new SequenceI[s.size()];
- s.copyInto(tmp);
+ SequenceI[] tmp = s.toArray(new SequenceI[s.size()]);
sequence[pe] = tmp;
if (c.size() > 0)
{
- String[] tch = new String[c.size()];
- c.copyInto(tch);
+ String[] tch = c.toArray(new String[c.size()]);
for (int i = 0; i < tch.length; i++)
{
if (tch[i] == nullChain)
*/
package jalview.gui;
-import java.util.*;
-import java.awt.*;
-
-import javax.swing.*;
-import javax.swing.event.*;
-
-import java.awt.event.*;
-import java.io.*;
-
-import jalview.jbgui.GStructureViewer;
-import jalview.api.SequenceStructureBinding;
import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
-import jalview.datamodel.*;
-import jalview.gui.ViewSelectionMenu.ViewSetProvider;
+import jalview.datamodel.Alignment;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.ColumnSelection;
import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
import jalview.ext.jmol.JalviewJmolBinding;
-import jalview.io.*;
-import jalview.schemes.*;
+import jalview.gui.ViewSelectionMenu.ViewSetProvider;
+import jalview.io.AppletFormatAdapter;
+import jalview.io.JalviewFileChooser;
+import jalview.io.JalviewFileView;
+import jalview.jbgui.GStructureViewer;
+import jalview.schemes.BuriedColourScheme;
+import jalview.schemes.ColourSchemeI;
+import jalview.schemes.HelixColourScheme;
+import jalview.schemes.HydrophobicColourScheme;
+import jalview.schemes.PurinePyrimidineColourScheme;
+import jalview.schemes.StrandColourScheme;
+import jalview.schemes.TaylorColourScheme;
+import jalview.schemes.TurnColourScheme;
+import jalview.schemes.ZappoColourScheme;
import jalview.util.MessageManager;
import jalview.util.Platform;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Graphics;
+import java.awt.Rectangle;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Vector;
+
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JColorChooser;
+import javax.swing.JInternalFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JSplitPane;
+import javax.swing.event.InternalFrameAdapter;
+import javax.swing.event.InternalFrameEvent;
+import javax.swing.event.MenuEvent;
+import javax.swing.event.MenuListener;
+
public class AppJmol extends GStructureViewer implements Runnable,
ViewSetProvider, JalviewStructureDisplayI
* @param bounds
* @deprecated defaults to AppJmol(String[] files, ... , viewid);
*/
+ @Deprecated
public AppJmol(String file, String id, SequenceI[] seq,
AlignmentPanel ap, String loadStatus, Rectangle bounds)
{
/**
* @deprecated
*/
+ @Deprecated
public AppJmol(String file, String id, SequenceI[] seq,
AlignmentPanel ap, String loadStatus, Rectangle bounds,
String viewid)
{
jmb.setColourBySequence(false);
seqColour.setSelected(false);
- jmolColour.setSelected(true);
+ viewerColour.setSelected(true);
}
if (usetoColour)
{
useAlignmentPanelForColourbyseq(ap);
jmb.setColourBySequence(true);
seqColour.setSelected(true);
- jmolColour.setSelected(false);
+ viewerColour.setSelected(false);
}
this.setBounds(bounds);
initMenus();
private void initMenus()
{
seqColour.setSelected(jmb.isColourBySequence());
- jmolColour.setSelected(!jmb.isColourBySequence());
+ viewerColour.setSelected(!jmb.isColourBySequence());
if (_colourwith == null)
{
_colourwith = new Vector<AlignmentPanel>();
}
});
handler.itemStateChanged(null);
- jmolActionMenu.add(alpanels);
- jmolActionMenu.addMenuListener(new MenuListener()
+ viewerActionMenu.add(alpanels);
+ viewerActionMenu.addMenuListener(new MenuListener()
{
@Override
"label.pdb_entry_is_already_displayed", new String[]
{ pdbentry.getId() }), MessageManager.formatMessage(
"label.map_sequences_to_visible_window", new String[]
- { pdbentry.getId() }), JOptionPane.YES_NO_OPTION);
+ { pdbentry.getId() }),
+ JOptionPane.YES_NO_CANCEL_OPTION);
+ if (option == JOptionPane.CANCEL_OPTION)
+ {
+ return;
+ }
if (option == JOptionPane.YES_OPTION)
{
// TODO : Fix multiple seq to one chain issue here.
{ pdbentry.getId(), topJmol.getTitle() }),
MessageManager
.getString("label.align_to_existing_structure_view"),
- JOptionPane.YES_NO_OPTION);
+ JOptionPane.YES_NO_CANCEL_OPTION);
+ if (option == JOptionPane.CANCEL_OPTION)
+ {
+ return;
+ }
if (option == JOptionPane.YES_OPTION)
{
topJmol.useAlignmentPanelForSuperposition(ap);
useAlignmentPanelForColourbyseq(nap);
jmb.setColourBySequence(enableColourBySeq);
seqColour.setSelected(enableColourBySeq);
- jmolColour.setSelected(!enableColourBySeq);
+ viewerColour.setSelected(!enableColourBySeq);
}
public void useAlignmentPanelForColourbyseq(AlignmentPanel nap)
return;
}
- private Vector getJmolsFor(AlignmentPanel ap2)
+ private Vector getJmolsFor(AlignmentPanel apanel)
{
- Vector otherJmols = new Vector();
- // Now this AppJmol is mapped to new sequences. We must add them to
- // the exisiting array
+ Vector result = new Vector();
JInternalFrame[] frames = Desktop.instance.getAllFrames();
- for (int i = 0; i < frames.length; i++)
+ for (JInternalFrame frame : frames)
{
- if (frames[i] instanceof AppJmol)
+ if (frame instanceof AppJmol)
{
- AppJmol topJmol = ((AppJmol) frames[i]);
- if (topJmol.isLinkedWith(ap2))
+ if (((AppJmol) frame).isLinkedWith(apanel))
{
- otherJmols.addElement(topJmol);
+ result.addElement(frame);
}
}
}
- return otherJmols;
+ return result;
}
void initJmol(String command)
for (int i = 0; i < chainMenu.getItemCount(); i++)
{
if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
+ {
((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
+ }
}
centerViewer();
allChainsSelected = false;
public void itemStateChanged(ItemEvent evt)
{
if (!allChainsSelected)
+ {
centerViewer();
+ }
}
});
worker = null;
}
+ @Override
public void pdbFile_actionPerformed(ActionEvent actionEvent)
{
JalviewFileChooser chooser = new JalviewFileChooser(
}
}
+ @Override
public void viewMapping_actionPerformed(ActionEvent actionEvent)
{
jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
600);
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
+ @Override
public void eps_actionPerformed(ActionEvent e)
{
makePDBImage(jalview.util.ImageMaker.EPS);
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
+ @Override
public void png_actionPerformed(ActionEvent e)
{
makePDBImage(jalview.util.ImageMaker.PNG);
}
}
- public void jmolColour_actionPerformed(ActionEvent actionEvent)
+ @Override
+ public void viewerColour_actionPerformed(ActionEvent actionEvent)
{
- if (jmolColour.isSelected())
+ if (viewerColour.isSelected())
{
// disable automatic sequence colouring.
jmb.setColourBySequence(false);
}
}
+ @Override
public void seqColour_actionPerformed(ActionEvent actionEvent)
{
jmb.setColourBySequence(seqColour.isSelected());
}
}
+ @Override
public void chainColour_actionPerformed(ActionEvent actionEvent)
{
chainColour.setSelected(true);
jmb.colourByChain();
}
+ @Override
public void chargeColour_actionPerformed(ActionEvent actionEvent)
{
chargeColour.setSelected(true);
jmb.colourByCharge();
}
+ @Override
public void zappoColour_actionPerformed(ActionEvent actionEvent)
{
zappoColour.setSelected(true);
jmb.setJalviewColourScheme(new ZappoColourScheme());
}
+ @Override
public void taylorColour_actionPerformed(ActionEvent actionEvent)
{
taylorColour.setSelected(true);
jmb.setJalviewColourScheme(new TaylorColourScheme());
}
+ @Override
public void hydroColour_actionPerformed(ActionEvent actionEvent)
{
hydroColour.setSelected(true);
jmb.setJalviewColourScheme(new HydrophobicColourScheme());
}
+ @Override
public void helixColour_actionPerformed(ActionEvent actionEvent)
{
helixColour.setSelected(true);
jmb.setJalviewColourScheme(new HelixColourScheme());
}
+ @Override
public void strandColour_actionPerformed(ActionEvent actionEvent)
{
strandColour.setSelected(true);
jmb.setJalviewColourScheme(new StrandColourScheme());
}
+ @Override
public void turnColour_actionPerformed(ActionEvent actionEvent)
{
turnColour.setSelected(true);
jmb.setJalviewColourScheme(new TurnColourScheme());
}
+ @Override
public void buriedColour_actionPerformed(ActionEvent actionEvent)
{
buriedColour.setSelected(true);
jmb.setJalviewColourScheme(new BuriedColourScheme());
}
+ @Override
public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
{
setJalviewColourScheme(new PurinePyrimidineColourScheme());
}
+ @Override
public void userColour_actionPerformed(ActionEvent actionEvent)
{
userColour.setSelected(true);
new UserDefinedColours(this, null);
}
+ @Override
public void backGround_actionPerformed(ActionEvent actionEvent)
{
java.awt.Color col = JColorChooser.showDialog(this,
}
}
- public void jmolHelp_actionPerformed(ActionEvent actionEvent)
+ @Override
+ public void showHelp_actionPerformed(ActionEvent actionEvent)
{
try
{
this.setTitle(jmb.getViewerTitle());
if (jmb.getPdbFile().length > 1 && jmb.sequence.length > 1)
{
- jmolActionMenu.setVisible(true);
+ viewerActionMenu.setVisible(true);
}
if (!jmb.isLoadingFromArchive())
{
_alignwith.add(ap);
}
;
- for (Component c : jmolActionMenu.getMenuComponents())
+ for (Component c : viewerActionMenu.getMenuComponents())
{
if (c != alignStructs)
{
- jmolActionMenu.remove((JMenuItem) c);
+ viewerActionMenu.remove((JMenuItem) c);
}
}
final ItemListener handler;
import jalview.schemes.ZappoColourScheme;
import jalview.util.MessageManager;
import jalview.util.Platform;
+import jalview.ws.dbsources.Pdb;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
+import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
-import java.util.Enumeration;
import java.util.List;
import java.util.Vector;
ViewSetProvider, JalviewStructureDisplayI
{
- JalviewChimeraBindingModel jmb;
+ private JalviewChimeraBindingModel jmb;
+
+ /*
+ * list of sequenceSet ids associated with the view
+ */
+ private ArrayList<String> _aps = new ArrayList<String>();
+
+ /*
+ * list of alignment panels to use for superposition
+ */
+ private Vector<AlignmentPanel> _alignwith = new Vector<AlignmentPanel>();
+
+ /*
+ * list of alignment panels that are used for colouring structures by aligned
+ * sequences
+ */
+ private Vector<AlignmentPanel> _colourwith = new Vector<AlignmentPanel>();
+
+ private boolean allChainsSelected = false;
+
+ private boolean alignAddedStructures = false;
AlignmentPanel ap;
- Vector atomsPicked = new Vector();
+ /*
+ * state flag for PDB retrieval thread
+ */
+ private boolean _started = false;
private boolean addingStructures = false;
- ViewSelectionMenu seqColourBy;
+ private IProgressIndicator progressBar = null;
+
+ private String viewId = null;
+
+ /*
+ * pdb retrieval thread.
+ */
+ private Thread worker = null;
/**
- *
- * @param files
- * @param ids
- * @param seqs
- * @param ap
- * @param usetoColour
- * - add the alignment panel to the list used for colouring these
- * structures
- * @param useToAlign
- * - add the alignment panel to the list used for aligning these
- * structures
- * @param leaveColouringToJmol
- * - do not update the colours from any other source. Jmol is
- * handling them
- * @param loadStatus
- * @param bounds
- * @param viewid
- *
- * public ChimeraViewFrame(String[] files, String[] ids,
- * SequenceI[][] seqs, AlignmentPanel ap, boolean usetoColour,
- * boolean useToAlign, boolean leaveColouringToJmol, String
- * loadStatus, Rectangle bounds, String viewid) { PDBEntry[]
- * pdbentrys = new PDBEntry[files.length]; for (int i = 0; i <
- * pdbentrys.length; i++) { PDBEntry pdbentry = new PDBEntry();
- * pdbentry.setFile(files[i]); pdbentry.setId(ids[i]); pdbentrys[i] =
- * pdbentry; } // / TODO: check if protocol is needed to be set, and
- * if chains are // autodiscovered. jmb = new
- * JalviewChimeraBindingModel(this,
- * ap.getStructureSelectionManager(), pdbentrys, seqs, null, null);
- *
- * jmb.setLoadingFromArchive(true); addAlignmentPanel(ap); if
- * (useToAlign) { useAlignmentPanelForSuperposition(ap); } if
- * (leaveColouringToJmol || !usetoColour) {
- * jmb.setColourBySequence(false); seqColour.setSelected(false);
- * jmolColour.setSelected(true); } if (usetoColour) {
- * useAlignmentPanelForColourbyseq(ap);
- * jmb.setColourBySequence(true); seqColour.setSelected(true);
- * jmolColour.setSelected(false); } this.setBounds(bounds);
- * initMenus(); viewId = viewid; //
- * jalview.gui.Desktop.addInternalFrame(this, "Loading File", //
- * bounds.width,bounds.height);
- *
- * this.addInternalFrameListener(new InternalFrameAdapter() { public
- * void internalFrameClosing(InternalFrameEvent internalFrameEvent) {
- * closeViewer(); } }); initJmol(loadStatus); // pdbentry, seq,
- * JBPCHECK!
- *
- * }
+ * Initialise menu options.
*/
private void initMenus()
{
+ viewerActionMenu.setText(MessageManager.getString("label.chimera"));
+ viewerColour.setText(MessageManager
+ .getString("label.colour_with_chimera"));
+ viewerColour.setToolTipText(MessageManager
+ .getString("label.let_chimera_manage_structure_colours"));
+ helpItem.setText(MessageManager.getString("label.chimera_help"));
seqColour.setSelected(jmb.isColourBySequence());
- jmolColour.setSelected(!jmb.isColourBySequence());
+ viewerColour.setSelected(!jmb.isColourBySequence());
if (_colourwith == null)
{
_colourwith = new Vector<AlignmentPanel>();
_alignwith = new Vector<AlignmentPanel>();
}
- seqColourBy = new ViewSelectionMenu(MessageManager.getString("label.colour_by"), this, _colourwith,
+ ViewSelectionMenu seqColourBy = new ViewSelectionMenu(
+ MessageManager.getString("label.colour_by"), this, _colourwith,
new ItemListener()
{
-
@Override
public void itemStateChanged(ItemEvent e)
{
}
else
{
- // update the jmol display now.
+ // update the Chimera display now.
seqColour_actionPerformed(null);
}
}
});
viewMenu.add(seqColourBy);
final ItemListener handler;
- JMenu alpanels = new ViewSelectionMenu(MessageManager.getString("label.superpose_with"), this,
+ JMenu alpanels = new ViewSelectionMenu(
+ MessageManager.getString("label.superpose_with"), this,
_alignwith, handler = new ItemListener()
{
-
@Override
public void itemStateChanged(ItemEvent e)
{
alignStructs.setToolTipText(MessageManager
.formatMessage(
"label.align_structures_using_linked_alignment_views",
- new String[]
+ new Object[]
{ new Integer(_alignwith.size()).toString() }));
}
});
handler.itemStateChanged(null);
- jmolActionMenu.add(alpanels);
- jmolActionMenu.addMenuListener(new MenuListener()
+ viewerActionMenu.add(alpanels);
+ viewerActionMenu.addMenuListener(new MenuListener()
{
@Override
public void menuDeselected(MenuEvent e)
{
// TODO Auto-generated method stub
-
}
@Override
public void menuCanceled(MenuEvent e)
{
// TODO Auto-generated method stub
-
}
});
}
- IProgressIndicator progressBar = null;
-
/**
- * add a single PDB structure to a new or existing Jmol view
+ * add a single PDB structure to a new or existing Chimera view
*
* @param pdbentry
* @param seq
public ChimeraViewFrame(PDBEntry pdbentry, SequenceI[] seq,
String[] chains, final AlignmentPanel ap)
{
+ super();
progressBar = ap.alignFrame;
// ////////////////////////////////
// Is the pdb file already loaded?
{
int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
MessageManager.formatMessage(
- "label.pdb_entry_is_already_displayed", new String[]
+ "label.pdb_entry_is_already_displayed", new Object[]
{ pdbentry.getId() }), MessageManager.formatMessage(
- "label.map_sequences_to_visible_window", new String[]
- { pdbentry.getId() }), JOptionPane.YES_NO_OPTION);
+ "label.map_sequences_to_visible_window", new Object[]
+ { pdbentry.getId() }),
+ JOptionPane.YES_NO_CANCEL_OPTION);
+ if (option == JOptionPane.CANCEL_OPTION)
+ {
+ return;
+ }
if (option == JOptionPane.YES_OPTION)
{
// TODO : Fix multiple seq to one chain issue here.
ap.paintAlignment(true);
}
- // Now this AppJmol is mapped to new sequences. We must add them to
- // the exisiting array
+ // Now this ChimeraViewFrame is mapped to new sequences. We must add
+ // them to the existing array
JInternalFrame[] frames = Desktop.instance.getAllFrames();
- for (int i = 0; i < frames.length; i++)
+ for (JInternalFrame frame : frames)
{
- if (frames[i] instanceof ChimeraViewFrame)
+ if (frame instanceof ChimeraViewFrame)
{
- final ChimeraViewFrame topJmol = ((ChimeraViewFrame) frames[i]);
+ final ChimeraViewFrame topView = ((ChimeraViewFrame) frame);
// JBPNOTE: this looks like a binding routine, rather than a gui
// routine
- for (int pe = 0; pe < topJmol.jmb.pdbentry.length; pe++)
+ for (int pe = 0; pe < topView.jmb.pdbentry.length; pe++)
{
- if (topJmol.jmb.pdbentry[pe].getFile().equals(alreadyMapped))
+ if (topView.jmb.pdbentry[pe].getFile().equals(alreadyMapped))
{
- topJmol.jmb.addSequence(pe, seq);
- topJmol.addAlignmentPanel(ap);
+ topView.jmb.addSequence(pe, seq);
+ topView.addAlignmentPanel(ap);
// add it to the set used for colouring
- topJmol.useAlignmentPanelForColourbyseq(ap);
- topJmol.buildChimeraActionMenu();
+ topView.useAlignmentPanelForColourbyseq(ap);
+ topView.buildChimeraActionMenu();
ap.getStructureSelectionManager()
.sequenceColoursChanged(ap);
break;
}
}
// /////////////////////////////////
- // Check if there are other Jmol views involving this alignment
+ // Check if there are other Chimera views involving this alignment
// and prompt user about adding this molecule to one of them
- Vector existingViews = getJmolsFor(ap);
- if (existingViews.size() > 0)
+ List<ChimeraViewFrame> existingViews = getChimeraWindowsFor(ap);
+ for (ChimeraViewFrame topView : existingViews)
{
- Enumeration jm = existingViews.elements();
- while (jm.hasMoreElements())
+ // TODO: highlight topView in view somehow
+ int option = JOptionPane.showInternalConfirmDialog(Desktop.desktop,
+ MessageManager.formatMessage("label.add_pdbentry_to_view",
+ new Object[]
+ { pdbentry.getId(), topView.getTitle() }),
+ MessageManager
+ .getString("label.align_to_existing_structure_view"),
+ JOptionPane.YES_NO_CANCEL_OPTION);
+ if (option == JOptionPane.CANCEL_OPTION)
{
- ChimeraViewFrame topJmol = (ChimeraViewFrame) jm.nextElement();
- // TODO: highlight topJmol in view somehow
- int option = JOptionPane
- .showInternalConfirmDialog(
- Desktop.desktop,
- MessageManager.formatMessage(
- "label.add_pdbentry_to_view", new String[]
- { pdbentry.getId(), topJmol.getTitle() }),
- MessageManager
- .getString("label.align_to_existing_structure_view"),
- JOptionPane.YES_NO_OPTION);
- if (option == JOptionPane.YES_OPTION)
- {
- topJmol.useAlignmentPanelForSuperposition(ap);
- topJmol.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
- return;
- }
+ return;
+ }
+ if (option == JOptionPane.YES_OPTION)
+ {
+ topView.useAlignmentPanelForSuperposition(ap);
+ topView.addStructure(pdbentry, seq, chains, true, ap.alignFrame);
+ return;
}
}
// /////////////////////////////////
- openNewJmol(ap, new PDBEntry[]
+ openNewChimera(ap, new PDBEntry[]
{ pdbentry }, new SequenceI[][]
{ seq });
}
- private void openNewJmol(AlignmentPanel ap, PDBEntry[] pdbentrys,
+ private void openNewChimera(AlignmentPanel ap, PDBEntry[] pdbentrys,
SequenceI[][] seqs)
{
progressBar = ap.alignFrame;
}
/**
- * create a new Jmol containing several structures superimposed using the
+ * create a new viewer containing several structures superimposed using the
* given alignPanel.
*
* @param ap
public ChimeraViewFrame(AlignmentPanel ap, PDBEntry[] pe,
SequenceI[][] seqs)
{
- openNewJmol(ap, pe, seqs);
+ super();
+ openNewChimera(ap, pe, seqs);
}
- /**
- * list of sequenceSet ids associated with the view
- */
- ArrayList<String> _aps = new ArrayList();
-
public AlignmentPanel[] getAllAlignmentPanels()
{
AlignmentPanel[] t, list = new AlignmentPanel[0];
}
/**
- * list of alignment panels to use for superposition
- */
- Vector<AlignmentPanel> _alignwith = new Vector<AlignmentPanel>();
-
- /**
- * list of alignment panels that are used for colouring structures by aligned
- * sequences
- */
- Vector<AlignmentPanel> _colourwith = new Vector<AlignmentPanel>();
-
- /**
* set the primary alignmentPanel reference and add another alignPanel to the
* list of ones to use for colouring and aligning
*
useAlignmentPanelForColourbyseq(nap);
jmb.setColourBySequence(enableColourBySeq);
seqColour.setSelected(enableColourBySeq);
- jmolColour.setSelected(!enableColourBySeq);
+ viewerColour.setSelected(!enableColourBySeq);
}
public void useAlignmentPanelForColourbyseq(AlignmentPanel nap)
}
/**
- * pdb retrieval thread.
- */
- private Thread worker = null;
-
- /**
* add a new structure (with associated sequences and chains) to this viewer,
* retrieving it if necessary first.
*
return;
}
- private Vector getJmolsFor(AlignmentPanel ap2)
+ private List<ChimeraViewFrame> getChimeraWindowsFor(AlignmentPanel apanel)
{
- Vector otherJmols = new Vector();
- // Now this AppJmol is mapped to new sequences. We must add them to
- // the exisiting array
+ List<ChimeraViewFrame> result = new ArrayList<ChimeraViewFrame>();
JInternalFrame[] frames = Desktop.instance.getAllFrames();
- for (int i = 0; i < frames.length; i++)
+ for (JInternalFrame frame : frames)
{
- if (frames[i] instanceof ChimeraViewFrame)
+ if (frame instanceof ChimeraViewFrame)
{
- ChimeraViewFrame topJmol = ((ChimeraViewFrame) frames[i]);
- if (topJmol.isLinkedWith(ap2))
+ if (((ChimeraViewFrame) frame).isLinkedWith(apanel))
{
- otherJmols.addElement(topJmol);
+ result.add((ChimeraViewFrame) frame);
}
}
}
- return otherJmols;
+ return result;
}
void initChimera(String command)
jmb.setFinishedInit(true);
}
- void setChainMenuItems(Vector chains)
+ void setChainMenuItems(List<String> chainNames)
{
chainMenu.removeAll();
- if (chains == null)
+ if (chainNames == null)
{
return;
}
for (int i = 0; i < chainMenu.getItemCount(); i++)
{
if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
+ {
((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
+ }
}
centerViewer();
allChainsSelected = false;
chainMenu.add(menuItem);
- for (int c = 0; c < chains.size(); c++)
+ for (String chainName : chainNames)
{
- menuItem = new JCheckBoxMenuItem(chains.elementAt(c).toString(), true);
+ menuItem = new JCheckBoxMenuItem(chainName, true);
menuItem.addItemListener(new ItemListener()
{
public void itemStateChanged(ItemEvent evt)
{
if (!allChainsSelected)
+ {
centerViewer();
+ }
}
});
}
}
- boolean allChainsSelected = false;
-
- private boolean alignAddedStructures = false;
-
void centerViewer()
{
- Vector toshow = new Vector();
- String lbl;
- int mlength, p, mnum;
+ List<String> toshow = new ArrayList<String>();
for (int i = 0; i < chainMenu.getItemCount(); i++)
{
if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
JCheckBoxMenuItem item = (JCheckBoxMenuItem) chainMenu.getItem(i);
if (item.isSelected())
{
- toshow.addElement(item.getText());
+ toshow.add(item.getText());
}
}
}
}
/**
- * state flag for PDB retrieval thread
+ * Open any newly added PDB structures in Chimera, having first fetched data
+ * from PDB (if not already saved).
*/
- private boolean _started = false;
-
public void run()
{
_started = true;
- String pdbid = "";
- // todo - record which pdbids were successfuly imported.
- StringBuffer errormsgs = new StringBuffer(), files = new StringBuffer();
- List<String> fileToLoad=new ArrayList<String>();
+ // todo - record which pdbids were successfully imported.
+ StringBuilder errormsgs = new StringBuilder(128);
+ StringBuilder files = new StringBuilder(128);
List<PDBEntry> filePDB = new ArrayList<PDBEntry>();
- List<Integer> filePDBpos =new ArrayList<Integer>();
+ List<Integer> filePDBpos = new ArrayList<Integer>();
+ PDBEntry thePdbEntry = null;
try
{
String[] curfiles = jmb.getPdbFile(); // files currently in viewer
// TODO: replace with reference fetching/transfer code (validate PDBentry
// as a DBRef?)
- jalview.ws.dbsources.Pdb pdbclient = new jalview.ws.dbsources.Pdb();
for (int pi = 0; pi < jmb.pdbentry.length; pi++)
{
String file = null;
- if (jmb.pdbentry[pi].getFile()==null)
+ thePdbEntry = jmb.pdbentry[pi];
+ if (thePdbEntry.getFile() == null)
{
- // retrieve the pdb and store it locally
- AlignmentI pdbseq = null;
- pdbid = jmb.pdbentry[pi].getId();
- long hdl = pdbid.hashCode() - System.currentTimeMillis();
- if (progressBar != null)
- {
- progressBar.setProgressBar(MessageManager.formatMessage("status.fetching_pdb", new String[]{pdbid}), hdl);
- }
- try
- {
- pdbseq = pdbclient.getSequenceRecords(pdbid = jmb.pdbentry[pi]
- .getId());
- } catch (OutOfMemoryError oomerror)
- {
- new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
- } catch (Exception ex)
- {
- ex.printStackTrace();
- errormsgs.append("'" + pdbid + "'");
- }
- if (progressBar != null)
- {
- progressBar.setProgressBar(MessageManager.getString("label.state_completed"), hdl);
- }
- if (pdbseq != null)
+ /*
+ * Retrieve PDB data, save to file, attach to PDBEntry
+ */
+ file = fetchPdbFile(thePdbEntry);
+ if (file == null)
{
- // just transfer the file name from the first sequence's first
- // PDBEntry
- file = new File(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId()
- .elementAt(0)).getFile()).getAbsolutePath();
- jmb.pdbentry[pi].setFile(file);
-
- files.append(" \"" + Platform.escapeString(file) + "\"");
- }
- else
- {
- errormsgs.append("'" + pdbid + "' ");
+ errormsgs.append("'" + thePdbEntry.getId() + "' ");
}
}
else
{
- file = new File(jmb.pdbentry[pi].getFile())
- .getAbsoluteFile().getPath();
+ /*
+ * Got file already - ignore if already loaded in Chimera.
+ */
+ file = new File(thePdbEntry.getFile()).getAbsoluteFile()
+ .getPath();
if (curfiles != null && curfiles.length > 0)
{
addingStructures = true; // already files loaded.
}
}
}
-
- if (file != null)
- {
- fileToLoad.add(file);
- filePDB.add(jmb.pdbentry[pi]);
- filePDBpos.add(Integer.valueOf(pi));
- files.append(" \"" + Platform.escapeString(file) + "\"");
- }
+ }
+ if (file != null)
+ {
+ filePDB.add(thePdbEntry);
+ filePDBpos.add(Integer.valueOf(pi));
+ files.append(" \"" + Platform.escapeString(file) + "\"");
}
}
} catch (OutOfMemoryError oomerror)
{
- new OOMWarning("Retrieving PDB files: " + pdbid, oomerror);
+ new OOMWarning("Retrieving PDB files: " + thePdbEntry.getId(),
+ oomerror);
} catch (Exception ex)
{
ex.printStackTrace();
- errormsgs.append("When retrieving pdbfiles : current was: '" + pdbid
- + "'");
+ errormsgs.append("When retrieving pdbfiles : current was: '"
+ + thePdbEntry.getId() + "'");
}
if (errormsgs.length() > 0)
{
JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
.formatMessage("label.pdb_entries_couldnt_be_retrieved",
- new String[]
+ new Object[]
{ errormsgs.toString() }), MessageManager
.getString("label.couldnt_load_file"),
JOptionPane.ERROR_MESSAGE);
-
}
- long lastnotify = jmb.getLoadNotifiesHandled();
+
if (files.length() > 0)
{
if (!addingStructures)
{
Cache.log.error("Couldn't open Chimera viewer!", ex);
}
- }
- int num=-1;
+ }
+ int num = -1;
for (PDBEntry pe : filePDB)
{
num++;
{
try
{
- int pos=filePDBpos.get(num).intValue();
+ int pos = filePDBpos.get(num).intValue();
jmb.openFile(pe);
jmb.addSequence(pos, jmb.sequence[pos]);
- File fl=new File(pe.getFile());
+ File fl = new File(pe.getFile());
String protocol = AppletFormatAdapter.URL;
try
{
if (fl.exists())
- {
- protocol = AppletFormatAdapter.FILE;
- }
- } catch (Exception e)
- {
- } catch (Error e)
{
+ protocol = AppletFormatAdapter.FILE;
}
- // Explicitly map to the filename used by Jmol ;
- jmb.ssm.setMapping(jmb.sequence[pos], null, pe.getFile(),
- protocol);
- // pdbentry[pe].getFile(), protocol);
+ } catch (Throwable e)
+ {
+ }
+ // Explicitly map to the filename used by Chimera ;
+ // TODO: use pe.getId() instead of pe.getFile() ?
+ jmb.ssm.setMapping(jmb.sequence[pos], null, pe.getFile(),
+ protocol);
} catch (OutOfMemoryError oomerror)
{
new OOMWarning(
}
}
}
- // jmb.getPdbFile();
jmb.setFinishedInit(true);
jmb.setLoadingFromArchive(false);
-
+
// refresh the sequence colours for the new structure(s)
for (AlignmentPanel ap : _colourwith)
{
worker = null;
}
+ /**
+ * Fetch PDB data and save to a local file. Returns the full path to the file,
+ * or null if fetch fails.
+ *
+ * @param processingEntry
+ * @return
+ * @throws Exception
+ */
+ private String fetchPdbFile(PDBEntry processingEntry) throws Exception
+ {
+ String filePath = null;
+ Pdb pdbclient = new Pdb();
+ AlignmentI pdbseq = null;
+ String pdbid = processingEntry.getId();
+ long hdl = pdbid.hashCode() - System.currentTimeMillis();
+ if (progressBar != null)
+ {
+ progressBar.setProgressBar(MessageManager.formatMessage(
+ "status.fetching_pdb", new Object[]
+ { pdbid }), hdl);
+ }
+ try
+ {
+ pdbseq = pdbclient.getSequenceRecords(pdbid);
+ } catch (OutOfMemoryError oomerror)
+ {
+ new OOMWarning("Retrieving PDB id " + pdbid, oomerror);
+ }
+ if (progressBar != null)
+ {
+ progressBar.setProgressBar(
+ MessageManager.getString("label.state_completed"), hdl);
+ }
+ /*
+ * If PDB data were saved and are not invalid (empty alignment), return the
+ * file path.
+ */
+ if (pdbseq != null && pdbseq.getHeight() > 0)
+ {
+ // just use the file name from the first sequence's first PDBEntry
+ filePath = new File(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId()
+ .elementAt(0)).getFile()).getAbsolutePath();
+ processingEntry.setFile(filePath);
+ }
+ return filePath;
+ }
+
+ @Override
public void pdbFile_actionPerformed(ActionEvent actionEvent)
{
JalviewFileChooser chooser = new JalviewFileChooser(
if (value == JalviewFileChooser.APPROVE_OPTION)
{
+ BufferedReader in = null;
try
{
// TODO: cope with multiple PDB files in view
- BufferedReader in = new BufferedReader(new FileReader(
- jmb.getPdbFile()[0]));
+ in = new BufferedReader(new FileReader(jmb.getPdbFile()[0]));
File outFile = chooser.getSelectedFile();
PrintWriter out = new PrintWriter(new FileOutputStream(outFile));
} catch (Exception ex)
{
ex.printStackTrace();
+ } finally
+ {
+ if (in != null)
+ {
+ try
+ {
+ in.close();
+ } catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ }
}
}
}
+ @Override
public void viewMapping_actionPerformed(ActionEvent actionEvent)
{
jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
600);
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
+ @Override
public void eps_actionPerformed(ActionEvent e)
{
- throw new Error(MessageManager.getString("error.eps_generation_not_implemented"));
+ throw new Error(
+ MessageManager
+ .getString("error.eps_generation_not_implemented"));
}
- /**
- * DOCUMENT ME!
- *
- * @param e
- * DOCUMENT ME!
- */
+ @Override
public void png_actionPerformed(ActionEvent e)
{
- throw new Error(MessageManager.getString("error.png_generation_not_implemented"));
+ throw new Error(
+ MessageManager
+ .getString("error.png_generation_not_implemented"));
}
- public void jmolColour_actionPerformed(ActionEvent actionEvent)
+ @Override
+ public void viewerColour_actionPerformed(ActionEvent actionEvent)
{
- if (jmolColour.isSelected())
+ if (viewerColour.isSelected())
{
// disable automatic sequence colouring.
jmb.setColourBySequence(false);
}
}
+ @Override
public void seqColour_actionPerformed(ActionEvent actionEvent)
{
jmb.setColourBySequence(seqColour.isSelected());
}
}
+ @Override
public void chainColour_actionPerformed(ActionEvent actionEvent)
{
chainColour.setSelected(true);
jmb.colourByChain();
}
+ @Override
public void chargeColour_actionPerformed(ActionEvent actionEvent)
{
chargeColour.setSelected(true);
jmb.colourByCharge();
}
+ @Override
public void zappoColour_actionPerformed(ActionEvent actionEvent)
{
zappoColour.setSelected(true);
jmb.setJalviewColourScheme(new ZappoColourScheme());
}
+ @Override
public void taylorColour_actionPerformed(ActionEvent actionEvent)
{
taylorColour.setSelected(true);
jmb.setJalviewColourScheme(new TaylorColourScheme());
}
+ @Override
public void hydroColour_actionPerformed(ActionEvent actionEvent)
{
hydroColour.setSelected(true);
jmb.setJalviewColourScheme(new HydrophobicColourScheme());
}
+ @Override
public void helixColour_actionPerformed(ActionEvent actionEvent)
{
helixColour.setSelected(true);
jmb.setJalviewColourScheme(new HelixColourScheme());
}
+ @Override
public void strandColour_actionPerformed(ActionEvent actionEvent)
{
strandColour.setSelected(true);
jmb.setJalviewColourScheme(new StrandColourScheme());
}
+ @Override
public void turnColour_actionPerformed(ActionEvent actionEvent)
{
turnColour.setSelected(true);
jmb.setJalviewColourScheme(new TurnColourScheme());
}
+ @Override
public void buriedColour_actionPerformed(ActionEvent actionEvent)
{
buriedColour.setSelected(true);
jmb.setJalviewColourScheme(new BuriedColourScheme());
}
+ @Override
public void purinePyrimidineColour_actionPerformed(ActionEvent actionEvent)
{
setJalviewColourScheme(new PurinePyrimidineColourScheme());
}
+ @Override
public void userColour_actionPerformed(ActionEvent actionEvent)
{
userColour.setSelected(true);
new UserDefinedColours(this, null);
}
+ @Override
public void backGround_actionPerformed(ActionEvent actionEvent)
{
- java.awt.Color col = JColorChooser.showDialog(this,
- MessageManager.getString("label.select_backgroud_colour"), null);
+ java.awt.Color col = JColorChooser
+ .showDialog(this, MessageManager
+ .getString("label.select_backgroud_colour"), null);
if (col != null)
{
jmb.setBackgroundColour(col);
}
}
- public void jmolHelp_actionPerformed(ActionEvent actionEvent)
+ @Override
+ public void showHelp_actionPerformed(ActionEvent actionEvent)
{
try
{
}
}
- String viewId = null;
-
public String getViewId()
{
if (viewId == null)
this.setTitle(jmb.getViewerTitle());
if (jmb.getPdbFile().length > 1 && jmb.sequence.length > 1)
{
- jmolActionMenu.setVisible(true);
+ viewerActionMenu.setVisible(true);
}
if (!jmb.isLoadingFromArchive())
{
_alignwith.add(ap);
}
;
- for (Component c : jmolActionMenu.getMenuComponents())
+ for (Component c : viewerActionMenu.getMenuComponents())
{
if (c != alignStructs)
{
- jmolActionMenu.remove((JMenuItem) c);
+ viewerActionMenu.remove((JMenuItem) c);
}
}
- final ItemListener handler;
}
/*
/**
*
* @param ap2
- * @return true if this Jmol instance is linked with the given alignPanel
+ * @return true if this Chimera instance is linked with the given alignPanel
*/
public boolean isLinkedWith(AlignmentPanel ap2)
{
*
* @return TRUE if the view is NOT being coloured by sequence associations.
*/
- public boolean isColouredByJmol()
+ public boolean isColouredByChimera()
{
return !jmb.isColourBySequence();
}
import jalview.util.MessageManager;
-import javax.swing.*;
-import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+
+import javax.swing.ButtonGroup;
+import javax.swing.JInternalFrame;
+import javax.swing.JMenu;
+import javax.swing.JMenuBar;
+import javax.swing.JMenuItem;
+import javax.swing.JRadioButtonMenuItem;
public class GStructureViewer extends JInternalFrame
{
userColour_actionPerformed(actionEvent);
}
});
- jmolColour.setSelected(false);
- jmolColour.setText(MessageManager.getString("label.colour_with_jmol"));
- jmolColour.setToolTipText(MessageManager
+ viewerColour.setSelected(false);
+ viewerColour
+ .setText(MessageManager.getString("label.colour_with_jmol"));
+ viewerColour.setToolTipText(MessageManager
.getString("label.let_jmol_manage_structure_colours"));
- jmolColour.addActionListener(new ActionListener()
+ viewerColour.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent actionEvent)
{
- jmolColour_actionPerformed(actionEvent);
+ viewerColour_actionPerformed(actionEvent);
}
});
helpMenu.setText(MessageManager.getString("action.help"));
- jmolHelp.setText(MessageManager.getString("label.jmol_help"));
- jmolHelp.addActionListener(new ActionListener()
+ helpItem.setText(MessageManager.getString("label.jmol_help"));
+ helpItem.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent actionEvent)
{
- jmolHelp_actionPerformed(actionEvent);
+ showHelp_actionPerformed(actionEvent);
}
});
alignStructs
alignStructs_actionPerformed(actionEvent);
}
});
- jmolActionMenu.setText(MessageManager.getString("label.jmol"));
+ viewerActionMenu.setText(MessageManager.getString("label.jmol"));
menuBar.add(fileMenu);
menuBar.add(viewMenu);
menuBar.add(colourMenu);
- menuBar.add(jmolActionMenu);
- jmolActionMenu.setVisible(false);
+ menuBar.add(viewerActionMenu);
+ viewerActionMenu.setVisible(false);
menuBar.add(helpMenu);
fileMenu.add(savemenu);
fileMenu.add(viewMapping);
colourMenu.add(buriedColour);
colourMenu.add(purinePyrimidineColour);
colourMenu.add(userColour);
- colourMenu.add(jmolColour);
+ colourMenu.add(viewerColour);
colourMenu.add(backGround);
colourButtons.add(seqColour);
colourButtons.add(turnColour);
colourButtons.add(buriedColour);
colourButtons.add(userColour);
- colourButtons.add(jmolColour);
+ colourButtons.add(viewerColour);
- helpMenu.add(jmolHelp);
- jmolActionMenu.add(alignStructs);
+ helpMenu.add(helpItem);
+ viewerActionMenu.add(alignStructs);
}
- protected void jmolColour_actionPerformed(ActionEvent actionEvent)
+ protected void viewerColour_actionPerformed(ActionEvent actionEvent)
{
}
protected JMenu colourMenu = new JMenu();
- protected JMenu jmolActionMenu = new JMenu();
+ protected JMenu viewerActionMenu = new JMenu();
protected JMenuItem alignStructs = new JMenuItem();
protected JRadioButtonMenuItem userColour = new JRadioButtonMenuItem();
- protected JRadioButtonMenuItem jmolColour = new JRadioButtonMenuItem();
+ protected JRadioButtonMenuItem viewerColour = new JRadioButtonMenuItem();
protected ButtonGroup colourButtons = new ButtonGroup();
JMenu helpMenu = new JMenu();
- JMenuItem jmolHelp = new JMenuItem();
+ protected JMenuItem helpItem = new JMenuItem();
public void pdbFile_actionPerformed(ActionEvent actionEvent)
{
}
- public void jmolHelp_actionPerformed(ActionEvent actionEvent)
+ public void showHelp_actionPerformed(ActionEvent actionEvent)
{
}
+ maxChain.residues.size() + "\n\n");
PrintStream ps = new PrintStream(System.out)
{
+ @Override
public void print(String x)
{
mappingDetails.append(x);
}
+ @Override
public void println()
{
mappingDetails.append("\n");