Turning Commands into Code: How SAMSON AI Helps Molecular Modelers Write Python Scripts

For anyone working in molecular modeling, automating repetitive tasks or prototyping analysis routines often requires scripting. But what if you’re not fully comfortable writing Python from scratch, or you just need a quick snippet to get started? That’s where SAMSON AI can make a difference.

Included in the SAMSON platform, SAMSON AI acts as an intelligent assistant that understands natural language and can translate it into Python code using the SAMSON API. This helps greatly reduce scripting complexity and lets you focus on science rather than syntax.

What is the benefit for molecular modelers?

Let’s face it: many modeling tasks involve repetitive or parameter-intensive setups—such as translating atom groups, calculating properties like gyration radii, or building quick GUIs for batch operations. While SAMSON already provides scripting capabilities, SAMSON AI takes this further by generating Python scripts on-demand, based on what you describe in natural language.

How the /script command works

To use this feature, open SAMSON AI with either Interface > Assistant or the keyboard shortcut Ctrl+0 (on Windows/Linux) or Cmd+0 (on Mac). Then, type your request starting with the /script command.

Here are a few real examples:

  • /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.

Every script generated uses the SAMSON Python API, which allows control over models, selections, visual styles, and more. If you already know Python, this AI-generated code can serve as a starting point to customize further. If you’re new to it, these scripts are a great way to learn by example.

Examples to try

Here are some prompts that might help with your tasks:

  • /script highlight all residues within 6 angstrom of the ligand.
  • /script generate 10 random conformations of the side chain at position 45.
  • /script write a script that exports the current molecule to a PDB file.

SAMSON AI will respond by displaying the code, which you can inspect, save, and tweak. It’s especially helpful when building workflows quickly or learning how to use SAMSON’s powerful API.

Assistant commands

Why this matters

The barrier to using Python for modeling tasks is real, especially for researchers or students transitioning into computational work. SAMSON AI lowers that barrier by enabling you to describe what you want in plain English and receive valid, executable Python in return.

You don’t have to leave the SAMSON environment to search for documentation or examples—the assistant handles it for you in context. This means faster prototyping, fewer errors, and smoother iteration during research.

To learn more about how SAMSON AI can help with scripting and other interactive commands, visit the full documentation at:

https://documentation.samson-connect.net/users/latest/samson-ai/

SAMSON and all SAMSON Extensions are free for non-commercial use. You can download SAMSON at https://www.samson-connect.net.

Comments are closed.