# LSD 3.4.8

Last modified: April, 02nd 2013.

## Table of contents

From spectra to data
Command interpreter
From data to structures
Very quick start
Drawing improvements
Data file structure

Basic commands
List definition
Execution control
Substructural information

Creating substructure files with mol2ab
Result processing with outlsd
Result viewing with genpos

## From spectra to data

The goal of LSD is to help the user to propose one or more molecular structures from data that is mainly extracted from 2D NMR spectra. Recording HMQC (or HSQC), HMBC and COSY spectra is the pre-requisite for LSD use. LSD has no knowledge of chemical shifts. There is no way to introduce this kind of data, for any nucleus type. LSD uses the chemical shift and coupling information provided by the user that are necessary to establish carbon hydridization state or to impose a particular neighborhood to a given atom.

NMR data coding for LSD may initially seem awkward to beginners. The following paragraphs are intended to help them. A useful documentation source may be found in the examples in the Data folder. A data file for LSD is a text file that contains commands, each being followed by one or more parameters. The most useful commands will be first introduced, but a thorough command set description is given in the Data file structure paragraph. A text-type user interface may seem old-fashioned, but it is sometimes easier to modify a text than to navigate though menus and sub-menus whose function is not always totally explicit.

The first step in the elucidation of an unknown molecular structure is to find its elemental formula and to determine the status of all non-hydrogen atoms. The status consists of an index, a chemical symbol, a hybridization state (sp, sp2 or sp3), a number of attached hydrogen atoms and a charge. Defining the status of all atoms is a strong constraint for the user. The status of heteroatoms is not always easy to define, mainly when more than one of their type is present. Even for carbon atoms, the chemical shift value is not sufficient to non-ambiguously deduce the hydridization state. More than a single data set must then be written and tested. More flexibility to status definition will be given in the near future, but for the moment the user has to cope with the present capabilities of LSD.

Atom indexing may be arbitrary. A recommended procedure is the indexing of carbons from 1 in decreasing order of their 13C chemical shift value. Heteroatoms, such as nitrogen or oxygen, receive the following numbers as indexes. Carbon indexes are then reported in the 1D projections around the 2D HMQC and HMBC spectra. It is possible to have another atom type (X) provided that its valence is defined by the user.

The command that defines an atom status is `MULT`. Uppercase letters need to be uppercase. `MULT` is followed by the atom index, the chemical symbol, 1, 2 or 3 for the hydridization state (sp, sp2 or sp3), the multiplicity (number of bound hydrogen atoms) and the charge (facultative). The command `MULT 1 C 2 0` says that atom 1 is a quaternary (`0`) sp2 (`2`) carbon (`C`). The data file contains as many `MULT` lines as non-hydrogen atoms in the molecule.

The following step is the indexing of hydrogen atoms. Again, the indexes may be given arbitrarily, but it is handy to give the same index to the proton and to the carbon atom that is attached to it. The HMQC (or HSQC) spectrum matches carbon and proton indexation schemes. Two inequivalent hydrogen atoms within a methylene group get the same index. The hydrogen indexes are then copied in the projections around the 2D COSY and HMBC spectra. A correlation in a 2D spectrum is characterized by the type of spectrum, the index of the atom in dimension 1 (carbon index in HMQC and HMBC spectra), and the index of the atom in dimension 2 (always a hydrogen atom index). The command `HMQC 4 4` indicates that carbon 4 and hydrogen 4 are bound together. The HMQC and HSQC commands are equivalent. Commands `HMBC` and `COSY` are coded in the same way.

Any easily deduced bond must be given to LSD through a `BOND` command. It takes the indexes of the bound atoms as parameters. If carbon 1 is that of a keto group and if there is an sp2 oxygen 22, the command `BOND 1 22` establishes the bond between atoms 1 and 22.

Unless specified, the order of the commands within a data file has no importance. The text that follows the `EXIT` command is ignored. Apart from purely NMR derived commands, other commands are needed for execution control. One should prefer to group them at the beginning of the data file. `MULT`, `HMQC`, `COSY`, `HMBC`, and `BOND` commands constitute the basic part of LSD data files.

