One of the most common and time-consuming tasks in molecular modeling is selecting subsets of atoms and tweaking their properties. Whether you’re preparing input structures, scripting transformations, or just exploring molecular shapes, doing this atom-by-atom can quickly become inefficient and frustrating.
If you work with complex models—like proteins, nanostructures, or synthetic materials—chances are you’ve faced this challenge. Fortunately, SAMSON offers a practical solution: the Simple Script Extension, which lets you select and modify atoms based on mathematical expressions and custom logic scripts.
Why This Matters
When dealing with molecular systems, you often need to:
- Shift parts of a model
- Highlight or hide atoms during visualization
- Select atoms based on their geometry or chemical properties
- Batch-modify atomic attributes like partial charges or coordinates
These tasks pop up during system preparation, analysis, visualization, or hypothesis testing. With the Simple Script Extension, you can do all that—without manually editing each atom.
Quick Primer on Simple Script
The Simple Script Extension introduces a scripting language for atom-level operations. You have access to variables tied to atomic coordinates, element types, visibility flags, and more. Standard logic and math operators—even trigonometric and statistical functions—are supported.
Here are a few examples to get a feeling for what’s possible:
1. Select atoms in the top-right quadrant of a model:
|
1 2 |
if (a.x > 0 and a.y > 0) n.selectionFlag := 1; else n.selectionFlag := 0; |

2. Hide all atoms outside a sphere of radius 10 centered at (0, 0, 2):
|
1 2 |
if ((a.x^2 + a.y^2 + (a.z - 2)^2) < 100) a.visibilityFlag := 1; else a.visibilityFlag := 0; |
3. Apply a sinusoidal distortion to a graphene sheet in the z-direction:
|
1 |
a.z := sin(a.x * pi / 12); |

4. Rotate all atoms about the x-axis by 45 degrees:
|
1 2 3 4 5 |
var theta := pi/4; var y_old := a.y; var z_old := a.z; a.y := y_old * cos(theta) - z_old * sin(theta); a.z := y_old * sin(theta) + z_old * cos(theta); |
Use Cases
- Visualization: Create dynamic views by showing/hiding atoms based on position or type.
- Structure preparation: Mass-edit atom properties like charges or positions using rule-based conditions.
- Data analysis: Highlight and extract specific parts of a model matching geometrical constraints.
Going Further
If selecting atoms is all you need, you might prefer the simpler Atoms Selector Extension, which uses the same expression system but focuses only on selection.
For more advanced control, combining loops, conditionals, and variable declarations in Simple Script lets you create complex structures or effects—like modeling nanoscale batarangs out of graphene. But even for everyday tasks, the scripting capabilities can streamline your workflow and save considerable time.
Learn more about what the Simple Script Extension can do.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.
