this.ap = ap;
jmb = new AppletJmolBinding(this, ap.getStructureSelectionManager(),
new PDBEntry[] { pdbentry }, new SequenceI[][] { seq },
- new String[][] { chains }, protocol);
+ protocol);
jmb.setColourBySequence(true);
if (pdbentry.getId() == null || pdbentry.getId().length() < 1)
{
jmb.loadInline(string);
}
- void setChainMenuItems(Vector<String> chains)
+ void setChainMenuItems(List<String> chains)
{
chainMenu.removeAll();
repaint();
return;
}
- setChainMenuItems(jmb.chainNames);
+ setChainMenuItems(jmb.getChainNames());
jmb.colourBySequence(ap);
setTitle(jmb.getViewerTitle());
public AppletJmolBinding(AppletJmol appletJmol,
StructureSelectionManager sSm, PDBEntry[] pdbentry,
- SequenceI[][] seq, String[][] chains, String protocol)
+ SequenceI[][] seq, String protocol)
{
- super(sSm, pdbentry, seq, chains, protocol);
+ super(sSm, pdbentry, seq, protocol);
appletJmolBinding = appletJmol;
}
appletJmolBinding.updateTitleAndMenus();
}
+ @Override
public void updateColours(Object source)
{
AlignmentPanel ap = (AlignmentPanel) source;
colourBySequence(ap);
}
+ @Override
public void showUrl(String url)
{
try
// do nothing.
}
+ @Override
public void selectionChanged(BS arg0)
{
// TODO Auto-generated method stub
private AlignmentPanel ap;
protected ExtJmol(jalview.appletgui.AlignFrame alframe,
- PDBEntry[] pdbentry, SequenceI[][] seq, String[][] chains,
+ PDBEntry[] pdbentry, SequenceI[][] seq,
String protocol)
{
super(alframe.alignPanel.getStructureSelectionManager(), pdbentry, seq,
- chains, protocol);
+ protocol);
}
public ExtJmol(Viewer viewer, AlignmentPanel alignPanel,
notifyFileLoaded(null, null, null, null, 0);
}
+ @Override
public void updateColours(Object source)
{
}
+ @Override
public void showUrl(String arg0)
{
showUrl(arg0, "jmol");
// ignore
}
+ @Override
public void selectionChanged(BS arg0)
{
System.out.println(arg0);
{
}
- /**
- * Constructor given file path and PDB id.
- *
- * @param filePath
- */
- // public PDBEntry(String filePath, String pdbId)
- // {
- // this.file = filePath;
- // this.id = pdbId;
- // }
public PDBEntry(String pdbId, String chain, PDBEntry.Type type,
String filePath)
Vector<String> atomsPicked = new Vector<String>();
- public Vector<String> chainNames;
+ private List<String> chainNames;
Hashtable<String, String> chainFile;
public Viewer viewer;
public JalviewJmolBinding(StructureSelectionManager ssm,
- PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
+ PDBEntry[] pdbentry, SequenceI[][] sequenceIs,
String protocol)
{
- super(ssm, pdbentry, sequenceIs, chains, protocol);
+ super(ssm, pdbentry, sequenceIs, protocol);
/*
* viewer = JmolViewer.allocateViewer(renderPanel, new SmarterJmolAdapter(),
* "jalviewJmol", ap.av.applet .getDocumentBase(),
fileLoadingError = null;
String[] oldmodels = modelFileNames;
modelFileNames = null;
- chainNames = new Vector<String>();
+ chainNames = new ArrayList<String>();
chainFile = new Hashtable<String, String>();
boolean notifyLoaded = false;
String[] modelfilenames = getPdbFile();
String chid = new String(pdb.getId() + ":"
+ pdb.getChains().elementAt(i).id);
chainFile.put(chid, fileName);
- chainNames.addElement(chid);
+ chainNames.add(chid);
}
notifyLoaded = true;
}
setLoadingFromArchive(false);
}
+ @Override
+ public List<String> getChainNames()
+ {
+ return chainNames;
+ }
+
public void notifyNewPickingModeMeasurement(int iatom, String strMeasure)
{
notifyAtomPicked(iatom, strMeasure, null);
import java.awt.Color;
import java.net.BindException;
import java.util.ArrayList;
+import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
private static final String ALPHACARBON = "CA";
+ private List<String> chainNames = new ArrayList<String>();
+
+ private Hashtable<String, String> chainFile = new Hashtable<String, String>();
/*
* Object through which we talk to Chimera
*/
* @param protocol
*/
public JalviewChimeraBinding(StructureSelectionManager ssm,
- PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
- String protocol)
+ PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String protocol)
{
- super(ssm, pdbentry, sequenceIs, chains, protocol);
+ super(ssm, pdbentry, sequenceIs, protocol);
viewer = new ChimeraManager(
new ext.edu.ucsf.rbvi.strucviz2.StructureManager(true));
}
{
return new String[0];
}
- // if (modelFileNames == null)
- // {
- // Collection<ChimeraModel> chimodels = viewer.getChimeraModels();
- // _modelFileNameMap = new int[chimodels.size()];
- // int j = 0;
- // for (ChimeraModel chimodel : chimodels)
- // {
- // String mdlName = chimodel.getModelName();
- // }
- // modelFileNames = new String[j];
- // // System.arraycopy(mset, 0, modelFileNames, 0, j);
- // }
return chimeraMaps.keySet().toArray(
modelFileNames = new String[chimeraMaps.size()]);
*
* @return
*/
- public List<String> getChainNames()
- {
- List<String> names = new ArrayList<String>();
- String[][] allNames = getChains();
- if (allNames != null)
- {
- for (String[] chainsForPdb : allNames)
- {
- if (chainsForPdb != null)
- {
- for (String chain : chainsForPdb)
- {
- if (chain != null && !names.contains(chain))
- {
- names.add(chain);
- }
- }
- }
- }
- }
- return names;
- }
/**
* Send a 'focus' command to Chimera to recentre the visible display
sm.highlightStructure(this, seq, positions);
}
}
+
+
+ @Override
+ public List<String> getChainNames()
+ {
+ return chainNames;
+ }
+
+ public Hashtable<String, String> getChainFile()
+ {
+ return chainFile;
+ }
+
}
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 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;
// / TODO: check if protocol is needed to be set, and if chains are
// autodiscovered.
jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(),
- pdbentrys, seqs, null, null);
+ pdbentrys, seqs, null);
jmb.setLoadingFromArchive(true);
addAlignmentPanel(ap);
{
progressBar = ap.alignFrame;
jmb = new AppJmolBinding(this, ap.getStructureSelectionManager(),
- pdbentrys, seqs, null, null);
+ pdbentrys, seqs, null);
addAlignmentPanel(ap);
useAlignmentPanelForColourbyseq(ap);
if (pdbentrys.length > 1)
jmb.setFinishedInit(true);
}
- void setChainMenuItems(Vector<String> chains)
- {
- chainMenu.removeAll();
- if (chains == null)
- {
- return;
- }
- JMenuItem menuItem = new JMenuItem(
- MessageManager.getString("label.all"));
- menuItem.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent evt)
- {
- allChainsSelected = true;
- 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 (String chain : chains)
- {
- menuItem = new JCheckBoxMenuItem(chain, true);
- menuItem.addItemListener(new ItemListener()
- {
- @Override
- public void itemStateChanged(ItemEvent evt)
- {
- if (!allChainsSelected)
- {
- centerViewer();
- }
- }
- });
- chainMenu.add(menuItem);
- }
- }
boolean allChainsSelected = false;
- void centerViewer()
+ @Override
+ void showSelectedChains()
{
Vector<String> toshow = new Vector<String>();
for (int i = 0; i < chainMenu.getItemCount(); i++)
repaint();
return;
}
- setChainMenuItems(jmb.chainNames);
+ setChainMenuItems(jmb.getChainNames());
this.setTitle(jmb.getViewerTitle());
if (jmb.getPdbFile().length > 1 && jmb.getSequence().length > 1)
private FeatureRenderer fr = null;
public AppJmolBinding(AppJmol appJmol, StructureSelectionManager sSm,
- PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
- String protocol)
+ PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String protocol)
{
- super(sSm, pdbentry, sequenceIs, chains, protocol);
+ super(sSm, pdbentry, sequenceIs, protocol);
appJmolWindow = appJmol;
}
// appJmolWindow.repaint();
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
+ @Override
public void run()
{
appJmolWindow.updateTitleAndMenus();
});
}
+ @Override
public void updateColours(Object source)
{
AlignmentPanel ap = (AlignmentPanel) source;
// msWalltime);
}
+ @Override
public void showUrl(String url)
{
showUrl(url, "jmol");
import jalview.io.AppletFormatAdapter;
import jalview.io.JalviewFileChooser;
import jalview.io.JalviewFileView;
+import jalview.io.StructureFile;
import jalview.schemes.BuriedColourScheme;
import jalview.schemes.ColourSchemeI;
import jalview.schemes.HelixColourScheme;
import jalview.ws.dbsources.Pdb;
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 javax.swing.JColorChooser;
import javax.swing.JInternalFrame;
import javax.swing.JMenu;
-import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.event.InternalFrameAdapter;
import javax.swing.event.InternalFrameEvent;
{
createProgressBar();
// FIXME extractChains needs pdbentries to match IDs to PDBEntry(s) on seqs
- String[][] chains = extractChains(seqs);
jmb = new JalviewChimeraBindingModel(this,
- ap.getStructureSelectionManager(), pdbentrys, seqs, chains,
- null);
+ ap.getStructureSelectionManager(), pdbentrys, seqs, null);
addAlignmentPanel(ap);
useAlignmentPanelForColourbyseq(ap);
if (pdbentrys.length > 1)
}
- /**
- * Retrieve chains for sequences by inspecting their PDB refs. The hope is
- * that the first will be to the sequence's own chain. Really need a more
- * managed way of doing this.
- *
- * @param seqs
- * @return
- */
- protected String[][] extractChains(SequenceI[][] seqs)
- {
- String[][] chains = new String[seqs.length][];
- for (int i = 0; i < seqs.length; i++)
- {
- chains[i] = new String[seqs[i].length];
- int seqno = 0;
- for (SequenceI seq : seqs[i])
- {
- String chain = null;
- if (seq.getDatasetSequence() != null)
- {
- Vector<PDBEntry> pdbrefs = seq.getDatasetSequence()
- .getAllPDBEntries();
- if (pdbrefs != null && pdbrefs.size() > 0)
- {
- // FIXME: SequenceI.PDBEntry[0] chain mapping used for
- // ChimeraViewFrame. Is this even used ???
- chain = pdbrefs.get(0).getChainCode();
- }
- }
- chains[i][seqno++] = chain;
- }
- }
- return chains;
- }
/**
* Create a new viewer from saved session state data including Chimera session
jmb.startChimeraListener();
}
- /**
- * If the list is not empty, add menu items for 'All' and each individual
- * chain to the "View | Show Chain" sub-menu. Multiple selections are allowed.
- *
- * @param chainNames
- */
- void setChainMenuItems(List<String> chainNames)
- {
- chainMenu.removeAll();
- if (chainNames == null || chainNames.isEmpty())
- {
- return;
- }
- JMenuItem menuItem = new JMenuItem(
- MessageManager.getString("label.all"));
- menuItem.addActionListener(new ActionListener()
- {
- @Override
- public void actionPerformed(ActionEvent evt)
- {
- allChainsSelected = true;
- for (int i = 0; i < chainMenu.getItemCount(); i++)
- {
- if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
- {
- ((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
- }
- }
- showSelectedChains();
- allChainsSelected = false;
- }
- });
-
- chainMenu.add(menuItem);
-
- for (String chainName : chainNames)
- {
- menuItem = new JCheckBoxMenuItem(chainName, true);
- menuItem.addItemListener(new ItemListener()
- {
- @Override
- public void itemStateChanged(ItemEvent evt)
- {
- if (!allChainsSelected)
- {
- showSelectedChains();
- }
- }
- });
-
- chainMenu.add(menuItem);
- }
- }
/**
* Show only the selected chain(s) in the viewer
*/
+ @Override
void showSelectedChains()
{
List<String> toshow = new ArrayList<String>();
List<PDBEntry> filePDB = new ArrayList<PDBEntry>();
List<Integer> filePDBpos = new ArrayList<Integer>();
PDBEntry thePdbEntry = null;
+ StructureFile pdb = null;
try
{
String[] curfiles = jmb.getPdbFile(); // files currently in viewer
stopProgressBar("", startTime);
}
// Explicitly map to the filename used by Chimera ;
- jmb.getSsm().setMapping(jmb.getSequence()[pos],
+ pdb = jmb.getSsm().setMapping(jmb.getSequence()[pos],
jmb.getChains()[pos], pe.getFile(), protocol);
+ stashFoundChains(pdb, pe.getFile());
} catch (OutOfMemoryError oomerror)
{
new OOMWarning(
}
}
}
+ jmb.refreshGUI();
jmb.setFinishedInit(true);
jmb.setLoadingFromArchive(false);
* @return
* @throws Exception
*/
+
+ private void stashFoundChains(StructureFile pdb, String file)
+ {
+ for (int i = 0; i < pdb.getChains().size(); i++)
+ {
+ String chid = new String(pdb.getId() + ":"
+ + pdb.getChains().elementAt(i).id);
+ jmb.getChainNames().add(chid);
+ jmb.getChainFile().put(chid, file);
+ }
+ }
private String fetchPdbFile(PDBEntry processingEntry) throws Exception
{
// FIXME: this is duplicated code with Jmol frame ?
private FeatureRenderer fr = null;
+
public JalviewChimeraBindingModel(ChimeraViewFrame chimeraViewFrame,
StructureSelectionManager ssm, PDBEntry[] pdbentry,
- SequenceI[][] sequenceIs, String[][] chains, String protocol)
+ SequenceI[][] sequenceIs, String protocol)
{
- super(ssm, pdbentry, sequenceIs, chains, protocol);
+ super(ssm, pdbentry, sequenceIs, protocol);
cvf = chimeraViewFrame;
}
{
javax.swing.SwingUtilities.invokeLater(new Runnable()
{
+ @Override
public void run()
{
cvf.updateTitleAndMenus();
});
}
+ @Override
public void updateColours(Object source)
{
AlignmentPanel ap = (AlignmentPanel) source;
* Send an asynchronous command to Chimera, in a new thread, optionally with
* an 'in progress' message in a progress bar somewhere
*/
+ @Override
protected void sendAsynchronousCommand(final String command,
final String progressMsg)
{
thread.start();
}
+
+
}
import jalview.util.MessageManager;
import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
+import javax.swing.JCheckBoxMenuItem;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
protected Thread worker = null;
+ protected boolean allChainsSelected = false;
+
/**
*
* @param ap2
this.ap = alp;
}
+ @Override
public AlignmentPanel[] getAllAlignmentPanels()
{
AlignmentPanel[] t, list = new AlignmentPanel[0];
// queue.
new Thread(new Runnable()
{
+ @Override
public void run()
{
while (worker != null && worker.isAlive() && _started)
}
return finished;
}
+
+ void setChainMenuItems(List<String> chainNames)
+ {
+ chainMenu.removeAll();
+ if (chainNames == null || chainNames.isEmpty())
+ {
+ return;
+ }
+ JMenuItem menuItem = new JMenuItem(
+ MessageManager.getString("label.all"));
+ menuItem.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent evt)
+ {
+ allChainsSelected = true;
+ for (int i = 0; i < chainMenu.getItemCount(); i++)
+ {
+ if (chainMenu.getItem(i) instanceof JCheckBoxMenuItem)
+ {
+ ((JCheckBoxMenuItem) chainMenu.getItem(i)).setSelected(true);
+ }
+ }
+ showSelectedChains();
+ allChainsSelected = false;
+ }
+ });
+
+ chainMenu.add(menuItem);
+
+ for (String chain : chainNames)
+ {
+ menuItem = new JCheckBoxMenuItem(chain, true);
+ menuItem.addItemListener(new ItemListener()
+ {
+ @Override
+ public void itemStateChanged(ItemEvent evt)
+ {
+ if (!allChainsSelected)
+ {
+ showSelectedChains();
+ }
+ }
+ });
+
+ chainMenu.add(menuItem);
+ }
+ }
+
+ abstract void showSelectedChains();
+
}
* @param protocol
*/
public AAStructureBindingModel(StructureSelectionManager ssm,
- PDBEntry[] pdbentry, SequenceI[][] sequenceIs, String[][] chains,
+ PDBEntry[] pdbentry, SequenceI[][] sequenceIs,
String protocol)
{
this.ssm = ssm;
this.sequence = sequenceIs;
this.nucleotide = Comparison.isNucleotide(sequenceIs);
- this.chains = chains;
this.pdbEntry = pdbentry;
this.protocol = protocol;
- if (chains == null)
- {
- this.chains = new String[pdbentry.length][];
- }
}
public StructureSelectionManager getSsm()
{
this.finishedInit = fi;
}
+
+ /**
+ * Returns a list of chains mapped in this viewer.
+ *
+ * @return
+ */
+ public abstract List<String> getChainNames();
+
}
pdbFiles[0] = new PDBEntry("1YCS", "A", Type.PDB, "INLINE1YCS");
pdbFiles[1] = new PDBEntry("3A6S", "B", Type.PDB, "INLINE3A6S");
pdbFiles[2] = new PDBEntry("1OOT", "A", Type.PDB, "INLINE1OOT");
- String[][] chains = new String[3][];
SequenceI[][] seqs = new SequenceI[3][];
seqs[0] = new SequenceI[] { seq1a, seq1b };
seqs[1] = new SequenceI[] { seq2 };
ssm.setMapping(new SequenceI[] { seq3 }, null, PDB_3,
AppletFormatAdapter.PASTE);
- testee = new AAStructureBindingModel(ssm, pdbFiles, seqs, chains, null)
+ testee = new AAStructureBindingModel(ssm, pdbFiles, seqs, null)
{
@Override
public String[] getPdbFile()
public void highlightAtoms(List<AtomSpec> atoms)
{
}
+
+ @Override
+ public List<String> getChainNames()
+ {
+ return null;
+ }
};
}