Smormo-Ed's Command Language

Table of Contents

1 Introduction

Smormo-Ed has a simple interpreter built into it. It accepts commands as s-expressions (like lisp or scheme). There is a "scratch area", which holds a molecule in the program's internal data structures. If the GUI is enabled, this is what can be seen in the window. Some commands accept or return molecules encoded as s-expression, and others operate on the molecule in the scratch area. mol->sexp and sexp->mol can be used to transfer a molecule into or out of the scratch area. Each atom in the scratch area has a flag indication if it is "selected" or not. Some procedures operation only on selected atoms.

Here is an example of a molecule encoded as an s-expression. (molecule (atom (element C) (x -137.64) (y -40.36) (tag A0)) (atom (element C) (x -95.64) (y -40.36) (tag A1)) (atom (element O) (x -53.64) (y -40.36) (tag A2)) (bond (tag A0) (tag A1)) (bond (tag A1) (tag A2)))

This molecule has 3 atoms and 2 bonds.

2 Procedures

2.1 Stopping

2.1.1 quit

(quit) End the program.

2.1.2 exit

(exit) Alias for quit.

2.1.3 quit-on-error

(quit-on-error t-or-f)

Indicate that the program should end after any error.

2.2 Flow Control

2.2.1 begin

(begin s-expressions)

Evaluate one more more statements. Return the return-value of the last one.

2.2.2 wait-for-click

(wait-for-click) Stop the script until the user clicks on the main window of the GUI.

2.3 Selection

2.3.1 select-all

(select-all) Select all atoms in the scratch area.

2.3.2 unselect-all

(unselect-all) Unselect all atoms in the scratch area.

2.3.3 select-by-atomic-number

(select-by-atomic-number atomic-number)

2.4 Deleting

2.4.1 delete-selected

(delete-selected) Delete selected atoms from the scratch area.

2.4.2 clear

(clear) Delete all atoms and bonds in the scratch area.

2.5 Conversion

2.5.1 sexp->mol

(sexp->mol molecule)

Interpret an s-expression molecule and place it in the scratch area.

2.5.2 mol->sexp

(mol->sexp) Turn the molecule in the scratch area into an s-expression.

2.5.3 sexp->format

(sexp->format molecule format)

2.5.4 format->sexp

(format->sexp data format)

2.5.5 sexp->name

(sexp->name molecule)

Run smormo-namer on an s-expression molecule, return a list of possible names for the molecule.

2.6 Hydrogens

2.6.1 strip-hydrogens

(strip-hydrogens molecule selected-only)

2.6.2 add-hydrogens

(add-hydrogens molecule selected-only)

2.7 Input and Output

2.7.1 read

(read) Read and return an s-expression from stdin.

2.7.2 display

(display s-expressions)

Print one or more s-expressions to stdout.

2.7.3 newline

(newline) Send a newline character to stdout.

2.7.4 load-molecule-file

(load-molecule-file filename)

Read a molecule from a file on disk. The format will be determined by the extension on the filename. This procedure is disabled in cgi mode.

2.7.5 save-molecule-file

(save-molecule-file molecule filename)

Save an s-expression molecule to a file on disk. The format will be determined by the extension on the filename. This procedure is disabled in cgi mode.

2.8 Atom Tags

2.8.1 tag-all-atoms

(tag-all-atoms) Give each atom in the scratch area a unique identity string.

2.8.2 tag-untagged-atoms

(tag-untagged-atoms) Give a unique identity string to atoms that lack one.

2.8.3 clear-atom-tags

(clear-atom-tags) Remove the identity string from all atoms in the scratch area.

2.9 Display

2.9.1 set-display-style

(set-display-style display-style)

2.9.2 set-electron-display-style

(set-electron-display-style electron-display-style)

2.10 Layout

2.10.1 spin

(spin degrees)

2.10.2 layout

(layout molecule)

Attempt to put atoms in the scratch area in positions that will make sense to a human.

2.10.3 flip

(flip) Flip diagram left-to-right

2.11 Debugging

2.11.1 eval-debug

(eval-debug on-or-off)

Turn on logging of s-expression evaluation.

2.11.2 debug-eval

(debug-eval on-or-off)

Alias for eval-debug.

2.11.3 layout-debug

(layout-debug on-or-off)

Turn on logging of molecule layout.

2.11.4 debug-layout

(debug-layout on-or-off)

Alias for layout-debug

2.11.5 debug-selected-atoms

(debug-selected-atoms skip-leaves)

2.11.6 debug-molecule

(debug-molecule) Print information about the molecule in the scratch area.

2.12 Miscellaneous

2.12.1 version

(version) Print out the program's version

3 Examples

3.1 version

This will cause Smormo-Ed to display its version and exit.

(begin (display (version)) (newline) (quit))

3.2 read and write smiles

(begin (quit-on-error #t) (display (sexp->format (format->sexp (read) "smiles") "smiles")) (newline) (quit)) "[C@H](F)(Cl)Br"

Author: Seth Alves <seth@hippo.hungry.com>

Date: 2010/09/14 09:25:18 AM