</xs:documentation>
</xs:annotation>
</xs:attribute>
-
+ <xs:attribute
+ name="chimeraSession" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation>
+Full path name to a saved Chimera session file (usually a .py file).
+ </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
/**
*
* @return true if Jalview or the Viewer is still restoring state or loading
- * is still going on (see setFinsihedLoadingFromArchive)
+ * is still going on (see setFinishedLoadingFromArchive)
*/
void setLoadingFromArchive(boolean loadingFromArchive);
*/
package jalview.api.structures;
-import jalview.api.FeatureRenderer;
-import jalview.api.SequenceRenderer;
-import jalview.api.SequenceStructureBinding;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.SequenceI;
-import jalview.ext.jmol.JalviewJmolBinding;
import jalview.schemes.ColourSchemeI;
-import jalview.schemes.UserColourScheme;
-import jalview.structure.StructureMappingcommandSet;
-import jalview.structure.StructureSelectionManager;
+import jalview.structures.models.AAStructureBindingModel;
public interface JalviewStructureDisplayI
{
- SequenceStructureBinding getBinding();
+ AAStructureBindingModel getBinding();
/**
* @return true if there is an active GUI handling a structure display
import jalview.schemes.TurnColourScheme;
import jalview.schemes.ZappoColourScheme;
import jalview.structure.StructureSelectionManager;
+import jalview.structures.models.AAStructureBindingModel;
import jalview.util.MessageManager;
import java.awt.BorderLayout;
return null;
}
}
- ExtJmol jmv = null;
+ AAStructureBindingModel jmv = null;
// TODO: search for a jmv that involves viewer
if (jmv == null)
{ // create a new viewer/jalview binding.
*/
package jalview.appletgui;
-import java.util.*;
-import java.awt.*;
-import java.awt.event.*;
-
-import jalview.api.SequenceStructureBinding;
-import jalview.datamodel.*;
-import jalview.structure.*;
-import jalview.io.*;
-
-import jalview.schemes.*;
+import jalview.datamodel.AlignmentI;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
+import jalview.io.AppletFormatAdapter;
+import jalview.io.FileParse;
+import jalview.schemes.BuriedColourScheme;
+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.UserColourScheme;
+import jalview.schemes.ZappoColourScheme;
+import jalview.structure.StructureSelectionManager;
import jalview.util.MessageManager;
+import java.awt.BorderLayout;
+import java.awt.CheckboxMenuItem;
+import java.awt.Color;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Frame;
+import java.awt.Graphics;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.MenuItem;
+import java.awt.Panel;
+import java.awt.Rectangle;
+import java.awt.TextArea;
+import java.awt.TextField;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Vector;
+
public class AppletJmol extends EmbmenuFrame implements
// StructureListener,
KeyListener, ActionListener, ItemListener
StringBuffer sb = new StringBuffer();
try
{
- for (int s = 0; s < jmb.pdbentry.length; s++)
+ for (int s = 0; s < jmb.getPdbCount(); s++)
{
- sb.append(jmb.printMapping(jmb.pdbentry[s].getFile()));
+ sb.append(jmb.printMapping(jmb.getPdbEntry(s).getFile()));
sb.append("\n");
}
cap.setText(sb.toString());
for (int i = 0; i < chainMenu.getItemCount(); i++)
{
if (chainMenu.getItem(i) instanceof CheckboxMenuItem)
+ {
((CheckboxMenuItem) chainMenu.getItem(i)).setState(true);
+ }
}
centerViewer();
jmb.colourBySequence(ap.av.getShowSequenceFeatures(), ap);
}
else if (!allChainsSelected)
+ {
centerViewer();
+ }
}
public void keyPressed(KeyEvent evt)
public void sendConsoleEcho(String strEcho)
{
if (appletJmolBinding.scriptWindow == null)
+ {
appletJmolBinding.showConsole(true);
+ }
appletJmolBinding.history.append("\n" + strEcho);
}
}
+ @Override
public void refreshPdbEntries()
{
- // TODO Auto-generated method stub
-
+ // noop
}
@Override
protected void releaseUIResources()
{
appletJmolBinding = null;
- if (console != null)
- {
- try
- {
- console.setVisible(false);
- } catch (Error e)
- {
- } catch (Exception x)
- {
- }
- ;
- console = null;
- }
-
+ closeConsole();
}
@Override
*/
package jalview.appletgui;
-import java.awt.Container;
-import java.util.BitSet;
-import java.util.Hashtable;
-import java.util.Vector;
-
-import org.jmol.api.JmolAppConsoleInterface;
-import org.jmol.api.JmolViewer;
-
import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureRenderer;
import jalview.api.SequenceRenderer;
import jalview.datamodel.SequenceI;
import jalview.ext.jmol.JalviewJmolBinding;
+import java.awt.Container;
+import java.util.ArrayList;
+import java.util.BitSet;
+import java.util.List;
+import java.util.Vector;
+
+import org.jmol.api.JmolAppConsoleInterface;
+import org.jmol.api.JmolViewer;
+
/**
* bind an alignment view to an external Jmol instance.
*
public ExtJmol(JmolViewer viewer, AlignmentPanel alignPanel,
SequenceI[][] seqs)
{
- super(alignPanel.getStructureSelectionManager(), viewer);
+ super(alignPanel.getStructureSelectionManager(), seqs, viewer);
ap = alignPanel;
- this.sequence = seqs;
notifyFileLoaded(null, null, null, null, 0);
}
public void refreshPdbEntries()
{
- Vector pdbe = new Vector();
- Hashtable fileids = new Hashtable();
+ List<PDBEntry> pdbe = new ArrayList<PDBEntry>();
+ List<String> fileids = new ArrayList<String>();
SequenceI[] sq = ap.av.getAlignment().getSequencesArray();
for (int s = 0; s < sq.length; s++)
{
for (int pe = 0, peSize = pdbids.size(); pe < peSize; pe++)
{
PDBEntry pentry = (PDBEntry) pdbids.elementAt(pe);
- if (!fileids.containsKey(pentry.getId()))
+ if (!fileids.contains(pentry.getId()))
{
- pdbe.addElement(pentry);
+ pdbe.add(pentry);
+ }
+ else
+ {
+ fileids.add(pentry.getId());
}
}
}
}
- pdbentry = new PDBEntry[pdbe.size()];
+ PDBEntry[] newEntries = new PDBEntry[pdbe.size()];
for (int pe = 0; pe < pdbe.size(); pe++)
{
- pdbentry[pe] = (PDBEntry) pdbe.elementAt(pe);
+ newEntries[pe] = pdbe.get(pe);
}
+ setPdbentry(newEntries);
}
@Override
protected void releaseUIResources()
{
ap = null;
- if (console != null)
- {
- try
- {
- console.setVisible(false);
- } catch (Error e)
- {
- } catch (Exception x)
- {
- }
- ;
- console = null;
- }
+ closeConsole();
}
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.PDBEntry;
import jalview.io.AppletFormatAdapter;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ResidueProperties;
-import jalview.structure.StructureListener;
import jalview.structure.StructureMapping;
+import jalview.structure.StructureMappingcommandSet;
import jalview.structure.StructureSelectionManager;
-import jalview.structures.models.SequenceStructureBindingModel;
+import jalview.structures.models.AAStructureBindingModel;
import jalview.util.MessageManager;
import java.awt.Color;
import org.jmol.constant.EnumCallback;
import org.jmol.popup.JmolPopup;
-public abstract class JalviewJmolBinding extends SequenceStructureBindingModel implements StructureListener,
- JmolStatusListener, SequenceStructureBinding,
- JmolSelectionListener, ComponentListener,
- StructureSelectionManagerProvider
-
+public abstract class JalviewJmolBinding extends AAStructureBindingModel
+ implements JmolStatusListener, JmolSelectionListener,
+ ComponentListener
{
- /**
+ /*
* 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.
*/
Hashtable chainFile;
- /**
- * array of target chains for seuqences - tied to pdbentry and sequence[]
- */
- protected String[][] chains;
-
- boolean colourBySequence = true;
-
StringBuffer eval = new StringBuffer();
public String fileLoadingError;
- /**
+ /*
* the default or current model displayed if the model cannot be identified
* from the selection message
*/
*/
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 JalviewJmolBinding(StructureSelectionManager ssm,
PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
String 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, chains, protocol);
/*
* viewer = JmolViewer.allocateViewer(renderPanel, new SmarterJmolAdapter(),
* "jalviewJmol", ap.av.applet .getDocumentBase(),
}
public JalviewJmolBinding(StructureSelectionManager ssm,
- JmolViewer viewer2)
+ SequenceI[][] seqs, JmolViewer theViewer)
{
- this.ssm = ssm;
- viewer = viewer2;
+ super(ssm, seqs);
+
+ viewer = theViewer;
viewer.setJmolStatusListener(this);
viewer.addSelectionListener(this);
}
*/
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);
}
/**
+ (1 + getModelNum((String) chainFile.get(lbl))) + " or ");
}
if (cmd.length() > 0)
+ {
cmd.setLength(cmd.length() - 4);
+ }
evalStateCommand("select *;restrict " + cmd + ";cartoon;center " + cmd);
}
{
viewer.setModeMouse(org.jmol.viewer.JmolConstants.MOUSE_NONE);
// remove listeners for all structures in viewer
- ssm.removeStructureViewerListener(this, this.getPdbFile());
+ getSsm().removeStructureViewerListener(this, this.getPdbFile());
// and shut down jmol
viewer.evalStringQuiet("zap");
viewer.setJmolStatusListener(null);
releaseUIResources();
}
- /**
- * called by JalviewJmolbinding after closeViewer is called - release any
- * resources and references so they can be garbage collected.
- */
- protected abstract void releaseUIResources();
-
public void colourByChain()
{
colourBySequence = false;
{
// HACK - in Jalview 2.8 this call may not be threadsafe so we catch
// every possible exception
- StructureMapping[] sm = ssm.getMapping(file);
+ StructureMapping[] sm = getSsm().getMapping(file);
if (sm == null || sm.length == 0)
{
waiting = true;
String[] chainNames = new String[files.length];
for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
{
- StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]);
+ StructureMapping[] mapping = getSsm().getMapping(files[pdbfnum]);
// RACE CONDITION - getMapping only returns Jmol loaded filenames once
// Jmol callback has completed.
if (mapping == null || mapping.length < 1)
throw new Error(MessageManager.getString("error.implementation_error_jmol_getting_data"));
}
int lastPos = -1;
- for (int s = 0; s < sequence[pdbfnum].length; s++)
+ final int sequenceCountForPdbFile = getSequence()[pdbfnum].length;
+ for (int s = 0; s < sequenceCountForPdbFile; 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 (mapping[m].getSequence() == getSequence()[pdbfnum][s]
+ && (sp = alignment.findIndex(getSequence()[pdbfnum][s])) > -1)
{
if (refStructure == -1)
{
chainNames[pdbfnum] = mapping[m].getPdbId()
+ targetC[pdbfnum];
// move on to next pdb file
- s = sequence[pdbfnum].length;
+ s = getSequence()[pdbfnum].length;
break;
}
}
jalview.api.AlignmentViewPanel alignmentv)
{
if (!colourBySequence || !isLoadingFinished())
+ {
return;
- if (ssm == null)
+ }
+ if (getSsm() == null)
{
return;
}
}
AlignmentI alignment = alignmentv.getAlignment();
- for (jalview.structure.StructureMappingcommandSet cpdbbyseq : JmolCommands
- .getColourBySequenceCommand(ssm, files, sequence, sr, fr,
- alignment))
+ for (jalview.structure.StructureMappingcommandSet cpdbbyseq : getColourBySequenceCommands(files, sr, fr, alignment))
+ {
for (String cbyseq : cpdbbyseq.commands)
{
- evalStateCommand(cbyseq);
+ executeWhenReady(cbyseq);
}
+ }
}
- public boolean isColourBySequence()
+ /**
+ * @param files
+ * @param sr
+ * @param fr
+ * @param alignment
+ * @return
+ */
+ protected StructureMappingcommandSet[] getColourBySequenceCommands(
+ String[] files, SequenceRenderer sr, FeatureRenderer fr,
+ AlignmentI alignment)
{
- return colourBySequence;
+ return JmolCommands
+ .getColourBySequenceCommand(getSsm(), files, getSequence(), sr,
+ fr,
+ alignment);
}
- public void setColourBySequence(boolean colourBySequence)
+ /**
+ * @param command
+ */
+ protected void executeWhenReady(String command)
{
- this.colourBySequence = colourBySequence;
+ evalStateCommand(command);
}
public void createImage(String file, String type, int quality)
String pdbfile)
{
if (getModelNum(pdbfile) < 0)
+ {
return null;
+ }
// TODO: verify atomIndex is selecting correct model.
return new Color(viewer.getAtomArgb(atomIndex));
}
for (int i = 0; i < mfn.length; i++)
{
if (mfn[i].equalsIgnoreCase(modelFileName))
+ {
return i;
+ }
}
return -1;
}
/**
* map from string to applet
*/
- public Map getRegistryInfo()
+ @Override
+ public Map<String, Object> getRegistryInfo()
{
// TODO Auto-generated method stub
return null;
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);
+ {
+ getSsm().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)
{
}
// deregister the Jmol instance for these structures - we'll add
// ourselves again at the end for the current structure set.
- ssm.removeStructureViewerListener(this, oldmfn);
+ getSsm().removeStructureViewerListener(this, oldmfn);
}
}
refreshPdbEntries();
+ ".0", "PDB");
pdbfhash = "" + pdbfile.hashCode();
}
- if (pdbentry != null)
- {
// search pdbentries and sequences to find correct pdbentry for this
// model
- for (int pe = 0; pe < pdbentry.length; pe++)
+ for (int pe = 0; pe < getPdbCount(); pe++)
+ {
+ boolean matches = false;
+ if (fileName == null)
{
- boolean matches = false;
- if (fileName == null)
+ if (false)
+ // see JAL-623 - need method of matching pasted data up
{
- if (false)
- // see JAL-623 - need method of matching pasted data up
- {
- pdb = ssm.setMapping(sequence[pe], chains[pe], pdbfile,
- AppletFormatAdapter.PASTE);
- pdbentry[modelnum].setFile("INLINE" + pdb.id);
- matches = true;
- foundEntry = true;
- }
+ pdb = getSsm().setMapping(getSequence()[pe], getChains()[pe],
+ pdbfile, AppletFormatAdapter.PASTE);
+ getPdbEntry(modelnum).setFile("INLINE" + pdb.id);
+ matches = true;
+ foundEntry = true;
}
- else
+ }
+ else
+ {
+ File fl;
+ if (matches = (fl = new File(getPdbEntry(pe).getFile()))
+ .equals(new File(fileName)))
{
- File fl;
- if (matches = (fl = new File(pdbentry[pe].getFile()))
- .equals(new File(fileName)))
+ foundEntry = true;
+ // TODO: Jmol can in principle retrieve from CLASSLOADER but
+ // this
+ // needs
+ // to be tested. See mantis bug
+ // https://mantis.lifesci.dundee.ac.uk/view.php?id=36605
+ String protocol = AppletFormatAdapter.URL;
+ try
{
- foundEntry = true;
- // TODO: Jmol can in principle retrieve from CLASSLOADER but
- // this
- // needs
- // to be tested. See mantis bug
- // https://mantis.lifesci.dundee.ac.uk/view.php?id=36605
- String protocol = AppletFormatAdapter.URL;
- try
- {
- if (fl.exists())
- {
- protocol = AppletFormatAdapter.FILE;
- }
- } catch (Exception e)
- {
- } catch (Error e)
+ if (fl.exists())
{
+ protocol = AppletFormatAdapter.FILE;
}
- // Explicitly map to the filename used by Jmol ;
- pdb = ssm.setMapping(sequence[pe], chains[pe], fileName,
- protocol);
- // pdbentry[pe].getFile(), protocol);
-
+ } catch (Exception e)
+ {
+ } catch (Error e)
+ {
}
+ // Explicitly map to the filename used by Jmol ;
+ pdb = getSsm().setMapping(getSequence()[pe], getChains()[pe],
+ fileName, protocol);
+ // pdbentry[pe].getFile(), protocol);
+
}
- if (matches)
+ }
+ if (matches)
+ {
+ // add an entry for every chain in the model
+ for (int i = 0; i < pdb.chains.size(); i++)
{
- // add an entry for every chain in the model
- for (int i = 0; i < pdb.chains.size(); i++)
- {
- String chid = new String(pdb.id + ":"
- + ((MCview.PDBChain) pdb.chains.elementAt(i)).id);
- chainFile.put(chid, fileName);
- chainNames.addElement(chid);
- }
- notifyLoaded = true;
+ String chid = new String(pdb.id + ":"
+ + pdb.chains.elementAt(i).id);
+ chainFile.put(chid, fileName);
+ chainNames.addElement(chid);
}
+ notifyLoaded = true;
}
}
+
if (!foundEntry && associateNewStructs)
{
// this is a foreign pdb file that jalview doesn't know about - add
}
// register ourselves as a listener and notify the gui that it needs to
// update itself.
- ssm.addStructureViewerListener(this);
+ getSsm().addStructureViewerListener(this);
if (notifyLoaded)
{
FeatureRenderer fr = getFeatureRenderer(null);
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));
protected org.jmol.api.JmolAppConsoleInterface console = null;
- public void componentResized(ComponentEvent e)
+ public void setBackgroundColour(java.awt.Color col)
{
-
+ jmolHistory(false);
+ viewer.evalStringQuiet("background [" + col.getRed() + ","
+ + col.getGreen() + "," + col.getBlue() + "];");
+ jmolHistory(true);
}
- public void componentMoved(ComponentEvent e)
+ /**
+ *
+ * @param pdbfile
+ * @return text report of alignment between pdbfile and any associated
+ * alignment sequences
+ */
+ public String printMapping(String pdbfile)
{
-
+ return getSsm().printMapping(pdbfile);
}
- public void componentShown(ComponentEvent e)
+ @Override
+ public void resizeInnerPanel(String data)
{
- showConsole(true);
+ // Jalview doesn't honour resize panel requests
+
}
- public void componentHidden(ComponentEvent e)
+ public boolean isFinishedInit()
{
- showConsole(false);
+ return finishedInit;
}
- public void setBackgroundColour(java.awt.Color col)
+ public void setFinishedInit(boolean finishedInit)
{
- jmolHistory(false);
- viewer.evalStringQuiet("background [" + col.getRed() + ","
- + col.getGreen() + "," + col.getBlue() + "];");
- jmolHistory(true);
+ this.finishedInit = finishedInit;
}
/**
- * add structures and any known sequence associations
*
- * @returns the pdb entries added to the current set.
*/
- public synchronized PDBEntry[] addSequenceAndChain(PDBEntry[] pdbe,
- SequenceI[][] seq, String[][] chns)
+ protected void closeConsole()
{
- int pe = -1;
- Vector v = new Vector();
- Vector rtn = new Vector();
- for (int i = 0; i < pdbentry.length; i++)
- {
- v.addElement(pdbentry[i]);
- }
- for (int i = 0; i < pdbe.length; i++)
+ if (console != null)
{
- int r = v.indexOf(pdbe[i]);
- if (r == -1 || r >= pdbentry.length)
+ try
{
- rtn.addElement(new int[]
- { v.size(), i });
- v.addElement(pdbe[i]);
- }
- else
+ console.setVisible(false);
+ } catch (Error e)
{
- // just make sure the sequence/chain entries are all up to date
- addSequenceAndChain(r, seq[i], chns[i]);
- }
- }
- pdbe = new PDBEntry[v.size()];
- v.copyInto(pdbe);
- pdbentry = pdbe;
- if (rtn.size() > 0)
- {
- // expand the tied seuqence[] and string[] arrays
- SequenceI[][] sqs = new SequenceI[pdbentry.length][];
- String[][] sch = new String[pdbentry.length][];
- System.arraycopy(sequence, 0, sqs, 0, sequence.length);
- System.arraycopy(chains, 0, sch, 0, this.chains.length);
- sequence = sqs;
- chains = sch;
- pdbe = new PDBEntry[rtn.size()];
- for (int r = 0; r < pdbe.length; r++)
+ } catch (Exception x)
{
- int[] stri = ((int[]) rtn.elementAt(r));
- // record the pdb file as a new addition
- pdbe[r] = pdbentry[stri[0]];
- // and add the new sequence/chain entries
- addSequenceAndChain(stri[0], seq[stri[1]], chns[stri[1]]);
}
+ ;
+ console = null;
}
- else
- {
- pdbe = null;
- }
- return pdbe;
}
- public void addSequence(int pe, SequenceI[] seq)
+ /**
+ * ComponentListener method
+ */
+ @Override
+ public void componentMoved(ComponentEvent e)
{
- // add sequences to the pe'th pdbentry's seuqence set.
- addSequenceAndChain(pe, seq, null);
}
- private void addSequenceAndChain(int pe, SequenceI[] seq, String[] tchain)
+ /**
+ * ComponentListener method
+ */
+ @Override
+ public void componentResized(ComponentEvent e)
{
- if (pe < 0 || pe >= pdbentry.length)
- {
- throw new Error(MessageManager.formatMessage("error.implementation_error_no_pdbentry_from_index", new String[]{Integer.valueOf(pe).toString()}));
- }
- final String nullChain = "TheNullChain";
- Vector s = new Vector();
- Vector c = new Vector();
- if (chains == null)
- {
- chains = new String[pdbentry.length][];
- }
- if (sequence[pe] != null)
- {
- for (int i = 0; i < sequence[pe].length; i++)
- {
- s.addElement(sequence[pe][i]);
- if (chains[pe] != null)
- {
- if (i < chains[pe].length)
- {
- c.addElement(chains[pe][i]);
- }
- else
- {
- c.addElement(nullChain);
- }
- }
- else
- {
- if (tchain != null && tchain.length > 0)
- {
- c.addElement(nullChain);
- }
- }
- }
- }
- for (int i = 0; i < seq.length; i++)
- {
- if (!s.contains(seq[i]))
- {
- s.addElement(seq[i]);
- if (tchain != null && i < tchain.length)
- {
- c.addElement(tchain[i] == null ? nullChain : tchain[i]);
- }
- }
- }
- SequenceI[] tmp = new SequenceI[s.size()];
- s.copyInto(tmp);
- sequence[pe] = tmp;
- if (c.size() > 0)
- {
- String[] tch = new String[c.size()];
- c.copyInto(tch);
- for (int i = 0; i < tch.length; i++)
- {
- if (tch[i] == nullChain)
- {
- tch[i] = null;
- }
- }
- chains[pe] = tch;
- }
- else
- {
- chains[pe] = null;
- }
}
/**
- *
- * @param pdbfile
- * @return text report of alignment between pdbfile and any associated
- * alignment sequences
+ * ComponentListener method
*/
- public String printMapping(String pdbfile)
+ @Override
+ public void componentShown(ComponentEvent e)
{
- return ssm.printMapping(pdbfile);
+ showConsole(true);
}
+ /**
+ * ComponentListener method
+ */
@Override
- public void resizeInnerPanel(String data)
+ public void componentHidden(ComponentEvent e)
{
- // Jalview doesn't honour resize panel requests
-
+ showConsole(false);
}
}
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.PDBEntry;
import jalview.io.AppletFormatAdapter;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.ResidueProperties;
-import jalview.structure.StructureListener;
import jalview.structure.StructureMapping;
+import jalview.structure.StructureMappingcommandSet;
import jalview.structure.StructureSelectionManager;
-import jalview.structures.models.SequenceStructureBindingModel;
+import jalview.structures.models.AAStructureBindingModel;
+import jalview.util.Comparison;
import jalview.util.MessageManager;
import java.awt.Color;
import ext.edu.ucsf.rbvi.strucviz2.StructureManager;
import ext.edu.ucsf.rbvi.strucviz2.StructureManager.ModelType;
-public abstract class JalviewChimeraBinding extends
- SequenceStructureBindingModel implements StructureListener,
- SequenceStructureBinding, StructureSelectionManagerProvider
-
+public abstract class JalviewChimeraBinding extends AAStructureBindingModel
{
private static final boolean debug = false;
private Map<String, String> chainFile;
- /**
- * array of target chains for sequences - tied to pdbentry and sequence[]
- */
- protected String[][] chains;
-
- boolean colourBySequence = true;
-
StringBuffer eval = new StringBuffer();
public String fileLoadingError;
// Explicitly map to the filename used by Chimera ;
// pdbentry[pe].getFile(), protocol);
- if (ssm != null)
+ if (getSsm() != null)
{
- ssm.addStructureViewerListener(this);
+ getSsm().addStructureViewerListener(this);
// ssm.addSelectionListener(this);
FeatureRenderer fr = getFeatureRenderer(null);
if (fr != null)
*/
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;
-
private List<String> lastReply;
+ /**
+ * Constructor
+ *
+ * @param ssm
+ * @param pdbentry
+ * @param sequenceIs
+ * @param chains
+ * @param protocol
+ */
public JalviewChimeraBinding(StructureSelectionManager ssm,
PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
String 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, chains, protocol);
viewer = new ChimeraManager(
csm = new ext.edu.ucsf.rbvi.strucviz2.StructureManager(true));
}
+ /**
+ * Constructor
+ *
+ * @param ssm
+ * @param theViewer
+ */
public JalviewChimeraBinding(StructureSelectionManager ssm,
- ChimeraManager viewer2)
+ ChimeraManager theViewer)
{
- this.ssm = ssm;
- viewer = viewer2;
+ super(ssm, null);
+ viewer = theViewer;
csm = viewer.getStructureManager();
}
*/
public String getViewerTitle(boolean verbose)
{
- if (sequence == null || pdbentry == null || sequence.length < 1
- || pdbentry.length < 1 || sequence[0].length < 1)
- {
- return ("Jalview Chimera Window");
- }
- // TODO: give a more informative title when multiple structures are
- // displayed.
- StringBuilder title = new StringBuilder(64);
- title.append("Chimera view for " + sequence[0][0].getName() + ":"
- + pdbentry[0].getId());
-
- if (verbose)
- {
- 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("Chimera", verbose);
}
/**
}
/**
- * Close down the Jalview viewer, and (optionally) the associate Chimera
+ * Close down the Jalview viewer, and (optionally) the associated Chimera
* window.
*/
public void closeViewer(boolean closeChimera)
{
- ssm.removeStructureViewerListener(this, this.getPdbFile());
+ getSsm().removeStructureViewerListener(this, this.getPdbFile());
if (closeChimera)
{
viewer.exitChimera();
releaseUIResources();
}
- /**
- * called by JalviewChimerabinding after closeViewer is called - release any
- * resources and references so they can be garbage collected.
- */
- protected abstract void releaseUIResources();
-
public void colourByChain()
{
colourBySequence = false;
{
// HACK - in Jalview 2.8 this call may not be threadsafe so we catch
// every possible exception
- StructureMapping[] sm = ssm.getMapping(file);
+ StructureMapping[] sm = getSsm().getMapping(file);
if (sm == null || sm.length == 0)
{
waiting = true;
String[] atomSpec = new String[files.length];
for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++)
{
- StructureMapping[] mapping = ssm.getMapping(files[pdbfnum]);
+ StructureMapping[] mapping = getSsm().getMapping(files[pdbfnum]);
// RACE CONDITION - getMapping only returns Jmol loaded filenames once
// Jmol callback has completed.
if (mapping == null || mapping.length < 1)
throw new Error(MessageManager.getString("error.implementation_error_chimera_getting_data"));
}
int lastPos = -1;
- for (int s = 0; s < sequence[pdbfnum].length; s++)
+ final int seqCountForPdbFile = getSequence()[pdbfnum].length;
+ for (int s = 0; s < seqCountForPdbFile; s++)
{
for (int sp, m = 0; m < mapping.length; m++)
{
- if (mapping[m].getSequence() == sequence[pdbfnum][s]
- && (sp = alignment.findIndex(sequence[pdbfnum][s])) > -1)
+ final SequenceI theSequence = getSequence()[pdbfnum][s];
+ if (mapping[m].getSequence() == theSequence
+ && (sp = alignment.findIndex(theSequence)) > -1)
{
if (refStructure == -1)
{
continue;
}
- if (jalview.util.Comparison.isGap(asp.getCharAt(r)))
+ if (Comparison.isGap(asp.getCharAt(r)))
{
// no mapping to gaps in sequence
continue;
+ targetC[pdbfnum];
atomSpec[pdbfnum] = asp.getRNA() != null ? PHOSPHORUS : ALPHACARBON;
// move on to next pdb file
- s = sequence[pdbfnum].length;
+ s = seqCountForPdbFile;
break;
}
}
{
return;
}
- if (ssm == null)
+ if (getSsm() == null)
{
return;
}
}
AlignmentI alignment = alignmentv.getAlignment();
- for (jalview.structure.StructureMappingcommandSet cpdbbyseq : ChimeraCommands
- .getColourBySequenceCommand(ssm, files, sequence, sr, fr,
- alignment))
+ for (jalview.structure.StructureMappingcommandSet cpdbbyseq : getColourBySequenceCommands(files, sr, fr, alignment))
{
- for (String cbyseq : cpdbbyseq.commands)
+ for (String command : cpdbbyseq.commands)
{
- waitForChimera();
- evalStateCommand(cbyseq, false);
- waitForChimera();
+ executeWhenReady(command);
}
}
}
+ /**
+ * @param files
+ * @param sr
+ * @param fr
+ * @param alignment
+ * @return
+ */
+ protected StructureMappingcommandSet[] getColourBySequenceCommands(
+ String[] files, SequenceRenderer sr, FeatureRenderer fr,
+ AlignmentI alignment)
+ {
+ return ChimeraCommands
+ .getColourBySequenceCommand(getSsm(), files, getSequence(), sr,
+ fr,
+ alignment);
+ }
+
+ /**
+ * @param command
+ */
+ protected void executeWhenReady(String command)
+ {
+ waitForChimera();
+ evalStateCommand(command, false);
+ waitForChimera();
+ }
+
private void waitForChimera()
{
while (viewer != null && viewer.isBusy())
}
}
- public boolean isColourBySequence()
- {
- return colourBySequence;
- }
-
- public void setColourBySequence(boolean colourBySequence)
- {
- this.colourBySequence = colourBySequence;
- }
+
// End StructureListener
// //////////////////////////
- public float[][] functionXY(String functionName, int x, int y)
- {
- return null;
- }
-
- public float[][][] functionXYZ(String functionName, int nx, int ny, int nz)
- {
- // TODO Auto-generated method stub
- return null;
- }
-
public Color getColour(int atomIndex, int pdbResNum, String chain,
String pdbfile)
{
}
if (lastMessage == null || !lastMessage.equals(strInfo))
{
- ssm.mouseOverStructure(pdbResNum, chainId, pdbfilename);
+ getSsm().mouseOverStructure(pdbResNum, chainId, pdbfilename);
}
lastMessage = strInfo;
}
// deregister the Jmol instance for these structures - we'll add
// ourselves again at the end for the current structure set.
- ssm.removeStructureViewerListener(this, oldmfn);
+ getSsm().removeStructureViewerListener(this, oldmfn);
}
}
// register ourselves as a listener and notify the gui that it needs to
// update itself.
- ssm.addStructureViewerListener(this);
+ getSsm().addStructureViewerListener(this);
if (notifyLoaded)
{
*/
public abstract void refreshGUI();
- public void componentResized(ComponentEvent e)
- {
-
- }
-
- public void componentMoved(ComponentEvent e)
- {
-
- }
-
- public void componentShown(ComponentEvent e)
- {
- }
-
- public void componentHidden(ComponentEvent e)
- {
- }
-
public void setLoadingFromArchive(boolean loadingFromArchive)
{
this.loadingFromArchive = loadingFromArchive;
}
/**
- * add structures and any known sequence associations
*
- * @returns the pdb entries added to the current set.
+ * @param pdbfile
+ * @return text report of alignment between pdbfile and any associated
+ * alignment sequences
*/
- public synchronized PDBEntry[] addSequenceAndChain(PDBEntry[] pdbe,
- SequenceI[][] seq, String[][] chns)
+ public String printMapping(String pdbfile)
{
- List<PDBEntry> v = new ArrayList<PDBEntry>();
- List<int[]> rtn = new ArrayList<int[]>();
- for (int i = 0; i < pdbentry.length; 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.add(new int[]
- { v.size(), i });
- v.add(pdbe[i]);
- }
- else
- {
- // just make sure the sequence/chain entries are all up to date
- addSequenceAndChain(r, seq[i], chns[i]);
- }
- }
- pdbe = v.toArray(new PDBEntry[v.size()]);
- pdbentry = pdbe;
- if (rtn.size() > 0)
- {
- // 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);
- System.arraycopy(chains, 0, sch, 0, this.chains.length);
- sequence = sqs;
- chains = sch;
- pdbe = new PDBEntry[rtn.size()];
- for (int r = 0; r < pdbe.length; 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
- addSequenceAndChain(stri[0], seq[stri[1]], chns[stri[1]]);
- }
- }
- else
- {
- pdbe = null;
- }
- return pdbe;
+ return getSsm().printMapping(pdbfile);
}
/**
- * Adds sequences to the pe'th pdbentry's sequence set.
+ * Ask Chimera to save its session to the given file. Returns true if
+ * successful, else false.
*
- * @param pe
- * @param seq
+ * @param filepath
+ * @return
*/
- public void addSequence(int pe, SequenceI[] seq)
- {
- addSequenceAndChain(pe, seq, null);
- }
-
- private void addSequenceAndChain(int pe, SequenceI[] seq, String[] tchain)
+ public boolean saveSession(String filepath)
{
- if (pe < 0 || pe >= pdbentry.length)
- {
- throw new Error(MessageManager.formatMessage(
- "error.implementation_error_no_pdbentry_from_index",
- new Object[]
- { Integer.valueOf(pe).toString() }));
- }
- final String nullChain = "TheNullChain";
- List<SequenceI> s = new ArrayList<SequenceI>();
- List<String> c = new ArrayList<String>();
- if (chains == null)
- {
- chains = new String[pdbentry.length][];
- }
- if (sequence[pe] != null)
- {
- for (int i = 0; i < sequence[pe].length; i++)
- {
- s.add(sequence[pe][i]);
- if (chains[pe] != null)
- {
- if (i < chains[pe].length)
- {
- c.add(chains[pe][i]);
- }
- else
- {
- c.add(nullChain);
- }
- }
- else
- {
- if (tchain != null && tchain.length > 0)
- {
- c.add(nullChain);
- }
- }
- }
- }
- for (int i = 0; i < seq.length; i++)
+ if (isChimeraRunning())
{
- if (!s.contains(seq[i]))
- {
- s.add(seq[i]);
- if (tchain != null && i < tchain.length)
- {
- c.add(tchain[i] == null ? nullChain : tchain[i]);
- }
- }
+ List<String> reply = viewer.sendChimeraCommand("save " + filepath,
+ true);
+ System.out.println(reply);
}
- SequenceI[] tmp = s.toArray(new SequenceI[s.size()]);
- sequence[pe] = tmp;
- if (c.size() > 0)
- {
- String[] tch = c.toArray(new String[c.size()]);
- for (int i = 0; i < tch.length; i++)
- {
- if (tch[i] == nullChain)
- {
- tch[i] = null;
- }
- }
- chains[pe] = tch;
- }
- else
- {
- chains[pe] = null;
- }
- }
-
- /**
- *
- * @param pdbfile
- * @return text report of alignment between pdbfile and any associated
- * alignment sequences
- */
- public String printMapping(String pdbfile)
- {
- return ssm.printMapping(pdbfile);
+ return false;
}
}
*/
package jalview.ext.varna;
-import java.awt.event.*;
-
-import jalview.api.SequenceStructureBinding;
import jalview.api.StructureSelectionManagerProvider;
-import jalview.structure.*;
+import jalview.structure.StructureListener;
import jalview.structures.models.SequenceStructureBindingModel;
-public abstract class JalviewVarnaBinding extends SequenceStructureBindingModel implements StructureListener,
- SequenceStructureBinding, ComponentListener,
- StructureSelectionManagerProvider
+import java.awt.event.ComponentListener;
+
+public abstract class JalviewVarnaBinding extends
+ SequenceStructureBindingModel implements StructureListener,
+ ComponentListener, StructureSelectionManagerProvider
{
*/
package jalview.gui;
-import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
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.gui.ViewSelectionMenu.ViewSetProvider;
import jalview.io.AppletFormatAdapter;
import jalview.io.JalviewFileChooser;
import jalview.schemes.TaylorColourScheme;
import jalview.schemes.TurnColourScheme;
import jalview.schemes.ZappoColourScheme;
+import jalview.structures.models.AAStructureBindingModel;
import jalview.util.MessageManager;
import jalview.util.Platform;
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.event.MenuListener;
public class AppJmol extends GStructureViewer implements Runnable,
- ViewSetProvider, JalviewStructureDisplayI
+ ViewSetProvider
{
AppJmolBinding jmb;
}
this.setBounds(bounds);
initMenus();
- viewId = viewid;
+ setViewId(viewid);
// jalview.gui.Desktop.addInternalFrame(this, "Loading File",
// bounds.width,bounds.height);
final AppJmol topJmol = ((AppJmol) frames[i]);
// 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 < topJmol.jmb.getPdbCount(); pe++)
{
- if (topJmol.jmb.pdbentry[pe].getFile().equals(alreadyMapped))
+ if (topJmol.jmb.getPdbEntry(pe).getFile()
+ .equals(alreadyMapped))
{
topJmol.jmb.addSequence(pe, seq);
topJmol.addAlignmentPanel(ap);
openNewJmol(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
*
{
if (frame instanceof AppJmol)
{
- if (((AppJmol) frame).isLinkedWith(apanel))
+ if (((GStructureViewer) frame).isLinkedWith(apanel))
{
result.addElement(frame);
}
// 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++)
+ for (int pi = 0; pi < jmb.getPdbCount(); pi++)
{
- String file = jmb.pdbentry[pi].getFile();
+ String file = jmb.getPdbEntry(pi).getFile();
if (file == null)
{
// retrieve the pdb and store it locally
AlignmentI pdbseq = null;
- pdbid = jmb.pdbentry[pi].getId();
+ pdbid = jmb.getPdbEntry(pi).getId();
long hdl = pdbid.hashCode() - System.currentTimeMillis();
if (progressBar != null)
{
}
try
{
- pdbseq = pdbclient.getSequenceRecords(pdbid = jmb.pdbentry[pi]
+ pdbseq = pdbclient.getSequenceRecords(pdbid = jmb.getPdbEntry(
+ pi)
.getId());
} catch (OutOfMemoryError oomerror)
{
// PDBEntry
file = new File(((PDBEntry) pdbseq.getSequenceAt(0).getPDBId()
.elementAt(0)).getFile()).getAbsolutePath();
- jmb.pdbentry[pi].setFile(file);
+ jmb.getPdbEntry(pi).setFile(file);
files.append(" \"" + Platform.escapeString(file) + "\"");
}
// need to wait around until script has finished
while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled()
: (jmb.isFinishedInit() && jmb.getPdbFile() != null && jmb
- .getPdbFile().length != jmb.pdbentry.length))
+ .getPdbFile().length != jmb.getPdbCount()))
{
try
{
jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
try
{
- for (int pdbe = 0; pdbe < jmb.pdbentry.length; pdbe++)
+ for (int pdbe = 0; pdbe < jmb.getPdbCount(); pdbe++)
{
- cap.appendText(jmb.printMapping(jmb.pdbentry[pdbe].getFile()));
+ cap.appendText(jmb.printMapping(jmb.getPdbEntry(pdbe).getFile()));
cap.appendText("\n");
}
} catch (OutOfMemoryError e)
+ "...", 20, currentSize.height / 2);
StringBuffer sb = new StringBuffer();
int lines = 0;
- for (int e = 0; e < jmb.pdbentry.length; e++)
+ for (int e = 0; e < jmb.getPdbCount(); e++)
{
- sb.append(jmb.pdbentry[e].getId());
- if (e < jmb.pdbentry.length - 1)
+ sb.append(jmb.getPdbEntry(e).getId());
+ if (e < jmb.getPdbCount() - 1)
{
sb.append(",");
}
- if (e == jmb.pdbentry.length - 1 || sb.length() > 20)
+ if (e == jmb.getPdbCount() - 1 || sb.length() > 20)
{
lines++;
g.drawString(sb.toString(), 20, currentSize.height / 2 - lines
}
}
- String viewId = null;
-
- public String getViewId()
- {
- if (viewId == null)
- {
- viewId = System.currentTimeMillis() + "." + this.hashCode();
- }
- return viewId;
- }
-
public void updateTitleAndMenus()
{
if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
setChainMenuItems(jmb.chainNames);
this.setTitle(jmb.getViewerTitle());
- if (jmb.getPdbFile().length > 1 && jmb.sequence.length > 1)
+ if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
{
viewerActionMenu.setVisible(true);
}
return ap;
}
- /**
- *
- * @param ap2
- * @return true if this Jmol instance is linked with the given alignPanel
- */
- public boolean isLinkedWith(AlignmentPanel ap2)
- {
- return _aps.contains(ap2.av.getSequenceSetId());
- }
-
- public boolean isUsedforaligment(AlignmentPanel ap2)
- {
-
- return (_alignwith != null) && _alignwith.contains(ap2);
- }
-
- public boolean isUsedforcolourby(AlignmentPanel ap2)
- {
- return (_colourwith != null) && _colourwith.contains(ap2);
- }
-
- /**
- *
- * @return TRUE if the view is NOT being coloured by sequence associations.
- */
- public boolean isColouredByJmol()
+ @Override
+ public AAStructureBindingModel getBinding()
{
- return !jmb.isColourBySequence();
+ return this.jmb;
}
- public JalviewJmolBinding getBinding()
+ @Override
+ public String getStateInfo()
{
- return jmb;
+ return jmb == null ? null : jmb.viewer.getStateInfo();
}
}
*/
package jalview.gui;
-import java.awt.Container;
-import java.util.BitSet;
-
import jalview.api.AlignmentViewPanel;
import jalview.bin.Cache;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
+import jalview.ext.jmol.JalviewJmolBinding;
import jalview.structure.StructureSelectionManager;
+import java.awt.Container;
+import java.util.BitSet;
+
import org.jmol.api.JmolAppConsoleInterface;
import org.jmol.api.JmolViewer;
import org.jmol.popup.JmolPopup;
import org.openscience.jmol.app.jmolpanel.AppConsole;
-public class AppJmolBinding extends jalview.ext.jmol.JalviewJmolBinding
+public class AppJmolBinding extends JalviewJmolBinding
{
-
- /**
- *
- */
private AppJmol appJmolWindow;
+ private FeatureRenderer fr = null;
+
public AppJmolBinding(AppJmol appJmol, StructureSelectionManager sSm,
PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
String protocol)
appJmolWindow = appJmol;
}
- FeatureRenderer fr = null;
-
@Override
- public jalview.api.FeatureRenderer getFeatureRenderer(
+ public FeatureRenderer getFeatureRenderer(
AlignmentViewPanel alignment)
{
AlignmentPanel ap = (alignment == null) ? appJmolWindow.ap
}
@Override
- public jalview.api.SequenceRenderer getSequenceRenderer(
+ public SequenceRenderer getSequenceRenderer(
AlignmentViewPanel alignment)
{
return new SequenceRenderer(((AlignmentPanel) alignment).av);
AlignmentPanel ap = (AlignmentPanel) source, topap;
// ignore events from panels not used to colour this view
if (!appJmolWindow.isUsedforcolourby(ap))
+ {
return;
+ }
if (!isLoadingFromArchive())
{
colourBySequence(ap.av.getShowSequenceFeatures(), ap);
public void newJmolPopup(boolean translateLocale, String menuName,
boolean asPopup)
{
-
jmolpopup = new JmolPopup();
jmolpopup.initialize(viewer, translateLocale, menuName, asPopup);
}
*/
public void addSequenceForStructFile(String pdbFile, SequenceI[] seq)
{
- for (int pe = 0; pe < pdbentry.length; pe++)
+ for (int pe = 0; pe < getPdbCount(); pe++)
{
- if (pdbentry[pe].getFile().equals(pdbFile))
+ if (getPdbEntry(pe).getFile().equals(pdbFile))
{
addSequence(pe, seq);
}
protected void releaseUIResources()
{
appJmolWindow = null;
- if (console != null)
- {
- try
- {
- console.setVisible(false);
- } catch (Error e)
- {
- } catch (Exception x)
- {
- }
- ;
- console = null;
- }
-
+ closeConsole();
}
@Override
if (svl instanceof SeqPanel)
{
appJmolWindow.removeAlignmentPanel(((SeqPanel) svl).ap);
-
}
- ;
}
}
*/
package jalview.gui;
-import jalview.api.SequenceStructureBinding;
-import jalview.api.structures.JalviewStructureDisplayI;
import jalview.bin.Cache;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentI;
import jalview.datamodel.ColumnSelection;
import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
+import jalview.ext.rbvi.chimera.JalviewChimeraBinding;
import jalview.gui.ViewSelectionMenu.ViewSetProvider;
import jalview.io.AppletFormatAdapter;
import jalview.io.JalviewFileChooser;
import jalview.schemes.TaylorColourScheme;
import jalview.schemes.TurnColourScheme;
import jalview.schemes.ZappoColourScheme;
+import jalview.structures.models.AAStructureBindingModel;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.ws.dbsources.Pdb;
*
*/
public class ChimeraViewFrame extends GStructureViewer implements Runnable,
- ViewSetProvider, JalviewStructureDisplayI
-
+ ViewSetProvider
{
- 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 JalviewChimeraBinding jmb;
private boolean allChainsSelected = false;
private IProgressIndicator progressBar = null;
- private String viewId = null;
-
/*
* pdb retrieval thread.
*/
final ChimeraViewFrame topView = ((ChimeraViewFrame) frame);
// JBPNOTE: this looks like a binding routine, rather than a gui
// routine
- for (int pe = 0; pe < topView.jmb.pdbentry.length; pe++)
+ for (int pe = 0; pe < topView.jmb.getPdbCount(); pe++)
{
- if (topView.jmb.pdbentry[pe].getFile().equals(alreadyMapped))
+ if (topView.jmb.getPdbEntry(pe).getFile()
+ .equals(
+ alreadyMapped))
{
topView.jmb.addSequence(pe, seq);
topView.addAlignmentPanel(ap);
jmb.setFinishedInit(false);
// TODO: consider waiting until the structure/view is fully loaded before
// displaying
- jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle(true),
+ jalview.gui.Desktop.addInternalFrame(this, jmb.getViewerTitle("Chimera", true),
getBounds().width, getBounds().height);
if (command == null)
{
{
String prompt = MessageManager
.formatMessage("label.confirm_close_chimera", new Object[]
- { jmb.getViewerTitle(false) });
+ { jmb.getViewerTitle("Chimera", false) });
prompt = JvSwingUtils.wrapTooltip(true, prompt);
int confirm = JOptionPane.showConfirmDialog(this, prompt,
MessageManager.getString("label.close_viewer"),
String[] curfiles = jmb.getPdbFile(); // files currently in viewer
// TODO: replace with reference fetching/transfer code (validate PDBentry
// as a DBRef?)
- for (int pi = 0; pi < jmb.pdbentry.length; pi++)
+ for (int pi = 0; pi < jmb.getPdbCount(); pi++)
{
String file = null;
- thePdbEntry = jmb.pdbentry[pi];
+ thePdbEntry = jmb.getPdbEntry(pi);
if (thePdbEntry.getFile() == null)
{
/*
{
int pos = filePDBpos.get(num).intValue();
jmb.openFile(pe);
- jmb.addSequence(pos, jmb.sequence[pos]);
+ jmb.addSequence(pos, jmb.getSequence()[pos]);
File fl = new File(pe.getFile());
String protocol = AppletFormatAdapter.URL;
try
}
// 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(),
+ jmb.getSsm().setMapping(jmb.getSequence()[pos], null,
+ pe.getFile(),
protocol);
} catch (OutOfMemoryError oomerror)
{
jalview.gui.CutAndPasteTransfer cap = new jalview.gui.CutAndPasteTransfer();
try
{
- for (int pdbe = 0; pdbe < jmb.pdbentry.length; pdbe++)
+ for (int pdbe = 0; pdbe < jmb.getPdbCount(); pdbe++)
{
- cap.appendText(jmb.printMapping(jmb.pdbentry[pdbe].getFile()));
+ cap.appendText(jmb.printMapping(jmb.getPdbEntry(pdbe).getFile()));
cap.appendText("\n");
}
} catch (OutOfMemoryError e)
}
}
- public String getViewId()
- {
- if (viewId == null)
- {
- viewId = System.currentTimeMillis() + "." + this.hashCode();
- }
- return viewId;
- }
-
public void updateTitleAndMenus()
{
if (jmb.fileLoadingError != null && jmb.fileLoadingError.length() > 0)
}
setChainMenuItems(jmb.chainNames);
- this.setTitle(jmb.getViewerTitle(true));
- if (jmb.getPdbFile().length > 1 && jmb.sequence.length > 1)
+ this.setTitle(jmb.getViewerTitle("Chimera", true));
+ if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
{
viewerActionMenu.setVisible(true);
}
return ap;
}
- /**
- *
- * @param ap2
- * @return true if this Chimera instance is linked with the given alignPanel
- */
- public boolean isLinkedWith(AlignmentPanel ap2)
- {
- return _aps.contains(ap2.av.getSequenceSetId());
- }
-
- public boolean isUsedforaligment(AlignmentPanel ap2)
- {
-
- return (_alignwith != null) && _alignwith.contains(ap2);
- }
-
- public boolean isUsedforcolourby(AlignmentPanel ap2)
+ @Override
+ public AAStructureBindingModel getBinding()
{
- return (_colourwith != null) && _colourwith.contains(ap2);
+ return jmb;
}
/**
+ * Ask Chimera to save its session to the designated file path. Returns true
+ * if successful, else false.
*
- * @return TRUE if the view is NOT being coloured by sequence associations.
+ * @param filepath
*/
- public boolean isColouredByChimera()
- {
- return !jmb.isColourBySequence();
- }
-
- public SequenceStructureBinding getBinding()
+ public boolean saveSession(String filepath)
{
- return jmb;
+ return jmb.saveSession(filepath);
}
-
}
import jalview.io.IdentifyFile;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
+import jalview.jbgui.GStructureViewer;
import jalview.structure.StructureSelectionManager;
import jalview.util.ImageMaker;
import jalview.util.MessageManager;
*/
private BlogReader jvnews = null;
+ private File projectFile;
+
/**
* @param listener
* @see jalview.gui.JalviewChangeSupport#addJalviewPropertyChangeListener(java.beans.PropertyChangeListener)
{
final Desktop me = this;
final java.io.File choice = chooser.getSelectedFile();
+ setProjectFile(choice);
+
new Thread(new Runnable()
{
public void run()
}
}
+ private void setProjectFile(File choice)
+ {
+ this.projectFile = choice;
+ }
+
+ public File getProjectFile()
+ {
+ return this.projectFile;
+ }
+
/**
* DOCUMENT ME!
*
if (value == JalviewFileChooser.APPROVE_OPTION)
{
- final String choice = chooser.getSelectedFile().getAbsolutePath();
- jalview.bin.Cache.setProperty("LAST_DIRECTORY", chooser
- .getSelectedFile().getParent());
+ final File selectedFile = chooser.getSelectedFile();
+ setProjectFile(selectedFile);
+ final String choice = selectedFile.getAbsolutePath();
+ jalview.bin.Cache.setProperty("LAST_DIRECTORY", selectedFile.getParent());
new Thread(new Runnable()
{
public void run()
return afs;
}
- public AppJmol[] getJmols()
+ public GStructureViewer[] getJmols()
{
JInternalFrame[] frames = Desktop.desktop.getAllFrames();
{
if (frames[i] instanceof AppJmol)
{
- AppJmol af = (AppJmol) frames[i];
+ GStructureViewer af = (GStructureViewer) frames[i];
avp.addElement(af);
}
}
{
return null;
}
- AppJmol afs[] = new AppJmol[avp.size()];
+ GStructureViewer afs[] = new GStructureViewer[avp.size()];
for (int i = 0, j = avp.size(); i < j; i++)
{
- afs[i] = (AppJmol) avp.elementAt(i);
+ afs[i] = (GStructureViewer) avp.elementAt(i);
}
avp.clear();
return afs;
import jalview.datamodel.Alignment;
import jalview.datamodel.AlignmentAnnotation;
import jalview.datamodel.AlignmentI;
+import jalview.datamodel.PDBEntry;
import jalview.datamodel.SequenceI;
+import jalview.jbgui.GStructureViewer;
import jalview.schemabinding.version2.AlcodMap;
import jalview.schemabinding.version2.Alcodon;
import jalview.schemabinding.version2.AlcodonFrame;
import jalview.schemes.GraduatedColor;
import jalview.schemes.ResidueColourScheme;
import jalview.schemes.ResidueProperties;
+import jalview.schemes.UserColourScheme;
import jalview.structure.StructureSelectionManager;
+import jalview.structures.models.AAStructureBindingModel;
import jalview.util.MessageManager;
import jalview.util.Platform;
import jalview.util.jarInputStreamProvider;
}
/**
- * create a JalviewModel from an algnment view and marshall it to a
+ * create a JalviewModel from an alignment view and marshall it to a
* JarOutputStream
*
* @param ap
boolean storeDS, JarOutputStream jout)
{
initSeqRefs();
- Vector jmolViewIds = new Vector(); //
- Vector userColours = new Vector();
+ List<String> chimeraViewIds = new ArrayList<String>();
+ List<UserColourScheme> userColours = new ArrayList<UserColourScheme>();
AlignViewport av = ap.av;
pdb.setId(entry.getId());
pdb.setType(entry.getType());
//
- // store any JMol views associated with this seqeunce
+ // store any JMol views associated with this sequence
// this section copes with duplicate entries in the project, so a
// dataset only view *should* be coped with sensibly
- AppJmol jmol;
+ List<String> jmolViewIds = new ArrayList<String>();
// This must have been loaded, is it still visible?
JInternalFrame[] frames = Desktop.desktop.getAllFrames();
String matchedFile = null;
for (int f = frames.length - 1; f > -1; f--)
{
- if (frames[f] instanceof AppJmol)
+ if (frames[f] instanceof GStructureViewer)
{
- jmol = (AppJmol) frames[f];
- for (int peid = 0; peid < jmol.jmb.pdbentry.length; peid++)
- {
- if (!jmol.jmb.pdbentry[peid].getId().equals(entry.getId())
- && !(entry.getId().length() > 4 && entry
- .getId()
- .toLowerCase()
- .startsWith(
- jmol.jmb.pdbentry[peid].getId()
- .toLowerCase())))
- {
- continue;
- }
- if (matchedFile == null)
- {
- matchedFile = jmol.jmb.pdbentry[peid].getFile();
- }
- else if (!matchedFile.equals(jmol.jmb.pdbentry[peid]
- .getFile()))
- {
- Cache.log
- .warn("Probably lost some PDB-Sequence mappings for this structure file (which apparently has same PDB Entry code): "
- + jmol.jmb.pdbentry[peid].getFile());
- ; // record the
- }
- // file so we
- // can get at it if the ID
- // match is ambiguous (e.g.
- // 1QIP==1qipA)
- String statestring = jmol.jmb.viewer.getStateInfo();
-
- for (int smap = 0; smap < jmol.jmb.sequence[peid].length; smap++)
- {
- // if (jal.findIndex(jmol.jmb.sequence[peid][smap]) > -1)
- if (jds == jmol.jmb.sequence[peid][smap])
- {
- StructureState state = new StructureState();
- state.setVisible(true);
- state.setXpos(jmol.getX());
- state.setYpos(jmol.getY());
- state.setWidth(jmol.getWidth());
- state.setHeight(jmol.getHeight());
- state.setViewId(jmol.getViewId());
- state.setAlignwithAlignPanel(jmol.isUsedforaligment(ap));
- state.setColourwithAlignPanel(jmol
- .isUsedforcolourby(ap));
- state.setColourByJmol(jmol.isColouredByJmol());
- if (!jmolViewIds.contains(state.getViewId()))
- {
- // Make sure we only store a Jmol state once in each XML
- // document.
- jmolViewIds.addElement(state.getViewId());
- state.setContent(statestring.replaceAll("\n", ""));
- }
- else
- {
- state.setContent("# duplicate state");
- }
- pdb.addStructureState(state);
- }
-
- }
- }
+ GStructureViewer viewFrame = (GStructureViewer) frames[f];
+ matchedFile = saveStructureState(ap, jds, pdb, entry,
+ jmolViewIds, matchedFile, viewFrame);
}
}
return object;
}
+ /**
+ * @param ap
+ * @param jds
+ * @param pdb
+ * @param entry
+ * @param jmolViewIds
+ * @param matchedFile
+ * @param viewFrame
+ * @return
+ */
+ protected String saveStructureState(AlignmentPanel ap,
+ jalview.datamodel.SequenceI jds, Pdbids pdb,
+ jalview.datamodel.PDBEntry entry, List<String> jmolViewIds,
+ String matchedFile, GStructureViewer viewFrame)
+ {
+ final AAStructureBindingModel bindingModel = viewFrame
+ .getBinding();
+ for (int peid = 0; peid < bindingModel
+ .getPdbCount(); peid++)
+ {
+ final PDBEntry pdbentry = bindingModel.getPdbEntry(peid);
+ final String pdbId = pdbentry.getId();
+ if (!pdbId.equals(entry.getId())
+ && !(entry.getId().length() > 4 && entry.getId()
+ .toLowerCase()
+ .startsWith(pdbId.toLowerCase())))
+ {
+ continue;
+ }
+ if (matchedFile == null)
+ {
+ matchedFile = pdbentry.getFile();
+ }
+ else if (!matchedFile.equals(pdbentry
+ .getFile()))
+ {
+ Cache.log
+ .warn("Probably lost some PDB-Sequence mappings for this structure file (which apparently has same PDB Entry code): "
+ + pdbentry.getFile());
+ }
+ // record the
+ // file so we
+ // can get at it if the ID
+ // match is ambiguous (e.g.
+ // 1QIP==1qipA)
+ String statestring = viewFrame.getStateInfo();
+
+ for (int smap = 0; smap < viewFrame.getBinding()
+ .getSequence()[peid].length; smap++)
+ {
+ // if (jal.findIndex(jmol.jmb.sequence[peid][smap]) > -1)
+ if (jds == viewFrame.getBinding().getSequence()[peid][smap])
+ {
+ StructureState state = new StructureState();
+ state.setVisible(true);
+ state.setXpos(viewFrame.getX());
+ state.setYpos(viewFrame.getY());
+ state.setWidth(viewFrame.getWidth());
+ state.setHeight(viewFrame.getHeight());
+ state.setViewId(viewFrame.getViewId());
+ state.setAlignwithAlignPanel(viewFrame.isUsedforaligment(ap));
+ state.setColourwithAlignPanel(viewFrame
+ .isUsedforcolourby(ap));
+ state.setColourByJmol(viewFrame.isColouredByViewer());
+ if (!jmolViewIds.contains(state.getViewId()))
+ {
+ // Make sure we only store a Jmol state once in each XML
+ // document.
+ jmolViewIds.add(state.getViewId());
+ state.setContent(statestring.replaceAll("\n", ""));
+ }
+ else
+ {
+ state.setContent("# duplicate state");
+ }
+ pdb.addStructureState(state);
+ }
+
+ }
+ }
+ return matchedFile;
+ }
+
private AnnotationColours constructAnnotationColours(
- AnnotationColourGradient acg, Vector userColours,
+ AnnotationColourGradient acg, List<UserColourScheme> userColours,
JalviewModelSequence jms)
{
AnnotationColours ac = new AnnotationColours();
}
String SetUserColourScheme(jalview.schemes.ColourSchemeI cs,
- Vector userColours, JalviewModelSequence jms)
+ List<UserColourScheme> userColours, JalviewModelSequence jms)
{
String id = null;
jalview.schemes.UserColourScheme ucs = (jalview.schemes.UserColourScheme) cs;
if (frames[f] instanceof AppJmol)
{
if (sviewid != null
- && ((AppJmol) frames[f]).getViewId().equals(sviewid))
+ && ((GStructureViewer) frames[f]).getViewId().equals(sviewid))
{
// post jalview 2.4 schema includes structure view id
comp = (AppJmol) frames[f];
String pdbFile = (String) filedat[0];
SequenceI[] seq = ((Vector<SequenceI>) filedat[2])
.toArray(new SequenceI[0]);
- comp.jmb.ssm.setMapping(seq, null, pdbFile,
+ comp.jmb.getSsm().setMapping(seq, null, pdbFile,
jalview.io.AppletFormatAdapter.FILE);
comp.jmb.addSequenceForStructFile(pdbFile, seq);
}
{
private ChimeraViewFrame cvf;
+ private FeatureRenderer fr = null;
+
public JalviewChimeraBindingModel(ChimeraViewFrame chimeraViewFrame,
StructureSelectionManager ssm, PDBEntry[] pdbentry,
SequenceI[][] sequenceIs, String[][] chains, String protocol)
cvf = chimeraViewFrame;
}
- FeatureRenderer fr = null;
-
@Override
- public jalview.api.FeatureRenderer getFeatureRenderer(
+ public FeatureRenderer getFeatureRenderer(
AlignmentViewPanel alignment)
{
AlignmentPanel ap = (alignment == null) ? cvf.ap
{
return new SequenceRenderer(((AlignmentPanel) alignment).av);
}
+
@Override
public void refreshGUI()
{
- // appJmolWindow.repaint();
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
public void run()
public void updateColours(Object source)
{
- AlignmentPanel ap = (AlignmentPanel) source, topap;
+ AlignmentPanel ap = (AlignmentPanel) source;
// ignore events from panels not used to colour this view
if (!cvf.isUsedforcolourby(ap))
{
colourBySequence(ap.av.getShowSequenceFeatures(), ap);
}
}
+
@Override
public void releaseReferences(Object svl)
{
- // TODO Auto-generated method stub
-
}
@Override
protected void releaseUIResources()
{
- // TODO Auto-generated method stub
-
}
@Override
public void refreshPdbEntries()
{
- // TODO Auto-generated method stub
-
}
}
import org.jmol.api.*;
+import jalview.jbgui.GStructureViewer;
+
import java.awt.*;
import java.awt.event.*;
+
import javax.swing.*;
import javax.swing.text.*;
+
import java.util.Vector;
import org.jmol.i18n.GT;
JmolViewer viewer;
- AppJmol appJmol;
+ GStructureViewer appJmol;
public ScriptWindow(AppJmol appJmol)
{
*/
package jalview.jbgui;
+import jalview.api.structures.JalviewStructureDisplayI;
+import jalview.gui.AlignmentPanel;
import jalview.util.MessageManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.util.ArrayList;
+import java.util.Vector;
import javax.swing.ButtonGroup;
import javax.swing.JInternalFrame;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
-public class GStructureViewer extends JInternalFrame
+public abstract class GStructureViewer extends JInternalFrame implements
+ JalviewStructureDisplayI
{
+ // private AAStructureBindingModel bindingModel;
+
+ protected JMenu savemenu = new JMenu();
+
+ protected JMenu viewMenu = new JMenu();
+
+ protected JMenu chainMenu = new JMenu();
+
+ protected JMenu viewerActionMenu = new JMenu();
+
+ protected JMenuItem alignStructs = new JMenuItem();
+
+ protected JRadioButtonMenuItem seqColour = new JRadioButtonMenuItem();
+
+ protected JRadioButtonMenuItem chainColour = new JRadioButtonMenuItem();
+
+ protected JRadioButtonMenuItem chargeColour = new JRadioButtonMenuItem();
+
+ protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
+
+ protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
+
+ protected JRadioButtonMenuItem hydroColour = new JRadioButtonMenuItem();
+
+ protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
+
+ protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
+
+ protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
+
+ protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
+
+ protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem();
+
+ protected JRadioButtonMenuItem userColour = new JRadioButtonMenuItem();
+
+ protected JRadioButtonMenuItem viewerColour = new JRadioButtonMenuItem();
+
+ protected JMenuItem helpItem = new JMenuItem();
+
+ /**
+ * list of sequenceSet ids associated with the view
+ */
+ protected ArrayList<String> _aps = new ArrayList<String>();
+
+ /**
+ * list of alignment panels to use for superposition
+ */
+ protected Vector<AlignmentPanel> _alignwith = new Vector<AlignmentPanel>();
+
+ /**
+ * list of alignment panels that are used for colouring structures by aligned
+ * sequences
+ */
+ protected Vector<AlignmentPanel> _colourwith = new Vector<AlignmentPanel>();
+
+ private String viewId = null;
+
+ /**
+ * Constructor
+ */
public GStructureViewer()
{
try
private void jbInit() throws Exception
{
+ JMenuBar menuBar = new JMenuBar();
this.setJMenuBar(menuBar);
+
+ JMenu fileMenu = new JMenu();
fileMenu.setText(MessageManager.getString("action.file"));
+
savemenu.setActionCommand(MessageManager.getString("action.save_image"));
savemenu.setText(MessageManager.getString("action.save_as"));
+
+ JMenuItem pdbFile = new JMenuItem();
pdbFile.setText(MessageManager.getString("label.pdb_file"));
pdbFile.addActionListener(new ActionListener()
{
pdbFile_actionPerformed(actionEvent);
}
});
+
+ JMenuItem png = new JMenuItem();
png.setText("PNG");
png.addActionListener(new ActionListener()
{
png_actionPerformed(actionEvent);
}
});
+
+ JMenuItem eps = new JMenuItem();
eps.setText("EPS");
eps.addActionListener(new ActionListener()
{
eps_actionPerformed(actionEvent);
}
});
+
+ JMenuItem viewMapping = new JMenuItem();
viewMapping.setText(MessageManager.getString("label.view_mapping"));
viewMapping.addActionListener(new ActionListener()
{
});
viewMenu.setText(MessageManager.getString("action.view"));
chainMenu.setText(MessageManager.getString("action.show_chain"));
+
+ JMenu colourMenu = new JMenu();
colourMenu.setText(MessageManager.getString("label.colours"));
+
+ JMenuItem backGround = new JMenuItem();
backGround.setText(MessageManager.getString("label.background_colour")
+ "...");
backGround.addActionListener(new ActionListener()
viewerColour_actionPerformed(actionEvent);
}
});
+
+ JMenu helpMenu = new JMenu();
helpMenu.setText(MessageManager.getString("action.help"));
helpItem.setText(MessageManager.getString("label.jmol_help"));
helpItem.addActionListener(new ActionListener()
colourMenu.add(viewerColour);
colourMenu.add(backGround);
+ ButtonGroup colourButtons = new ButtonGroup();
+
colourButtons.add(seqColour);
colourButtons.add(chainColour);
colourButtons.add(chargeColour);
{
}
- JMenuBar menuBar = new JMenuBar();
-
- JMenu fileMenu = new JMenu();
-
- protected JMenu savemenu = new JMenu();
-
- JMenuItem pdbFile = new JMenuItem();
-
- JMenuItem png = new JMenuItem();
-
- JMenuItem eps = new JMenuItem();
-
- JMenuItem viewMapping = new JMenuItem();
-
- protected JMenu viewMenu = new JMenu();
-
- protected JMenu chainMenu = new JMenu();
-
- JMenu jMenu1 = new JMenu();
-
- protected JMenu colourMenu = new JMenu();
-
- protected JMenu viewerActionMenu = new JMenu();
-
- protected JMenuItem alignStructs = new JMenuItem();
-
- JMenuItem backGround = new JMenuItem();
-
- protected JRadioButtonMenuItem seqColour = new JRadioButtonMenuItem();
-
- protected JRadioButtonMenuItem chainColour = new JRadioButtonMenuItem();
-
- protected JRadioButtonMenuItem chargeColour = new JRadioButtonMenuItem();
-
- protected JRadioButtonMenuItem zappoColour = new JRadioButtonMenuItem();
-
- protected JRadioButtonMenuItem taylorColour = new JRadioButtonMenuItem();
-
- protected JRadioButtonMenuItem hydroColour = new JRadioButtonMenuItem();
-
- protected JRadioButtonMenuItem strandColour = new JRadioButtonMenuItem();
-
- protected JRadioButtonMenuItem helixColour = new JRadioButtonMenuItem();
-
- protected JRadioButtonMenuItem turnColour = new JRadioButtonMenuItem();
-
- protected JRadioButtonMenuItem buriedColour = new JRadioButtonMenuItem();
-
- protected JRadioButtonMenuItem purinePyrimidineColour = new JRadioButtonMenuItem();
-
- protected JRadioButtonMenuItem userColour = new JRadioButtonMenuItem();
-
- protected JRadioButtonMenuItem viewerColour = new JRadioButtonMenuItem();
-
- protected ButtonGroup colourButtons = new ButtonGroup();
-
- JMenu helpMenu = new JMenu();
-
- protected JMenuItem helpItem = new JMenuItem();
-
public void pdbFile_actionPerformed(ActionEvent actionEvent)
{
{
}
+
+ // {
+ // return bindingModel;
+ // }
+
+ // public void setBindingModel(AAStructureBindingModel bindingModel)
+ // {
+ // this.bindingModel = bindingModel;
+ // }
+
+ /**
+ *
+ * @param ap2
+ * @return true if this Jmol instance is linked with the given alignPanel
+ */
+ public boolean isLinkedWith(AlignmentPanel ap2)
+ {
+ return _aps.contains(ap2.av.getSequenceSetId());
+ }
+
+ public boolean isUsedforaligment(AlignmentPanel ap2)
+ {
+
+ return (_alignwith != null) && _alignwith.contains(ap2);
+ }
+
+ public boolean isUsedforcolourby(AlignmentPanel ap2)
+ {
+ return (_colourwith != null) && _colourwith.contains(ap2);
+ }
+
+ /**
+ *
+ * @return TRUE if the view is NOT being coloured by the alignment colours.
+ */
+ public boolean isColouredByViewer()
+ {
+ return !getBinding().isColourBySequence();
+ }
+
+ public String getViewId()
+ {
+ if (viewId == null)
+ {
+ viewId = System.currentTimeMillis() + "." + this.hashCode();
+ }
+ return viewId;
+ }
+
+ protected void setViewId(String viewId)
+ {
+ this.viewId = viewId;
+ }
+
+ public String getStateInfo()
+ {
+ return null;
+ }
}
--- /dev/null
+package jalview.structures.models;
+
+import jalview.api.StructureSelectionManagerProvider;
+import jalview.datamodel.PDBEntry;
+import jalview.datamodel.SequenceI;
+import jalview.structure.StructureListener;
+import jalview.structure.StructureSelectionManager;
+import jalview.util.MessageManager;
+
+import java.awt.event.ComponentEvent;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * A base class to hold common function for protein structure model binding.
+ * Initial version created by refactoring JMol and Chimera binding models, but
+ * other structure viewers could in principle be accommodated in future.
+ *
+ * @author gmcarstairs
+ *
+ */
+public abstract class AAStructureBindingModel extends
+ SequenceStructureBindingModel implements StructureListener,
+ StructureSelectionManagerProvider
+{
+
+ private StructureSelectionManager ssm;
+
+ private PDBEntry[] pdbEntry;
+
+ /*
+ * sequences mapped to each pdbentry
+ */
+ private SequenceI[][] sequence;
+
+ /*
+ * array of target chains for sequences - tied to pdbentry and sequence[]
+ */
+ private String[][] chains;
+
+ /*
+ * datasource protocol for access to PDBEntrylatest
+ */
+ String protocol = null;
+
+ protected boolean colourBySequence = true;
+
+ /**
+ * Constructor
+ *
+ * @param ssm
+ * @param seqs
+ */
+ public AAStructureBindingModel(StructureSelectionManager ssm,
+ SequenceI[][] seqs)
+ {
+ this.ssm = ssm;
+ this.sequence = seqs;
+ }
+
+ /**
+ * Constructor
+ *
+ * @param ssm
+ * @param pdbentry
+ * @param sequenceIs
+ * @param chains
+ * @param protocol
+ */
+ public AAStructureBindingModel(StructureSelectionManager ssm,
+ PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
+ String 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][];
+ }
+ }
+
+ public StructureSelectionManager getSsm()
+ {
+ return ssm;
+ }
+
+ /**
+ * Returns the i'th PDBEntry (or null)
+ *
+ * @param i
+ * @return
+ */
+ public PDBEntry getPdbEntry(int i)
+ {
+ return (pdbEntry != null && pdbEntry.length > i) ? pdbEntry[i] : null;
+ }
+
+ /**
+ * Returns the number of modelled PDB file entries.
+ *
+ * @return
+ */
+ public int getPdbCount()
+ {
+ return pdbEntry == null ? 0 : pdbEntry.length;
+ }
+
+ public SequenceI[][] getSequence()
+ {
+ return sequence;
+ }
+
+ public String[][] getChains()
+ {
+ return chains;
+ }
+
+ public String getProtocol()
+ {
+ return protocol;
+ }
+
+ // TODO may remove this if calling methods can be pulled up here
+ protected void setPdbentry(PDBEntry[] pdbentry)
+ {
+ this.pdbEntry = pdbentry;
+ }
+
+ protected void setSequence(SequenceI[][] sequence)
+ {
+ this.sequence = sequence;
+ }
+
+ protected void setChains(String[][] chains)
+ {
+ this.chains = chains;
+ }
+
+ /**
+ * Construct a title string for the viewer window based on the data Jalview
+ * knows about
+ * @param viewerName TODO
+ * @param verbose
+ *
+ * @return
+ */
+ public String getViewerTitle(String viewerName, boolean verbose)
+ {
+ if (getSequence() == null || getSequence().length < 1
+ || getPdbCount() < 1
+ || getSequence()[0].length < 1)
+ {
+ return ("Jalview " + viewerName + " Window");
+ }
+ // TODO: give a more informative title when multiple structures are
+ // displayed.
+ StringBuilder title = new StringBuilder(64);
+ final PDBEntry pdbEntry = getPdbEntry(0);
+ title.append(viewerName + " view for " + getSequence()[0][0].getName()
+ + ":"
+ + pdbEntry.getId());
+
+ if (verbose)
+ {
+ if (pdbEntry.getProperty() != null)
+ {
+ if (pdbEntry.getProperty().get("method") != null)
+ {
+ title.append(" Method: ");
+ title.append(pdbEntry.getProperty().get("method"));
+ }
+ if (pdbEntry.getProperty().get("chains") != null)
+ {
+ title.append(" Chain:");
+ title.append(pdbEntry.getProperty().get("chains"));
+ }
+ }
+ }
+ return title.toString();
+ }
+
+ /**
+ * Called by after closeViewer is called, to release any resources and
+ * references so they can be garbage collected. Override if needed.
+ */
+ protected void releaseUIResources()
+ {
+
+ }
+
+ public boolean isColourBySequence()
+ {
+ return colourBySequence;
+ }
+
+ public void setColourBySequence(boolean colourBySequence)
+ {
+ this.colourBySequence = colourBySequence;
+ }
+
+ protected void addSequenceAndChain(int pe, SequenceI[] seq,
+ String[] tchain)
+ {
+ if (pe < 0 || pe >= getPdbCount())
+ {
+ throw new Error(MessageManager.formatMessage(
+ "error.implementation_error_no_pdbentry_from_index",
+ new Object[]
+ { Integer.valueOf(pe).toString() }));
+ }
+ final String nullChain = "TheNullChain";
+ List<SequenceI> s = new ArrayList<SequenceI>();
+ List<String> c = new ArrayList<String>();
+ if (getChains() == null)
+ {
+ setChains(new String[getPdbCount()][]);
+ }
+ if (getSequence()[pe] != null)
+ {
+ for (int i = 0; i < getSequence()[pe].length; i++)
+ {
+ s.add(getSequence()[pe][i]);
+ if (getChains()[pe] != null)
+ {
+ if (i < getChains()[pe].length)
+ {
+ c.add(getChains()[pe][i]);
+ }
+ else
+ {
+ c.add(nullChain);
+ }
+ }
+ else
+ {
+ if (tchain != null && tchain.length > 0)
+ {
+ c.add(nullChain);
+ }
+ }
+ }
+ }
+ for (int i = 0; i < seq.length; i++)
+ {
+ if (!s.contains(seq[i]))
+ {
+ s.add(seq[i]);
+ if (tchain != null && i < tchain.length)
+ {
+ c.add(tchain[i] == null ? nullChain : tchain[i]);
+ }
+ }
+ }
+ SequenceI[] tmp = s.toArray(new SequenceI[s.size()]);
+ getSequence()[pe] = tmp;
+ if (c.size() > 0)
+ {
+ String[] tch = c.toArray(new String[c.size()]);
+ for (int i = 0; i < tch.length; i++)
+ {
+ if (tch[i] == nullChain)
+ {
+ tch[i] = null;
+ }
+ }
+ getChains()[pe] = tch;
+ }
+ else
+ {
+ getChains()[pe] = null;
+ }
+ }
+
+ /**
+ * add structures and any known sequence associations
+ *
+ * @returns the pdb entries added to the current set.
+ */
+ public synchronized PDBEntry[] addSequenceAndChain(PDBEntry[] pdbe, SequenceI[][] seq,
+ String[][] chns)
+ {
+ List<PDBEntry> v = new ArrayList<PDBEntry>();
+ List<int[]> rtn = new ArrayList<int[]>();
+ for (int i = 0; i < getPdbCount(); i++)
+ {
+ v.add(getPdbEntry(i));
+ }
+ for (int i = 0; i < pdbe.length; i++)
+ {
+ int r = v.indexOf(pdbe[i]);
+ if (r == -1 || r >= getPdbCount())
+ {
+ rtn.add(new int[]
+ { v.size(), i });
+ v.add(pdbe[i]);
+ }
+ else
+ {
+ // just make sure the sequence/chain entries are all up to date
+ addSequenceAndChain(r, seq[i], chns[i]);
+ }
+ }
+ pdbe = v.toArray(new PDBEntry[v.size()]);
+ setPdbentry(pdbe);
+ if (rtn.size() > 0)
+ {
+ // expand the tied sequence[] and string[] arrays
+ SequenceI[][] sqs = new SequenceI[getPdbCount()][];
+ String[][] sch = new String[getPdbCount()][];
+ System.arraycopy(getSequence(), 0, sqs, 0, getSequence().length);
+ System.arraycopy(getChains(), 0, sch, 0, this.getChains().length);
+ setSequence(sqs);
+ setChains(sch);
+ pdbe = new PDBEntry[rtn.size()];
+ for (int r = 0; r < pdbe.length; r++)
+ {
+ int[] stri = (rtn.get(r));
+ // record the pdb file as a new addition
+ pdbe[r] = getPdbEntry(stri[0]);
+ // and add the new sequence/chain entries
+ addSequenceAndChain(stri[0], seq[stri[1]], chns[stri[1]]);
+ }
+ }
+ else
+ {
+ pdbe = null;
+ }
+ return pdbe;
+ }
+
+ /**
+ * Add sequences to the pe'th pdbentry's sequence set.
+ *
+ * @param pe
+ * @param seq
+ */
+ public void addSequence(int pe, SequenceI[] seq)
+ {
+ addSequenceAndChain(pe, seq, null);
+ }
+
+}
\ No newline at end of file
/**
*
- * @return true if Jmol is still restoring state or loading is still going on
- * (see setFinsihedLoadingFromArchive)
+ * @return true if viewer is still restoring state or loading is still going
+ * on (see setFinishedLoadingFromArchive)
*/
@Override
public boolean isLoadingFromArchive()