Quickly Find the Right Molecular Paths Based on Atom Counts

When building or analyzing molecular models, selecting relevant structural components efficiently can be a tedious process. For example, you may want to isolate all molecular paths that contain a certain number of atoms—say, to study backbone flexibility in oligomers, filter out irrelevant fragments, or quickly find structures matching a size criterion.

If you are using SAMSON, the Node Specification Language (NSL) provides an elegant way to do this using path attributes. In this post, we’ll look at the numberOfAtoms path attribute, a self-contained and powerful tool in NSL that helps you target specific path nodes based on how many atoms they contain.

Why filter molecular paths by length?

Paths in SAMSON typically represent linear sequences of atoms, like polymer chains or molecular backbones. When working with large systems, you may face a situation where:

  • Some paths are too short to be relevant (e.g. solvent or noise fragments)
  • You want to focus on larger substructures (e.g. segments of a macromolecule)
  • You need to group or process structural elements of comparable size

Instead of selecting these manually, SAMSON’s path.numberOfAtoms (short form: p.nat) makes it easy to automate this filtering.

How it works

The p.nat attribute matches paths based on the number of atoms they contain. This means you can instantly filter path nodes in your document based on integer conditions:

  • p.nat > 100: selects all paths with more than 100 atoms.
  • p.nat 100:200: selects paths that have between 100 and 200 atoms, inclusive.

These expressions can be used directly in the Select tool in SAMSON or in NSL-based scripts to create advanced queries that integrate well with your design or analysis workflow.

Benefits of using p.nat

This attribute is especially helpful in dynamic systems or large molecular assemblies where manual selection is not feasible. Some practical use cases include:

  • Visualizing only large molecular parts while hiding fragments
  • Filtering imported structures to keep only the relevant paths
  • Selecting similarly-sized molecules across your document for comparison

You can combine p.nat with other NSL criteria (like p.n "C*" to filter by name) to perform even more specific selections.

Example use

If you want to only display the paths related to macromolecules with more than 150 atoms, simply enter:

in the Select tool in SAMSON, and it will instantly select the corresponding paths. You can then hide the others, extract the selection, or analyze just those components.

Conclusion

The numberOfAtoms attribute is a small but precise tool that solves a common molecular modeling frustration: identifying and isolating structural paths by size. Learning and using this attribute can streamline your workflows and help you get to relevant structures faster.

To learn more about path attributes in NSL, visit the official documentation page here: https://documentation.samson-connect.net/users/latest/nsl/path/.

SAMSON and all SAMSON Extensions are free for non-commercial use. Download SAMSON at https://www.samson-connect.net.

Comments are closed.