org.jmol.smiles

Class PatternMatcher

public class PatternMatcher extends 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(jmolViewer);
 try {
   BitSet bitSet = matcher.getSubstructureSet(smilesString);
   // Use bitSet...
 } catch (InvalidSmilesException e) {
   // Exception management
 }
 

Author: Nicolas Vervelle

See Also: SmilesMolecule

Field Summary
intatomCount
ModelSetmodelSet
Constructor Summary
PatternMatcher()
Constructs a PatternMatcher.
Method Summary
BitSetgetSubstructureSet(String smiles)
Returns a vector of bits indicating which atoms match the pattern.
BitSetgetSubstructureSet(SmilesMolecule pattern)
Returns a vector of bits indicating which atoms match the pattern.
voidsearchMatch(BitSet bs, SmilesMolecule pattern, int atomNum)
Recursively search matches.
voidsearchMatch(BitSet bs, SmilesMolecule pattern, SmilesAtom patternAtom, int atomNum, int i)
Recursively search matches.
voidsetViewer(Viewer viewer)

Field Detail

atomCount

private int atomCount

modelSet

private ModelSet modelSet

Constructor Detail

PatternMatcher

public PatternMatcher()
Constructs a PatternMatcher.

Method Detail

getSubstructureSet

public BitSet getSubstructureSet(String smiles)
Returns a vector of bits indicating which atoms match the pattern.

Parameters: smiles SMILES pattern.

Returns: BitSet Array indicating which atoms match the pattern.

Throws: Exception Raised if smiles is not a valid SMILES pattern.

getSubstructureSet

public 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(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(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.

setViewer

public void setViewer(Viewer viewer)