SmilesSearch
Date: 2019-10-22

org.jmol.smiles

## Class SmilesSearch

- java.lang.Object
- - org.jmol.util.JmolMolecule
  - - org.jmol.smiles.SmilesSearch

-     public class SmilesSearch
      extends JmolMolecule

  A class to build and carry out a SMILES or SMARTS match
  Author:
    Bob Hanson hansonr@stolaf.edu

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `(package private) boolean` | `aromaticDefined`
    `(package private) boolean` | `aromaticDouble`
    `(package private) boolean` | `aromaticMMFF94`
    `(package private) boolean` | `aromaticOpen`
    `(package private) boolean` | `aromaticPlanar`
    `(package private) boolean` | `aromaticStrict`
    `(package private) boolean` | `aromaticUnknown`
    `(package private) boolean` | `asVector`
    `(package private) java.lang.String` | `atropKeys`
    `(package private) javajs.util.BS` | `bsAromatic`
    `(package private) javajs.util.BS` | `bsAromatic5`
    `(package private) javajs.util.BS` | `bsAromatic6`
    `private javajs.util.BS` | `bsAromaticRings`
    `private javajs.util.BS` | `bsCheck`
    `private javajs.util.BS` | `bsFound`
    `private javajs.util.BS` | `bsReturn`
    `private javajs.util.BS` | `bsSelected`
    `(package private) boolean` | `exitFirstMatch`
    `(package private) int` | `flags`
    `(package private) boolean` | `getMaps`
    `(package private) boolean` | `groupByModel`
    `(package private) boolean` | `haveBondStereochemistry`
    `(package private) boolean` | `haveComponents`
    `(package private) boolean` | `haveSelected`
    `(package private) boolean` | `haveTopo`
    `private java.util.Map<java.lang.String,java.lang.Object>` | `htNested`
    `(package private) boolean` | `ignoreAtomClass`
    `(package private) boolean` | `ignoreStereochemistry`
    `(package private) boolean` | `invertStereochemistry`
    `(package private) boolean` | `isNormalized`
    `private boolean` | `isRingCheck`
    `private boolean` | `isSilent`
    `(package private) boolean` | `isSmarts`
    `(package private) boolean` | `isTopology`
    `(package private) SmilesAtom` | `lastChainAtom`
    `boolean` | `mapUnique`
    `(package private) javajs.util.Lst<SmilesMeasure>` | `measures`
    `(package private) int` | `nDouble`
    `(package private) boolean` | `needAromatic`
    `(package private) boolean` | `needRingData`
    `(package private) boolean` | `needRingMemberships`
    `private SmilesBond` | `nestedBond`
    `private int` | `nNested`
    `(package private) boolean` | `noAromatic`
    `(package private) java.lang.String` | `pattern`
    `(package private) boolean` | `patternAromatic` Set in set() to indicate to SmilesMatcher that the string already has aromatic atoms indicated and so no aromaticity model should be applied.
    `(package private) SmilesAtom[]` | `patternAtoms`
    `(package private) boolean` | `patternBioSequence`
    `private int[]` | `ringConnections`
    `(package private) int` | `ringCount`
    `private int[]` | `ringCounts`
    `private javajs.util.BS[]` | `ringData`
    `(package private) int` | `ringDataMax`
    `(package private) javajs.util.Lst<javajs.util.BS>` | `ringSets`
    `private int` | `selectedAtomCount`
    `(package private) boolean` | `setAtropicity`
    `(package private) SmilesStereo` | `stereo`
    `private static int` | `SUBMODE_NESTED`
    `private static int` | `SUBMODE_OR`
    `private static int` | `SUBMODE_RINGCHECK`
    `(package private) SmilesSearch[]` | `subSearches`
    `(package private) int` | `targetAtomCount`
    `(package private) Node[]` | `targetAtoms`
    `(package private) SmilesSearch` | `top`
    `private javajs.util.Lst<javajs.util.BS>` | `uniqueList`
    `(package private) VTemp` | `v`
    `private javajs.util.Lst<java.lang.Object>` | `vReturn`

    - ### Fields inherited from class org.jmol.util.JmolMolecule

      `ac, altElementCounts, altElementMax, atomList, elementCounts, elementNumberMax, firstAtomIndex, indexInModel, mf, modelIndex, moleculeIndex, nElements, nodes`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SmilesSearch()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `(package private) SmilesAtom` | `addAtom()`
    `(package private) static int` | `addFlags(int flags, java.lang.String strFlags)`
    `(package private) int` | `addNested(java.lang.String pattern)`
    `(package private) SmilesAtom` | `appendAtom(SmilesAtom sAtom)`
    `private boolean` | `checkMatchBond(SmilesAtom patternAtom, SmilesAtom atom1, SmilesBond patternBond, int iAtom, int matchingAtom, Edge bond)`
    `private boolean` | `checkPrimitiveAtom(SmilesAtom patternAtom, int iTarget)`
    `private boolean` | `checkPrimitiveBond(SmilesBond patternBond, int iAtom1, int iAtom2, Edge bond)`
    `private boolean` | `checkStereochemistry()`
    `(package private) void` | `clear()`
    `private void` | `clearBsFound(int iAtom)`
    `(package private) void` | `createTopoMap(javajs.util.BS bsAro)`
    `private boolean` | `doCheckAtom(int j)`
    `(package private) Node` | `findImplicitHydrogen(Node atom)`
    `private int` | `getAtropIndex(SmilesBond b, boolean isFirst)`
    `private javajs.util.BS` | `getBSAromaticRings()`
    `(package private) int` | `getMissingHydrogenCount()`
    `(package private) java.lang.Object` | `getNested(int iNested)`
    `(package private) void` | `getRingData(javajs.util.Lst<javajs.util.BS>[] vRings, boolean needRingData, boolean doTestAromatic)`
    `(package private) void` | `getSelections()` htNested may contain $(select xxxx) primitives.
    `(package private) static boolean` | `isRingBond(javajs.util.Lst<javajs.util.BS> ringSets, javajs.util.BS bsAromaticRings, int a1, int a2)`
    `private boolean` | `nextPatternAtom(int atomNum, int iAtom, boolean firstAtomOnly, int c)`
    `private boolean` | `nextTargetAtom(SmilesAtom patternAtom, Node jmolAtom, int atomNum, int iAtom, boolean firstAtomOnly, int c)` Check for a specific match of a model set atom with a pattern position
    `(package private) static void` | `normalizeAromaticity(SmilesAtom[] atoms, javajs.util.BS bsAromatic, int flags)` create a temporary object to generate the aromaticity in a SMILES pattern for which there is no explicit aromaticity (Kekule) Not applicable to SMARTS
    `(package private) java.lang.Object` | `search()` the start of the search.
    `private java.lang.Object` | `search2(boolean firstAtomOnly)`
    `(package private) void` | `set()`
    `(package private) void` | `setFlags(int flags)`
    `(package private) void` | `setNested(int iNested, java.lang.Object o)`
    `(package private) void` | `setRingData(javajs.util.BS bsA, javajs.util.Lst<javajs.util.BS>[] vRings, boolean doProcessAromatic)` Sets up all aromatic and ring data.
    `(package private) void` | `setSelected(javajs.util.BS bs)`
    `(package private) void` | `setTop(SmilesSearch parent)`
    `private void` | `setTopoCoordinates(SmilesAtom dbAtom1, SmilesAtom dbAtom2, SmilesAtom dbAtom1a, SmilesAtom dbAtom2a, int bondType)`
    `(package private) java.lang.Object` | `subsearch(SmilesSearch search, int submode)`
    `java.lang.String` | `toString()`

    - ### Methods inherited from class org.jmol.util.JmolMolecule

      `addMolecule, getBitSetForMF, getBranchBitSet, getMolecularFormula, getMolecularFormulaAtoms, getMolecules`

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

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

