If you work in molecular modeling, you’ve likely faced challenges automating workflows or testing new ideas quickly. The good news is that SAMSON equips you with a powerful Python scripting environment, enabling flexible and efficient molecular design. Here’s how SAMSON’s Python scripting capabilities can transform your workflow.
Why Use Python in SAMSON?
Python is a widely-used programming language in the scientific community, and SAMSON leverages its power through the SAMSON Python API. This integration allows molecular modelers and researchers to:
- Create automated analysis pipelines.
- Simulate molecular behavior directly from scripts.
- Integrate Python packages for bioinformatics, deep learning, data visualization, and more.
- Develop custom workflows that meet specific research needs.
One standout feature is the ability to use SAMSON AI. This assistant can generate Python scripts tailored to your requirements. Simply use the /script command in the SAMSON AI assistant, and it will produce Python code powered by the SAMSON Python API.
Getting Started with Python in SAMSON
To access Python scripting in SAMSON, start with the Python Scripting Extension. This extension provides the following key tools:
- Python Console: This console integrates the Jupyter Qt Console. You can use it to experiment with Python code, automate tasks, and test workflows interactively.
- Code Editor: SAMSON’s Code Editor integrates the Monaco Editor from Visual Studio Code, delivering features such as syntax highlighting, auto-completion, and the ability to run Python scripts directly.
- Package Manager: Install, upgrade, or remove Python packages seamlessly. This feature lets you manage dependencies efficiently.
Running Python Scripts
The Code Editor offers an intuitive environment to write, edit, and execute Python scripts. You can even start from ready-to-use Python script templates, which demonstrate common use cases of the SAMSON Python API.
To execute a script, click the Run button (
) in the Code Editor’s left panel, or access scripts using the Python Console for immediate execution. With features like integrated GUI creation using PyQt, the editor is a versatile tool for automation tasks and prototyping.

Manage Python Packages
In SAMSON, package management is straightforward. You can access the Python Package Manager from the Python Console by going to Edit > Manage packages…. Easily install packages from PyPI or provide a path to local Python packages. You can even install packages in editable mode, which is particularly useful when developing custom Python code.

Embedding Python Scripts for Seamless Collaboration
Another excellent feature in SAMSON is the capability to embed Python scripts within SAMSON Documents. This allows you to bundle scripts, data, and molecular models into a single file for easy sharing and reproducibility. Embedded files continue to function when shared with colleagues or students, either through email, GitHub, or the SAMSON Connect – Documents platform.

For example, as a researcher, you can attach Python scripts for analyzing data to your published molecular models for increased transparency. As an educator, you could deliver interactive exercises for students, combining lecture materials with Python-based tasks.
Start Scripting Today
If you’re new to Python scripting in SAMSON, or if you’d like to dive deeper into using the SAMSON Python API, the Python Scripting Guide is a great place to start. It offers detailed instructions and examples designed to accelerate your learning curve.
Note: SAMSON and all SAMSON Extensions are free for non-commercial use. You can download SAMSON at https://www.samson-connect.net.
