When working on molecular modeling, selecting and visualizing atoms corresponding to specific criteria can be a recurring challenge. Whether you’re analyzing specific molecular fragments, modifying atomic properties, or fine-tuning nanoscale designs, having a systematic approach to selecting atoms is essential. The Simple Script Extension in SAMSON provides a straightforward solution to identify and manipulate individual atoms using mathematical expressions.
For example, you may want to focus only on those atoms in your structure that fall within a certain region of space. Let’s walk through how to efficiently show or hide atoms inside a user-defined spherical region. This kind of task is especially useful when studying molecular dynamics or analyzing spatial relationships in large biomolecules.
Defining a Spherical Region for Visualization
A common operation is to display atoms within a sphere of a particular radius, centered at a specific point. This allows for localized analysis without visual distraction from the rest of the structure. Here’s how you can achieve this with a simple script in SAMSON:
|
1 2 3 4 |
if ((a.x^2 + a.y^2 + (a.z - 2)^2) < 100) a.visibilityFlag := 1; else a.visibilityFlag := 0; |
The code snippet above specifies a sphere centered at (0, 0, 2) with a radius of 10 in selected length units. It checks each atom’s coordinates and decides whether to display (a.visibilityFlag := 1) or hide (a.visibilityFlag := 0) based on whether that atom lies within the sphere’s geometry. The condition uses the standard sphere equation:
(x – x0)2 + (y – y0)2 + (z – z0)2 < r2
Why Scripting Adds Value
Often, molecular visualizations involve dealing with hundreds or thousands of atoms. Searching for atoms that meet very specific spatial conditions might be impractical without automation. The scripting functionality in SAMSON drastically simplifies what would otherwise require significant manual effort.
Using mathematical expressions in scripts offers flexibility. For example, the center and radius of the sphere can be easily modified by updating the respective values in the script. This reusability makes it a powerful tool for exploration and highlighting details in complex molecular systems.
Visual Example: Atoms Inside a Sphere
To give you a better idea, here’s what happens when you apply such a script to a molecular system:

With this script applied, only atoms inside the spherical region remain visible, ensuring a clutter-free visualization. This technique can be further combined with other scripts to segment structures or highlight specific chains, residues, or atomic types.
Next Steps
If you’re ready to simplify atom visualization and selection in your molecular workflows, try this feature on your own models. You can use the Simple Script Extension to customize scripts and adapt them to your particular needs. For more advanced functionality, consider exploring SAMSON’s Python scripting capabilities, which allow for even more programmable workflows.
To explore the full potential of this feature, visit the complete documentation page here.
Note: SAMSON and all SAMSON Extensions are free for non-commercial use. You can download SAMSON from https://www.samson-connect.net.
