org.jmol.smiles
Class SmilesGenerator

java.lang.Object
  extended by org.jmol.smiles.SmilesGenerator

public class SmilesGenerator
extends 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
private  int atomCount
           
private  JmolNode[] atoms
           
private  BitSet bsAromatic
           
private  BitSet bsBondsDn
           
private  BitSet bsBondsUp
           
private  BitSet bsIncludingH
           
private  BitSet bsSelected
           
private  BitSet bsToDo
           
private  Hashtable htRings
           
private  Hashtable htRingsSequence
           
private  int nPairs
           
private  JmolNode prevAtom
           
private  JmolNode[] prevSp2Atoms
           
private  StringBuffer ringSets
           
private  SmilesSearch.VTemp vTemp
           
 
Constructor Summary
SmilesGenerator()
           
 
Method Summary
private  void addBracketedBioName(StringBuffer sb, JmolNode a, String atomName)
           
private  String addStereoCheck(int atomIndex, JmolNode[] stereo, int i, String s)
          checks a group and either adds a new group to the growing check string or returns null
private  String checkStereoPairs(JmolNode atom, int atomIndex, JmolNode[] stereo, int stereoFlag)
           
private  void dumpRingKeys(StringBuffer sb, Hashtable ht)
           
(package private)  String getBioSmiles(JmolNode[] atoms, int atomCount, BitSet bsSelected, boolean allowUnmatchedRings, boolean addCrossLinks, String comment)
           
private  char getBondStereochemistry(JmolEdge bond, JmolNode atomFrom)
          Retrieves the saved character based on the index of the bond.
private  String getRingCache(int i0, int i1, Hashtable ht)
           
protected static String getRingKey(int i0, int i1)
           
(package private)  String getSmiles(JmolNode[] atoms, int atomCount, BitSet bsSelected)
           
private  JmolNode getSmiles(StringBuffer sb, JmolNode atom, boolean allowConnectionsToOutsideWorld, boolean allowBranches)
           
private  String getSmilesComponent(JmolNode atom, BitSet bs, boolean allowConnectionsToOutsideWorld)
          creates a valid SMILES string from a model.
private static String getStereoFlag(JmolNode atom0, JmolNode[] atoms, int nAtoms, SmilesSearch.VTemp v)
           
private  void setBondDirections()
          Creates global BitSets bsBondsUp and bsBondsDown.
private  String sortInorganic(JmolNode atom, List v)
          We must sort the bond vector such that a diaxial pair is first and last.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

atoms

private JmolNode[] atoms

atomCount

private int atomCount

bsSelected

private BitSet bsSelected

bsAromatic

private BitSet bsAromatic

ringSets

private StringBuffer ringSets

vTemp

private SmilesSearch.VTemp vTemp

nPairs

private int nPairs

bsBondsUp

private BitSet bsBondsUp

bsBondsDn

private BitSet bsBondsDn

bsToDo

private BitSet bsToDo

prevAtom

private JmolNode prevAtom

prevSp2Atoms

private JmolNode[] prevSp2Atoms

htRingsSequence

private Hashtable htRingsSequence

htRings

private Hashtable htRings

bsIncludingH

private BitSet bsIncludingH
Constructor Detail

SmilesGenerator

public SmilesGenerator()
Method Detail

getSmiles

String getSmiles(JmolNode[] atoms,
                 int atomCount,
                 BitSet bsSelected)
           throws InvalidSmilesException
Throws:
InvalidSmilesException

getBioSmiles

String getBioSmiles(JmolNode[] atoms,
                    int atomCount,
                    BitSet bsSelected,
                    boolean allowUnmatchedRings,
                    boolean addCrossLinks,
                    String comment)
              throws InvalidSmilesException
Throws:
InvalidSmilesException

addBracketedBioName

private void addBracketedBioName(StringBuffer sb,
                                 JmolNode a,
                                 String atomName)

getSmilesComponent

private String getSmilesComponent(JmolNode atom,
                                  BitSet bs,
                                  boolean allowConnectionsToOutsideWorld)
                           throws InvalidSmilesException
creates a valid SMILES string from a model. TODO: stereochemistry other than square planar and tetrahedral

Parameters:
atom -
bs -
allowConnectionsToOutsideWorld -
Returns:
SMILES
Throws:
InvalidSmilesException

getBondStereochemistry

private char getBondStereochemistry(JmolEdge bond,
                                    JmolNode 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.


getSmiles

private JmolNode getSmiles(StringBuffer sb,
                           JmolNode atom,
                           boolean allowConnectionsToOutsideWorld,
                           boolean allowBranches)

sortInorganic

private String sortInorganic(JmolNode atom,
                             List v)
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.

Parameters:
atom -
v -
Returns:
"@" or "@@" or ""

checkStereoPairs

private String checkStereoPairs(JmolNode atom,
                                int atomIndex,
                                JmolNode[] stereo,
                                int stereoFlag)

getStereoFlag

private static String getStereoFlag(JmolNode atom0,
                                    JmolNode[] atoms,
                                    int nAtoms,
                                    SmilesSearch.VTemp v)
Parameters:
atom0 -
atoms -
nAtoms -
v -
Returns:
String

addStereoCheck

private String addStereoCheck(int atomIndex,
                              JmolNode[] stereo,
                              int i,
                              String s)
checks a group and either adds a new group to the growing check string or returns null

Parameters:
atomIndex -
stereo -
i -
s -
Returns:
null if duplicate

getRingCache

private String getRingCache(int i0,
                            int i1,
                            Hashtable ht)

dumpRingKeys

private void dumpRingKeys(StringBuffer sb,
                          Hashtable ht)

getRingKey

protected static String getRingKey(int i0,
                                   int i1)