Selecting
In SAMSON, to do some operations (inspect, edit, move, simulate, etc) with nodes (atoms, residues, molecules) it is necessary to select them.
SAMSON provides several ways for doing simple and complex selections:
- Selection commands, see the Select menu
- Selecting using the Document View
- Selection editors
- Selection filters
- Selecting using the Node Specification Language
- Python Scripting for even more complex and scripted selections.
Interactive tutorials in SAMSON (Help > Tutorials): "Working with documents", "Selecting in the Viewport", "Selecting using the Node Specification Language".
What you will learn from this tutorial:
From this tutorial, you will learn how to select nodes in the Document view, and using commands, editors, selection filters, and Node Specification Language.
What is not covered in this tutorial:
For how to select nodes with the help of Python Scripting, please, refer to the Python Scripting Guide.
Selection commands#
SAMSON provides a number of various selection commands that can be found in the Select menu or via Find everything at the top of the menu.
Some selection commands are available via the context toolbar which appears when something is selected.
Some selection commands ("Select all" and "Deselect all") are available in the selection filter menu in the top-right corner of the viewport.
Hover above the commands in SAMSON to see more information on them in their tool tips.
In general, the selection commands select from the whole document and not from the current selection.
Some of these commands have special modifiers that change how they work (see command tool tips):
- Press Ctrl/Cmd and click on the command to add to the current selection.
- Press Alt and click on the command to remove from the current selection.
- Press Shift and click on the command to intersect with the current selection.
Note
Some commands are enabled only if the active document has specific nodes to which they can be applied (structural models, atoms, etc) or only if something is selected (for commands that act on the selection).
Selecting using the Document View#
You can select nodes through the Document view which shows the hierarchical data graph of the active document. If you do not see the Document view, you can enable it via Interface > Document view (1).
- , : Ctrl+1, : Cmd+1
Open any molecule, e.g. "1YRF - Default structure.sam" from the Samples folder. To unfold a level, click on the + (); to fold a level, click on - (). To select a node, simply click on it in the Document view. For example, in the image below a residue is selected.
To perform more complex selections:
- Hold Ctrl/Cmd and click on a node in the Document view to add it to the current selection or remove it from the current selection if it already was selected.
- Hold Shift and click on a node to select nodes consecutively.
When selecting nodes, a context toolbar appears with specialized actions. It gives you a quick access to some actions that can be done on selections and to some general actions.
At the bottom of the Document view you can see the selection summary which shows the number of selected nodes, and below it you can see some other statistics.
Tip
Click on the selection summary or right-click on the selection to see context menu and the context toolbar.
You can filter nodes in the Document view by entering in the Filter nodes... (1) box a string (filtering by name) or a Node Specification Language expression (filtering by properties and other complex expressions). It does not select nodes right away but only filters them. To select nodes matching the filter, press Enter.
- Shortcut: Shift+F
Let's filter lysine (LYS) residues by name, type LYS
in the Filter nodes... (1) box and press Enter to select the filtered nodes.
- Shortcut: Shift+F
You might notice in the Document view, in the selection summary, or in the Inspector that 15 nodes were actually selected in total, while there are only 5 LYS residues, this is because backbones and side chains of LYS residues were as well selected, since their names also contain "LYS". Filtering by string is based on names of the nodes. For a more precise filtering you can use the Node Specification Language. To choose only LYS residues, type the following Node Specification Language expression: residue.type LYS
(or a short version r.t LYS
). Press Enter to select the nodes matching the filter. You should see that only the LYS residues are selected now.
Note
If you have the Inspector opened (1), you can see in it some detailed info on the selected nodes. The Inspector is a powerful tool with which you can view and edit properties of selected nodes. Please, see Inspecting to learn more about how to work with the Inspector.
- Interface > Inspector, , : Ctrl+2, : Cmd+2
See Selecting using the Node Specification Language section to learn more about how to select nodes using Node Specification Language expressions.
Selecting using Editors#
SAMSON provides a rectangle selection editor (, shortcut: R) to perform selections in the viewport. You can find the selection editor, as all other editors, in the left-side menu in the Viewport.
Note
In SAMSON, there is always an active editor and the selection editor is set as the active editor when you start SAMSON.
The rectangle selection editor acts in two modes:
- a point selection in which it selects when you click on nodes,
- a rectangle selection in which it selects via a rectangle.
To select a node in the viewport via a point selection, left-click on it in the viewport. To select more than one node, hold Ctrl/Cmd. To remove a node from the selection, hold Alt.
To select nodes in the viewport via a rectangle selection, left-click and hold in the viewport and start moving your mouse, you will see the rectangle, once you release the left button the nodes behind the drawn rectangle will be selected. To select more than once, hold Ctrl. To unselect using the rectangle selection, hold Alt.
The rectangle selection can either select or not select nodes hidden behind other nodes. To modify this setting, go to Interface > Preferences > Editor > Select and change the "Perform deep selection" option. Note that the deep selection might be significantly slower for big systems.
The selection level at which the selection editor operates depends on the selection filter (more on it in the next section) which you can find in the top-right corner of the viewport.
For example, if the selection filter is set to "Residues" then the selection editor will be selecting on the residues level when you click on an atom in the viewport.
See Selection filter for more information.
Tip
To center the camera on the selection, press Shift+Space.
Selection filters#
The selection filter governs at which node level the rectangle selection editor and some other editors operate. The selection filter is in the top-right corner of the viewport. By default, the selection filter is set to "Any node".
SAMSON provides a number of selection filters by default, and you can add your own selection filters (see Selecting using the Node Specification Language).
To the right of the selection filter, you can find some common selection actions:
- Select all: selects all selectable nodes in the active document based on the current selection filter.
- Deselect all: deselects all selected nodes in the active document. Enabled only if the selection is not empty.
If the selection filter is set to "Any node", then when you click on the "Select all" button () just next to the selection filter, then it will select all the nodes present in the document.
To clear the selection, click on the "Deselect All" button ().
If the selection filter is set to "Residues", then the selection editor will be selecting on the residues level when you click on an atom in the viewport. If you click on the "Select all" button (), then it will select all residues present in the document.
If the selection filter is set to "Atoms", then when you click on the "Select all" button () it will select all the atoms present in the document.
Reset the selection filter to "Any node".
Selecting using the Node Specification Language#
You can use the Node Specification Language (NSL) for selecting nodes via the Document view's filter as it was shown in the Selecting using the Document View section, or by using the Find window (1).
- The Find window can be opened via Select > Find () and Ctrl+F on Windows and Linux or Cmd+F on Mac.
See the Node Specification Language section to learn more about it.
Saving selection filters#
A Node Specification Language expression can be saved as a selection filter. To do so:
- Open the Find window (Select > Find , Ctrl/Cmd + F).
- Type a selection string.
- Click "Save".
- Enter the name for the selection filter - it will be shown in the selection filter list - and click "OK".
Let's save the selection filter which gives us LYS or HIS residues: r.t LYS or r.t HIS
. Click on the Save button and name it "LYS and HIS residues" then press OK or Enter.
The newly added selection filter should appear at the end of the selection filter list.
You can remove any custom filter or reset all custom filters. To remove a custom filter, set this filter as the active one and right-click on the selection filter list.
Note
Clicking on the "Reset selection filters" will remove all the selection filters added by you.
Saving selections as groups#
In SAMSON, selections can be saved as groups that reference the nodes. This is useful, for example, to have a fast access to some nodes and to perform some actions on selections (e.g., an intersection).
Note
A group does not contain the nodes it refers to, but only links to them. If you select a group but some of the nodes were deleted, only the still existing nodes will be selected.
Open a molecule and select some atoms. Right-click on the selection and click on Select > Group ().
In the pop-up dialog, provide the group name.
The newly created group will be added to the end of the document, and you should see it in the Document view.
You can perform different actions with a group via its context menu.
Inverting and expanding selections#
To invert the selection, click Select > Invert or right-click on the selection either in the Document view or in the viewport and, in the context menu, click Invert selection.
To expand the selection, go to Select > Expand or right-click on the selection either in the Document view or in the viewport and, in the context menu, go to Expand selection and choose how to expand the selection.