Writing scripts to analyze and manipulate molecular systems often requires both knowledge of a specific API and time spent debugging syntax errors. If you’re working with Python in SAMSON and find yourself switching between the documentation and your code editor too often, SAMSON AI can simplify your workflow.
In this post, we’ll take a closer look at the /script command in SAMSON AI, which helps generate ready-to-run Python scripts from natural language descriptions. This feature can be especially useful for researchers, computational chemists, and educators who routinely perform repetitive molecular operations, but want to spend less time writing boilerplate code.
What does /script do exactly?
The /script command in SAMSON AI is designed to create Python scripts that interact with molecular models using the SAMSON Python API. Instead of recalling specific function names or argument structures, you can just describe the task in plain language and let the assistant translate that into working code.
Here are a few examples you can try:
/script select all atoms and translate them in the z direction by 1 angstrom./script create a GUI that lets me enter a distance in angstrom, with a 'Move' button./script compute the gyration radius of the receptor.
This natural language interface is especially helpful when:
- You’re prototyping a new feature or analysis method.
- You’re teaching scripting to students and want them to focus on the concept instead of syntax.
- You want to construct GUI elements quickly, like buttons or sliders, for internal tools.
Why this matters
In traditional scripting environments, there’s a learning curve involved in becoming proficient with a domain-specific API. For molecular modelers who may not identify primarily as programmers, this becomes a barrier to productivity. The /script command shortens that curve significantly.
For example, let’s say you often want to calculate geometric properties of a ligand or receptor, but don’t want to manually filter atoms and apply formulas each time. You could simply say:
/script compute the gyration radius of the ligand.
SAMSON AI will return a script that accesses the molecular nodes, computes the radius of gyration, and optionally visualizes or logs it.
Customization and Extensibility
Since the scripts are written in Python, you can extend them with additional libraries, such as NumPy for mathematical analysis, matplotlib for plotting, or even machine learning tools like scikit-learn or PyTorch.
The generated script isn’t a black box: you’re encouraged to tweak and explore. It’s a learning tool as much as it is a time-saver.
Best Practices
- Start with clear commands—use simple and complete sentences to describe the task.
- Review the generated script to understand its logic before executing it.
- If something doesn’t work as expected, try rewording your command to be more specific.
Where to start
To use this feature, open SAMSON AI by navigating to Interface > Assistant or pressing Ctrl + 0 (on Windows/Linux) or Cmd + 0 (on macOS).
Then type /script followed by what you want the assistant to generate.
To explore all the other AI-assisted commands available in SAMSON AI, including actions, node selection, or even teaching the assistant from a document, visit the official documentation.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can download SAMSON at https://www.samson-connect.net.
