For molecular modelers working with Python scripts, context-switching between external editors and molecular modeling tools is common—and often frustrating. If you’ve ever wished that you could write, edit, and run your scripts without leaving your molecular design environment, SAMSON has something to make your workflow much easier: its integrated Code Editor.
SAMSON’s Code Editor combines scripting and modeling in one place. Built on the Monaco Editor behind Visual Studio Code, it brings familiar features like syntax highlighting, auto-completion, and the ability to run scripts directly in SAMSON. This lets you automate tasks, test algorithms, and develop molecular modeling workflows right inside your modeling environment.
Why Use the Code Editor in SAMSON?
- No juggling between tools: You can script directly inside SAMSON while visualizing 3D models in real time.
- Intelligent code writing: Thanks to the Monaco foundation, the editor supports rich coding features such as auto-completion and error highlighting.
- Immediate execution: Run your Python scripts with a single click or from the Run menu. The outputs and errors can be viewed via the integrated Python Console, which uses a Jupyter Qt environment.
- Script templates available: Don’t know where to start? Prebuilt Python script templates demonstrate many uses of the SAMSON Python API.
Running Your First Script
To run a script in SAMSON’s Code Editor, follow these steps:
- Click Interface > Code Editor from the menu.
- Open or create a new Python (.py) file.
- Use the left panel’s Run button (▶️ icon) or choose Run from the top menu.
- Results are displayed immediately in the Python Console.
Script Templates: Start Without Starting From Scratch
Not sure where to begin? The Code Editor provides several script templates. These examples demonstrate how to manipulate models, visualize data, create user interfaces with PyQt, and access SAMSON’s specialized Python API. You can modify these templates or use them as base structures for your own tools.
Need more inspiration? The Python Scripting Guide: Examples offers a wide collection of practical scripts for daily modeling tasks.
Beyond Coding: Run, Test, Share
Editing and running scripts is just the beginning. You can bundle your scripts along with molecular models, instructions, or research data into a SAMSON document. This self-contained file can then be sent to collaborators or students for reproducibility or teaching.
This makes the Code Editor not only a scripting tool but part of a complete pipeline—from ideation to sharing and education.
To learn more about SAMSON’s integrated scripting features, visit the official documentation page.
SAMSON and all SAMSON Extensions are free for non-commercial use. You can get SAMSON at https://www.samson-connect.net.