- - ### Field Detail

    - #### isSmarts

          boolean isSmarts

    - #### top

          SmilesSearch top

    - #### pattern

          java.lang.String pattern

    - #### patternAtoms

          SmilesAtom[] patternAtoms

    - #### targetAtoms

          Node[] targetAtoms

    - #### targetAtomCount

          int targetAtomCount

    - #### bsSelected

          private javajs.util.BS bsSelected

    - #### v

          VTemp v

    - #### aromaticOpen

          boolean aromaticOpen

    - #### aromaticStrict

          boolean aromaticStrict

    - #### aromaticPlanar

          boolean aromaticPlanar

    - #### aromaticDouble

          boolean aromaticDouble

    - #### aromaticMMFF94

          boolean aromaticMMFF94

    - #### aromaticDefined

          boolean aromaticDefined

    - #### aromaticUnknown

          boolean aromaticUnknown

    - #### noAromatic

          boolean noAromatic

    - #### ignoreAtomClass

          boolean ignoreAtomClass

    - #### ignoreStereochemistry

          boolean ignoreStereochemistry

    - #### invertStereochemistry

          boolean invertStereochemistry

    - #### exitFirstMatch

          boolean exitFirstMatch

    - #### groupByModel

          boolean groupByModel

    - #### setAtropicity

          boolean setAtropicity

    - #### patternAromatic

          boolean patternAromatic

      Set in set() to indicate to SmilesMatcher that the string already has aromatic atoms indicated and so no aromaticity model should be applied.

    - #### haveTopo

          boolean haveTopo

    - #### isTopology

          boolean isTopology

    - #### patternBioSequence

          boolean patternBioSequence

    - #### subSearches

          SmilesSearch[] subSearches

    - #### haveSelected

          boolean haveSelected

    - #### haveBondStereochemistry

          boolean haveBondStereochemistry

    - #### stereo

          SmilesStereo stereo

    - #### needRingData

          boolean needRingData

    - #### needAromatic

          boolean needAromatic

    - #### needRingMemberships

          boolean needRingMemberships

    - #### nDouble

          int nDouble

    - #### ringDataMax

          int ringDataMax

    - #### ringSets

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

    - #### ringCount

          int ringCount

    - #### measures

          javajs.util.Lst<SmilesMeasure> measures

    - #### flags

          int flags

    - #### bsAromatic

          javajs.util.BS bsAromatic

    - #### bsAromatic5

          javajs.util.BS bsAromatic5

    - #### bsAromatic6

          javajs.util.BS bsAromatic6

    - #### atropKeys

          java.lang.String atropKeys

    - #### lastChainAtom

          SmilesAtom lastChainAtom

    - #### asVector

          boolean asVector

    - #### getMaps

          boolean getMaps

    - #### isNormalized

          boolean isNormalized

    - #### haveComponents

          boolean haveComponents

    - #### isSilent

          private boolean isSilent

    - #### isRingCheck

          private boolean isRingCheck

    - #### selectedAtomCount

          private int selectedAtomCount

    - #### ringData

          private javajs.util.BS[] ringData

    - #### ringCounts

          private int[] ringCounts

    - #### ringConnections

          private int[] ringConnections

    - #### bsFound

          private javajs.util.BS bsFound

    - #### htNested

          private java.util.Map<java.lang.String,java.lang.Object> htNested

    - #### nNested

          private int nNested

    - #### nestedBond

          private SmilesBond nestedBond

    - #### vReturn

          private javajs.util.Lst<java.lang.Object> vReturn

    - #### uniqueList

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

    - #### bsReturn

          private javajs.util.BS bsReturn

    - #### bsCheck

          private javajs.util.BS bsCheck

    - #### mapUnique

          public boolean mapUnique

    - #### bsAromaticRings

          private javajs.util.BS bsAromaticRings

    - #### SUBMODE_NESTED

          private static final int SUBMODE_NESTED

      See Also:
        Constant Field Values

    - #### SUBMODE_RINGCHECK

          private static final int SUBMODE_RINGCHECK

      See Also:
        Constant Field Values

    - #### SUBMODE_OR

          private static final int SUBMODE_OR

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### SmilesSearch

          public SmilesSearch()

  - ### Method Detail

    - #### setTop

          void setTop(SmilesSearch parent)

    - #### addFlags

          static final int addFlags(int flags,
                                    java.lang.String strFlags)

    - #### setFlags

          void setFlags(int flags)

    - #### set

          void set()
            throws InvalidSmilesException

      Throws:
        `InvalidSmilesException`

    - #### setSelected

          void setSelected(javajs.util.BS bs)

    - #### addAtom

          SmilesAtom addAtom()

    - #### appendAtom

          SmilesAtom appendAtom(SmilesAtom sAtom)

    - #### addNested

          int addNested(java.lang.String pattern)

    - #### clear

          void clear()

    - #### clearBsFound

          private void clearBsFound(int iAtom)

    - #### setNested

          void setNested(int iNested,
                         java.lang.Object o)

    - #### getNested

          java.lang.Object getNested(int iNested)

    - #### getMissingHydrogenCount

          int getMissingHydrogenCount()

    - #### setRingData

          void setRingData(javajs.util.BS bsA,
                           javajs.util.Lst<javajs.util.BS>[] vRings,
                           boolean doProcessAromatic)
                    throws InvalidSmilesException

      Sets up all aromatic and ring data. Called from SmilesGenerator.getSmilesComponent and SmilesMatcher.matchPriv.
      Parameters:
        `bsA` -
        `vRings` -
        `doProcessAromatic` -
      Throws:
        `InvalidSmilesException`

    - #### getRingData

          void getRingData(javajs.util.Lst<javajs.util.BS>[] vRings,
                           boolean needRingData,
                           boolean doTestAromatic)
                    throws InvalidSmilesException

      Throws:
        `InvalidSmilesException`

    - #### subsearch

          java.lang.Object subsearch(SmilesSearch search,
                                     int submode)
                              throws InvalidSmilesException

      Parameters:
        `search` -
        `submode` -
      Returns:
        Object
      Throws:
        `InvalidSmilesException`

    - #### search

          java.lang.Object search()
                           throws InvalidSmilesException

      the start of the search. ret will be either a Vector or a BitSet
      Returns:
        BitSet or Vector
      Throws:
        `InvalidSmilesException`

    - #### search2

          private java.lang.Object search2(boolean firstAtomOnly)
                                    throws InvalidSmilesException

      Throws:
        `InvalidSmilesException`

    - #### nextPatternAtom

          private boolean nextPatternAtom(int atomNum,
                                          int iAtom,
                                          boolean firstAtomOnly,
                                          int c)
                                   throws InvalidSmilesException

      Throws:
        `InvalidSmilesException`

    - #### doCheckAtom

          private boolean doCheckAtom(int j)

    - #### nextTargetAtom

          private final boolean nextTargetAtom(SmilesAtom patternAtom,
                                               Node jmolAtom,
                                               int atomNum,
                                               int iAtom,
                                               boolean firstAtomOnly,
                                               int c)
                                        throws InvalidSmilesException

      Check for a specific match of a model set atom with a pattern position
      Parameters:
        `patternAtom` - Atom of the pattern that is currently tested.
        `jmolAtom` -
        `atomNum` - Current atom of the pattern.
        `iAtom` - Atom number of the Jmol atom that is currently tested to match `patternAtom`.
        `firstAtomOnly` -
        `c` -
      Returns:
        true to continue or false if oneOnly
      Throws:
        `InvalidSmilesException`

    - #### checkPrimitiveAtom

          private boolean checkPrimitiveAtom(SmilesAtom patternAtom,
                                             int iTarget)
                                      throws InvalidSmilesException

      Parameters:
        `patternAtom` -
        `iTarget` -
      Returns:
        true if a match
      Throws:
        `InvalidSmilesException`

    - #### checkMatchBond

          private boolean checkMatchBond(SmilesAtom patternAtom,
                                         SmilesAtom atom1,
                                         SmilesBond patternBond,
                                         int iAtom,
                                         int matchingAtom,
                                         Edge bond)

    - #### checkPrimitiveBond

          private boolean checkPrimitiveBond(SmilesBond patternBond,
                                             int iAtom1,
                                             int iAtom2,
                                             Edge bond)

    - #### getBSAromaticRings

          private javajs.util.BS getBSAromaticRings()

    - #### isRingBond

          static boolean isRingBond(javajs.util.Lst<javajs.util.BS> ringSets,
                                    javajs.util.BS bsAromaticRings,
                                    int a1,
                                    int a2)

    - #### checkStereochemistry

          private boolean checkStereochemistry()

    - #### getAtropIndex

          private int getAtropIndex(SmilesBond b,
                                    boolean isFirst)

    - #### setTopoCoordinates

          private void setTopoCoordinates(SmilesAtom dbAtom1,
                                          SmilesAtom dbAtom2,
                                          SmilesAtom dbAtom1a,
                                          SmilesAtom dbAtom2a,
                                          int bondType)

    - #### createTopoMap

          void createTopoMap(javajs.util.BS bsAro)
                      throws InvalidSmilesException

      Parameters:
        `bsAro` - null for molecular formula calculation only
      Throws:
        `InvalidSmilesException`

    - #### normalizeAromaticity

          static void normalizeAromaticity(SmilesAtom[] atoms,
                                           javajs.util.BS bsAromatic,
                                           int flags)
                                    throws InvalidSmilesException

      create a temporary object to generate the aromaticity in a SMILES pattern for which there is no explicit aromaticity (Kekule) Not applicable to SMARTS
      Parameters:
        `atoms` -
        `bsAromatic` -
        `flags` -
      Throws:
        `InvalidSmilesException`

    - #### getSelections

          void getSelections()

      htNested may contain $(select xxxx) primitives. We want to clear those up before we start any search.

    - #### findImplicitHydrogen

          Node findImplicitHydrogen(Node atom)

    - #### toString

          public java.lang.String toString()

      Overrides:
        `toString` in class `java.lang.Object`