import jalview.datamodel.SequenceI;
import jalview.ext.rbvi.chimera.JalviewChimeraBinding;
import jalview.gui.StructureViewer.ViewerType;
-import jalview.io.AppletFormatAdapter;
+import jalview.io.DataSourceType;
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 java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
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;
import javax.swing.event.MenuEvent;
*/
public class ChimeraViewFrame extends StructureViewerBase
{
- private JalviewChimeraBinding jmb;
+ JalviewChimeraBinding jmb;
private boolean allChainsSelected = false;
*/
private void initMenus()
{
- viewerActionMenu.setText(MessageManager.getString("label.chimera"));
+ String chimera = MessageManager.getString("label.chimera");
+ viewerActionMenu.setText(chimera);
viewerColour.setText(MessageManager
.getString("label.colour_with_chimera"));
viewerColour.setToolTipText(MessageManager
viewerActionMenu.add(alpanels);
viewerActionMenu.addMenuListener(new MenuListener()
{
-
@Override
public void menuSelected(MenuEvent e)
{
handler.itemStateChanged(null);
}
-
@Override
public void menuDeselected(MenuEvent e)
{
- // TODO Auto-generated method stub
}
-
@Override
public void menuCanceled(MenuEvent e)
{
- // TODO Auto-generated method stub
}
});
+
JMenuItem writeFeatures = new JMenuItem(
- MessageManager.getString("label.create_chimera_attributes"));
- writeFeatures.setToolTipText(MessageManager
- .getString("label.create_chimera_attributes_tip"));
+ MessageManager.getString("label.create_viewer_attributes"));
+ writeFeatures.setToolTipText(MessageManager.formatMessage(
+ "label.create_viewer_attributes_tip", chimera));
writeFeatures.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
- sendFeaturesToChimera();
+ sendFeaturesToViewer();
}
});
viewerActionMenu.add(writeFeatures);
+
+ final JMenu fetchAttributes = new JMenu(MessageManager.formatMessage(
+ "label.fetch_viewer_attributes", chimera));
+ fetchAttributes.setToolTipText(MessageManager.formatMessage(
+ "label.fetch_viewer_attributes_tip", chimera));
+ fetchAttributes.addMouseListener(new MouseAdapter()
+ {
+
+ @Override
+ public void mouseEntered(MouseEvent e)
+ {
+ buildAttributesMenu(fetchAttributes);
+ }
+ });
+ viewerActionMenu.add(fetchAttributes);
+ }
+
+ /**
+ * Asks Chimera for residues with the given attribute name, and set as
+ * features on the corresponding sequence positions (if any)
+ *
+ * @param attName
+ */
+ @Override
+ protected void getResidueAttributes(String attName)
+ {
+ jmb.copyStructureAttributesToFeatures(attName, getAlignmentPanel());
}
/**
* <p>
* For example: setattr r jv:chain "Ferredoxin-1, Chloroplastic" #0:94.A
*/
- protected void sendFeaturesToChimera()
+ @Override
+ protected void sendFeaturesToViewer()
{
- jmb.sendFeaturesToChimera(getAlignmentPanel());
+ jmb.sendFeaturesToViewer(getAlignmentPanel());
}
/**
SequenceI[][] seqs)
{
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
* file
*
*/
void initChimera()
{
- jalview.gui.Desktop.addInternalFrame(this,
- jmb.getViewerTitle("Chimera", true), getBounds().width,
- getBounds().height);
+ Desktop.addInternalFrame(this, jmb.getViewerTitle("Chimera", true),
+ getBounds().width, getBounds().height);
if (!jmb.launchChimera())
{
- JOptionPane.showMessageDialog(Desktop.desktop,
+ JvOptionPane.showMessageDialog(Desktop.desktop,
MessageManager.getString("label.chimera_failed"),
MessageManager.getString("label.error_loading_file"),
- JOptionPane.ERROR_MESSAGE);
+ JvOptionPane.ERROR_MESSAGE);
this.dispose();
return;
}
*
* @param chainNames
*/
+ @Override
void setChainMenuItems(List<String> chainNames)
{
chainMenu.removeAll();
/**
* Show only the selected chain(s) in the viewer
*/
+ @Override
void showSelectedChains()
{
List<String> toshow = new ArrayList<String>();
"label.confirm_close_chimera",
new Object[] { jmb.getViewerTitle("Chimera", false) });
prompt = JvSwingUtils.wrapTooltip(true, prompt);
- int confirm = JOptionPane.showConfirmDialog(this, prompt,
+ int confirm = JvOptionPane.showConfirmDialog(this, prompt,
MessageManager.getString("label.close_viewer"),
- JOptionPane.YES_NO_CANCEL_OPTION);
+ JvOptionPane.YES_NO_CANCEL_OPTION);
/*
* abort closure if user hits escape or Cancel
*/
- if (confirm == JOptionPane.CANCEL_OPTION
- || confirm == JOptionPane.CLOSED_OPTION)
+ if (confirm == JvOptionPane.CANCEL_OPTION
+ || confirm == JvOptionPane.CLOSED_OPTION)
{
return;
}
- closeChimera = confirm == JOptionPane.YES_OPTION;
+ closeChimera = confirm == JvOptionPane.YES_OPTION;
}
jmb.closeViewer(closeChimera);
}
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
if (errormsgs.length() > 0)
{
- JOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
+ JvOptionPane.showInternalMessageDialog(Desktop.desktop, MessageManager
.formatMessage("label.pdb_entries_couldnt_be_retrieved",
new Object[] { errormsgs.toString() }),
MessageManager.getString("label.couldnt_load_file"),
- JOptionPane.ERROR_MESSAGE);
+ JvOptionPane.ERROR_MESSAGE);
}
if (files.length() > 0)
}
}
int num = -1;
-
for (PDBEntry pe : filePDB)
{
num++;
jmb.openFile(pe);
jmb.addSequence(pos, jmb.getSequence()[pos]);
File fl = new File(pe.getFile());
- String protocol = AppletFormatAdapter.URL;
+ DataSourceType protocol = DataSourceType.URL;
try
{
if (fl.exists())
{
- protocol = AppletFormatAdapter.FILE;
+ protocol = DataSourceType.FILE;
}
} catch (Throwable e)
{
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 ?
{
return jmb;
}
+
+ @Override
+ protected List<String> getResidueAttributeNames()
+ {
+ return jmb.getResidueAttributes();
+ }
}