A less trivial part in the writing of LSD data files is the definition of atom properties and of the associated lists. An atom property (`PROP` command) indicates for an atom or for all atoms in a list the number of neighbors that must be members of another atom list. The number 0 means "all". For example, the chemical shift of the carbon atoms indexed 8, 9 and 10 is about 15 ppm. The hydrogen atoms indexed 8, 9 and 10 are those of methyl groups appearing at about 1 ppm as singlets. Carbons 8, 9 and 10 are most probably bound only to quaternary carbons. You need to build two lists in order to code this constraint with LSD. The first list contains the atoms 8, 9 and 10 while the second one contains all the quaternary carbons. An atom list is described by its index and its content. The content is either explicitely defined (giving the index of all atoms within the list) or using atom status. It is also possible to combine lists according to the operations defined in the set theory. Back to the example, `LIST L1 8 9 10` defines list 1 and puts atoms 8, 9 and 10 in it. `QUAT L2` defines list 2 and puts all quaternary carbons in it. Once L1 and L2 are defined, the constraint on atoms 8, 9 and 10 is coded by the `PROP L1 0 L2` command. It could have also been possible to write `PROP L1 1 L2`, because a methyl group carbon always has a single neighbor. List and property definition commands are treated in the order they are written in the data file. Changing their order can change their meaning.

A common temptation for beginners is spectra over-interpretation, meaning that non-significant information is introduced. Inconsistent or wrong data leads LSD to fail, producing a message that indicates which is the deepest analysis level reached (the so much hated "max stack level: " message). Introducing nJ COSY or HMBC correlations with n greater than 3 also leads LSD to fail, unless otherwise specified (see below). In order to avoid this unpleasant situation, the weakest COSY and HMBC correlations should be first written as comments, by putting a semicolon at the beginning of the corresponding commands. If the number of found solutions is too big, it's time to remove semicolons to impose more property or correlation constraints to the problem.

New with version 3.1.0: Elimination of invalid HMBC correlations
Two reasons may be invoked if the analysis of a HMBC correlation does not lead to a solution. Either the present state of the molecule is not compatible with the analyzed correlation (case 1), or the correlation itself is invalid (case 2). The latter case arises either by accident (spectral artefact or typing error, for example) or because the correlation arises from a coupling through more than three bonds. In case 1, the resolution mecanism will be able to correct the structure state to produce a solution if the entire data set is correct. In case 2, no correction can lead to a solution. The invalid correlation can now be eliminated to check whether it is responsable for the resolution failure.

The `ELIM` command provides the maximum number of correlations it is possible to eliminate, so that at least one solution is produced. The `ELIM` command also provides the maximum allowed number of bonds between the atoms in all eliminated correlations. The latter constraint may be deactivated for the detection of accidentally invalid correlations.

This brief overview of LSD commands will allow users to be more familiar with the writing of data files. However, reading of Data file structure is a mandatory step in the learning of the LSD command language.

## Command interpreter

In order to process the content of an LSD input file by typing system commands, Linux and Mac users need to open a "Terminal" application, which is named "Command prompt" in Windows MSDOS.

The syntax of system commands may differ between Linux/Mac and MSDOS.

Both command interpreters indicate that the user may start to type a command by displaying a character string named "prompt".

In the following sections, `UNIXprompt$` is the Linux/Mac prompt (Unix-type systems) and `DOSprompt$` is the Windows prompt. The commands that follow the simple `prompt$` are valid for the two types of command interpreter.

In both cases, use the `cd` command to set the LSD executable in the current directory.

The Linux/Mac users need to have the current directory (named .) in the list of directories in which the Terminal searches the executable files. This can temporarily be achieved by typing

`UNIXprompt$ export PATH=.:$PATH`

## From data to structures

A data file named "pinene" is provided in the Data folder.
Running LSD on it is simple achieved using:

`UNIXprompt$ cp Data/pinene .`
`DOSprompt$ copy Data\pinene.lsd .`

`UNIXprompt$ lsd pinene`
`DOSprompt$ lsd pinene.lsd`

LSD writes that 1 solution is found.
A file named pinene.sol is created, containing atom connectivity information.
Any data file named abc or abc.xyz produces a solution file named abc.sol or abc.xyz.sol.
A 2D coordinate file pinene.coo can then be generated:

