Five Lysines, Fifteen Nodes: Make Molecular Selections More Exact

A selection that looks right at first can quietly include more than you intended. This often happens when filtering molecular structures by name: matching a residue label may also match its backbone or side-chain nodes. The result can complicate inspection, editing, measurement, or any later step that depends on selecting exactly the right level of the molecular hierarchy.

In SAMSON, the fix is to move from a broad name search to a query that specifies the kind of node you want. Here is a practical workflow for selecting residues precisely, checking the result, and saving the query for reuse.

Why a name search can select too much

The Document view lets you filter nodes by entering a string in its Filter nodes… box. The string filters by node names, and pressing Enter selects the matching nodes. That is convenient for a quick search, but names can be shared across different levels of the structure.

For example, searching for LYS may match lysine residues as well as their backbones and side chains, because those nodes also have names containing LYS. In the documented example, five LYS residues produce fifteen selected nodes. The extra matches are not necessarily errors in the structure: they are a reminder that a name search is not the same as a residue-only query.

Filtering nodes using the LYS name string

Specify the node type with NSL

For a residue-level selection, use the Node Specification Language (NSL) expression residue.type LYS. The shorter equivalent is r.t LYS. Enter either expression in the Document view filter and press Enter. This asks SAMSON for nodes that are residues whose type is LYS, rather than every node whose name happens to contain those letters.

Selecting LYS residues with a Node Specification Language expression

A useful habit is to check the selection summary after filtering. It shows the number of selected nodes; the Inspector can also display information about the selection. If the count does not match the level you intended to select, revisit the query before moving on to edits or analysis.

Turn a successful query into a reusable filter

If you regularly need the same selection, save the NSL expression as a custom selection filter. Open the Find window using Select > Find or Ctrl/Cmd + F, enter the expression, click Save, and give the filter a clear name. For example, a query for either lysine or histidine residues is r.t LYS or r.t HIS; a descriptive name such as LYS and HIS residues makes its purpose easier to recognize later.

Saved filters are useful when you want to rerun a rule against the document. A group serves a different purpose: it stores references to the nodes in a particular selection, so you can access those nodes again. Groups do not contain copies of the nodes; if some referenced nodes are deleted, selecting the group selects only those that still exist. In short, save a filter when you want to preserve the selection logic, and create a group when you want convenient access to a specific set of nodes.

Keep the selection level in mind

Filtering in the Document view and selecting in the viewport are related, but the selection filter controls the node level used by the rectangle selection editor and some other editors. For instance, setting the selection filter to Residues means a viewport click on an atom selects at the residue level. If you need individual atoms instead, choose Atoms. This distinction helps avoid a common mismatch: clicking one visible atom does not always mean the resulting selection contains only that atom.

For a reliable routine: decide whether the task needs atoms or residues, write a query that states that level explicitly, press Enter, and verify the selection count. Save frequently used queries as filters, and use groups when you want to recall a particular selection. These small checks can prevent a broad or ambiguous selection from following you into the next stage of a workflow.

For more selection methods and examples, see the SAMSON selection documentation.

Note: SAMSON and all SAMSON Extensions are free for non-commercial use. Get SAMSON.

Comments are closed.