SmilesGenerator
Date: 2019-10-22

org.jmol.smiles

## Class SmilesGenerator

- java.lang.Object
- - org.jmol.smiles.SmilesGenerator

-     public class SmilesGenerator
      extends java.lang.Object

  Double bond, allene, square planar and tetrahedral stereochemistry only not octahedral or trigonal bipyramidal. No attempt at canonicalization -- unnecessary for model searching. see SmilesMatcher and package.html for details Bob Hanson, Jmol 12.0.RC17 2010.06.5

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private int` | `ac`
    `private boolean` | `addAtomComment`
    `private SimpleNode[]` | `alleneStereo`
    `private boolean` | `aromaticDouble`
    `private javajs.util.Lst<javajs.util.BS>` | `aromaticRings`
    `private SimpleNode[]` | `atemp`
    `private Node[]` | `atoms`
    `private javajs.util.BS` | `bsAromatic`
    `private javajs.util.BS` | `bsBondsDn`
    `private javajs.util.BS` | `bsBondsUp`
    `private javajs.util.BS` | `bsIncludingH`
    `private javajs.util.BS` | `bsRingKeys`
    `private javajs.util.BS` | `bsSelected`
    `private javajs.util.BS` | `bsToDo`
    `private int` | `chainCheck`
    `private boolean` | `explicitH`
    `private int` | `flags`
    `(package private) boolean` | `getAromatic`
    `private java.util.Map<java.lang.String,java.lang.Object[]>` | `htRings`
    `private java.util.Map<java.lang.String,java.lang.Object[]>` | `htRingsSequence`
    `private int` | `iHypervalent`
    `private boolean` | `isPolyhedral`
    `private boolean` | `noBioComment`
    `private boolean` | `noStereo`
    `private int` | `nPairs`
    `private int` | `nPairsMax`
    `private boolean` | `openSMILES`
    `javajs.util.P3` | `polySmilesCenter`
    `private SimpleNode` | `prevAtom`
    `private SimpleNode[]` | `prevSp2Atoms`
    `private int` | `ptAtom`
    `private int` | `ptSp2Atom0`
    `private javajs.util.Lst<javajs.util.BS>` | `ringSets`
    `private SmilesMatcher` | `sm`
    `private SmilesStereo` | `smilesStereo`
    `private boolean` | `topologyOnly`
    `private VTemp` | `vTemp`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SmilesGenerator()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private void` | `addBracketedBioName(javajs.util.SB sb, Node atom, java.lang.String atomName, boolean addComment)`
    `private java.lang.String` | `addStereoCheck(int level, int atomIndex, SimpleNode atom, java.lang.String s, javajs.util.BS bsDone)` checks a group and either adds a new group to the growing check string or returns null
    `private java.lang.String` | `checkStereoPairs(SimpleNode atom, int atomIndex, SimpleNode[] stereo, int stereoFlag)`
    `private void` | `dumpRingKeys(javajs.util.SB sb, java.util.Map<java.lang.String,java.lang.Object[]> ht)`
    `private void` | `generateRingData()` get aromaticity, ringSets, and aromaticRings fields so that we can assign / and \ and also provide inter-aromatic single bond
    `private java.lang.String` | `getBioSmiles(javajs.util.BS bsSelected, java.lang.String comment, int flags)`
    `private java.lang.String` | `getBondOrder(Edge bondPrev, int atomIndex, int prevIndex, boolean isAromatic)`
    `private char` | `getBondStereochemistry(Edge bond, SimpleNode atomFrom)` Retrieves the saved character based on the index of the bond.
    `private java.lang.String` | `getRingCache(int i0, int i1, java.util.Map<java.lang.String,java.lang.Object[]> ht)`
    `protected static java.lang.String` | `getRingKey(int i0, int i1)`
    `private java.lang.String` | `getRingPointer(int i)`
    `(package private) java.lang.String` | `getSmiles(SmilesMatcher sm, Node[] atoms, int ac, javajs.util.BS bsSelected, java.lang.String comment, int flags)`
    `private Node` | `getSmilesAt(javajs.util.SB sb, SimpleNode atom, boolean allowConnectionsToOutsideWorld, boolean allowBranches, boolean forceBrackets)`
    `private java.lang.String` | `getSmilesComponent(Node atom, javajs.util.BS bs, boolean allowBioResidues, boolean allowConnectionsToOutsideWorld, boolean forceBrackets)` creates a valid SMILES string from a model.
    `private boolean` | `isSameAromaticRing(int a1, int a2)`
    `private void` | `setBondDirections()` Creates global BitSets bsBondsUp and bsBondsDown.
    `(package private) void` | `sortBonds(SimpleNode atom, SimpleNode refAtom, javajs.util.P3 center)`
    `private java.lang.String` | `sortInorganic(SimpleNode atom, javajs.util.Lst<Edge> v, VTemp vTemp)` We must sort the bond vector such that a diaxial pair is first and last.
    `private void` | `swapArray(SimpleNode[] a, int i0, int i1, int i2)` swap slices of an array [i0 i1) with [i1 i2)

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### atoms

          private Node[] atoms

    - #### ac

          private int ac

    - #### bsSelected

          private javajs.util.BS bsSelected

    - #### bsAromatic

          private javajs.util.BS bsAromatic

    - #### flags

          private int flags

    - #### explicitH

          private boolean explicitH

    - #### ringSets

          private javajs.util.Lst<javajs.util.BS> ringSets

    - #### vTemp

          private VTemp vTemp

    - #### nPairs

          private int nPairs

    - #### nPairsMax

          private int nPairsMax

    - #### bsBondsUp

          private javajs.util.BS bsBondsUp

    - #### bsBondsDn

          private javajs.util.BS bsBondsDn

    - #### bsToDo

          private javajs.util.BS bsToDo

    - #### prevAtom

          private SimpleNode prevAtom

    - #### prevSp2Atoms

          private SimpleNode[] prevSp2Atoms

    - #### alleneStereo

          private SimpleNode[] alleneStereo

    - #### htRingsSequence

          private java.util.Map<java.lang.String,java.lang.Object[]> htRingsSequence

    - #### htRings

          private java.util.Map<java.lang.String,java.lang.Object[]> htRings

    - #### bsRingKeys

          private javajs.util.BS bsRingKeys

    - #### bsIncludingH

          private javajs.util.BS bsIncludingH

    - #### topologyOnly

          private boolean topologyOnly

    - #### getAromatic

          boolean getAromatic

    - #### addAtomComment

          private boolean addAtomComment

    - #### noBioComment

          private boolean noBioComment

    - #### aromaticDouble

          private boolean aromaticDouble

    - #### noStereo

          private boolean noStereo

    - #### openSMILES

          private boolean openSMILES

    - #### polySmilesCenter

          public javajs.util.P3 polySmilesCenter

    - #### smilesStereo

          private SmilesStereo smilesStereo

    - #### isPolyhedral

          private boolean isPolyhedral

    - #### aromaticRings

          private javajs.util.Lst<javajs.util.BS> aromaticRings

    - #### sm

          private SmilesMatcher sm

    - #### iHypervalent

          private int iHypervalent

    - #### ptAtom

          private int ptAtom

    - #### ptSp2Atom0

          private int ptSp2Atom0

    - #### atemp

          private SimpleNode[] atemp

    - #### chainCheck

          private int chainCheck

  - ### Constructor Detail

    - #### SmilesGenerator

          public SmilesGenerator()

  - ### Method Detail

    - #### getSmiles

          java.lang.String getSmiles(SmilesMatcher sm,
                                     Node[] atoms,
                                     int ac,
                                     javajs.util.BS bsSelected,
                                     java.lang.String comment,
                                     int flags)
                              throws InvalidSmilesException

      Throws:
        `InvalidSmilesException`

    - #### getBioSmiles

          private java.lang.String getBioSmiles(javajs.util.BS bsSelected,
                                                java.lang.String comment,
                                                int flags)
                                         throws InvalidSmilesException

      Throws:
        `InvalidSmilesException`

    - #### addBracketedBioName

          private void addBracketedBioName(javajs.util.SB sb,
                                           Node atom,
                                           java.lang.String atomName,
                                           boolean addComment)

    - #### getSmilesComponent

          private java.lang.String getSmilesComponent(Node atom,
                                                      javajs.util.BS bs,
                                                      boolean allowBioResidues,
                                                      boolean allowConnectionsToOutsideWorld,
                                                      boolean forceBrackets)
                                               throws InvalidSmilesException

      creates a valid SMILES string from a model. TODO: stereochemistry other than square planar and tetrahedral
      Parameters:
        `atom` -
        `bs` -
        `allowBioResidues` -
        `allowConnectionsToOutsideWorld` -
        `forceBrackets` -
      Returns:
        SMILES
      Throws:
        `InvalidSmilesException`

    - #### generateRingData

          private void generateRingData()
                                 throws InvalidSmilesException

      get aromaticity, ringSets, and aromaticRings fields so that we can assign / and \ and also provide inter-aromatic single bond
      Throws:
        `InvalidSmilesException`

    - #### getBondStereochemistry

          private char getBondStereochemistry(Edge bond,
                                              SimpleNode atomFrom)

      Retrieves the saved character based on the index of the bond. bsBondsUp and bsBondsDown are global fields.
      Parameters:
        `bond` -
        `atomFrom` -
      Returns:
        the correct character '/', '\\', '\0' (meaning "no stereochemistry")

    - #### setBondDirections

          private void setBondDirections()

      Creates global BitSets bsBondsUp and bsBondsDown. Noniterative.

    - #### getSmilesAt

          private Node getSmilesAt(javajs.util.SB sb,
                                   SimpleNode atom,
                                   boolean allowConnectionsToOutsideWorld,
                                   boolean allowBranches,
                                   boolean forceBrackets)

    - #### swapArray

          private void swapArray(SimpleNode[] a,
                                 int i0,
                                 int i1,
                                 int i2)

      swap slices of an array [i0 i1) with [i1 i2)
      Parameters:
        `a` -
        `i0` -
        `i1` -
        `i2` -

    - #### getBondOrder

          private java.lang.String getBondOrder(Edge bondPrev,
                                                int atomIndex,
                                                int prevIndex,
                                                boolean isAromatic)

      Parameters:
        `bondPrev` -
        `atomIndex` -
        `prevIndex` -
        `isAromatic` -
      Returns:
        "-", "=", "#", "$", or ""

    - #### isSameAromaticRing

          private boolean isSameAromaticRing(int a1,
                                             int a2)

    - #### sortBonds

          void sortBonds(SimpleNode atom,
                         SimpleNode refAtom,
                         javajs.util.P3 center)

    - #### sortInorganic

          private java.lang.String sortInorganic(SimpleNode atom,
                                                 javajs.util.Lst<Edge> v,
                                                 VTemp vTemp)

      We must sort the bond vector such that a diaxial pair is first and last. Then we assign stereochemistry based on what is left. The assignment is not made if there are no diaxial groups or with octahedral if there are fewer than three or trigonal bipyramidal with no axial ligands.
      Parameters:
        `atom` -
        `v` -
        `vTemp` -
      Returns:
        "@" or "@@" or ""

    - #### checkStereoPairs

          private java.lang.String checkStereoPairs(SimpleNode atom,
                                                    int atomIndex,
                                                    SimpleNode[] stereo,
                                                    int stereoFlag)

    - #### addStereoCheck

          private java.lang.String addStereoCheck(int level,
                                                  int atomIndex,
                                                  SimpleNode atom,
                                                  java.lang.String s,
                                                  javajs.util.BS bsDone)

      checks a group and either adds a new group to the growing check string or returns null
      Parameters:
        `level` -
        `atomIndex` -
        `atom` -
        `s` -
        `bsDone` -
      Returns:
        null if duplicate

    - #### getRingCache

          private java.lang.String getRingCache(int i0,
                                                int i1,
                                                java.util.Map<java.lang.String,java.lang.Object[]> ht)

    - #### getRingPointer

          private java.lang.String getRingPointer(int i)

    - #### dumpRingKeys

          private void dumpRingKeys(javajs.util.SB sb,
                                    java.util.Map<java.lang.String,java.lang.Object[]> ht)

    - #### getRingKey

          protected static java.lang.String getRingKey(int i0,
                                                       int i1)