`prompt$ outlsd 6 < pinene.sol > pinene.coo`

The outlsd program creates 2D coordinates from connectivities.
The result is viewed using a Postscript® previewer.
Postscript drawings are first produced with:

`prompt$ genpos < pinene.coo > pinene.ps`

and displayed on screen using:

`prompt$ xpsview pinene.ps`

if xpsview is the currently available Postscript display program (might be gv or gsview32).
A double click on the pinene.ps file icon shows the result as well.

## Very quick start

The command:

`prompt$ solve pinene`

does the whole job in one shot: structure resolution, creation and display of the structure drawings.
It is generally not a good idea to proceed this way with a new data set.
However, this can be done once the data set runs from the command line without any error (see From data to structures).

## Drawing improvement

The coordinates generated by outlsd sometime produce drawings that are difficult to read.
A simple program named m_edit was written in order to interactively improve the quality of the structure drawings.
You need to have Tcl/Tk and the `wish` command installed in order to run M_EDIT (version 8.0 or later).
The command

`prompt$ m_edit`

launches m_edit.
The File menu allows to read and save files, and to exit from the program. The View menu is used to navigate forward and backward through a set of structures within a file. The supported file formats are .coo (the LSD-specific format) and .mol.

Using m_edit is very intuitive: atoms are moved using the left mouse button.
There is no multiple atom selection mechanism available yet, sorry.

Molecules are selected by default, as shown by their title, written in black. The Select menu allow to unselect(title in red)/reselect(title in black) molecules. The status of the current molecule can be changed by clicking on the title. Selected molecules can be kept (and the unselected one removed) using the Keep item of the Select menu.

Molecule drawings can be horizontally and vertically flipped using the Arrange menu.
A buffer (Buffer menu) was added, so that a modified molecule set (item Save To) can be retrieved (item Load From).

## Data file structure

A data file is made of commands and comments.
The number of commands is limited to 300.
A comment is everything between a ";" and the end of the line.

A command is made of a command mnemonic, generally followed by 1 to 5 parameters.
All parts of a command are separated by spaces. Commands are case-sensitive.
From version 3.2.0 included, the `EXIT` command may be omitted. If there, everything beyond it is ignored.

All command mnemonics are made of 4 alphanumeric characters.
Some of them end with space characters (`^`), such as `CH^^`.

Mnemonics are followed by parameters, separated by blanks.
The parameter types are described using the following symbols:

- I: a positive integer (0 included).
- T: -1, 0, or 1.
- V: a single positive (0 included) integer or a set of positive (0 included) integers.
  A set is delimited by parentheses and the items are separated by blanks.
  The number of items is 4 or less.
- A: an atom symbol : `C N N5 O S S4 S6 F Cl Br I P P5 Si B X` only.
  It may also be `A` in sub-atom definition, see the Substructural information paragraph.
- Ln: an atom's list reference, n is strictly positive.
- B: stands for I or Ln.
- S: a set of positive integers separated by spaces.
  The difference with V-type parameters is the absence of parenthesis.
  A S-type argument is always the last one in the command line.
