Mastering Node Selection with Logical Operators in SAMSON

For molecular modelers seeking precision and efficiency, identifying the exact nodes or structures within a vast molecular model can be a pain point. This is where the Node Specification Language (NSL) in SAMSON shines. Among its many capabilities, logical operators allow you to combine criteria to define extremely specific node subsets. In this guide, we’ll walk through how to harness logical operators within NSL to streamline your molecular modeling workflows.

What Are Logical Operators in NSL?

Logical operators in NSL let you define relationships and combinations between sets of nodes, enabling highly targeted selections. The available operators are:

  • and
  • not
  • or
  • xor (exclusive or).

These operators let you combine different queries to refine your node selection with unparalleled flexibility.

Practical Applications with Examples

Below are some practical use cases of logical operators in NSL:

  • Combining Conditions: Use and to select nodes that satisfy multiple criteria. For example, sg.id 1000:1040 and sg.nat < 4 matches structural groups with IDs between 1000 and 1040 and fewer than 4 atoms.
  • Excluding Nodes: Use not to exclude specific nodes from your selection. For instance, n.t r and not r.t CYS yields residues that are not cysteines.
  • Union of Sets: Use or to combine different node groups. Example: a.sn <= 20 or a.sn >= 40 selects atoms with serial numbers smaller than 20 or larger than 40.
  • Exclusive Selection: Use xor to select nodes that meet one criteria but not both. Consider a.sn >= 20 xor a.oc >= 0.5, which picks atoms either with serial numbers greater than or equal to 20 or occupancies greater than or equal to 0.5, but not both.

Important Note on not

It’s crucial to understand the implications of the not operator. For example, not r.t CYS does not just exclude cysteine residues. It also includes all other node types that aren’t residues or cysteines (e.g., folders). To avoid unintended matches, always specify the context, such as n.t r and not r.t CYS.

Streamline Selections with Examples

Let’s see how combining logical operators can make your node selection even more powerful:

  • n.t a within 5A of "GLN 2" and not n.t a in "GLN 2": Selects atoms within 5 angstroms of GLN 2, but not atoms that belong to GLN 2.
  • (C or H) and not (r.t PRO): Selects carbons and hydrogens that do not belong to proline residues.

By thoughtfully combining these operators, you can perform highly complex selections in just a few lines of NSL.

Why Logical Operators Matter

The ability to use logical operators ensures that no matter how specific or complex your task, SAMSON’s NSL can adapt to your needs. Whether you’re analyzing protein residues, isolating ligands, or customizing selections for visualization, logical operators empower you to work faster and more effectively.

For more examples of practical NSL expressions and logical operator usage, visit the Node Specification Language documentation.

Note: SAMSON and all SAMSON Extensions are free for non-commercial use. You can download SAMSON at samson-connect.net.

Comments are closed.