org.jmol.smiles
Class PatternMatcher

java.lang.Object
  extended by org.jmol.smiles.PatternMatcher
All Implemented Interfaces:
SmilesMatcherInterface

public class PatternMatcher
extends java.lang.Object
implements SmilesMatcherInterface

A class to match a SMILES pattern with a Jmol molecule.

The SMILES specification can been found at the SMILES Home Page.

An example on how to use it:


 PatternMatcher matcher = new PatternMatcher(modelSet);
 try {
   BitSet bitSet = matcher.getSubstructureSet(smilesString);
   // Use bitSet...
 } catch (InvalidSmilesException e) {
   // Exception management
 }
 

Author:
Nicolas Vervelle
See Also:
SmilesMolecule

Field Summary
private  int atomCount
           
private  ModelSet modelSet
           
 
Constructor Summary
PatternMatcher()
          Constructs a PatternMatcher.
 
Method Summary
 java.util.BitSet getSubstructureSet(SmilesMolecule pattern)
          Returns a vector of bits indicating which atoms match the pattern.
 java.util.BitSet getSubstructureSet(java.lang.String smiles)
          Returns a vector of bits indicating which atoms match the pattern.
private  void searchMatch(java.util.BitSet bs, SmilesMolecule pattern, int atomNum)
          Recursively search matches.
private  void searchMatch(java.util.BitSet bs, SmilesMolecule pattern, SmilesAtom patternAtom, int atomNum, int i)
          Recursively search matches.
 void setModelSet(ModelSet modelSet)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

atomCount

private int atomCount

modelSet

private ModelSet modelSet
Constructor Detail

PatternMatcher

public PatternMatcher()
Constructs a PatternMatcher.

Method Detail

setModelSet

public void setModelSet(ModelSet modelSet)
Specified by:
setModelSet in interface SmilesMatcherInterface

getSubstructureSet

public java.util.BitSet getSubstructureSet(java.lang.String smiles)
                                    throws java.lang.Exception
Returns a vector of bits indicating which atoms match the pattern.

Specified by:
getSubstructureSet in interface SmilesMatcherInterface
Parameters:
smiles - SMILES pattern.
Returns:
BitSet Array indicating which atoms match the pattern.
Throws:
java.lang.Exception - Raised if smiles is not a valid SMILES pattern.

getSubstructureSet

public java.util.BitSet getSubstructureSet(SmilesMolecule pattern)
Returns a vector of bits indicating which atoms match the pattern.

Parameters:
pattern - SMILES pattern.
Returns:
BitSet Array indicating which atoms match the pattern.

searchMatch

private void searchMatch(java.util.BitSet bs,
                         SmilesMolecule pattern,
                         int atomNum)
Recursively search matches.

Parameters:
bs - Resulting BitSet (each atom in a structure is set to 1).
pattern - SMILES pattern.
atomNum - Current atom of the pattern.

searchMatch

private void searchMatch(java.util.BitSet bs,
                         SmilesMolecule pattern,
                         SmilesAtom patternAtom,
                         int atomNum,
                         int i)
Recursively search matches.

Parameters:
bs - Resulting BitSet (each atom in a structure is set to 1).
pattern - SMILES pattern.
patternAtom - Atom of the pattern that is currently tested.
atomNum - Current atom of the pattern.
i - Atom number of the atom that is currently tested to match patternAtom.