- Sn : an atom's reference number, according to substructure numbering. Example: `S1`.
- R: a real number.
- Fn: a substructure reference number, n is strictly positive.
- C: a character string, enclosed by double quotes ("). Its length is not limited and it may extend over many lines.
- H: an optional sign: either + or -.
- O: an optional positive (0 included) integer.
- Z: -1, 0, 1 or 2.

The parameters of a command are successively referenced by P1, P2, P3, P4 and P5.
The `EXIT` command is the only one without any parameter.

### Basic commands

- `MULT` I A I I Z: defines atom status.
  - P1: atom number, arbitrary. Atom 0 is undefined.
    Atoms must be numbered between 1 and 60.
    Skipping numbers is theoretically possible but was not tested.
  - P2: atomic symbol. Valid atomic symbols are `C N N5 O S S4 S6 F Cl Br I P P5 Si B X`.
    `S` is a divalent sulfur atom, `S4` is a tetravalent one and `S6` is hexavalent.
    `N5` and `P5` are pentavalent nitrogen and phosphorus atoms.
    The valence and mass of atom `X` are defined using the `VALE` command.
  - P3: 1, 2 or 3, for sp, sp2 and sp3 atoms.
    To set the hybridization state, the following rules apply:
    An atom involved in exactly one double bond is sp2.
    An atom involved in a triple bond or two double bonds is sp.
  - P4: number of hydrogen atoms that are bonded to the atom.
  - P5: formal electric charge: -1, 0, 1 or 2 (facultative, equal to 0 by default).
  Example: `MULT 1 C 2 0`. Atom 1 is a quaternary (`0`) sp2 (`2`) carbon (`C`).

- `VALE` A I R: sets valence and mass of atom X.
  - P1: symbol (X).
  - P2: valence.
  - P3: mass.
  Remark: `VALE` is not compatible with the `DUPL 2` command.

- `BOND` I I: bond
  - P1: atom 1.
  - P2: atom 2.

- `HMQC` (or `HSQC`) I I: heteronuclear correlation through 1 bond
  - P1: non hydrogen atom.
  - P2: hydrogen atom.
  Two inequivalent hydrogen atoms bound to the same atom may have different numbers.
  It is generally useful (but not mandatory) to give identical numbers to a non-hydrogen atom and to the hydrogen atom(s) that is (are) directly bound.
  Example: `HSQC 4 4`. Carbon 4 and hydrogen 4 are bound together.

- `COSY` V I O O: three bond COSY correlation
  - P1: hydrogen atom 1.
  - P2: hydrogen atom 2.
  - P3: optional coupling path length, lower limit.
  - P4: optional coupling path length, upper limit.
  The length of the coupling path may be extended if an `ELIM` command is present.
  When P3 is the only present optional argument, it defines the only possible coupling path length. Its minimim value is 3.
  When both P3 and P4 are present, with P3 greater or equal to 3 and P4 greater or equal to P3, the coupling path length must be in the [P3, P4] range. If P4 is equal to 0, the length must be greater to P3.
  If an `ELIM` command is present, the highest coupling path length of a correlation cannot be greater than the length value that is imposed by the `ELIM` command + 1.
  Examples:
  - `COSY 2 9`: Hydrogen atom 2 correlates with hydrogen atom 9 through 3 bonds.
  - `COSY (4 6) 9`: Hydrogen atom 4 or 6 correlates with hydrogen atom 9 through 3 bonds.
  - `COSY 5 9 3 4`: Hydrogen atom 5 correlates with hydrogen atom 9 through 3 or 4 bonds. This correlation will never be eliminated, even if an `ELIM` command is present.

- `HMBC` V I O O: heteronuclear correlation through 2 or 3 bonds
  - P1: non hydrogen atom number or a list of them.
  - P2: hydrogen atom number.
  - P3: optional coupling path length, lower limit.
  - P4: optional coupling path length, upper limit.
  The length of the coupling path may be extended if an `ELIM` command is present.
  When P3 is the only present optional argument, it defines the only possible coupling path length. Its minimim value is 2.
  When both P3 and P4 are present, with P3 greater or equal to 2 and P4 greater or equal to P3, the coupling path length must be in the [P3, P4] range. If P4 is equal to 0, the length must be greater to P3.
  If an `ELIM` command is present, the highest coupling path length of a correlation cannot be greater than the length value that is imposed by the `ELIM` command.
  Examples:
  - `HMBC 3 8`: Atom 3 correlates with hydrogen atom 8.
  - `HMBC (4 5) 8`: Atom 4 or 5 correlates with hydrogen atom 8.
  - `HMBC 6 8 2`: Atom 6 correlates with hydrogen atom 8 through 2 bonds.
  - `HMBC 6 8 4`: Atom 6 correlates with hydrogen atom 8 through 4 bonds. This is only possible if an `ELIM` command is present.
  - `HMBC 6 8 2 3`: Atom 6 correlates with hydrogen atom 8 through 2 or 3 bonds. This correlation will never be eliminated, even if an `ELIM` command is present.
  The sum of HMBC and COSY correlation numbers is limited to 100.

- `LIST` Ln S: defines a list of atoms
  - P1: list index, n is comprised between 1 and 20.
  - P2: non hydrogen atoms numbers.
  See below for other list definition commands.
  Example: `LIST L1 4 6 14`: The L1 list contains the atoms 4, 6 and 14.

- `PROP` B I Ln H: environment of atoms
  - P1: the atom(s) referenced in P1 have exactly P2 neighbors in P3.
  - P2: exact number of neighbors. The value 0 stands for "all".
  - P3: neighbors list.
  - P4: optional sign (+ or -).
  Examples:
  - `PROP L1 0 L2`: Each atom in L1 has all its neighbors in L2.
  - `PROP 12 1 L3`: Atom 12 has exactly 1 neighbor in L3.
  - `PROP 12 1 L3 +`: Atom 12 has 1 or more neighbors in L3.
  - `PROP 12 1 L3 -`: Atom 12 has 1 or less neighbor in L3.
  - `PROP 12 0 L3 -`: Atom 12 has 0 or less (meaning exactly 0) neighbor in L3.

- `SHIX` I R: defines chemical shift of non-hydrogen atoms
  - P1: atom index (atom must be defined by a `MULT` command).
  - P2: chemical shift value.
  Example: `SHIX 1 210.5`: Chemical shift value of atom 1 is 210.5 ppm.

- `SHIH` I R: defines chemical shift of hydrogen atoms
  - P1: hydrogen index (hydrogen must be defined by an `HSQC` or `HMQC` command).
  - P2: chemical shift value.
  Example: `SHIH 15 5.4`: Chemical shift value of hydrogen 15 is 5.4 ppm.

- `EXIT`: end of data file. (may be omitted)

### List definition

The commands that are described here help to define the lists of atoms that are required by the `PROP` command.
They are interpreted in the order in which they are written.
They are hereafter sorted according to their number of arguments:

- 1 argument.
  P1, of type Ln, is the reference of the list that is created.
  - `CARB`: carbon atoms.
  - `HETE`: non-carbon atoms.
  - `SP3` : atoms with only single bonds (`SP3^`, with a trailing space).
  - `SP2` : atoms with exactly one double bond (`SP2^`).
  - `SP` : atoms with one triple bond or two double bonds (`SP^^`).
  - `FULL`: the full atom list.
  - `QUAT`: carbon atoms bound to 0 hydrogen atom.
  - `CH` : carbon atoms bound to 1 hydrogen atom (`CH^^`, with 2 trailing spaces).
  - `CH2` : carbon atoms bound to 2 hydrogen atoms (`CH2^`).
  - `CH3` : carbon atoms bound to 3 hydrogen atoms (`CH3^`).
  - `CHAR`: charged atoms.
  - `CPOS`: atoms carrying a positive charge.
  - `CNEG`: atoms carrying a negative charge.
  Example: `CARB L5`. L5 is the list of all carbon atoms of the molecule.

- 2 arguments.
  P1, of type Ln, is the reference of the list that is created. P2, of type A is an atomic symbol.
  - `ELEM`: list of all atoms of atomic symbol A.
  Example: `ELEM L2 N`. L2 is the list of all N atoms.

  P1, of type Ln, is the reference of the list that is created. P2, of type I is an integer, for comparison.
  - `GREQ`: atoms whose reference is greater than or egal to P2.
  - `LEEQ`: atoms whose reference is smaller than or egal to P2.
  - `GRTH`: atoms whose reference is strictly greater than P2.
  - `LETH`: atoms whose reference is strictly smaller than P2.
  Example: `GREQ L1 10`. L1 is the list of all atom references from 10, 10 included.

- 3 arguments.
  P1, of type B, is a list or single atom reference. P2, of type B, is a list or single atom reference. P3, of type Ln, is the reference of the list that is created.
  - `UNIO`: P3 is the union of P1 and P2.
  - `INTE`: P3 is the intersection of P1 and P2.
  - `DIFF`: P3 contains the atoms in P1 not belonging to P2.
  Example: `UNIO L1 10 L2`. L2 contains the atoms in L1 and 10.

### Execution control

- `ENTR` I: lists atoms state before problem solving.
  - P1 = 0: no listing (default).
  - P1 = 1: active state.

- `HIST` I: lists the resolution path of the solutions
  - P1 = 0: does nothing (default).
  - P1 = 1: active state.

- `DISP` I: output format
  - P1 = 0: produces bond lists.
  - P1 = 1: results are formatted for outlsd (default).

- `VERB` I: verbosity
  - P1 = 0: dummy (default).
  - P1 = 1: active state.
  - P1 = 2: very verbose.

- `PART` I: output of uncomplete solutions
  - P1 = 0: no (default).
  - P1 = 1: yes.
  This feature allows the reduction of the number of solutions by grouping them into sets presenting common structural fragments generated from correlation analysis.
  An uncomplete solution is produced by analysis of all correlations but has uncomplete atoms.
  The complete solutions would be produced by systematically pairing the remaining uncomplete atoms.
  An uncomplete solution can always be completed.

- `STEP` I: single step operation
  - P1 = 0: nothing (default).
  - P1 = 1: active state.
  An analysis step number is given to check the progression of LSD...
  The single step mode is not really useful is the absence of true interfaces.
  It requires `VERB 2`. The user is prompted for the action to be taken.

- `WORK` I: search solutions
  - P1 = 0: LSD reads and interpretes the input data only.
  - P1 = 1: active state (default).

- `MLEV` I: stop analysis at step number P1
  - P1 = 0 (default) : nothing.
  - P1 = usually the step number given by LSD when it fails...

- `DUPL` I: elimination of duplicate solutions
  - P1 = 0: duplicate structures may be produced.
  - P1 = 1: duplicate solutions are removed.
  - P1 = 2: duplicate structures are removed (default).

- `SUBS` T: substructure validation
  - P1 = 0: no substructure checking.
  - P1 = 1: accepts structures that validate the substructure constraint (default).
  - P1 = -1: accepts structures that do not validate the substructure constraint.

- `ELIM` I I: elimination of invalid HMBC and/or COSY correlations
  - P1: maximum number of eliminated correlations.
  - P2: maximum number of bonds between the atoms in eliminated correlations.
    The upper limit is P2 for a HMBC correlation and P2 + 1 for a COSY correlation.
    0 means: no limitation.
  Example : `ELIM 3 5`. 3 HMBC and/or COSY correlations, at most, can be eliminated. Each HMBC eliminated correlation is mediated through a 4J coupling (mandatory lower limited) or a 5J coupling (proposed upper limit). In the case of a COSY correlation, the interval is from 5J (mandatory lower limit) to 6J (proposed upper limit).

- `FILT` I: substructure filtering mode selection
  - P1 = 0: normal use of LSD (default).
  - P1 = 1: activates filer mode.
  In filter mode, LSD uses `VALE`, `MULT`, `BOND` and sub-structure related commands to search for the presence of the latter in the structure. Typical call of LSD in this context is "lsd < file > &>/dev/null". The returned value is :
  - -1: invalid data.
  - 0: substructure not found.
  - 1: substructure found.
  This feature is intended to be used within a shell script or in any context in which the returned value can be read.

- `CNTD` I: elimination of non-connected solutions
  - P1 = 0: no checking.
  - P1 = 1: only connected solutions are produced (default).

- `MAXS` I: limits the number of produced solutions
  - P1 = 0: no checking (default).
  - P1 > 0: execution stopped after P1 solutions.

- `MAXT` I: limits the resolution time
  - P1 = 0: no checking (default).
  - P1 > 0: execution stopped after P1 seconds.

- `CCLA` I: controls the use of C atom equivalence classes
  - P1 = 0: no classes. All 13C assignments are generated (default).
  - P1 = 1: Initially non-bonded non-correlating C atoms are equivalent.

- `COUF` C: sets the path to the solution counter file
  - P1: path to the solution counter file (default: solncounter).
  The solution counter file contains a single line with the number of presently found solutions.

- `STOF` C: sets the path to the lsd stop file
  - P1: path to the lsd stop file (default: stoplsd).
  If a solution stop file is created while lsd is running, then lsd is stopped.

- `BRUL` I: test for anti-Bredt structure
  - P1 = 0: no checking.
  - P1 = 1: anti-Bredt structures are excluded (default).

### Substructural information

Solutions found by LSD after correlation analysis and uncomplete atom pairing can be selected according to a substructure constraint.
The substructure constraint is provided by substructure definitions and by the way they are combined.
A substructure is either native (defined in the problem input file, as it was before version 3.2.0), or externally defined.
The Data/pinene file contains an example of substructural constraint coding.

A substructure is a set of sub-atoms (`SSTR` commands) that are connected by sub-bonds (`LINK` commands) and eventually pre-assigned (`ASGN` commands).

- `SSTR` Sn A V V: sub-atom status
  - P1: sub-atom number.
  - P2: sub-atom symbol.
  - P3: hybridization state, `1` (sp), `2` (sp2) or `3` (sp3) or `(2 3)` (both) or `(1 2 3)` (both).
  - P4: multiplicity.
  Example: `SSTR S1 C (2 3) (0 1 2)`. Atom 1 of the substructure is a carbon, either sp2 or sp3, with possibly 0, 1 or 2 hydrogen atoms.
  There is no a priori relationship between atom and sub-atom numbering.
  P2 may also be "A", which means "Any".
  A-type sub-atoms can match any atom of the structure.
  The number of sub-atoms is limited to 60.

- `LINK` Sn Sn: bond within the substructure.
  - P1: first sub-atom of the bond.
  - P2: second sub-atom of the bond.
  Example: `LINK S1 S2`. Sub-atoms 1 and 2 are chemically bound.
  The number of bonds between sub-atoms is limited to 60.

- `ASGN` Sn I: assignment of a sub-atom.
  - P1: sub-atom number.
  - P2: number of the corresponding atom.
  Example: `ASGN S3 5`. Sub-atom 3 is identified as being atom 5.

An external substructure is referred to by a fragment number and the path to the file that contains its definition. The latter is coded exactly in the same way as it is for a native substructure.

- `DEFF` Fn C: define fragment from its file name.
  - P1: fragment number, greater of equal to 1.
  - P2: path to the fragment.
  Example: `DEFF F3 "Filters/ring3"`. Fragment F3 is a generic 3-membered ring.

- `SKEL` FnC : define fragment from its skeleton name.
  - P1: fragment number, greater of equal to 1.
  - P2: skeleton name. Details here
  Example: `SKEL F4 "PINANE"`. Fragment F4 is the pinane skeleton.
  From version 3.4.1 included, this command is not mandatory. An external substructure could be referred to directly by the skeleton name without using a fragment number.

- `PATH` C: defines where to search for skeletons.
  - P1: path to skeleton database. Details here
  Example: `PATH "Filters/TERPENES/MONOTERP"`. Adds Filters/TERPENES/MONOTERP to the list of places in which skeleton definition files will be searched for.

Results of substructure searches are combined together to determine the validity of the current structure:

- `FEXP` C: fragment (logical) expression.
  - P1: logical expression that combines fragment search results.
    In this expression, fragments are each defined by a number preceded by "F" or directly by a skeleton name between two backquotes "`" (only possible from version 3.4.1 included).
    If the P1 character string starts with the ">" sign, the characters that follow it are interpreted as a file name. The content of this file is a logical expression that combines fragment search results.
    The fragment definitions are connected together by the `NOT`, `AND` and `OR` operators, given here in decreasing order of precedence. Precedence order may be changed by means of parenthesis.
  Examples:
  - `FEXP "NOT F1 AND F2"`. Is equivalent to `FEXP "(NOT F1) AND F2"`.
  - `FEXP "F1 AND F2 OR F3"`. Is equivalent to `FEXP "(F1 AND F2) OR F3"`.
  - `FEXP "`LABDANE` OR `CLERODANE``.

The `DEFF`, `SKEL`, `PATH`, and `FEXP` commands implement in LSD the functionnality of solution filtering.
In the absence of `FEXP` and `SKEL` commands, the native substructure is taken into account, if it exists.
If a `FEXP` or `SKEL` command is present, the native substructure is accessed to via `F0` as if a `DEFF F0 "..."` existed. If no native substructure is defined, `F0` is the empty substructure, the one that always matches a structure.
If the parameter of `SUBS` is 0, no substructure search at all is performed. If it is -1, the result of the evaluation of the logical expression that is provided by the `FEXP` command is inverted.

The `SKEL` command associates a fragment number (see `DEFF`) with a SKELeton name, a name like PINANE that refers to a substructure that fits with pinene and with many other natural compounds.
LSD searches in a user provided sketelon database for a file that describes that skeleton. The fragment number is then associated with the file path that leads to the corresponding LSD substructure file.
The default location of the skeleton database is the Filters directory that comes with the other LSD files. A `PATH` command replaces the default location of the skeleton database by a new one. Subsequent `PATH` commands define alternative locations in which skeletons can also be found.
Each time a `SKEL` command is processed all the defined skeleton database directories are explored and all their embedded sub-directories as well. Each time a file named toc (Table of Contents) is found during this exploration, its contents is scanned. If the searched skeleton name is found at line n of a toc file, then a file named filen must exist in the same directory and should be the substructure description file that corresponds to the desired skeleton.
The `PATH` command has no influence on the behavior of the `DEFF` command. A toc file must only contain a single skeleton name per line, a name must not contain a separation character such as a blank or a tab.
A converter named mol2ab is available to help users translate MDL .mol files into LSD substructure description files.

LSD comes with a non-exhaustive collection of natural product skeletons. They are provided as MDL .mol files in the MOL directory so that users could create LSD substructure files at their own convenience using mol2ab. The result of the conversion of all files in the MOL directory is stored in Filters/TERPENES directory.

## Creating substructure files with mol2ab

The mol2ab program converts structures in .mol format into substructures for LSD.
Users can convert the .mol files that are supplied with LSD or their personal files, produced by any chemical structure drawing program.
The following rules apply to the conversion process:

- Any hydrogen atom from the structure may be abstracted
- Any single bond may be converted to a double bond
- Any double bond may be converted to a triple bond
- A triple bond remains a triple bond
- The atomic element names are preserved

Usage:
`prompt$ mol2ab Directory pilot-file`

The pilot-file must contain lines with two fields:

- first field is the skeleton name that will be associated to the .mol file
- second field is a .mol file name that must exist in the current directory

The Directory must exist and should be empty. It will be filled with the initial .mol files (renamed file1.mol ... filen.mol) and their equivalent LSD files (file1 ... filen) if n is the number of lines in the pilot file.
A toc file is also created so that LSD can retrieve substructure files from skeleton names.

Example: The making of Filters/MONOTERP.
The following commands are written for UNIX-like systems.
The current directory of the command interpreter is initially the one of LSD.
For Windows, the `/`s must by replaced by `\`s.

     prompt$  cd MOL
     prompt$  cd Monoterp_mol
     prompt$  mkdir MONOTERP
     prompt$  ../../mol2ab MONOTERP ../monoterp_mol.txt

## Result processing with outlsd

In order to use outlsd, LSD must not be run with `DISP 0`.
The outlsd program reads from and writes to standard devices.
It takes an integer n comprised between 1 and 9 as argument.

`prompt$ outlsd 7 < pinene.sol > pinene.mol`

Depending on n, the result contains

- n = 1: bond lists (no real interest)
- n = 5: SMILES chains
- n = 6: 2D coordinates for genpos and m_edit (.coo extension)
- n = 7: 2D MOL or SD format (.mol or .sdf extension) for some commercial products and m_edit
- n = 8: 3D SD format (.sdf extension) with fancy 3D coordinates, implicit H atoms
- n = 9: 3D SD format (.sdf extension) with fancy 3D coordinates, explicit H atoms

Options 2, 3 and 4 are not available anymore, starting from version 3.4.1.

Commercial software may read the multi-molecule structure files that are produced with option 7 only if their extension is .sdf.

## Result viewing with genpos

The option 6 of outlsd produces an output that starts with the magic word DRAW, in a format suitable for its treatment by the genpos program. genpos reads and writes from standard devices and generates PostScript instructions.

`prompt$ genpos < pinene.coo > pinene.ps`

The resulting file can be opened by Postscript previewers or be sent to Postscript printers.

Copyright(C)2000 CNRS-UMR 7312-Jean-Marc Nuzillard