<li><strong>Show Chains<br>
</strong><em>Select which of the PDB file's chains are to be
displayed.</em></li>
- <li><strong>Colour by ..<br></strong><em>Submenu
+ <li><strong>Ligands<br>
+ </strong><em>When available, allows the display of all, none or specific
+ ligands (also known as HETATM groups) in the Jmol view, using CPK
+ spacefilling.</em></li>
+ <li><strong>Colour by ..<br></strong><em>Submenu
allowing specific alignment views to be selected for
colouring associated chains in the structure display. This
menu contains all the alignment views associated with the
- <!-- JAL-4273 --> Visible adjuster marks to grab and adjust annotation panel height and id width
- <!-- JAL-4260 --> Adjustable ID margin when alignment is wrapped
- <!-- JAL-4274 --> Command line options and configurable bitmap export preferences for height, width and scale factor
+- <!-- JAL-4307 --> Show or hide ligands in a Jmol structure view via View Ligands submenu
### Improved support for working with computationally determined models
- <!-- JAL-3895 --> Alphafold red/orange/yellow/green colourscheme for structures
warning.using_old_command_line_arguments = It looks like you are using old command line arguments. These are now deprecated and will be removed in a future release of Jalview.\nFind out about the new command line arguments at\n
warning.using_mixed_command_line_arguments = Jalview cannot use both old (-arg) and new (--arg) command line arguments. Please check your command line arguments.\ne.g. {0} and {1}
warning.the_following_errors = The following errors and warnings occurred whilst processing files:
+action.show_hetatm = Show Ligands (HETATM)
package jalview.api.structures;
import java.io.File;
+import java.util.Collections;
+import java.util.List;
import jalview.api.AlignmentViewPanel;
import jalview.datamodel.PDBEntry;
File saveSession();
+ /**
+ *
+ * @return heteroatoms in a form suitable for display and passing to command generator to display hetatms
+ */
+ default List<String> getHetatms() {
+ return Collections.EMPTY_LIST;
+ }
+
}
import java.io.File;
import java.net.URL;
import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import org.jmol.c.CBK;
import org.jmol.viewer.Viewer;
+import com.google.common.collect.Lists;
+
import jalview.api.AlignmentViewPanel;
import jalview.api.FeatureRenderer;
import jalview.api.FeatureSettingsModelI;
// End StructureListener
// //////////////////////////
-
+
+ ////////////////////////////
+ // HETATM get
+ //
+
+ @Override
+ public List<String> getHetatmNames()
+ {
+ HashMap<String,String> hetlist=new HashMap();
+ for (int mc=0;mc<jmolViewer.ms.mc; mc++)
+ {
+ Map<String,String> hets = jmolViewer.ms.getHeteroList(mc);
+ hetlist.putAll(hets);
+ }
+ return Arrays.asList(hetlist.keySet().toArray(new String[0]));
+ }
+ //
+ ////////////////////////////
+
@Override
public float[][] functionXY(String functionName, int x, int y)
{
"restore STATE \"" + Platform.escapeBackslashes(filePath) + "\"");
}
+ @Override
+ public List<StructureCommandI> showHetatms(List<String> toShow)
+ {
+ // always clear the current hetero cpk display
+
+ StringBuilder sb = new StringBuilder();
+ sb.append("select hetero; cpk off;");
+
+ if (toShow != null && !toShow.isEmpty())
+ {
+ // select what was requested
+ sb.append("select ");
+ boolean or = false;
+ for (String k : toShow)
+ {
+ sb.append(or ? " or " : " ");
+ sb.append(k);
+ or = true;
+ }
+ // and show as
+ sb.append("; cpk;");
+ }
+
+ return Arrays.asList(new StructureCommand(sb.toString()));
+ }
/**
* Obsolete method, only referenced from
* jalview.javascript.MouseOverStructureListener
protected boolean allChainsSelected = false;
+ protected boolean allHetatmBeingSelected = false;
+
protected JMenu viewSelectionMenu;
/**
chainMenu.add(menuItem);
}
}
+ void setHetatmMenuItems(List<String> hetatmNames)
+ {
+ hetatmMenu.removeAll();
+ if (hetatmNames == null || hetatmNames.isEmpty())
+ {
+ hetatmMenu.setVisible(false);
+ return;
+ }
+ hetatmMenu.setVisible(true);
+ allHetatmBeingSelected=false;
+ JMenuItem allMenuItem = new JMenuItem(
+ MessageManager.getString("label.all"));
+ JMenuItem noneMenuItem = new JMenuItem(
+ MessageManager.getString("label.none"));
+ allMenuItem.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ {
+ allHetatmBeingSelected=true;
+ // Toggle state of everything - on
+ for (int i = 0; i < hetatmMenu.getItemCount(); i++)
+ {
+ if (hetatmMenu.getItem(i) instanceof JCheckBoxMenuItem)
+ {
+ ((JCheckBoxMenuItem) hetatmMenu.getItem(i)).setSelected(true);
+ }
+ }
+ allHetatmBeingSelected=false;
+ showSelectedHetatms();
+ }
+ }});
+
+ noneMenuItem.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ {
+ allHetatmBeingSelected=true;
+ // Toggle state of everything off
+ for (int i = 0; i < hetatmMenu.getItemCount(); i++)
+ {
+ if (hetatmMenu.getItem(i) instanceof JCheckBoxMenuItem)
+ {
+ ((JCheckBoxMenuItem) hetatmMenu.getItem(i)).setSelected(false);
+ }
+ }
+ allHetatmBeingSelected=false;
+ showSelectedHetatms();
+ }
+ }});
+ hetatmMenu.add(noneMenuItem);
+ hetatmMenu.add(allMenuItem);
+
+ for (String chain : hetatmNames)
+ {
+ JCheckBoxMenuItem menuItem = new JCheckBoxMenuItem(chain, false);
+ menuItem.addItemListener(new ItemListener()
+ {
+ @Override
+ public void itemStateChanged(ItemEvent evt)
+ {
+ if (!allHetatmBeingSelected)
+ {
+ // update viewer only when we were clicked, not programmatically
+ // checked/unchecked
+ showSelectedHetatms();
+ }
+ }
+ });
+
+ hetatmMenu.add(menuItem);
+ }
+ }
/**
* Action on selecting one of Jalview's registered colour schemes
return;
}
setChainMenuItems(binding.getChainNames());
+ setHetatmMenuItems(binding.getHetatmNames());
this.setTitle(binding.getViewerTitle(getViewerName(), true));
}
getBinding().showChains(toshow);
}
-
+ /**
+ * Display selected hetatms in viewer
+ */
+ protected void showSelectedHetatms()
+ {
+ List<String> toshow = new ArrayList<>();
+ for (int i = 0; i < hetatmMenu.getItemCount(); i++)
+ {
+ if (hetatmMenu.getItem(i) instanceof JCheckBoxMenuItem)
+ {
+ JCheckBoxMenuItem item = (JCheckBoxMenuItem) hetatmMenu.getItem(i);
+ if (item.isSelected())
+ {
+ toshow.add(item.getText());
+ }
+ }
+ }
+ getBinding().showHetatms(toshow);
+ }
/**
* Tries to fetch a PDB file and save to a temporary local file. Returns the
* saved file path if successful, or null if not.
protected JMenu chainMenu;
+ protected JMenu hetatmMenu;
+
protected JMenu viewerActionMenu;
protected JMenuItem alignStructs;
chainMenu = new JMenu();
chainMenu.setText(MessageManager.getString("action.show_chain"));
+ hetatmMenu = new JMenu();
+ hetatmMenu.setText(MessageManager.getString("action.show_hetatm"));
+
fitToWindow = new JMenuItem();
fitToWindow.setText(MessageManager.getString("label.fit_to_window"));
fitToWindow.addActionListener(new ActionListener()
savemenu.add(png);
savemenu.add(eps);
viewMenu.add(chainMenu);
+ viewMenu.add(hetatmMenu);
helpMenu.add(helpItem);
menuBar.add(fileMenu);
package jalview.structure;
import java.awt.Color;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
StructureCommandI getResidueAttributes(String attName);
List<StructureCommandI> centerViewOn(List<AtomSpecModel> residues);
+
+ default List<StructureCommandI> showHetatms(List<String> toShow) {
+ return Collections.EMPTY_LIST;
+ }
}
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
+import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
{
return 0;
}
+
+ public List<String> getHetatmNames() {
+ return Collections.EMPTY_LIST;
+ }
+ /**
+ * Generates and executes a command to show the given hetatm types as CPK
+ *
+ * @param toShow - one or more of strings from getHetatmNames
+ */
+ public void showHetatms(List<String> toShow)
+ {
+ executeCommands(commandGenerator.showHetatms(toShow), false, "Adjusting hetatm visibility");
+ }
+
}