SAMSON Python Scripting#
Automate molecular modeling in SAMSON with Python.
The Python Scripting extension in SAMSON provides Python bindings for the SAMSON API and an integrated Python console. It gives you access to most of the SAMSON SDK so that you can automate SAMSON workflows with Python.
Python bindings for the SAMSON API follow the same structure as the SAMSON SDK: classes have the same short names as in the SDK and functions are exposed with the same names and parameters, except for some getter/setter functions that are exposed as class properties where possible. This makes it possible to transfer code between Python and C++ with minor modifications.
The Python console in SAMSON comes with an integrated Jupyter Qt Console.
Note
This version of the Python bindings is for SAMSON SDK 2026 R1.
Python bindings are done thanks to pybind11 (pybind11 license).
What you can do#
Use Python scripting in SAMSON to:
run SAMSON commands and actions;
select and retrieve nodes with the Node Specification Language (NSL);
inspect and modify atoms, molecules, documents, cameras, and other nodes;
build molecular systems programmatically;
import and export files and trajectory frames;
colorize, visualize, render, and animate molecular models;
use SAMSON AI and the Code Editor to create and run scripts;
create simple dialogs or more advanced Qt-based GUIs.
Start here#
If you are new to SAMSON Python scripting, start with the short tutorial: Start scripting in SAMSON. Then continue with:
Getting started for imports, help, command history, scripts, and package installation;
Python scripting mental model for the main concepts behind commands, documents, nodes, selections, undo, and units;
Developing scripts for SAMSON AI, the Code Editor, embedded scripts, and GUIs;
Examples for complete scripts grouped by task;
API overview for common entry points before you browse the full API reference.
Popular tasks#
Documentation#
The Python Scripting Guide is organized by the way users usually work: first-run onboarding, core concepts, task guides, examples, API reference, and release information.
Core concepts
How-to guides
Examples and recipes
AI assistant support
API reference#
The Python Scripting API reference is subdivided into groups that correspond to the SAMSON SDK Organization.
API reference
Release notes and versions
For AI assistants#
The AI agent guide summarizes the most important pages, API choices, undo patterns, NSL usage, and common pitfalls for coding assistants. The generated llms.txt file provides a compact map of the Python Scripting Guide and links to per-page Markdown files. The generated llms-full.txt file provides a full text export of the guide and API reference.