Managing Molecular Visibility and Selection in NSL

When working with complex molecular systems, keeping your visualizations clean and relevant is crucial. Whether you’re navigating a large biomolecular complex or focusing on a specific small molecule in a crowded environment, performing visibility and selection queries quickly and precisely can save hours of manual clicking.

In SAMSON’s Node Specification Language (NSL), a set of attributes allows you to efficiently filter and interact with molecules based on their visibility and selection-related states. This blog post covers some of the most useful molecule attribute filters for managing visibility and selection flags—perfect for streamlining your modeling workflow.

Why visibility and selection attributes matter

Modelers often toggle visibility and selection interactively through a GUI, but in systems with hundreds or thousands of molecules or nodes, scripting and filtering using NSL can be a significant productivity booster. Using attribute-based queries allows for repeatable, automated filtering in scenes, especially when combined with custom pipelines or multistage modeling workflows.

Main visibility and selection attributes

The attributes related to visibility and selection include:

  • visible (short name: v): Indicates whether the molecule is currently visible in the viewport.
  • hidden (short name: h): A complementary field to visible; often inversely related.
  • selectionFlag (short name: sf): Indicates whether this node is flagged for selection.
  • selected: Indicates whether the molecule is currently selected. Unlike other attributes, selected has no short name.
  • visibilityFlag (short name: vf): Denotes whether this node is flagged for visibility control, useful in scripting or automations.

Examples of useful queries

If you want to view only the molecules that are visible and selected:

To hide all molecules that are currently visible, you could use this selection and then toggle their visibility:

If you’re cleaning up your scene to focus only on selected parts, try:

Looking to manage selection flags instead of visibility? This is helpful for scripting pre-selection of components:

Short names for fast querying

Short names dramatically reduce typing and are especially handy in scripts or when searching for patterns repeatedly:

  • mol.v for molecule.visible
  • mol.h for molecule.hidden
  • mol.sf for molecule.selectionFlag
  • mol.vf for molecule.visibilityFlag

Note that mol.selected does not have a short name, a subtle but important detail to avoid confusion.

Conclusion

Learning how to leverage the visibility and selection attributes in SAMSON’s NSL can significantly improve how you work with large molecular systems. It makes visualization more manageable, automates tedious selection processes, and reduces the risk of missing key elements in a crowded environment.

To see the complete list of molecule attributes, visit the official documentation here: https://documentation.samson-connect.net/users/latest/nsl/molecule/

SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON here.

Comments are closed.